diff --git a/.github/workflows/vanilla-reload.yml b/.github/workflows/vanilla-reload.yml index 21c57331..2e183506 100644 --- a/.github/workflows/vanilla-reload.yml +++ b/.github/workflows/vanilla-reload.yml @@ -14,6 +14,11 @@ on: - "scripts/mc_validation/local_rcon_server.py" - "scripts/mc_validation/rcon_client.py" - "sand-cli/**" + - "sand-lang/**" + - "sand-version/**" + - "sand-build/src/vanilla_catalog.rs" + - "scripts/validate_language.py" + - "scripts/validate_language_values.py" - "sand-core/src/**" - "sand-macros/src/**" - "sand/src/**" @@ -179,6 +184,131 @@ jobs: --jar "$SAND_SERVER_JAR" \ --output "target/vanilla-reload/${{ matrix.version }}" + - name: Validate language arithmetic and runtime operands + if: matrix.version == '26.2' + run: | + cargo build -p sand-cli + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --output "target/vanilla-reload/${{ matrix.version }}/language-control-flow" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/assignments.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-assignments" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/structs.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-structs" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/borrows.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-borrows" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/collections.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-collections" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/text.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-text" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/sequences.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-vectors" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/patterns.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-patterns" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/match_guards.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-match-guards" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/match_bindings.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-match-bindings" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/block_expressions.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-block-expressions" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/generics.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-generics" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/traits.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-traits" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/callables.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-callables" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/relations.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-relations" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/world_ops.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-world-ops" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --wait-for-result --load-dimension language_probe:workshop \ + --fixture sand-lang/tests/fixtures/flat_dimensions.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-flat-dimensions" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --load-dimension language_probe:grove \ + --fixture sand-lang/tests/fixtures/custom_biomes.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-custom-biomes" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/structure_templates.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-structure-templates" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/equipment.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-equipment" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/entity_filters.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-entity-filters" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --wait-for-result --fixture sand-lang/tests/fixtures/loot_pools.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-loot-pools" + source="target/vanilla-reload/${{ matrix.version }}/language-time-spatial-source" + mkdir -p "$source" + cp sand-lang/tests/fixtures/time_spatial.sand "$source/pack.sand" + target/debug/sand lang add time "$source" + target/debug/sand lang add spatial "$source" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture "$source/pack.sand" \ + --output "target/vanilla-reload/${{ matrix.version }}/language-time-spatial" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/damage_types.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-damage-types" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --wait-for-result --fixture sand-lang/tests/fixtures/entity_motion.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-entity-motion" + python3 scripts/validate_language.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --fixture sand-lang/tests/fixtures/world_predicates.sand \ + --output "target/vanilla-reload/${{ matrix.version }}/language-world-predicates" + mkdir -p "target/vanilla-reload/${{ matrix.version }}/language-authored-tests" + target/debug/sand lang test sand-lang/tests/fixtures/authored_tests.sand \ + --accept-eula --jar "$SAND_SERVER_JAR" 2>&1 \ + | tee "target/vanilla-reload/${{ matrix.version }}/language-authored-tests/results.log" + python3 scripts/validate_language_collections.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --output "target/vanilla-reload/${{ matrix.version }}/language-collections-library" + python3 scripts/validate_language_values.py \ + --binary target/debug/sand --jar "$SAND_SERVER_JAR" \ + --output "target/vanilla-reload/${{ matrix.version }}/language-values" + - name: Validate 26.3 compute execution if: matrix.version == '26.3' run: | @@ -429,6 +559,20 @@ jobs: retention-days: 14 path: | target/vanilla-reload/${{ matrix.version }}/latest.log + target/vanilla-reload/${{ matrix.version }}/language-control-flow + target/vanilla-reload/${{ matrix.version }}/language-values + target/vanilla-reload/${{ matrix.version }}/language-assignments + target/vanilla-reload/${{ matrix.version }}/language-structs + target/vanilla-reload/${{ matrix.version }}/language-borrows + target/vanilla-reload/${{ matrix.version }}/language-collections + target/vanilla-reload/${{ matrix.version }}/language-text + target/vanilla-reload/${{ matrix.version }}/language-vectors + target/vanilla-reload/${{ matrix.version }}/language-collections-library + target/vanilla-reload/${{ matrix.version }}/language-traits + target/vanilla-reload/${{ matrix.version }}/language-callables + target/vanilla-reload/${{ matrix.version }}/language-relations + target/vanilla-reload/${{ matrix.version }}/language-world-ops + target/vanilla-reload/${{ matrix.version }}/language-authored-tests target/vanilla-reload/${{ matrix.version }}/world-gameplay target/vanilla-reload/${{ matrix.version }}/runtime-report target/vanilla-reload/${{ matrix.version }}/compute diff --git a/Cargo.lock b/Cargo.lock index 7be992ae..97b7b4fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,6 +106,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.11.0" @@ -346,6 +352,15 @@ dependencies = [ "itertools", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.7" @@ -512,7 +527,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "bitflags", + "bitflags 2.11.0", "block2", "libc", "objc2", @@ -600,6 +615,15 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fluent-uri" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1143,6 +1167,32 @@ version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +[[package]] +name = "lsp-server" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee25a31f2e571e426eef2896179450cafc7e2f5be00d8a93b1c2d21c0ff7656" +dependencies = [ + "crossbeam-channel", + "log", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "lsp-types" +version = "0.97.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53353550a17c04ac46c585feb189c2db82154fc84b79c7a66c96c2c644f66071" +dependencies = [ + "bitflags 1.3.2", + "fluent-uri", + "serde", + "serde_json", + "serde_repr", +] + [[package]] name = "memchr" version = "2.8.0" @@ -1199,7 +1249,7 @@ version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d6d0705320c1e6ba1d912b5e37cf18071b6c2e9b7fa8215a1e8a7651966f5d3" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cfg-if", "cfg_aliases", "libc", @@ -1274,7 +1324,7 @@ version = "0.10.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cfg-if", "foreign-types", "libc", @@ -1669,7 +1719,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys", @@ -1806,6 +1856,8 @@ dependencies = [ "sand-build", "sand-components", "sand-core", + "sand-lang", + "sand-lsp", "serde", "serde_json", "tempfile", @@ -1822,6 +1874,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.18", "unicode-general-category", @@ -1838,6 +1892,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.18", @@ -1847,6 +1902,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64", "inventory", "sand", "sand-api-contract", @@ -1873,6 +1929,28 @@ dependencies = [ "serde_json", ] +[[package]] +name = "sand-lang" +version = "0.1.0" +dependencies = [ + "pest", + "pest_derive", + "sand", + "sand-version", + "serde_json", +] + +[[package]] +name = "sand-lsp" +version = "0.1.0" +dependencies = [ + "lsp-server", + "lsp-types", + "sand-lang", + "serde", + "serde_json", +] + [[package]] name = "sand-macros" version = "0.1.0" @@ -1894,6 +1972,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] @@ -1936,7 +2015,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags", + "bitflags 2.11.0", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -2018,6 +2097,17 @@ dependencies = [ "serde_core", ] +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + [[package]] name = "serde_spanned" version = "1.0.4" @@ -2156,7 +2246,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ - "bitflags", + "bitflags 2.11.0", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -2366,7 +2456,7 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ - "bitflags", + "bitflags 2.11.0", "bytes", "futures-util", "http", diff --git a/Cargo.toml b/Cargo.toml index ba2c098d..f195cb30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,8 @@ members = [ "sand", "sand-api-enforce", "sand-cli", + "sand-lang", + "sand-lsp", "sand-core", "sand-macros", "sand-api-contract", diff --git a/README.md b/README.md index 9d35b620..e5c03b85 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ and explicitly named raw escape hatches remain available for advanced edges. | Interactions and inventory | Player menus, object-bound conversations, journals, quantity-aware payments and guarded transfers | [Interaction hub](examples/interaction_hub/) | | Presentation | Block/item/text scenes, transforms, lifetime-owned HUDs, particles and sounds | [Gameplay guide](book/src/23d-owned-gameplay.md) | | Datapack resources | Typed recipes, advancements, loot, predicates, item modifiers, tags, dialogs, enchantments and worldgen builders | [Trailforge](examples/book_project/), [Examples index](examples/README.md) | +| Rust-free authoring | The Sand language: Rust-syntax `.sand` files that compile through the same backend, with a language server (`sand lsp`) | [Sand language guide](book/src/language.md), [Encounters](examples/lang_encounters/) | | Companion resource packs | Separate client-asset packaging, version metadata and deterministic archives | [Resource-pack guide](book/src/17a-companion-resource-packs.md) | The [capability matrix](docs/architecture/capability-matrix.md) records the diff --git a/ROADMAP.md b/ROADMAP.md index a4c37d0a..7c7de3b5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -214,6 +214,132 @@ Acceptance: deterministic output and semantic parity across targets; optimized paths have versioned native evidence. Static command counts are not MSPT claims. See [benchmarks and limitations](BENCHMARKS.md). +## Sand language expansion + +The language uses the portable compiler shared with Rust. The current surface +and Rust-only areas are documented in [the language guide](book/src/language.md). +This checklist tracks the requested expansion; unchecked entries are not shipped. + +- [x] Recursive functions, scoped locals, scalar casts, counting loops and custom + events with payloads. +- [x] Exhaustive statement `match`, constant alternatives, mutable parameters, + reversed/stepped ranges, left-to-right bound evaluation and safe range endpoints. +- [x] Package formatting through `sand fmt`, `sand lang fmt`, `--check` and LSP; + naming and mutability quick fixes that edit declarations and references. +- [x] Automated vanilla 26.2 control-flow probe with 20 assertions and reload; + run `scripts/validate_language.py` with a built CLI and bundled server JAR. +- [x] Constant/runtime signed arithmetic parity, target-specific vanilla catalogs + shared by validation/completion, and runtime item counts, damage, teleport, + experience and sound options. +- [x] General boolean arguments and stored predicates; two-player native proof + for inventory isolation, runtime numeric commands and player properties. +- [x] Named, nested struct values in locals, arguments, returns, events and State; + value receivers and State receivers in impl blocks, with privacy and IDE support. +- [x] Final-write assignment clamping and RHS snapshots; vanilla regression probes + for aliasing, casts, bounded float arithmetic, record calls and event copies. +- [x] Runtime timer durations with checked seconds conversion and player-State + method isolation in the two-player runtime probe. +- [x] Fixed-size arrays with inference, repeat literals, nested State/records, + calls/returns, snapshot iteration, checked indexing, indexed mutable receivers, + and len/is_empty/contains/get_or/fill methods; forty native assertions. +- [x] Owned runtime strings, scalar formatting, Unicode indexing/slicing, substring + methods, plain runtime text and styled interpolation; native recursive, owner + lifecycle and per-player reload proofs. +- [x] Growable `Vec` values, nested/recursive records, indexed borrowed + methods, deep copies/equality, bounded mutation and snapshot iteration; native + vector, array and text regressions plus independent player reload proofs. +- [x] Value-producing matches for owned values, flat dispatch for large matches, + nested record/fixed-array destructuring and shorthand-safe editor renames. +- [x] Match guards for statement and value forms, with ordered fallthrough. +- [x] Arm-local match bindings and nested record and array destructuring. +- [x] Scoped block expressions with tail values, including value match arms. +- [ ] Enum payloads. +- [x] Bundled generic maps and sets with owned values, whole-record and array + equality, an offline installer, and vanilla capacity and persistence checks. +- [x] Read-only and mutable struct receivers, with write-back on early return and + recursive calls; retained EntityRef values, reload-safe identities, explicit + resolution, and damage attribution with native two-player kill-credit proof. +- [x] Generic functions, nominal records and impl methods, inference and explicit + applications, per-specialization slots/contexts, canonical source identities, + bounded expansion and native recursive/owned-value proof. +- [x] Static traits, required signatures, and generic function and method bounds. +- [x] Typed function values, owned move closures, generic call signatures, + recursive indirect calls and player-State persistence. +- [ ] Executor-specific callable signatures and general borrowed slices. +- [x] Typed enchantments generated from one verified catalog for Rust and Sand. +- [x] Bundled typed durations and storable positions through ordinary Sand + records and impl methods. Use existing entity State for checked membership. +- [x] Retain individual vanilla entity relationships in `EntityRef` values, + and mount and dismount retained vehicles. +- [x] Equip, clear, and test hand and armor slots with typed equipment slots and + custom item identity. +- [x] Filter entity queries with a State score range and a typed native NBT + compound, composed with attachment, distance, sorting, and limits. +- [x] Velocity reads and bounded non-player velocity writes. +- [x] Read-only inventory counts for vanilla and custom items, numeric queries + for checked entity NBT paths, and bounded item removal with a computed count. +- [x] Numbered player-slot inventory transfers through the shared Rust system + with whole stacks, exact amounts, component checks, and callbacks. +- [ ] Broader equipment and entity data operations, motion controls, and + archetypes. +- [ ] Broader event triggers, filters, tracked changes and event chains. +- [x] Top-level `wait` statements in entity and player functions, with + per-invocation locals, original dimension, and owner-scoped cancellation. +- [x] Runtime wait durations in ticks and seconds, captured for each invocation. +- [x] Waits in nested conditional branches with one shared continuation and + per-invocation locals. +- [ ] Waits inside loops and matches, and server continuations. +- [x] Dimension checks and scoped calls, and block cloning with mask, filter, + overlap, and move modes. +- [x] Biome predicates validated against the target version’s shared catalog. +- [x] Checked block entity paths, numeric reads and writes, and field removal. +- [x] Typed NBT literal writes and native data copies between block entities. +- [x] Flat dimension declarations, typed references and loaded waits in the + declared dimension. +- [x] Custom biome climate and colors, with typed references from dimensions and + predicates. +- [x] Structure template imports from saved native NBT files and typed placement + at absolute or relative positions. +- [x] Biome spawn tables with typed weighted entities, group sizes, and density costs. +- [ ] Natural structure generation, biome terrain features, other world + generators and dimension types, and first-class native block data. +- [x] Independent loot pools with weighted entries, random chance, and + weather conditions. +- [x] Native damage type declarations and typed vanilla damage types, both + available with retained attacker attribution. +- [x] Named native world predicates shared by function guards and loot pools. +- [x] Smithing armor trim recipes with a named native pattern. +- [x] Client-localized component text with positional arguments in messages and + static resources. +- [x] Interactive chat with hover text, links, command suggestions and clipboard actions. +- [x] Fixed written books using canonical item components, rich pages and page navigation. +- [x] Runtime particle count, spread and speed with atomic range checks. +- [x] Native advancement resources with named inventory, placement and kill criteria, + all/any requirements, visible presentation and experience rewards. +- [x] Player-scoped advancement completion and named criterion queries. +- [x] Ordered completion handlers using the authored advancement's native reward + function. +- [x] Native notice dialogs with translated text and player-scoped open and clear. +- [x] Paginated native menus with named views, player-scoped one-shot callbacks, + and State guards for choices and sessions. +- [ ] Broader advancement triggers, worldgen and VFX. +- [x] Owner-scoped HUDs with bounded lifetime, rich actionbars, private + State-driven boss bars, and cancellation. +- [ ] Expose the Rust combat, abilities, encounters, jobs, rosters, + projectiles, progression, scenes, sessions and checkpoints + through canonical shared models. +- [x] Sand-authored tests with assertions, disposable vanilla runs, and source + maps for portable operations and emitted function identities. +- [x] Emitted command-line mappings, including generated helper functions. +- [x] Live Zed diagnostics and inferred-context hints using a worktree build. +- [ ] Breakpoints. + +Acceptance: compiler/export tests prove observable output, runtime features have +native evidence, and each new public model preserves deterministic export, +collision safety and per-player/per-invocation ownership. Minecraft's finite +integer range, command limit and player-data restrictions remain runtime +constraints; a new surface syntax alone does not remove them. + ## Validation and coverage work - [x] Full local gate: `scripts/check.sh` plus `git diff --check`. diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index befa5a24..b6cba2cd 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -45,6 +45,10 @@ - [Quests and session phases](23j-progression-and-sessions.md) - [Journals and checkpoints](23m-journals-and-checkpoints.md) +# The Sand Language + +- [Writing Packs In Sand Source](language.md) + # Typed World & Server Configuration - [24. What Ships In The Datapack vs. What's Local To Your Dev Server](23-world-vs-server.md) diff --git a/book/src/language.md b/book/src/language.md new file mode 100644 index 00000000..0088aa78 --- /dev/null +++ b/book/src/language.md @@ -0,0 +1,1915 @@ +# The Sand Language + +Sand packs can be written in Rust or in the **Sand language**: `.sand` files +with Rust's syntax that compile straight to a datapack. Both are entry points +into the same compiler. A `.sand` package lowers to Sand's portable program +model and is validated and emitted by the same backend as Rust and JSON +frontends, so equivalent packs produce byte-identical datapacks. + +The difference is *when* code runs. In Rust, an `if` runs while the pack is +being built. In Sand source, every `if`, `for`, and assignment is gameplay that +runs inside Minecraft. You don't need macros or a Cargo build, and you don't +have to think in two stages. + +```rust,ignore +//! Coins for everyone. +#![pack(namespace = "coins", minecraft = "26.2")] + +player state Wallet { + #[clamp(0..=9999)] + coins: number, +} + +#[on(first_join)] +fn welcome() { + chat!("{gold}Welcome, {player}!{reset} You have {Wallet.coins} coins."); + give_item(Item::Bread, 4); +} + +#[on(death)] +fn tax() { + Wallet.coins = Wallet.coins * 9 / 10; + actionbar!("{red}You dropped some coins."); +} +``` + +## Getting started + +```sh +sand lang new my-pack # create my-pack/ with pack.sand and a module +cd my-pack +sand fmt # format the package (or --check for CI) +sand lang check # report errors and warnings +sand lang build # write the datapack to dist/ +sand lang run # compile and launch a local Minecraft server +sand lang emit # print the portable program JSON +``` + +`sand lang run` downloads the matching server, installs the pack in a test +world under `dist/server/`, and starts it (add `--offline` for easier local +joining). Language projects have no `sand.toml`; `sand run` also works from a +folder containing `pack.sand`. While the server runs, `sand lang build` updates +the test world, so `/reload` picks up your edits. + +To use a pack elsewhere, copy `dist/` into a world's `datapacks` +folder and run `/reload`. +A larger example lives in +[`examples/lang_encounters`](../../examples/lang_encounters/pack.sand). + +## Editor setup (Zed) + +The language server gives you diagnostics as you type, hover explanations for +every item, builtin, attribute, and keyword, plus completion, go to definition, +references, rename, formatting, naming and mutability quick fixes, an outline, +and inlay hints showing where each function +runs. + +1. Install the `sand` CLI so editors can start `sand lsp`: + `cargo install --path sand-cli` from the Sand repository. +2. Run `sand lang zed`. It writes a Zed extension and a tree-sitter grammar + for highlighting to `~/.sand/zed` (or `--dir `). +3. In Zed, run **`zed: install dev extension`** from the command palette and + choose the printed `zed-sand` folder. Zed compiles it with Rust (rustup). + +Open any `.sand` file to start the server. Sand finds the package by walking +up from the file to the nearest `pack.sand`. If `sand` is not on Zed's `PATH`, +point Zed at it in `settings.json`: + +```json +{ "lsp": { "sand": { "binary": { "path": "/path/to/sand", "arguments": ["lsp"] } } } } +``` + +After upgrading Sand, run `sand lang zed` again and rebuild the extension from +Zed's extensions page. Other editors can use any LSP client: run `sand lsp` as +a stdio server for `*.sand` files. + +## Naming + +Sand follows one naming convention, the same one Rust uses. The compiler +warns when a name breaks it and suggests the fixed spelling. + +| Style | Used for | Examples | +| --- | --- | --- | +| `PascalCase` | things you declare and refer to: `state`, `enum` and its variants, `flow`, `item`, `recipe`, `tag`; typed value sets and their values | `Wallet`, `Phase::Idle`, `RubySword`, `Item::Diamond`, `Rarity::Epic` | +| `snake_case` | things that run or hold values: functions, builtins, fields, variables, parameters, modules | `buy_heart`, `give_item`, `Wallet.coins`, `let price` | +| `SCREAMING_SNAKE_CASE` | constants | `MAX_HEALTH` | + +Builtins are named `verb` or `verb_object`: `give_item`, `clear_item`, +`add_effect`, `play_sound`, `spawn_particle`, `add_tag`, `count_entities`. +Value sets are singular nouns: `Item`, +`Block`, `Entity`, `Sound`, `Particle`, `Attribute`, `Effect`, `Potion`, +`Rarity`, `Sort`. Attribute words such as `#[tick]` and `#[on(death)]` are +lowercase, as in Rust. + +Resource identities are always snake_case: `item RubySword` in the root +module becomes `:ruby_sword`. + +## Packages and modules + +A package starts at a root file, conventionally `pack.sand`, which declares the +pack with an inner attribute: + +```rust,ignore +#![pack(namespace = "arena", minecraft = "26.2", description = "Arena minigame")] +``` + +`namespace` is required. `minecraft` defaults to the newest supported target, +and `description` defaults to the root file's `//!` docs. + +Modules follow Rust's layout. `mod combat;` in the root loads `combat.sand` or +`combat/mod.sand`, and `mod hits;` inside `combat.sand` loads +`combat/hits.sand`. Inline `mod name { ... }` blocks work too. Paths and +privacy follow Rust: `use crate::Hero;`, `use super::util::{a, b as c};`, and +items are private to their module (and its children) unless marked `pub`. + +Every generated identity derives from the namespace, module path, and item +name: `fn grant` in `rewards.sand` becomes `arena:rewards/grant`, and +`player state Hero` becomes the State `arena:hero`. + +## Declarations + +| Item | Meaning | +| --- | --- | +| `player state Name { field: number = 0, ... }` | One value per player | +| `global state Name { ... }` | One shared value for the server | +| `enum Phase { Idle, Active = 5 }` | Named integer phases, usable as field types | +| `const NAME: number = expr;` | Compile-time constant (`+ - * / %`, `as number`) | +| `struct Point { x: float, y: float }` | A named, typed value with fields | +| `impl Point { ... }` | Associated functions and methods for a struct or State | +| `fn name() { ... }` | A Minecraft function | +| `extern "ns:path" fn name();` | A function implemented by another pack | +| `flow Name on State.field { ... }` | A state machine over a field | +| `mod name;` / `use path;` | Modules and imports | +| `item Name { ... }` | A custom item | +| `recipe Name { ... }` | A crafting, cooking, or stonecutting recipe | +| `tag Name: Item { ... }` | A group of items, blocks (`Block`), or entities (`Entity`) | + +Fields default to `0`, or to the first variant for enum fields. +`#[clamp(min..=max)]` clamps every write to an `number` field. + +Function attributes: + +- `#[tick]` / `#[load]` run the function every tick or on load, on the server. +- `#[on(event)]` runs the function as the player when a player event happens: + `join` (every join, including the first), `first_join`, `death`, `kill` + (any entity, or `kill = Entity::Zombie`), `kill_player`, + `killed_by = Entity::Creeper`, `use_item = Item::CarrotOnAStick`, + `craft_item = Item::Bread`, `pick_up_item = Item::Diamond`, + `mine_block = Block::DiamondOre`, `jump`, `drop_item`, `sleep`, + `take_damage`, and `deal_damage`. +- `#[tag("ns:name")]` adds the function to any function tag. +- `#[player]` requires a player executor explicitly. Without it, the context is + inferred (see below). + +## Struct values and methods + +Structs group existing value types into named records. They work in locals, +function arguments and returns, event payloads, and State fields, including nested +records. Copies are independent; changing one copy does not change another. + +```rust,ignore +struct Point { pub x: float, pub y: float } +impl Point { + pub fn new(x: float, y: float) -> Self { return Self { x, y }; } + pub fn east(mut self, distance: float) -> Self { + self.x += distance; + return self; + } +} +player state Hero { position: Point, energy: number = 100 } +impl Hero { + pub fn spend(&mut self, amount: number) { self.energy -= amount; } + pub fn energy_left(&self) -> number { return self.energy; } +} +fn example() { + let origin = Point::new(1.0, 2.0); + let shifted = origin.east(3.0); + for player in players() { + Hero.position = shifted; + Hero.spend(5); + } +} +``` + +Use `Type::function(...)` for associated functions and `value.method(...)` for +methods. `Self` names the enclosing type. Field shorthand (`Point { x, y }`) +uses locals with matching names. Literal fields evaluate in their written order; +all fields must appear exactly once. Struct fields and methods follow module +privacy; add `pub` to expose them. Implementations may live in another module of +the same package, with the same visibility checks as ordinary code. + +Struct methods can take `self` or `mut self` **by value**: return `Self` and +assign it back to keep a change. They can also take `&self` to read a value or +`&mut self` to update a mutable local or State field. Mutable receiver changes +commit when the call returns, including early returns and recursive calls; these +are scoped method receivers rather than general reference values. Mutable calls +on immutable variables or temporary expressions are errors. Use `==` and `!=` to compare records of the same type field by field. +Empty records and direct recursive layouts are rejected. A vector breaks layout +recursion, allowing records such as `Node { children: Vec }`. Each record has at +most 32 levels and 1,024 scalar leaves. Struct declarations have no field defaults +or clamps; an uninitialized record recursively uses zero or the first enum +variant, and string fields use empty text. State defaults can instead provide a complete record literal. + +State methods use `&self` or `&mut self` to access persistent storage. These are +State receivers, not general Rust references. Player and entity receivers require +the corresponding executor, even if a method does not read a field. A read-only +receiver cannot write its State or call its mutable methods. Associated State +functions can use `Self.field` without a receiver. Existing clamps apply to final +field writes, and a whole-record State assignment copies every leaf. Arguments, +returns, recursive calls and event payloads use the same record representation. + +The [Blinkstep example](../../examples/lang_methods/pack.sand) combines a private +position record with player State methods and a runtime cooldown. + +## Fixed-size arrays + +Arrays use one shared element type and a compile-time length: + +```rust,ignore +let mut values: [number; 3] = [1, 2, 3]; +values[1] += 5; +let zeros = [0; 8]; +for value in values { chat!("{value}"); } +``` + +Arrays work in locals, State, records, function arguments/returns, custom events, +and recursive frames. Elements can themselves be arrays, structs, enums, or +entity references. Type inference works for nonempty literals and repeat forms; +an empty literal needs a type such as `[number; 0]`. Lengths can name number +constants. Arrays and their elements copy independently. `[expression; N]` +evaluates its expression once and copies the result, even when N is zero. + +`for value in array` evaluates its source once and iterates a snapshot. Changing +the original array does not change later elements in that iteration. The loop +binding is an immutable value copy. Nested loops, `break`, `continue` and early +returns use the same rules as counting loops. + +Indexes accept runtime whole numbers. A constant out-of-range index is an +error. An invalid runtime read returns the element's default; an invalid write +leaves the array unchanged. `get_or(index, fallback)` provides an explicit +fallback. Mutable methods on invalid indexed receivers skip their bodies and +return a default result. Indexes evaluate once, including for nested assignment +and mutable method receivers. Indexed assignment freezes its indexes before +evaluating the right-hand side. + +| Method | Behavior | +| --- | --- | +| `array.len()` | Fixed length as a number | +| `array.is_empty()` | Whether length is zero | +| `array.contains(value)` | Value equality, including nested aggregate leaves | +| `array.get_or(index, fallback)` | Element or supplied fallback | +| `array.fill(value)` | Replace every element with an independent copy; needs a mutable receiver | + +Arrays have at most 1,024 elements; complete aggregate layouts have at most +1,024 scalar leaves and 32 storage levels. Arrays may contain strings, vectors +and records with stored fields. See the +[quest-board example](../../examples/lang_collections/pack.sand). + +## Growable vectors + +`Vec` is an owned growable sequence of one value type. Initialize it with an +array-shaped literal in a `Vec` context, leave it empty with a typed binding, +or convert an existing array with `.to_vec()`. + +```rust,ignore +let mut values: Vec = [1, 2, 3]; +values.push(4); +let mut copied = values; +copied[0] = 90; // values still starts with 1 +for value in values { broadcast!(value.to_string()); } +let words = ["hello", "world"].to_vec(); +``` + +Vectors work in State, nested records, function parameters/returns, and event +payloads. Elements may contain arrays, strings, other vectors or recursive +records. Every copy is independent. Vector indexing reads the element's default +when the index is outside its runtime length; invalid writes leave the vector +unchanged. A constant negative index is a diagnostic. Indexed mutable methods +freeze the index once, and skip the method body for an invalid receiver. + +A `for value in collection` loop evaluates its source once and iterates a value +snapshot. Mutating the original collection in the loop preserves the original +iteration sequence. This applies to arrays, vectors and strings; string loop +bindings are single-character strings. Loop bindings are immutable values. + +| Method | Result | +| --- | --- | +| `len()`, `is_empty()` | Current element count or emptiness | +| `get_or(index, fallback)` | Element or eagerly evaluated fallback | +| `contains(value)` | Deep typed value equality | +| `push(value)` | Append an independent copy; return whether it was added | +| `pop_or(fallback)` | Remove the last element, or return the fallback | +| `remove_or(index, fallback)` | Remove one indexed element, or return the fallback | +| `insert(index, value)` | Insert at an index up to the length; return whether inserted | +| `extend(values)` | Append independent copies and return the count added | +| `clear()` | Remove all elements | +| `truncate(length)` | Keep at most that many elements; a negative length clears the vector | + +Mutation methods require a mutable local, writable record field, or writable +State receiver. As with borrowed struct methods, the receiver is copied in +before explicit arguments and committed when the method returns. Explicit +arguments evaluate once in authored order, including fallbacks and arguments to +an operation that cannot add an element. `==` and `!=` compare entire vectors. + +Each vector supports up to 1,024 elements. A full vector rejects `push` and +`insert`; `extend` adds as many elements as fit. Expanded State defaults have a +1 MiB budget checked before repeat expansion; build larger values at runtime. +General borrowed slices remain future work. + +See the [exploration-log example](../../examples/lang_vectors/pack.sand), which +stores a separate growable vector of coordinate records for each player. + +### Maps and sets + +Run `sand lang add collections` from your project directory to install an +editable `collections.sand` module. It works offline and preserves any existing +file at that path. Import its types as normal Sand definitions: + +```rust,ignore +use collections::{Map, Set}; + +player state Journal { + counts: Map, + discoveries: Set +} + +fn record(ore: string) { + let total = Journal.counts.get_or(ore, 0) + 1; + Journal.counts.insert(ore, total); + Journal.discoveries.insert(ore); +} +``` + +Maps preserve insertion order and compare keys by value. `insert` replaces an +existing value in place and returns true. It returns false when adding a new +key would exceed capacity. Sets keep distinct values in insertion order. +Their `insert` returns false for a duplicate or a full set. Each collection +holds up to 1,024 elements and uses linear lookup. Large collections and complex +keys can consume much of Minecraft's command budget. + +`Map` provides `get_or`, `contains_key`, `insert`, `remove`, `remove_or`, +`keys`, `values`, and `entries`. `Set` provides `contains`, `insert`, +`remove`, and `values`. Both have `new`, `len`, `is_empty`, and `clear`. +Returned entries and vectors are independent copies. + +See the [ore journal example](../../examples/lang_maps/pack.sand). + +### Tests and source maps + +Mark a parameterless server-context function returning `bool` with `#[test]`. +Use `assert!` to fail at a specific source line. A test can also return +`false` directly. + +```rust,ignore +fn doubled(value: number) -> number { return value * 2; } + +#[test] +fn doubles_numbers() -> bool { + assert!(doubled(7) == 14); + return true; +} +``` + +Run `sand lang test --list` to discover tests or +`sand lang test --accept-eula` to run them in a disposable vanilla world. +Provide `--jar path/to/server.jar` for an existing server artifact. The runner +checks the server version and exits unsuccessfully if any test fails. Tests share +the disposable world during one suite, so initialize any State a test relies on. +Normal builds omit test entry points. + +Run `sand lang source-map` to print JSON that links portable operation pointers, +emitted function paths, and generated command lines to Sand source. The file +table is relative to the package root directory. Source ranges use UTF-8 byte +offsets. The `commands` index uses pack-relative `.mcfunction` paths and +inclusive one-based line ranges, including generated branches and macros. This +command compiles in memory and reports ordinary Sand errors if emission fails. + +## Types + +| Type | Holds | Stored as | +| --- | --- | --- | +| `number` | whole numbers | a scoreboard score | +| `float` | decimals with three places, like `1.5` | a score holding `value * 1000` | +| `bool` | `true` or `false` | a score holding one or zero | +| an `enum` | one of its named phases | a score holding the phase's number | +| `string` | owned Unicode text | UUID-owned or global command storage | +| a `struct` | named fields of existing value types | score or storage slots per leaf | +| `[T; N]` | N independent values of one type | the same aggregate leaf layout | +| `Vec` | up to 1,024 owned values of one type | UUID-owned or global command storage | + +Scoreboards only hold whole numbers, so `float` is fixed point, the same +scheme as Rust's `Fixed` fields. Sand rescales arithmetic for you. Its range +is about +/-2,147,483, and multiplying two large fields can overflow; constant +factors are reduced first to make that less likely. + +`number` and `float` do not mix implicitly (a whole-number literal is fine in +a `float` calculation); convert with `as float` and `as number`. `as number` +also converts enum phases and rounds a `float` down. + +```rust,ignore +player state Hero { + #[clamp(0.0..=2.0)] + speed: float = 0.5, + coins: number, + rich: bool, +} + +fn update() { + Hero.speed = Hero.speed * 1.5; + Hero.rich = Hero.coins >= 50; + if Hero.rich && !is_tired() { Hero.coins -= 1; } +} +``` + +A `bool` works directly in conditions, and conditions also work as function +arguments: `accept(n > 0, !ready)`. Predicates such as `has_state(Mana)` can +be stored or passed as booleans. Text can only show whole numbers, so copy a +`float` first: +`let shown = Hero.speed as number;`, then write `{shown}`. + +## Functions and variables + +Functions take typed parameters and may return a value, just like Rust: + +```rust,ignore +/// The price of one extra heart, rising with each purchase. +fn heart_price(owned: number) -> number { + return 50 + owned * 25; +} + +#[on(use_item = Item::CarrotOnAStick)] +fn buy_heart() { + let health = Player.max_health; // 20.0 = ten hearts + if health >= 40.0 { + actionbar!("{gold}You already have the maximum health."); + return; // early return + } + let price = heart_price(((health - 20.0) / 2.0) as number); + if Wallet.coins < price { + chat!("{red}You need {price} coins."); + return; + } + Wallet.coins -= price; + Player.max_health = health + 2.0; +} +``` + +- `let name = value;` declares a variable; `let mut` allows reassignment. + Variables are block-scoped and can shadow outer ones. +- Parameters are immutable by default; write `mut amount: number` to allow + reassignment within the function. Arguments are passed by value. +- `return;` ends a function early; `return value;` returns from a function + declared with `-> number`. Every path must return a value in such functions. +- Functions can call each other and themselves, directly or through other + functions. Recursion works like in Rust: each call has its own variables. + +```rust,ignore +fn factorial(n: number) -> number { + if n <= 1 { return 1; } + return n * factorial(n - 1); +} + +fn is_even(n: number) -> bool { + if n == 0 { return true; } + return is_odd(n - 1); +} +fn is_odd(n: number) -> bool { + if n == 0 { return false; } + return is_even(n - 1); +} +``` + + A function returning `bool` can be used directly as a condition: + `if is_even(Hero.gold) { ... }`. Minecraft limits how many commands one + tick can run (65,536 by default), which bounds how deep recursion can go. +- Entry points (`#[tick]`, `#[load]`, `#[on(...)]`, `schedule`, flow hooks) + run without arguments, so they cannot take parameters. + +## Statements + +```rust,ignore +Hero.energy = 10; // set a State field +Hero.energy += 5; // also -=, *=, /=, %= +let total = Hero.gold * 3 + bonus(2); // any integer expression +Dice.roll = random(1..=6); // random integer +grant(); // call (module paths work: rewards::grant()) +for player in players() { ... } // run the body as each online player +for i in 0..10 { ... } // count 0 to 9; `0..=10` includes 10 +while n != 1 && steps < 100 { ... } // loop while any condition holds +loop { if done() { break; } } // loop until `break` or `return` +emit Payday(25); // run every handler of a custom event +if Hero.energy >= 30 && Hero.gold > Rival.gold { ... } else { ... } +``` + +Arithmetic follows normal precedence with parentheses, using Minecraft's 32-bit +scoreboard maths (division rounds down). A clamped field is clamped once, +after the whole value is computed. + +Conditions compare any integer expressions (`== != < <= > >=`) or test `in` a +range (`a..b`, `a..=b`, `a..`, `..=b`). Combine them with `&&`, `||`, `!`, and +parentheses. Every comparison is evaluated at most once, and exactly one branch +runs. + +### Loops + +`while`, `loop`, and counting `for` repeat their body; `break;` leaves the +innermost one and `continue;` skips to its next pass: + +```rust,ignore +fn first_square_over(limit: number) -> number { + for i in 0..1000 { + if i * i > limit { return i; } + } + return -1; +} + +fn collatz_steps(start: number) -> number { + let mut n = start; + let mut steps = 0; + while n != 1 { + if n % 2 == 0 { n = n / 2; } else { n = n * 3 + 1; } + steps += 1; + } + return steps; +} +``` + +A counting `for` computes both bounds once, from left to right, before the +first pass, and its variable cannot be assigned. Parenthesized ranges support +`.rev()` and `.step_by(n)`, where `n` is a positive constant whole number: + +```rust,ignore +for i in (0..10).step_by(2) { ... } // 0, 2, 4, 6, 8 +for i in (0..10).rev() { ... } // 9 down to 0 +for i in (0..=10).rev().step_by(3) { ... } // 10, 7, 4, 1 +``` + +Empty ranges stay empty when reversed. Counting stops at the scoreboard's +integer boundaries without wrapping. + + `while` accepts any condition; one plain +comparison is checked directly, and anything else is computed into a flag +before each pass. + +Inside `for player in players()`, `continue;` skips to the next player; +`break;` is an error there, because every player runs once. As in +Rust, the loop changes who runs the body but not where: `offset(..)`, sounds, +particles, and summons stay at the caller's position (the world spawn in +`#[tick]`). `#[on(...)]` handlers and `for name in entities(..)` bodies do run +positioned at their player or entity. + +Conditions can also ask about the world and the executor: + +| Condition | True when | +| --- | --- | +| `has_state(Mana)` | the executor has this `entity state` attached | +| `any_entities(type = .., tag = .., distance = ..)` | at least one entity matches | +| `block_is(Block::Water, offset(0, -1, 0))` | the position holds this block or `Block` tag | +| `holding(Item::Diamond)`, `holding(Wand, offhand = true)`, `holding(Helmet, slot = EquipmentSlot::Head)` | the executor has this item in the selected slot | +| `is_sneaking()`, `is_sprinting()`, `is_swimming()`, `is_on_fire()` | the executor is doing it | +| `timer_running(Ability.dash)`, `timer_done(Ability.dash)` | a `timer` field has time left, or none | + + +`equip(item, slot, count = 1)` replaces one equipment stack on the executor. +`clear_equipment(slot)` discards that stack. Use `EquipmentSlot::Head`, `Chest`, +`Legs`, `Feet`, `Mainhand`, or `Offhand` for writes and checks. A declared +custom item carries its components when equipped and matches by identity in +`holding`. Choose either `slot` or `offhand` when checking equipment. A slot +must exist on the executing entity, and Minecraft applies its native stack +limits. + +### Generics + +Functions and structs can declare type parameters. Calls infer them from value +arguments and an expected result type. Use `::` when a type has no value from +which to infer it: + +```rust,ignore +fn duplicate(value: T) -> [T; 2] { return [value, value]; } +struct Envelope { value: T } +impl Envelope { + fn new(value: T) -> Self { return Self { value }; } + fn read(&self) -> T { return self.value; } + fn choose(&self, first: U, second: U) -> U { return first; } +} +let copies = duplicate("hello"); +let envelope = Envelope::::new("saved"); +let wrapped: Envelope> = Envelope { value: [1, 2] }; +``` + +Type annotations use `Envelope`; record literals may infer their type +arguments from fields or the expected type, or spell `Envelope:: { ... }`. +Generic records work in State, defaults, events, arrays, vectors, parameters and +returns. Recursive records can use vectors, such as +`Node { value: T, children: Vec> }`. + +Generic impl blocks use the same ownership, receiver and privacy rules as other +impls. Methods can introduce their own parameters and accept explicit arguments +as `value.method::(...)`. Concrete call slots and execution contexts belong to +each specialization; copies and recursive calls preserve the same isolation as +ordinary functions. Navigation and rename follow the authored source across +specializations. Signature help uses concrete parameter types, including nested +generic arguments, and completed call results can supply receiver completions. + +Sand specializes generic bodies when concrete types are used. It checks each +specialization, rather than proving an unused generic body valid for all possible +types. Trait bounds check the concrete types used in each specialization. A package supports +at most 256 function specializations and 256 record specializations; expanding +record types stop at 64 nested specializations. The existing finite record-layout +limits still apply. These checks prevent recursively growing compile-time types. +See the [generic mining-history example](../../examples/lang_generics/pack.sand). + +### Function values and closures + +Use `fn(number) -> string` for a callable that takes a number and returns text. +Omit the arrow for a function that produces no value. An ordinary named function +can be stored by writing its name without parentheses. Bind a stored callback to +a local to call it. + +```rust,ignore +fn with_prefix(prefix: string) -> fn(number) -> string { + return move |points: number| -> string { + return prefix + points.to_string(); + }; +} + +let label = with_prefix("Points: "); +let message = label(7); +``` + +A move closure owns a snapshot of its captured locals. Captures are immutable +inside the closure and can contain records, collections, or other callbacks. +Function values can be passed to generic functions and saved in State. Dispatch +only invokes compile-checked functions with the same signature. A missing or +unrecognized callable skips the call and returns the value type's default. + +Callable targets currently run without a player or entity executor. Named +targets must be concrete non-generic functions or associated functions. Define a +closure in a generic body to retain a specialized value. Closures survive reload +of the same compiled pack. Recompiling a changed source can invalidate stored +closure identities, so initialize persistent callbacks as part of pack setup. +See the [reward notes example](../../examples/lang_callbacks/pack.sand). + +### Traits + +A trait declares required method signatures. Use `impl Trait for Type` to supply +them and `T: Trait` to require that contract in a generic function. Combine +requirements with `+`. + +```rust,ignore +trait Named { + fn name(&self) -> string; +} + +struct Quest { title: string } +impl Named for Quest { + fn name(&self) -> string { return self.title; } +} + +fn announce(quest: T) { + chat!(quest.name()); +} +``` + +Implementations may use borrowed receivers and refer to the implementing type as +`Self`. Generic records can implement a trait as in +`impl Named for Container`. Each concrete implementation must supply the +declared receiver, parameter types, and return type. Generic calls select a +concrete implementation at compile time. Trait objects, default method bodies, +associated types, and fully qualified calls to overlapping methods are still +outside the language. + +### Match + +`match` evaluates its value once and runs exactly one arm. Arms have their own +local scope and can return, break, or continue their enclosing loop: + +```rust,ignore +fn price(phase: Phase) -> number { + match phase { + Phase::Idle => { return 10; } + Phase::Fighting | Phase::Resting => { return 20; } + } +} +``` + +Patterns are typed constants or enum variants, with `|` joining alternatives. +Cover every enum variant, both booleans, or add a catch-all arm such as +`_ => { ... }` or `let name => { ... }`. Duplicate unguarded patterns, missing +cases, and arms following an unguarded catch-all are errors. Dispatch depth +does not grow with the number of arms. + +A value match evaluates only the selected arm's expression. It works in local +initializers, assignments, returns, arguments, and larger expressions. All arms +must produce the same type, including owned strings, records, arrays and vectors: + +```rust,ignore +let label = match phase { + Phase::Idle => "waiting", + Phase::Fighting | Phase::Resting => "busy", +}; +let rewards: Vec = match won { true => [5, 10], false => [] }; +``` + +Value arms are comma-separated expressions. Statement arms use scoped blocks. + +Use `if` after a pattern to add a guard in either form of `match`. Sand tests +the guard only after the pattern matches. If it evaluates to false, matching +continues with the next arm. Only unguarded arms contribute to exhaustiveness. + +Write `let` in an arm to bind the matched value or destructure a record or +fixed array. The bindings are owned copies visible in that arm's guard and body +or expression. An unguarded binding pattern covers every remaining value of the +matched type. + +```rust,ignore +let amount = match reward { + let Reward { amounts: [iron, gold], .. } if gold > 0 => iron + gold, + let Reward { amounts: [iron, _], .. } => iron, +}; +``` + + +```rust,ignore +let rank = match mined { + 10 | 20 => Rank::Beginner, + _ if mined <= 40 => Rank::Explorer, + _ => Rank::Veteran, +}; +``` + +### Block expressions + +A block can produce a value after executing scoped statements. Leave off the +semicolon on the last expression. Locals declared inside the block are visible +through its final expression. Use a block anywhere an expression fits, +including a function argument or a value match arm. + +```rust,ignore +let label = match active { + true => { + let score = Progress.mined.to_string(); + "Mined " + score + " blocks" + }, + false => "Waiting", +}; +``` + +Use the final expression to yield a result. Loops inside the block can use +`break` and `continue` locally. Function `return`, suspension and jumps to +surrounding loops are unavailable inside value blocks. + + +### Destructuring + +`let` can unpack a record or a fixed array into independent owned locals. Nested +patterns, renamed fields, `_` and `..` for omitted record fields are supported. +Use `mut` on each binding that will change: + +```rust,ignore +let Point { x, y: mut height } = point; +let [first, _, mut last] = [1, 2, 3]; +height += x; +last += first; +``` + +The initializer runs once before any binding becomes visible. Array patterns +must have the exact fixed length; vectors require explicit checked element access. +Record fields follow privacy rules. Missing fields without `..`, duplicate fields, +duplicate bindings, and incompatible types are errors. Renaming a shorthand field +or local in the editor expands the shorthand to preserve the other symbol. +See the [mining-streak example](../../examples/lang_patterns/pack.sand). + +### Casts + +`value as T` converts between `number`, `float`, `bool`, and enums. The same +rules apply to constants and to values computed while the game runs: + +| From \\ to | `number` | `float` | `bool` | enum | +| --- | --- | --- | --- | --- | +| `number` | same | `3` → `3.0` | `x != 0` | the variant with that value | +| `float` | rounds down: `2.7` → `2`, `-1.5` → `-2` | same | `x != 0.0` | error | +| `bool` | `0` or `1` | `0.0` or `1.0` | same | error | +| enum | its value | its value | error | the same enum only | + +As in Rust, `-x as T` casts the negated value. Impossible casts say what to +write instead, and a constant cast to an enum must name an existing variant. + +## Players and entities + +`Player` is the executing player, read and written like a State. Its fields +are entity data (read-only) and every attribute (read and write): + +```rust,ignore +fn tune() { + if Player.health < 6.0 && Player.food > 10 { + Player.movement_speed *= 1.2; // attributes can be assigned + } + Player.max_health = 40.0; + Player.step_height = 1.0; +} +``` + +Inside `for zombie in entities(..)` and `for player in players()`, the loop +variable is a handle to the entity running the body: `zombie.health`, +`zombie.scale = 2.0;`. Only the innermost loop's entity can be used. + +| Property | Type | Notes | +| --- | --- | --- | +| `health`, `absorption` | `float` | half-hearts | +| `air` | `number` | ticks of breath; 300 is full | +| `fire` | `number` | ticks left burning | +| `fall_distance` | `float` | blocks | +| `on_ground` | `bool` | | +| `x`, `y`, `z` | `float` | position | +| `food`, `xp_level`, `xp_total`, `selected_slot` | `number` | players only | +| `saturation`, `xp_progress` | `float` | players only | +| any attribute: `max_health`, `movement_speed`, `step_height`, `scale`, `gravity`, ... | `float` | base value; assignable | + +Attribute names are the attribute's identity without `minecraft:`, so +`Attribute::StepHeight` is `step_height`. Assigning read-only data is an error +that names the builtin to use instead, such as `damage(..)` or `teleport(..)`. +The editor completes properties after `Player.` or a loop variable and shows +each one's type, whether it can be assigned, and the command it becomes. + +## Text + +Text macros take a string with `{...}` interpolation: + +| Macro | Shows | +| --- | --- | +| `chat!("...")` | a chat message to the executing player | +| `broadcast!("...")` | a chat message to every player | +| `actionbar!("...")` | text above the executing player's hotbar | +| `title!("...")` / `subtitle!("...")` | a big title (set the subtitle first) | + +Inside the text, `{variable}` or `{State.field}` shows a number or string and `{player}` +shows the player's name. Style names (`{gold}`, `{red}`, `{bold}`, `{italic}`, +`{underlined}`, all sixteen colours, and `{reset}`) style the text that follows. +Write `{{` and `}}` for literal braces. + +```rust,ignore +title!("{yellow}{bold}Round {World.round}"); +chat!("{gray}Coins: {gold}{Wallet.coins}"); +``` + +`Text::translate("key", ...)` sends Minecraft a client translation key and one +positional text argument per placeholder. Each argument can be a format string, +a runtime `string` in a message, or another translation. Item names, lore, and +boss bar titles can use translations with fixed arguments. + +```rust,ignore +fn greeting(label: string) { + chat!(Text::translate("chat.type.text", "{player}", label)); +} +``` + +Built-in keys come from Minecraft’s language files. Keys supplied by a resource +pack resolve for players who have that pack. Sand stores runtime strings as +plain text when it passes them to placeholder arguments. + +### Interactive chat + +`Text::hover(label, tooltip)` adds a text tooltip. `Text::link(label, url)` +opens an HTTP(S) link, `Text::suggest(label, command)` fills the chat input, +and `Text::copy(label, value)` copies a quoted string to the clipboard. +These components work in `chat!`, `broadcast!`, and written-book pages. Compose them with +translations and formatted text. + +```rust,ignore +chat!(Text::hover( + Text::suggest("{aqua}Next round", "/trigger next"), + "Click to put the command in chat", +)); +``` + +### Runtime strings + +`string` is an owned value supported in locals, constants, State, record fields, +arrays, function parameters/returns and event payloads. Assignment makes an +independent copy; borrowed struct methods and recursive calls preserve strings +through the same value and frame model as other fields. + +```rust,ignore +const PREFIX: string = "Hello, "; +player state Notes { title: string = "Journal" } +let mut message = PREFIX + "world 🌍"; +message += "!"; +let count = 42; +let line = "Collected " + count.to_string() + " items"; +chat!(line); +chat!("{gold}{Notes.title}: {message}"); +``` + +Literal macro arguments retain format interpolation. Runtime string arguments +are shown as plain text, so braces and text such as `$(uuid)` remain literal. +`{local.field}` and nested State/record field paths may interpolate strings. + +| Operation | Result | +| --- | --- | +| `left + right`, `text += suffix` | Concatenate text | +| `left == right`, `left != right` | Compare the full character sequence | +| `text.len()`, `text.is_empty()` | Character count or emptiness | +| `text[index]` | One character as a string; invalid runtime indices return empty text | +| `text.slice(start, end)` | Independent text in a clamped half-open range; reversed ranges are empty | +| `text.contains(value)` | Substring membership; empty text is always contained | +| `text.starts_with(value)`, `text.ends_with(value)` | Prefix or suffix membership | +| `value.to_string()` | Signed decimal number, three-place float, boolean or enum variant name | + +Indices count Unicode scalar values, so a supplementary character counts once; +combining characters remain separate. Stored strings use typed NBT character +lists, and each State owner uses the canonical UUID lifecycle. These are plain +text values, not rich-text component values or arbitrary imported NBT strings. +String comparisons support equality rather than ordering. String constants may +combine literals and other string constants. Numeric casts do not parse text. + +Escapes include `\\`, `\"`, `\n`, `\r`, `\t`, `\0`, `\b`, `\f` and +`\u{hex}` for a Unicode scalar value. Malformed escapes report a source error. +`to_string` preserves the minimum signed integer without overflowing. A float +always shows three decimal places, including trailing zeros; an invalid enum +discriminant formats as its number. Text literals and expanded string constants +support up to 65,536 UTF-8 bytes, with at most 64 expansion levels. Runtime text +operations run as Minecraft commands, +so large values and searches remain subject to command execution limits. + +See the [saved journal example](../../examples/lang_runtime_text/pack.sand). + +## Vanilla values + +Items, blocks, entity types, sounds, particles, attributes, status effects, +and potions are typed, exactly as in Rust: + +```rust,ignore +give_item(Item::Diamond, 3); +add_effect(Effect::Speed, seconds = 10); +play_sound(Sound::EntityPlayerLevelup); +spawn_particle(Particle::Heart, count = 5); +``` + +| Sand | Rust | +| --- | --- | +| `Item::...`, `Block::...`, `Entity::...` | `sand::vanilla::Item` and friends | +| `Sound::...`, `Particle::...`, `Attribute::...` | `sand::vanilla::SoundEvent`, ... | +| `Effect::...`, `Potion::...` | `sand::registry::EffectId`, `PotionId` | + +The editor lists every value after `Item::` (or straight away inside a +builtin's argument), hovers show the Minecraft identity, and misspellings +get a "did you mean". The values come from the same generated registries as +Rust, so they always match the target Minecraft version. A namespaced string +such as `"mymod:ruby"` still works for modded or custom content; writing a +vanilla identity as a string gets a warning pointing at the typed value. + +## Builtins + +| Builtin | Does | +| --- | --- | +| `play_sound(Sound::..., volume = 1.0, pitch = 1.0)` | play a sound to the player | +| `spawn_particle(Particle::..., count = 1, spread = 0.0, speed = 0.0)` | spawn particles above the executor | +| `add_effect(Effect::..., seconds = 10, level = 2, hide_particles = true)` | give a status effect (omit `seconds` for infinite) | +| `clear_effect()` / `clear_effect(Effect::...)` | remove effects | +| `give_item(Item::..., 3)` | give items | +| `clear_item(Item::..., 2)` / `clear_inventory()` | remove items | +| `schedule(function, seconds = 5)` | run a server function later (`ticks = n` also works) | +| `raw!("command")` | run one command exactly as written (escape hatch) | + +Hover any builtin in the editor to see its arguments and the Minecraft command +it becomes. + +### Particle effects + +`spawn_particle` places particles one block above the current execution +position. The count, spread and speed accept runtime values. Count must be a +`number` from 0 to 100,000. Spread and speed accept numbers or floats from 0 to +1,000. Sand evaluates arguments in source order and skips the command when a +runtime value is out of range. + +```rust,ignore +let sparks = Hero.energy / 10; +spawn_particle(Particle::HappyVillager, count = sparks, spread = 0.25); +``` + +## Entities + +`for name in entities(..)` runs its body as each matching entity, positioned +at it. Filters are named arguments: + +```rust,ignore +#[tick] +fn sweep() { + for player in players() { + for zombie in entities(type = Entity::Zombie, distance = ..=8, limit = 3, sort = Sort::Nearest) { + damage(4.0); + add_tag("hit"); + } + } + World.zombies = count_entities(type = Entity::Zombie); +} +``` + +| Builtin | Does | +| --- | --- | +| `entities(type, tag, distance, limit, sort)` | `for` source: run as each match | +| `count_entities(...)` | how many entities match (an expression) | +| `kill()` | kill the executing entity | +| `add_tag("x")` / `remove_tag("x")` | add or remove a tag | +| `damage(amount, by = reference)` | damage the executor, optionally credited to a retained attacker | +| `summon(Entity::..., tag = "x")` | summon at the executor's position | +| `set_velocity(x, y, z)` | set the executing non-player entity’s velocity in blocks per tick | + +`any_entities`, `count_entities`, `entities`, and `teleport_to` share their +filters. Use `with = Threat` to require attached entity State. Use +`score = Threat.level` with `score_range = 3..=8` to check a `number` field +on each candidate. Exact numbers, open bounds, and exclusive upper bounds +also work. Missing scores exclude the candidate. + +Use `nbt = Nbt { Silent: true }` to match a subset of the entity’s native data. +Compounds accept nested `Nbt { ... }`, lists, literal strings, and constant +numbers and booleans. Integers use NBT ints, decimals use doubles, and bools +use bytes. NBT numeric tag types must match the native field. The compiler +applies all filters before sorting and limiting the selection. + +Read `entity.velocity_x`, `entity.velocity_y`, and `entity.velocity_z` through +the entity handle. `set_velocity` writes all three axes together. Every axis +must be within -10 to 10 blocks per tick. A runtime value outside that range +skips the write. + +An entity may not be a player, so player State and player builtins are errors +inside an `entities` loop. A function that uses `kill()`, `tag`, or `damage` +outside a loop **runs as an entity**, the third execution context: callable +from player functions and entity loops, but not from `#[tick]` directly. + +### Entity State + +`entity state` stores values on individual entities, using the same model as +Rust's `#[state(scope = entity)]`: + +```rust,ignore +entity state Mana { + #[clamp(0..=100)] + current: number = 10, +} + +#[tick] +fn tick() { + for mob in entities(type = Entity::Witch) { + if has_state(Mana) { + Mana.current += 1; + } else { + attach_state(Mana); + } + } + for carrier in entities(with = Mana) { damage(1.0); } +} +``` + +`attach_state` gives fields without a value their defaults, and keeps existing +values. `detach_state` clears them. Value reads from an absent entity-State field +use the type's default (zero, empty text/vector, or the first enum phase), so a +getter cannot retain a previous entity's value. Reading does not attach the State +or write its declared field default. A function that touches entity State +outside a loop runs as an entity. Flows only run over player or global State. + +### Retained entity references + +`EntityRef` stores a persistent, pack-owned entity identity in a local, State +field, record, parameter, return value, or custom event payload. Capture the +executing entity with `entity_ref()` and resolve it explicitly: + +```rust,ignore +entity state Mark { owner: EntityRef } +fn mark() { + let owner = entity_ref(); + for target in entities(type = Entity::Zombie, distance = ..=8) { + attach_state(Mark); + Mark.owner = owner; + } +} +fn hurt_marked() { + for target in entities(with = Mark) { + damage(4.0, by = Mark.owner); + for player in resolve_player(Mark.owner) { chat!("Your mark hit!"); } + } +} +``` + +Pass `relation = Relation::Vehicle` to retain the executor's current vehicle. +`Relation::Owner`, `Leasher`, `Target`, `Controller`, `Attacker`, and `Origin` +also resolve to at most one entity. A missing relationship returns an empty +reference. Once retained, the reference identifies that entity even if the +relationship changes. + +Use `mount(vehicle)` to ride a retained non-player entity in the current +dimension. An empty or unavailable vehicle leaves the executor where it is. +Use `dismount()` to get off the current vehicle. +See the [minecart shuttle example](../../examples/lang_vehicles/pack.sand). + +`resolve_player(reference)` runs a `for` body as an online player, at that player, +including across dimensions. `resolve_entity(reference)` also resolves loaded +non-player entities in the current dimension; its body has an entity context. +Missing, dead, unloaded, and empty references skip the body. Default references +are empty. IDs survive reload, are isolated by pack, never wrap, and are never +reassigned; exhaustion produces an empty reference. References support copying +and equality, not arithmetic or numeric casts. + +`damage(amount, by = reference)` attributes generic damage to the retained +attacker, including vanilla kill credit. Missing attackers skip the damage. +This preserves ownership instead of silently making an attack unattributed. +The [marked-combat example](../../examples/lang_reference_combat/pack.sand) +combines these references with delayed entity-State timers. + +### Movement + +`teleport(x, y, z)` moves the executor to coordinates computed at runtime or +written as constants, +`teleport_by(dx, dy, dz)` moves it relatively, and `teleport_to(type = ...)` +moves it to the nearest entity matching the same filters as `entities(..)`. + +## Custom events + +An event is a name your own functions can react to. Declare it, optionally with +a typed payload; mark handlers with `#[on(...)]`; run them all with `emit`: + +```rust,ignore +event Payday(amount: number); + +#[on(Payday)] +fn deposit(amount: number) { Wallet.coins += amount; } + +#[on(Payday)] +fn celebrate() { chat!("{gold}Paid!"); } // ignores the payload + +fn wages() { emit Payday(25); } +``` + +Handlers run in declaration order, as whoever emitted the event, and take +either exactly the event's parameters or none. `emit Name;` emits an event +without a payload. Arguments are evaluated once, and a handler may emit the +event again (it is recursion, so it needs a stopping condition). If a handler needs +a player, emitting the event needs one too, and the editor says so. Any module +can handle a `pub event`. + +## Timers and cooldowns + +A `timer` field counts down by one every tick until it reaches zero, using the +same State lifecycle as Rust's `Timer` and `Cooldown` fields: + +```rust,ignore +player state Ability { dash: timer } + +fn dash() { + if timer_running(Ability.dash) { + actionbar!("{red}{Ability.dash} ticks left"); + return; + } + start_timer(Ability.dash, seconds = 3); + teleport_by(0.0, 0.5, 0.0); +} +``` + +`start_timer` takes exactly one of `ticks` or `seconds`, including runtime +`number` values. Durations must be positive: ticks allow up to 2,147,483,647, +seconds up to 107,374,182. Invalid constants are errors; an invalid runtime +duration leaves the timer unchanged. `stop_timer` ends one early. A timer reads as the number of ticks left, so comparisons and `{Ability.dash}` +text work too. + +### Duration and position libraries + +Run `sand lang add time` to use the bundled `Duration` type. Read a value +with `.as_ticks()` when passing it to `wait` or `start_timer`. Negative tick +values and seconds outside the representable range become zero. +`saturating_add` caps the total at the largest scoreboard integer. + +Run `sand lang add spatial` to use `Position`. Construct one from coordinates +or take a player snapshot with `Position::player()`. It stores three +fixed-point `float` coordinates. Calling `.teleport()` moves the current +executor to that position in its current dimension. A position can be stored +in State, copied, and passed to functions. + +The [checkpoints example](../../examples/lang_checkpoints/) saves a position +per player and uses a typed cooldown for returning to it. + +### Waiting within a function + +Use `wait(20)` or `wait(seconds = 1)` in a function body or an `if` or `else` +branch with an entity or player executor. When the delay ends, the rest of the function runs +with its own saved parameters and locals. It runs as the original executor at +the saved position and dimension. State fields are read live when the function +resumes. A caller can continue as soon as the called function suspends. +Pass a computed `number` in ticks or seconds to give each invocation a +different delay. Invalid runtime durations continue immediately. Invalid +constant durations produce a diagnostic. + +```rust,ignore +player state Orders { count: number } + +fn prepare() { + let quantity = Orders.count; + actionbar!("Preparing {quantity} loaves…"); + if quantity > 1 { + wait(seconds = 2); + } else { + wait(10); + } + give_item(Item::Bread, count = quantity); +} +``` + +Delays count ticks while the continuation's chunk is loaded in a vanilla +dimension or a dimension declared in the pack. A missing owner ends the wait. +A player can move to another dimension while the saved chunk is still loaded. A datapack reload +invalidates outstanding waits. Use `cancel_waits()` as the original executor +to cancel that entity's pending waits in this pack. + +Waits keep up to 64 local fields including record fields and admit up to 128 +pending instances at each wait statement. +After a branch finishes, execution continues with the statements that follow +it. A `return;` within a resumed branch ends that invocation. Use waits in +functions with no return value or mutable borrowed receiver. For delayed work +from a loop or match arm, call a function that contains the wait. See the +[bakery example](../../examples/lang_waits/pack.sand). + +## The world + +Block positions are `pos(x, y, z)` in world coordinates or `offset(dx, dy, dz)` +relative to the executor. Both take constants. + +`dimension_is(Dimension::Overworld)` checks the current command dimension. +`in_dimension(Dimension::TheNether, setup_nether)` runs a parameterless function +in that dimension with the same executor. Subsequent statements return to the +original context. Minecraft scales horizontal coordinates when crossing between +the Overworld and Nether. Use an absolute `pos(...)` for specific block locations. +The vanilla choices are `Overworld`, `TheNether`, and `TheEnd`. Pass the name of +a dimension declared by the pack, or a namespaced identity such as +`"another_pack:arena"` when the dimension comes from another pack. + +`biome_is(Biome::Plains, pos(0, 80, 0))` checks the biome at a block position +in the current dimension. Biome identifiers and editor suggestions come from +the selected Minecraft version. Use a declared biome by name or a namespaced +identity for a biome from another pack. + +### Flat dimensions + +Declare a flat dimension with a stack of terrain layers in bottom-to-top order. + +```rust,ignore +dimension Workshop { + type: DimensionType::Overworld, + biome: Biome::Desert, + layers: [ + { block: Block::Bedrock, height: 1 }, + { block: Block::Sandstone, height: 2 }, + ], +} + +fn inspect_workshop() { + in_dimension(Workshop, report_workshop); +} + +fn report_workshop() { + if dimension_is(Workshop) { + broadcast!("The workshop is available."); + } +} +``` + +Each layer needs a block and a positive height. The defaults are +`DimensionType::Overworld`, `Biome::Plains`, and `structures: false`. Install +the pack before starting the world so Minecraft registers the dimension. +As in vanilla dimensions, scheduled entity work counts ticks only while its +chunk is loaded. + +### Custom biomes + +A `biome` declaration adds climate and colors that a dimension or predicate +can reference by name. + +```rust,ignore +biome LanternGrove { + temperature: 0.65, + downfall: 0.5, + water_color: "#246a73", + foliage_color: "#436a55", +} + +dimension Grove { + biome: LanternGrove, + layers: [{ block: Block::GrassBlock, height: 1 }], +} +``` + +`temperature` and `downfall` default to 0.5. Downfall ranges from zero to one. +`precipitation` defaults to true and enables rain or snow according to temperature. +Use quoted `"#rrggbb"` colors for `fog_color`, `water_color`, `water_fog_color`, +`sky_color`, `grass_color`, and `foliage_color`. The biome starts with empty +terrain feature and natural mob spawn tables. Install the pack before the +world starts to register the biome and any dimension that uses it. + +Use `spawners` to assign natural spawning entries by mob category. +Entries use typed Minecraft entity names. Weights are relative to other entries +in the same category, and the default minimum group size is one. +When omitted, the maximum defaults to the minimum. +`spawn_costs` optionally supplies an entity’s local density budget and its +per-mob charge. + +```rust,ignore +biome RabbitGrove { + spawners: { + creature: [{ entity: Entity::Rabbit, weight: 12, min_count: 2, max_count: 4 }], + }, + spawn_costs: [{ entity: Entity::Rabbit, energy_budget: 1.5, charge: 0.25 }], +} +``` + +Vanilla still applies spawn rules such as block, light, and difficulty checks. + +### Reading entity data and inventories + +`entity_data_number("Health")` reads the vanilla integer result of a checked +NBT path on the executing entity. Use this for fields beyond Sand's named +entity properties. A list query such as `entity_data_number("Pos")` returns +its length. A missing value returns zero. + +A player function can use `inventory_count(Item::Bread)` to count matching +items without removing them. A vanilla item counts all matching base stacks. +Pass a declared custom item to count only stacks created with that identity. +Use `clear_item(item, count = quantity)` with a constant or computed +`number` to remove up to that many matches. Zero removes nothing. A negative +runtime count skips removal. + +### Moving items between inventory slots + +An `inventory_transfer` moves items between two explicit slots of the current +player's inventory. Slots 0 through 8 are the hotbar. Slots 9 through 35 are the +main inventory. + +```rust,ignore +inventory_transfer StowRations { + from: 0, + to: 9, + amount: 2, + success: packed, + rejected: show_rejection, +} + +fn pack_rations() { + transfer_inventory(StowRations); +} + +fn packed() { actionbar!("{green}Packed two rations"); } +fn show_rejection() { actionbar!("{red}The move could not be completed"); } +``` + +Use a constant `amount` from 1 to 99 for an exact move. Omit it to move the +whole stack. An occupied slot accepts items when their identity and components +match and it has capacity. The optional zero-argument callbacks run as the +player after the attempt releases the inventory lock. + +### Player-owned HUDs + +A named `hud` can show an actionbar, a private boss bar, or both. Start it +as a player with `start_hud` and use `cancel_hud` to end that player's +instances early. + +```rust,ignore +player state Scout { progress: number } + +hud Survey { + ticks: 200, + every: 5, + actionbar: "{aqua}Survey in progress", + bossbar: { title: "Survey", value: Scout.progress, max: 100 }, +} + +fn begin_survey() { + Scout.progress = 0; + start_hud(Survey); +} +``` + +A HUD lasts for its configured number of loaded ticks. The `every` field +sets the refresh interval and defaults to one tick. A boss bar value can be +a constant or a `number` or `timer` State field. It stays between zero and the bar's +maximum. A player's most recently started Sand HUD with an actionbar owns +that slot. Sand removes its presentation at cancellation, expiry, or reload. + +### Structure templates + +Save a structure as a Minecraft gzip NBT file and put it inside the package. +Declare its path relative to the package root that contains `pack.sand`. + +```rust,ignore +structure_template CheckpointMarker { + source: "structures/checkpoint_marker.nbt", +} + +fn build_checkpoint() { + place_template(CheckpointMarker, offset(0, 0, 2)); +} +``` + +The build copies the asset into the datapack under its declared name. +`place_template` accepts `pos(...)` or `offset(...)` and requires the destination +chunks to be loaded. To place a template supplied by another pack, pass a +namespaced identity such as `"adventure:rooms/camp"`. The portable JSON produced +by `sand lang emit` includes the asset bytes, so another compiler host can +build the same template without access to the package files. + +### Block data and regions + +`block_data_number(at, path)` reads the vanilla integer result of a block +entity's data query. For example, `block_data_number(offset(0, 0, 1), "Items")` +reads the number of entries. A failed read returns zero. Use +`set_block_data(at, path, value)` to write a computed integer or a typed NBT +literal. String and list literals and `Nbt { ... }` compounds work as values. +`copy_block_data(from, source_path, to, destination_path)` transfers the +selected value between loaded block entities. The copy requires a present +source value. Use `remove_block_data(at, path)` to clear a selection. +Minecraft applies each block entity's own data rules. + +`clone_blocks(from, to, destination)` copies an inclusive region to a destination +corner. Use `masked = true` to preserve the destination beneath source air, or +`filter = Block::Stone` to copy only one block or a declared block tag. +`mode = CloneMode::Move` clears what it copies, and `CloneMode::Force` allows +overlapping regions. The default mode is `CloneMode::Normal`. See the +[checkpoint room example](../../examples/lang_world_ops/pack.sand). + +```rust,ignore +set_block(Block::Stone, offset(0, -1, 0)); +fill_blocks(Block::Air, offset(-2, 0, -2), offset(2, 3, 2)); +set_time(6000); +set_weather(Weather::Rain, seconds = 60); +set_gamemode(GameMode::Adventure); +add_experience(points = 10); // or levels = 2 +``` + +## Boss bars + +```rust,ignore +bossbar Raid { + title: "{red}Raid Boss", + color: BossBarColor::Purple, + style: BossBarStyle::Notched10, + max: 200, +} + +fn begin() { + show_bossbar_all(Raid); + set_bossbar(Raid, Fight.boss_hp); +} +``` + +`show_bossbar`/`hide_bossbar` change one player and leave the others alone; +`show_bossbar_all`/`hide_bossbar_all` change everyone online. `set_bossbar` and +`set_bossbar_max` take any `number` expression. + +## Items, recipes, and tags + +Data resources are declarations with typed fields: + +```rust,ignore +/// A sword forged from redstone. +item RubySword { + base: Item::DiamondSword, + name: "{red}{bold}Ruby Sword", + lore: ["{gray}Forged in fire."], + rarity: Rarity::Epic, + unbreakable: true, + enchantments: [{ enchantment: Enchantment::Sharpness, level: 5 }], +} + +tag Ores: Item { values: [Item::IronOre, "#minecraft:coal_ores"] } + +recipe RubySwordRecipe { + shaped: [" R ", " R ", " S "], + key: { R: Item::RedstoneBlock, S: Item::Stick }, + result: RubySword, +} + +recipe Nugget { smelting: Ores, result: Item::IronNugget, experience: 0.5 } +recipe RedDye { shapeless: [Item::Poppy, Item::Poppy], result: Item::RedDye, count: 2 } +``` + +- `item` fields: `base`, `name`, `lore`, `rarity`, `glint`, `unbreakable`, + `max_stack`, `enchantments`, `custom_model_data`. Enchantment variants use the + same target catalog as Rust. Use a namespaced string for an external + enchantment. `give_item(RubySword)` and + `clear_item(RubySword)` use its identity, a `custom_data` marker, exactly + like Rust's `CustomItem::custom_data`. +- `recipe` takes exactly one of `shaped` (with `key`), `shapeless`, + `smelting`, `blasting`, `smoking`, `campfire`, or `stonecutting`, plus + `result` and optionally `count`, `experience`, and `time`. Custom items can + be results but not ingredients: vanilla matches ingredients only by item or + tag. +- `tag Name: Item { values: [...] }` (or `Block`, `Entity`) takes `values`: + typed values, other tags of the same type, or `"#ns:tag"` strings, and + optionally `replace`. + +These lower through the same typed builders as Rust (`ShapedRecipe`, +`CustomItem`, `TypedTag`, ...). The editor completes field names and +offers the right typed values for each field. + +Smithing upgrades name their template, `base`, and `addition`: + +```rust,ignore +recipe Upgrade { + smithing: Item::NetheriteUpgradeSmithingTemplate, + base: Item::DiamondAxe, + addition: Item::NetheriteIngot, + result: Item::NetheriteAxe, +} +``` + +Smithing trims apply a named pattern to the armor in the base slot, preserving +its item and components. Use a quoted namespaced trim pattern ID. Omit +`result` and `count` for trim recipes. + +```rust,ignore +recipe GuardTrim { + smithing_trim: Item::SentryArmorTrimSmithingTemplate, + base: "#minecraft:trimmable_armor", + addition: Item::AmethystShard, + trim_pattern: "minecraft:sentry", +} +``` + +### Written books + +Use `book` on a custom item with `base: Item::WrittenBook`. The native title and +author are quoted strings. Pages accept fixed formatted text, translations and +interactive components. `Text::page(label, number)` links to a page in the same +book, starting at 1. + +```rust,ignore +item FieldGuide { + base: Item::WrittenBook, + book: { + title: "Field guide", + author: "Sand", + pages: [ + Text::page("{aqua}Contents", 2), + "{bold}Chapter 1\n{reset}Explore the world.", + ], + }, +} +``` + +Give the book with `give_item(FieldGuide)` or use it as a recipe result. Sand +validates the native 32 UTF-16 code-unit title limit and supports up to 100 +pages. Pages use fixed content authored in the item declaration. + +### Advancements + +Use named criteria to define player milestones tracked by Minecraft. Each +criterion uses one trigger: `inventory_item`, `place_block`, or `kill_entity`. +Every criterion is required by default. Set `require_any: true` to require one. +An advancement can award experience points once per completion. + +```rust,ignore +advancement ReadyForAdventure { + display: { + icon: Item::Spyglass, + title: "{gold}Ready for adventure", + description: "Get a spyglass or place a campfire.", + background: "minecraft:gui/advancements/backgrounds/adventure", + }, + criteria: { + get_spyglass: { inventory_item: Item::Spyglass }, + place_campfire: { place_block: Block::Campfire }, + }, + require_any: true, + experience: 5, +} +``` + +An advancement without a `display` still tracks progress and awards experience. +Minecraft 26.3 requires a background texture for a visible root. Keep criterion +names stable to preserve progress after a datapack update. + +Use `advancement_done(ReadyForAdventure)` in a player function to read the +whole advancement. Pass `criterion = "get_spyglass"` to check one named +criterion. A quoted namespaced ID also lets you read another pack’s advancement. + +Use `#[on(advancement = ReadyForAdventure)]` to run a function as the player +when they complete this pack's advancement. + +```rust,ignore +#[on(advancement = ReadyForAdventure)] +fn celebrate() { + chat!("{gold}Ready for adventure!"); +} +``` + +The advancement's native reward runs the handlers once per player completion. +Handlers in the same module run in declaration order. Experience rewards and +the player's advancement progress use the same vanilla completion. + +### Native menus + +Use `menu` for a native dialog with gameplay choices. A button can call a +parameterless function as the selecting player, enter another view, or do both. + +```rust,ignore +menu CampSupplies { + title: "{gold}Camp supplies", + ticks: 200, + page_size: 1, + while_open: Camp.active, + choices: [ + { label: "Stow rations", next: "confirm" }, + { label: "Show instructions", action: show_slots }, + ], + views: [{ + name: "confirm", + title: "Pack two rations?", + choices: [ + { label: "Pack rations", action: pack_rations, when: Camp.can_pack }, + { label: "Back", next: "main" }, + ], + }], +} + +fn open_supplies() { + open_menu(CampSupplies); +} +``` + +The engine gives each player a new set of button tokens on opening or changing +pages. A valid choice consumes that player's session before calling its +function. Use `close_menu(CampSupplies)` to invalidate its session early. +`ticks` sets the online timeout. A menu supports up to 256 buttons across all +views, and each view needs at least one button. Set `page_size` from 1 to 64 for +automatic Previous and Next controls within each view. The menu opens at +`"main"` unless `start` names another view. A transition gives the destination +fresh tokens. If the callback opens another menu itself, that menu takes priority. + +`when` checks a boolean State field immediately before a choice runs. The +button stays visible when the field is false. `while_open` checks a boolean +State field when opening, on each online tick, and again during dispatch. A +false or unavailable field closes or rejects that player's session. + +### Notice dialogs + +A named `dialog` displays a native notice with fixed rich text and a dismiss +button. Use `show_dialog` and `clear_dialog` in a player function. + +```rust,ignore +dialog Guide { + title: "{gold}Field journal", + body: [ + "Mine stone or defeat zombies to record entries.", + "Right-click the notebook to read your notes.", + ], + button: "Start exploring", +} + +#[on(first_join)] +fn welcome() { + show_dialog(Guide); +} +``` + +The body and button are optional. Omit the button label to use the client's +localized Done label. The title, body and button can use `Text::translate`. +A quoted namespaced ID can refer to a dialog in another pack. + +### Named predicates + +```rust,ignore +predicate Camp { + block: Block::Stone, + biome: Biome::Plains, + dimension: Dimension::Overworld, +} +fn welcome() { + if predicate_matches(Camp) { + broadcast!("The camp is ready."); + } +} +``` + +A declaration exports a native predicate. Include at least one constraint. +All listed constraints must pass. `block`, `biome`, and `dimension` read the +current execution location. `weather` and `chance` add optional native checks. +A loot pool can share it with `{ when: Camp, items: [Item::Bread] }`. + +### Damage types + +```rust,ignore +damage_type Thorn { + message_id: "scout_thorn", + exhaustion: 0.2, + scaling: DamageScaling::Never, + effects: DamageEffects::Thorns, +} + +fn thorn_hit(caster: EntityRef) { + damage(2.0, type = Thorn, by = caster); +} +``` + +A declaration exports a native damage type. `message_id` supplies the suffix of +its `death.attack` translation key. Provide translated text in the resource +pack. Use `DamageType::Generic` or another typed vanilla ID when a custom +resource is unnecessary. The optional `by` retains vanilla attribution for +either kind of damage type. + +### Loot tables + +```rust,ignore +loot Crate { + rolls: 2, + items: [Item::Diamond, { item: Item::Emerald, weight: 4, count: 3 }], +} + +fn open_crate() { give_loot(Crate); } // or drop_loot(Crate) at the executor +``` + +Use `pools` for independent groups of loot. Each pool rolls its own weighted +items, and its optional `chance` and `weather` conditions must both pass. +`Weather::Rain` matches rain without thunder. `Weather::Thunder` matches +thunderstorms. Chance runs from zero to one and is checked once per pool. + +```rust,ignore +loot RaidSupplies { + pools: [ + { items: [Item::Bread] }, + { weather: Weather::Thunder, chance: 0.25, items: [Item::Diamond] }, + ], +} +``` + +## Flows + +A flow drives a State field through phases. Inside a flow over an enum field, +variants can be written without their enum prefix. + +```rust,ignore +enum Phase { Idle, Fighting, Resting } +player state Hero { phase: Phase, energy: number = 100 } + +flow Encounter on Hero.phase { + Idle -> Fighting if Hero.energy >= 30 priority 10; + Fighting -> Resting if Hero.energy <= 10; + + enter Fighting => start_fight; // a named function + tick Fighting every 20 { // or an inline body + Hero.energy -= 1; + } + exit Resting { Hero.energy = 100; } +} +``` + +At most one transition fires per cycle (higher `priority` first, then +declaration order). A transition guard compares the field with constants. + +## Execution context + +Player State belongs to the executing player, so code that reads or writes it +needs one. Sand infers each function's context: + +- a function that touches player State, uses a player builtin (`chat!`, + `give_item`, `play_sound`, `{player}`, ...) outside a `for player in players()` loop, + or calls a function that does, **runs as a player**; +- a function that acts on the executing entity (`kill()`, `tag`, `damage`) + outside a loop, or calls one that does, **runs as an entity**; +- everything else **runs on the server** and can be called from anywhere. + +Entry points without a player are `#[tick]`, `#[load]`, the +`minecraft:tick`/`minecraft:load` tags, scheduled functions, and global flow +hooks. If one needs a player, the error explains the chain that requires it: + +```text +error[context]: `tick` runs from #[tick] without a player, but it calls `regen`, which needs a player + --> pack.sand:5:4 + | +5 | fn tick() { + | ^^^^ + --> pack.sand:4:1 + | +4 | #[tick] + | ^^^^^^^ runs on the server here + --> pack.sand:6:5 + | +6 | regen(); + | ^^^^^ player function called here + = help: move player work into `for player in players() { ... }` +``` + +Player event handlers (`#[on(...)]`) always run as the player. + +## How Sand compiles + +`sand lang build` runs four stages, all in one process with no Cargo build: + +1. **Parse.** Each `.sand` file is parsed into a syntax tree with error + recovery, so one mistake never hides the rest of the file. +2. **Analyse.** Names resolve through modules and `use`; types, mutability, + arguments, and returns are checked; and every function's execution context + (player or server) is inferred from what it touches. This is the same + analysis the language server runs as you type. +3. **Lower.** The package becomes Sand's portable program: a JSON-shaped model + of State, functions, and typed operations (`sand lang emit` prints it). +4. **Emit.** The same backend used by Rust and JSON frontends validates the + program and writes the datapack. + +Datapacks have no variables, call stack, or return values, so Sand maps each +language feature onto what Minecraft does have: + +| Sand | Minecraft | +| --- | --- | +| `player state` / `global state` field | a scoreboard objective, held by `@s` or a fixed holder | +| `let` variable, parameter, temporary | a slot on one compiler-owned global holder | +| `fn` | a `.mcfunction` file | +| calling `f(a, b)` | copy arguments into `f`'s parameter slots, then `function ns:f` | +| a call that can come back to its caller | first save the caller's slots on a `:__sand_frames` storage stack, restore them after | +| `return value;` | write `f`'s return slot, then `return 1` | +| `return;` from inside an `if` | the branch helper returns 1; the caller runs `execute if function run return 1` | +| `if` / `else` | `execute if score ... run return run function ` in a helper | +| `while`, `loop`, `for i in a..b` | a helper that runs its body and tail-calls itself while the condition holds | +| `break;` / `continue;` | a jump flag that skips the rest of the pass | +| `Player.health` | `execute store result score ... run data get entity @s Health 1000` | +| `Player.max_health = expr;` | the value is copied into storage and applied by a macro function | +| `x * 3 + y` | `scoreboard players operation` steps through temporaries | + +Variables are slots rather than stack frames, so Sand works out from the call +graph which calls can lead back into their caller (directly, through other +functions, or through an event a handler emits again). Only those calls save +and restore the caller's variables; every other call is a plain `function` +command. Arguments that call functions, and the arguments of a function +calling itself, are computed before any parameter is overwritten. Commands +run one after another within a tick, so players never see each other's +variables, even inside `for player in players()`. + +## Parity with Rust + +The language emits resources through Sand's compiler and uses the same typed +command and State models as Rust. Today the language covers: + +| Area | Language | Rust-only for now | +| --- | --- | --- | +| State | player, global, and entity State; scalars, records, strings, arrays, vectors, timers, clamps, flows, and impl methods | custom State migrations and derived values | +| Logic | recursive functions, borrowed method receivers, generics, static traits, function values, owned closures, destructuring, value-producing `match`, loops, casts, and top-level entity/player waits | Rust compile-time metaprogramming and richer owned tasks | +| Players and entities | loops and queries with NBT and score filters, retained identities and relationships, attributed damage, mounts, teleportation, attributes, entity properties and checked NBT reads, effects, items, inventory counts, equipment slots, non-player velocity, experience, and entity flags | archetypes | +| Events | join, first join, death, kills (by type), killed by, item use, crafting, pickups, mining, jumping, dropping, sleeping, damage taken/dealt, custom events with payloads, authored advancement completion | broader advancement triggers, equipment changes, tracked transitions, event chains | +| World | block placement, reads and cloning, time, weather, dimension and biome tests, scoped calls, flat dimensions, custom biome climate, colors and spawn tables, structure templates, typed block data literals and copies | natural structure generation, biome terrain features, other dimension generators and types | +| Text and feedback | chat, broadcast, actionbar, titles, translations, clickable text and tooltips, sounds, particles, boss bars | VFX sequences | +| Data | custom items, crafting/cooking/stonecutting/smithing upgrade and trim recipes, item/block/entity tags, conditional multi-pool loot, damage types, native world predicates, advancements, written books and notice dialogs | broader triggers, worldgen, interactive dialog flows | +| Gameplay systems | checked inventory transfers, player-owned HUDs and native menus | combat, abilities, encounters, jobs, rosters, projectiles, progression, scenes, sessions, status effects, checkpoints | + +`raw!("...")` covers single commands that have no builtin yet. + + +## Automated runtime regression probe + +The repository includes a control-flow fixture and a runner that compiles it, +executes 20 assertions on a disposable vanilla 26.2 server, and checks reload: + +```sh +cargo build -p sand-cli +python3 scripts/validate_language.py --binary target/debug/sand \ + --jar /path/to/bundled-server.jar --output /tmp/sand-language-probe +``` + +The JAR must be the complete downloaded server bundle, including its libraries. +The output path must be new; it retains the emitted pack and server logs. + +## Runtime command arguments + +Item counts, experience points/levels, sound volume/pitch, damage amounts and +teleport coordinates accept parameters, State values and calculations: + +```rust,ignore +fn reward(count: number) { give_item(Item::Bread, count); } +fn hit(amount: float) { damage(amount); } +fn move_to(x: float, y: float, z: float) { teleport(x, y, z); } +``` + +Arguments are evaluated once, in source order. A later argument cannot change a +value already captured by an earlier one. Runtime item counts outside `1..=6400` +and damage amounts outside `0.01..=1000000` perform no action; invalid constants +are compile errors. Runtime sound volumes must be nonnegative and pitch must be +within `0..=2`; out-of-range values perform no action. Other builtin parameters, +including effect durations, still require constants unless their hover +documentation says otherwise. + +The compiler validates vanilla identifiers against the pack's selected version, +independently of the version used to build the CLI. Completion follows that same +catalog. Custom namespaces remain explicit interoperability boundaries. Refresh +committed catalogs only through the maintenance generator: + +```sh +cargo run -p sand-build --example refresh_vanilla_catalog -- \ + sand-version/src/vanilla_catalog.json 26.1 26.1.1 26.1.2 26.2 26.3 +``` + +A separate vanilla 26.2 proof uses two real passive clients: + +```sh +python3 scripts/validate_language_values.py --binary target/debug/sand \ + --jar /path/to/bundled-server.jar --output /tmp/sand-values-probe +``` + +It checks independent inventories, invalid-count guards, custom-item macro text, +player position/attribute properties, dynamic experience and entity damage, and +coordinate evaluation order. It does not verify rendered UI or scripted player +controls. diff --git a/editors/README.md b/editors/README.md new file mode 100644 index 00000000..cfccafbc --- /dev/null +++ b/editors/README.md @@ -0,0 +1,21 @@ +# Editor support for the Sand language + +- [`tree-sitter-sand/`](tree-sitter-sand/grammar.js) — tree-sitter grammar used + for highlighting, brackets, indentation, and outlines. Regenerate the parser + after editing `grammar.js`: + + ```sh + cd editors/tree-sitter-sand + npx tree-sitter-cli@0.25.10 generate --abi 14 + ``` + + The compiler's grammar is `sand-lang/src/sand.pest`; keep both in step. + +- [`zed/`](zed/src/lib.rs) — the Zed extension: language configuration, + queries, and a launcher for `sand lsp`. `sand lang zed` embeds these files + and installs them with a pinned local copy of the grammar, so most users + never touch this directory. Keep `zed/languages/sand/highlights.scm` identical + to `tree-sitter-sand/queries/highlights.scm`. + +Any other editor can run `sand lsp` as a stdio language server for `*.sand`. +See the [Sand language guide](../book/src/language.md#editor-setup-zed). diff --git a/editors/tree-sitter-sand/grammar.js b/editors/tree-sitter-sand/grammar.js new file mode 100644 index 00000000..077c06c5 --- /dev/null +++ b/editors/tree-sitter-sand/grammar.js @@ -0,0 +1,409 @@ +/** + * Tree-sitter grammar for the Sand datapack language (`.sand`). + * + * This grammar drives editor highlighting, brackets, indentation, and + * outlines. The authoritative grammar used by the compiler and language + * server is `sand-lang/src/sand.pest`; keep the two in step. + */ + +const PREC = { + or: 1, + and: 2, + not: 3, + compare: 4, + additive: 5, + multiplicative: 6, + unary: 8, + cast: 7, +}; + +const commaSep = (rule) => optional(seq(rule, repeat(seq(',', rule)), optional(','))); + +module.exports = grammar({ + name: 'sand', + + extras: ($) => [/\s/, $.doc_comment, $.line_comment, $.block_comment], + + word: ($) => $.identifier, + + conflicts: ($) => [[$.type, $.applied_type], [$._condition, $._expression], [$._expression, $.place], [$.record_expression, $._condition], [$.record_expression, $._expression]], + + rules: { + source_file: ($) => repeat(choice($.inner_attribute, $._item)), + + // ── Comments ─────────────────────────────────────────────────────────── + doc_comment: (_) => token(prec(2, seq(choice('///', '//!'), /.*/))), + line_comment: (_) => token(prec(1, seq('//', /.*/))), + block_comment: (_) => token(seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/')), + + // ── Attributes ───────────────────────────────────────────────────────── + attribute: ($) => seq('#', '[', $._attribute_body, ']'), + inner_attribute: ($) => seq('#', '!', '[', $._attribute_body, ']'), + _attribute_body: ($) => + seq(field('name', alias($.identifier, $.attribute_name)), optional($.attribute_arguments)), + attribute_arguments: ($) => seq('(', commaSep($.attribute_argument), ')'), + attribute_argument: ($) => + choice(seq(field('key', alias($.identifier, $.argument_name)), '=', $._value), $._value), + _value: ($) => choice($.range, $._expression), + + visibility: (_) => 'pub', + + // ── Items ────────────────────────────────────────────────────────────── + _item: ($) => + choice( + $.mod_item, + $.use_item, + $.const_item, + $.enum_item, + $.state_item, + $.struct_item, + $.trait_item, + $.impl_item, + $.flow_item, + $.extern_function, + $.function_item, + $.event_item, + $.data_item, + ), + + struct_item: ($) => seq(repeat($.attribute), optional($.visibility), 'struct', field('name', $.identifier), optional($.generic_parameters), '{', commaSep($.field_declaration), '}'), + trait_item: ($) => seq(repeat($.attribute), optional($.visibility), 'trait', field('name', $.identifier), '{', repeat($.trait_method), '}'), + trait_method: ($) => seq('fn', field('name', $.identifier), $.parameters, optional(seq('->', field('return_type', $.type))), ';'), + impl_item: ($) => seq('impl', optional($.generic_parameters), optional(seq(field('trait', $.path), 'for')), field('type', $.path), optional($.type_arguments), '{', repeat($.function_item), '}'), + record_expression: ($) => seq(field('type', $.path), '{', $.record_field, repeat(seq(',', $.record_field)), optional(','), '}'), + record_field: ($) => seq(field('name', $.identifier), optional(seq(':', $._value_or_condition))), + method_expression: ($) => prec.left(10, seq(field('receiver', $._expression), '.', field('method', $.identifier), optional(seq('::', $.type_arguments)), $.arguments)), + field_expression: ($) => prec.left(10, seq(field('value', $._expression), '.', field('field', $.identifier))), + receiver: (_) => seq(optional('&'), optional('mut'), 'self'), + + event_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'event', + field('name', $.identifier), + optional($.parameters), + ';', + ), + + data_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + field('kind', alias(choice('item', 'recipe', 'tag', 'bossbar', 'loot', 'damage_type', 'predicate', 'advancement', 'dialog', 'dimension', 'biome', 'structure_template', 'inventory_transfer', 'hud', 'menu'), $.data_kind)), + field('name', $.identifier), + optional(seq(':', field('type', $.type))), + $.data_object, + ), + data_object: ($) => seq('{', commaSep($.data_field), '}'), + data_field: ($) => + seq( + field('key', choice(alias($.identifier, $.field_identifier), $.string)), + ':', + field('value', $._data_value), + ), + _data_value: ($) => choice($.data_object, $._expression), + + mod_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'mod', + field('name', $.identifier), + choice(';', seq('{', repeat($._item), '}')), + ), + + use_item: ($) => seq(repeat($.attribute), optional($.visibility), 'use', $.use_tree, ';'), + // Segments are spelled out (rather than reusing `path`) so `a::b::{c}` + // needs only one token of lookahead after `::`. + use_tree: ($) => + seq( + $._path_segment, + repeat(seq('::', $._path_segment)), + optional(choice(seq('::', $.use_group), seq('as', field('alias', $.identifier)))), + ), + use_group: ($) => seq('{', commaSep($.use_tree), '}'), + + const_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'const', + field('name', $.identifier), + ':', + field('type', $.type), + '=', + field('value', $._expression), + ';', + ), + + enum_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'enum', + field('name', $.identifier), + '{', + commaSep($.variant), + '}', + ), + variant: ($) => seq(field('name', $.identifier), optional(seq('=', field('value', $._expression)))), + + state_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + field('scope', alias(choice('player', 'global', 'entity'), $.scope)), + 'state', + field('name', $.identifier), + '{', + commaSep($.field_declaration), + '}', + ), + field_declaration: ($) => + seq( + repeat($.attribute), + optional($.visibility), + field('name', alias($.identifier, $.field_identifier)), + ':', + field('type', $.type), + optional(seq('=', field('default', $._expression))), + ), + type: ($) => choice($.function_type, $.array_type, $.applied_type, $.path), + function_type: ($) => prec.right(seq("fn", "(", commaSep($.type), ")", optional(seq("->", $.type)))), + applied_type: ($) => seq(field('name', $.path), '<', $.type, repeat(seq(',', $.type)), optional(','), '>'), + array_type: ($) => seq('[', field('element', $.type), ';', field('length', choice($.integer, $.path)), ']'), + array_expression: ($) => seq('[', choice(commaSep(choice($.data_object, $._value_or_condition)), seq($._expression, ';', choice($.integer, $.path))), ']'), + index_expression: ($) => prec.left(10, seq(field('value', $._expression), '[', field('index', $._expression), ']')), + + flow_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'flow', + field('name', $.identifier), + 'on', + field('field', $.place), + '{', + repeat(choice($.transition, $.hook)), + '}', + ), + transition: ($) => + seq( + field('from', $._expression), + '->', + field('to', $._expression), + optional(seq('if', field('guard', $._condition))), + optional(seq('priority', field('priority', $._expression))), + ';', + ), + hook: ($) => + seq( + field('phase', alias(choice('enter', 'exit', 'tick'), $.hook_phase)), + field('state', $._expression), + optional(seq('every', field('every', $._expression))), + choice(seq('=>', field('function', $.path), ';'), field('body', $.block)), + ), + + extern_function: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'extern', + field('id', $.string), + 'fn', + field('name', $.identifier), + '(', + ')', + ';', + ), + + function_item: ($) => + seq( + repeat($.attribute), + optional($.visibility), + 'fn', + field('name', $.identifier), + optional($.function_type_parameters), + $.parameters, + optional(seq('->', field('return_type', $.type))), + field('body', $.block), + ), + parameters: ($) => seq('(', commaSep(choice($.receiver, $.parameter)), ')'), + parameter: ($) => seq(optional($.mutable_specifier), field('name', $.identifier), ':', field('type', $.type)), + + // ── Statements ───────────────────────────────────────────────────────── + block: ($) => seq('{', repeat($._statement), '}'), + _statement: ($) => + choice( + $.destructure_statement, + $.let_statement, + $.return_statement, + $.continue_statement, + $.break_statement, + $.emit_statement, + $.match_statement, + $.while_statement, + $.loop_statement, + $.if_statement, + $.for_statement, + $.macro_invocation, + $.assignment, + $.call_statement, + ), + let_statement: ($) => + seq( + 'let', + optional($.mutable_specifier), + field('name', $.identifier), + optional(seq(':', field('type', $.type))), + optional(seq('=', field('value', $._value_or_condition))), + ';', + ), + destructure_statement: ($) => seq('let', field('pattern', choice($.record_pattern, $.array_pattern, '_')), optional(seq(':', field('type', $.type))), '=', field('value', $._value_or_condition), ';'), + _value_pattern: ($) => choice($.record_pattern, $.array_pattern, '_', $.binding_pattern), + binding_pattern: ($) => seq(optional($.mutable_specifier), field('name', $.identifier)), + record_pattern: ($) => seq(field('type', $.path), '{', optional(choice(seq($.pattern_field, repeat(seq(',', $.pattern_field)), optional(seq(',', '..')), optional(',')), '..')), '}'), + pattern_field: ($) => seq(field('name', $.identifier), optional(seq(':', $._value_pattern))), + array_pattern: ($) => seq('[', commaSep($._value_pattern), ']'), + mutable_specifier: (_) => 'mut', + return_statement: ($) => seq('return', optional($._value_or_condition), ';'), + _value_or_condition: ($) => choice($._expression, $.comparison, $.logical_condition, $.not_condition, $.in_range), + continue_statement: (_) => seq('continue', ';'), + break_statement: (_) => seq('break', ';'), + emit_statement: ($) => + seq('emit', field('event', $.path), optional($.arguments), ';'), + loop_statement: ($) => seq('loop', field('body', $.block)), + match_statement: ($) => + seq('match', field('value', $._expression), '{', repeat($.match_arm), '}'), + match_expression: ($) => seq('match', field('value', $._expression), '{', $.match_value_arm, repeat(seq(',', $.match_value_arm)), optional(','), '}'), + match_value_arm: ($) => seq(field('pattern', choice($.match_binding, '_', seq($._expression, repeat(seq('|', $._expression))))), optional($.match_guard), '=>', field('value', $._value_or_condition)), + match_arm: ($) => + seq(field('pattern', choice($.match_binding, '_', seq($._expression, repeat(seq('|', $._expression))))), + optional($.match_guard), '=>', field('body', $.block), optional(',')), + match_binding: ($) => seq('let', field('binding', $._value_pattern)), + match_guard: ($) => seq('if', field('condition', $._condition)), + while_statement: ($) => + seq('while', field('condition', $._condition), field('body', $.block)), + if_statement: ($) => + seq( + 'if', + field('condition', $._condition), + field('consequence', $.block), + optional(seq('else', field('alternative', choice($.if_statement, $.block)))), + ), + for_statement: ($) => + seq( + 'for', + field('binding', $.identifier), + 'in', + field('source', choice($._expression, $.count_range)), + field('body', $.block), + ), + count_range: ($) => choice($.range, + seq('(', $.range, ')', optional(seq('.', 'rev', '(', ')')), + optional(seq('.', 'step_by', '(', $._expression, ')')))), + macro_invocation: ($) => + seq(field('macro', alias($.identifier, $.macro_name)), '!', $.arguments, ';'), + assignment: ($) => + seq( + field('target', $._expression), + field('operator', choice('=', '+=', '-=', '*=', '/=', '%=')), + field('value', $._value_or_condition), + ';', + ), + call_statement: ($) => seq(choice($.call_expression, $.method_expression), ';'), + + // ── Conditions ───────────────────────────────────────────────────────── + _condition: ($) => + choice($.logical_condition, $.not_condition, $.comparison, $.in_range, $.parenthesized_expression, $.call_expression, $.method_expression, $.field_expression, $.index_expression, $.place, $.path, $.boolean), + logical_condition: ($) => + choice( + prec.left(PREC.or, seq($._condition, '||', $._condition)), + prec.left(PREC.and, seq($._condition, '&&', $._condition)), + ), + not_condition: ($) => prec(PREC.not, seq('!', $._condition)), + comparison: ($) => + prec.left( + PREC.compare, + seq($._expression, choice('==', '!=', '<', '<=', '>', '>='), $._expression), + ), + in_range: ($) => prec(PREC.compare, seq($._expression, 'in', $.range)), + range: ($) => + prec.right(seq(optional($._expression), choice('..', '..='), optional($._expression))), + + // ── Expressions ──────────────────────────────────────────────────────── + closure_expression: ($) => seq('move', '|', commaSep($.parameter), '|', optional(seq('->', $.type)), field('body', $.block)), + block_expression: ($) => + seq('{', repeat($._statement), field('value', $._value_or_condition), '}'), + _expression: ($) => + choice( + $.block_expression, + $.match_expression, + $.closure_expression, + $.integer, + $.float, + $.boolean, + $.string, + $.place, + $.path, + $.call_expression, + $.unary_expression, + $.binary_expression, + $.cast_expression, + $.parenthesized_expression, + $.record_expression, + $.method_expression, + $.field_expression, + $.array_expression, + $.index_expression, + ), + call_expression: ($) => seq(field('function', $.path), $.arguments), + arguments: ($) => seq('(', commaSep($.argument), ')'), + argument: ($) => + choice(seq(field('name', alias($.identifier, $.argument_name)), '=', $._argument_value), $._argument_value), + _argument_value: ($) => choice($.range, $._value_or_condition), + place: ($) => + seq(field('state', $.path), '.', field('field', alias($.identifier, $.field_identifier))), + unary_expression: ($) => prec(PREC.unary, seq('-', $._expression)), + binary_expression: ($) => + choice( + prec.left(PREC.additive, seq($._expression, choice('+', '-'), $._expression)), + prec.left(PREC.multiplicative, seq($._expression, choice('*', '/', '%'), $._expression)), + ), + cast_expression: ($) => prec(PREC.cast, seq($._expression, 'as', $.type)), + parenthesized_expression: ($) => seq('(', $._value_or_condition, ')'), + + function_type_parameters: ($) => seq('<', $.function_type_parameter, repeat(seq(',', $.function_type_parameter)), optional(','), '>'), + function_type_parameter: ($) => seq(field('name', $.identifier), optional(seq(':', field('bound', $.path), repeat(seq('+', field('bound', $.path)))))), + generic_parameters: ($) => seq('<', $.identifier, repeat(seq(',', $.identifier)), optional(','), '>'), + type_arguments: ($) => seq('<', $.type, repeat(seq(',', $.type)), optional(','), '>'), + path: ($) => prec.left(seq($._path_segment, optional(seq('::', $.type_arguments)), repeat(seq('::', $._path_segment, optional(seq('::', $.type_arguments)))))), + _path_segment: ($) => choice($.identifier, $.crate, $.self, $.super), + crate: (_) => 'crate', + self: (_) => 'self', + super: (_) => 'super', + + // ── Literals ─────────────────────────────────────────────────────────── + integer: (_) => /[0-9][0-9_]*/, + float: (_) => /[0-9]+\.[0-9]+/, + boolean: (_) => choice('true', 'false'), + string: ($) => + seq( + '"', + repeat(choice($.string_content, $.escape_sequence, $.brace_escape, $.interpolation)), + token.immediate('"'), + ), + string_content: (_) => token.immediate(prec(1, /[^"\\{}]+/)), + escape_sequence: (_) => token.immediate(seq('\\', /./)), + brace_escape: (_) => token.immediate(prec(2, choice('{{', '}}'))), + interpolation: ($) => + seq( + token.immediate('{'), + optional(alias(token.immediate(/[^{}"]+/), $.interpolation_content)), + token.immediate('}'), + ), + + identifier: (_) => /[A-Za-z_][A-Za-z0-9_]*/, + }, +}); diff --git a/editors/tree-sitter-sand/package.json b/editors/tree-sitter-sand/package.json new file mode 100644 index 00000000..56a92973 --- /dev/null +++ b/editors/tree-sitter-sand/package.json @@ -0,0 +1,14 @@ +{ + "name": "tree-sitter-sand", + "version": "0.1.0", + "description": "Tree-sitter grammar for the Sand datapack language", + "license": "MIT", + "main": "bindings/node", + "tree-sitter": [ + { + "scope": "source.sand", + "file-types": ["sand"], + "highlights": "queries/highlights.scm" + } + ] +} diff --git a/editors/tree-sitter-sand/queries/highlights.scm b/editors/tree-sitter-sand/queries/highlights.scm new file mode 100644 index 00000000..f1fd0254 --- /dev/null +++ b/editors/tree-sitter-sand/queries/highlights.scm @@ -0,0 +1,129 @@ +; Comments +(doc_comment) @comment.doc +(line_comment) @comment +(block_comment) @comment + +; Literals +(string) @string +(escape_sequence) @string.escape +(brace_escape) @string.escape +(interpolation + "{" @punctuation.special + "}" @punctuation.special) @embedded +(interpolation_content) @variable.special +(integer) @number +(float) @number +(boolean) @boolean + +; Attributes: #[tick], #[on(death)], #![pack(...)] +(attribute "#" @attribute "[" @attribute "]" @attribute) +(inner_attribute "#" @attribute "!" @attribute "[" @attribute "]" @attribute) +(attribute_name) @attribute +(argument_name) @property + +; Struct values and inherent methods +(trait_item name: (identifier) @type) +(trait_method name: (identifier) @function.method) +(function_type_parameter name: (identifier) @type bound: (path) @type) +(impl_item trait: (path) @type) +(struct_item name: (identifier) @type) +(impl_item type: (path) @type) +(record_expression type: (path) @type) +(record_field name: (identifier) @property) +(record_pattern type: (path) @type) +(pattern_field name: (identifier) @property) +(binding_pattern name: (identifier) @variable) +(method_expression method: (identifier) @function.method) +(field_expression field: (identifier) @property) +(receiver) @variable.builtin +(generic_parameters (identifier) @type) + +; Declarations +(function_item name: (identifier) @function) +(extern_function name: (identifier) @function) +(event_item name: (identifier) @type) +(state_item name: (identifier) @type) +(enum_item name: (identifier) @type) +(flow_item name: (identifier) @type) +(mod_item name: (identifier) @namespace) +(const_item name: (identifier) @constant) +(variant name: (identifier) @variant) +(field_declaration name: (field_identifier) @property) +(data_item name: (identifier) @type) +(data_kind) @keyword +(data_field key: (field_identifier) @property) +(parameter name: (identifier) @variable.parameter) +(let_statement name: (identifier) @variable) +(mutable_specifier) @keyword.modifier +(type) @type +(scope) @keyword.modifier +(hook_phase) @keyword + +; Uses +(place field: (field_identifier) @property) +(macro_invocation macro: (macro_name) @function.macro "!" @function.macro) +(call_expression function: (path (identifier) @function .)) +(transition from: (path (identifier) @variant)) +(transition to: (path (identifier) @variant)) +(hook state: (path (identifier) @variant)) +(hook function: (path (identifier) @function .)) + +; Paths: `Type::Variant`, `module::item`, upper-case names as types +((identifier) @type + (#match? @type "^[A-Z][A-Za-z0-9_]*$")) +((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$")) +(crate) @keyword +(self) @keyword +(super) @keyword + +; Keywords +[ + "fn" + "struct" + "move" + "trait" + "impl" + "mod" + "use" + "const" + "enum" + "state" + "flow" + "event" + "extern" + "as" + "on" + "let" +] @keyword + +[ + "if" + "else" + "for" + "in" + "every" + "priority" + "match" + "while" + "loop" + "return" + "continue" + "break" + "emit" +] @keyword.control + +(visibility) @keyword + +; Operators and punctuation +[ + "=" "+=" "-=" "*=" "/=" "%=" + "==" "!=" "<" "<=" ">" ">=" + "&&" "||" "!" "|" + "+" "-" "*" "/" "%" + ".." "..=" + "->" "=>" +] @operator + +["(" ")" "{" "}" "[" "]"] @punctuation.bracket +["," ";" ":" "::" "."] @punctuation.delimiter diff --git a/editors/tree-sitter-sand/src/grammar.json b/editors/tree-sitter-sand/src/grammar.json new file mode 100644 index 00000000..40b91f47 --- /dev/null +++ b/editors/tree-sitter-sand/src/grammar.json @@ -0,0 +1,4979 @@ +{ + "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json", + "name": "sand", + "word": "identifier", + "rules": { + "source_file": { + "type": "REPEAT", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "inner_attribute" + }, + { + "type": "SYMBOL", + "name": "_item" + } + ] + } + }, + "doc_comment": { + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 2, + "content": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "///" + }, + { + "type": "STRING", + "value": "//!" + } + ] + }, + { + "type": "PATTERN", + "value": ".*" + } + ] + } + } + }, + "line_comment": { + "type": "TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "//" + }, + { + "type": "PATTERN", + "value": ".*" + } + ] + } + } + }, + "block_comment": { + "type": "TOKEN", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "/*" + }, + { + "type": "PATTERN", + "value": "[^*]*\\*+([^/*][^*]*\\*+)*" + }, + { + "type": "STRING", + "value": "/" + } + ] + } + }, + "attribute": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "#" + }, + { + "type": "STRING", + "value": "[" + }, + { + "type": "SYMBOL", + "name": "_attribute_body" + }, + { + "type": "STRING", + "value": "]" + } + ] + }, + "inner_attribute": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "#" + }, + { + "type": "STRING", + "value": "!" + }, + { + "type": "STRING", + "value": "[" + }, + { + "type": "SYMBOL", + "name": "_attribute_body" + }, + { + "type": "STRING", + "value": "]" + } + ] + }, + "_attribute_body": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "attribute_name" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "attribute_arguments" + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "attribute_arguments": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "attribute_argument" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "attribute_argument" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "attribute_argument": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "key", + "content": { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "argument_name" + } + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "_value" + } + ] + }, + { + "type": "SYMBOL", + "name": "_value" + } + ] + }, + "_value": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "range" + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + }, + "visibility": { + "type": "STRING", + "value": "pub" + }, + "_item": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "mod_item" + }, + { + "type": "SYMBOL", + "name": "use_item" + }, + { + "type": "SYMBOL", + "name": "const_item" + }, + { + "type": "SYMBOL", + "name": "enum_item" + }, + { + "type": "SYMBOL", + "name": "state_item" + }, + { + "type": "SYMBOL", + "name": "struct_item" + }, + { + "type": "SYMBOL", + "name": "trait_item" + }, + { + "type": "SYMBOL", + "name": "impl_item" + }, + { + "type": "SYMBOL", + "name": "flow_item" + }, + { + "type": "SYMBOL", + "name": "extern_function" + }, + { + "type": "SYMBOL", + "name": "function_item" + }, + { + "type": "SYMBOL", + "name": "event_item" + }, + { + "type": "SYMBOL", + "name": "data_item" + } + ] + }, + "struct_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "struct" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "generic_parameters" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "field_declaration" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "field_declaration" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "trait_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "trait" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "trait_method" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "trait_method": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "fn" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "SYMBOL", + "name": "parameters" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "->" + }, + { + "type": "FIELD", + "name": "return_type", + "content": { + "type": "SYMBOL", + "name": "type" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "impl_item": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "impl" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "generic_parameters" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "trait", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "STRING", + "value": "for" + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "type_arguments" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "function_item" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "record_expression": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "SYMBOL", + "name": "record_field" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "record_field" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "record_field": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "_value_or_condition" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "method_expression": { + "type": "PREC_LEFT", + "value": 10, + "content": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "receiver", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "." + }, + { + "type": "FIELD", + "name": "method", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "::" + }, + { + "type": "SYMBOL", + "name": "type_arguments" + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SYMBOL", + "name": "arguments" + } + ] + } + }, + "field_expression": { + "type": "PREC_LEFT", + "value": 10, + "content": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "." + }, + { + "type": "FIELD", + "name": "field", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + } + ] + } + }, + "receiver": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "&" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "mut" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "self" + } + ] + }, + "event_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "event" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "parameters" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "data_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "kind", + "content": { + "type": "ALIAS", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "item" + }, + { + "type": "STRING", + "value": "recipe" + }, + { + "type": "STRING", + "value": "tag" + }, + { + "type": "STRING", + "value": "bossbar" + }, + { + "type": "STRING", + "value": "loot" + }, + { + "type": "STRING", + "value": "damage_type" + }, + { + "type": "STRING", + "value": "predicate" + }, + { + "type": "STRING", + "value": "advancement" + }, + { + "type": "STRING", + "value": "dialog" + }, + { + "type": "STRING", + "value": "dimension" + }, + { + "type": "STRING", + "value": "biome" + }, + { + "type": "STRING", + "value": "structure_template" + }, + { + "type": "STRING", + "value": "inventory_transfer" + }, + { + "type": "STRING", + "value": "hud" + }, + { + "type": "STRING", + "value": "menu" + } + ] + }, + "named": true, + "value": "data_kind" + } + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "type" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SYMBOL", + "name": "data_object" + } + ] + }, + "data_object": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "data_field" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "data_field" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "data_field": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "key", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "field_identifier" + }, + { + "type": "SYMBOL", + "name": "string" + } + ] + } + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_data_value" + } + } + ] + }, + "_data_value": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "data_object" + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + }, + "mod_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "mod" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": ";" + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_item" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + } + ] + } + ] + }, + "use_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "use" + }, + { + "type": "SYMBOL", + "name": "use_tree" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "use_tree": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_path_segment" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "::" + }, + { + "type": "SYMBOL", + "name": "_path_segment" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "::" + }, + { + "type": "SYMBOL", + "name": "use_group" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "as" + }, + { + "type": "FIELD", + "name": "alias", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "use_group": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "use_tree" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "use_tree" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "const_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "const" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "type" + } + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "enum_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "enum" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "variant" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "variant" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "variant": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "state_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "scope", + "content": { + "type": "ALIAS", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "player" + }, + { + "type": "STRING", + "value": "global" + }, + { + "type": "STRING", + "value": "entity" + } + ] + }, + "named": true, + "value": "scope" + } + }, + { + "type": "STRING", + "value": "state" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "field_declaration" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "field_declaration" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "field_declaration": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "field_identifier" + } + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "type" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "default", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "type": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "function_type" + }, + { + "type": "SYMBOL", + "name": "array_type" + }, + { + "type": "SYMBOL", + "name": "applied_type" + }, + { + "type": "SYMBOL", + "name": "path" + } + ] + }, + "function_type": { + "type": "PREC_RIGHT", + "value": 0, + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "fn" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "type" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "type" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "->" + }, + { + "type": "SYMBOL", + "name": "type" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + } + }, + "applied_type": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "STRING", + "value": "<" + }, + { + "type": "SYMBOL", + "name": "type" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "type" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ">" + } + ] + }, + "array_type": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "[" + }, + { + "type": "FIELD", + "name": "element", + "content": { + "type": "SYMBOL", + "name": "type" + } + }, + { + "type": "STRING", + "value": ";" + }, + { + "type": "FIELD", + "name": "length", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "integer" + }, + { + "type": "SYMBOL", + "name": "path" + } + ] + } + }, + { + "type": "STRING", + "value": "]" + } + ] + }, + "array_expression": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "[" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "data_object" + }, + { + "type": "SYMBOL", + "name": "_value_or_condition" + } + ] + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "data_object" + }, + { + "type": "SYMBOL", + "name": "_value_or_condition" + } + ] + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "STRING", + "value": ";" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "integer" + }, + { + "type": "SYMBOL", + "name": "path" + } + ] + } + ] + } + ] + }, + { + "type": "STRING", + "value": "]" + } + ] + }, + "index_expression": { + "type": "PREC_LEFT", + "value": 10, + "content": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "[" + }, + { + "type": "FIELD", + "name": "index", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "]" + } + ] + } + }, + "flow_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "flow" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": "on" + }, + { + "type": "FIELD", + "name": "field", + "content": { + "type": "SYMBOL", + "name": "place" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "transition" + }, + { + "type": "SYMBOL", + "name": "hook" + } + ] + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "transition": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "from", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "->" + }, + { + "type": "FIELD", + "name": "to", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "if" + }, + { + "type": "FIELD", + "name": "guard", + "content": { + "type": "SYMBOL", + "name": "_condition" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "priority" + }, + { + "type": "FIELD", + "name": "priority", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "hook": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "phase", + "content": { + "type": "ALIAS", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "enter" + }, + { + "type": "STRING", + "value": "exit" + }, + { + "type": "STRING", + "value": "tick" + } + ] + }, + "named": true, + "value": "hook_phase" + } + }, + { + "type": "FIELD", + "name": "state", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "every" + }, + { + "type": "FIELD", + "name": "every", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=>" + }, + { + "type": "FIELD", + "name": "function", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + } + ] + } + ] + }, + "extern_function": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "extern" + }, + { + "type": "FIELD", + "name": "id", + "content": { + "type": "SYMBOL", + "name": "string" + } + }, + { + "type": "STRING", + "value": "fn" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "STRING", + "value": ")" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "function_item": { + "type": "SEQ", + "members": [ + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "attribute" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "visibility" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "fn" + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "function_type_parameters" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "SYMBOL", + "name": "parameters" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "->" + }, + { + "type": "FIELD", + "name": "return_type", + "content": { + "type": "SYMBOL", + "name": "type" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + } + ] + }, + "parameters": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "receiver" + }, + { + "type": "SYMBOL", + "name": "parameter" + } + ] + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "receiver" + }, + { + "type": "SYMBOL", + "name": "parameter" + } + ] + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "parameter": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "mutable_specifier" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "type" + } + } + ] + }, + "block": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_statement" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "destructure_statement" + }, + { + "type": "SYMBOL", + "name": "let_statement" + }, + { + "type": "SYMBOL", + "name": "return_statement" + }, + { + "type": "SYMBOL", + "name": "continue_statement" + }, + { + "type": "SYMBOL", + "name": "break_statement" + }, + { + "type": "SYMBOL", + "name": "emit_statement" + }, + { + "type": "SYMBOL", + "name": "match_statement" + }, + { + "type": "SYMBOL", + "name": "while_statement" + }, + { + "type": "SYMBOL", + "name": "loop_statement" + }, + { + "type": "SYMBOL", + "name": "if_statement" + }, + { + "type": "SYMBOL", + "name": "for_statement" + }, + { + "type": "SYMBOL", + "name": "macro_invocation" + }, + { + "type": "SYMBOL", + "name": "assignment" + }, + { + "type": "SYMBOL", + "name": "call_statement" + } + ] + }, + "let_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "let" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "mutable_specifier" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "type" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_value_or_condition" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "destructure_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "let" + }, + { + "type": "FIELD", + "name": "pattern", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "record_pattern" + }, + { + "type": "SYMBOL", + "name": "array_pattern" + }, + { + "type": "STRING", + "value": "_" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "type" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_value_or_condition" + } + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "_value_pattern": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "record_pattern" + }, + { + "type": "SYMBOL", + "name": "array_pattern" + }, + { + "type": "STRING", + "value": "_" + }, + { + "type": "SYMBOL", + "name": "binding_pattern" + } + ] + }, + "binding_pattern": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "mutable_specifier" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + } + ] + }, + "record_pattern": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "type", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "pattern_field" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "pattern_field" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "STRING", + "value": ".." + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "STRING", + "value": ".." + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "pattern_field": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "SYMBOL", + "name": "_value_pattern" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "array_pattern": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "[" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_value_pattern" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "_value_pattern" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "]" + } + ] + }, + "mutable_specifier": { + "type": "STRING", + "value": "mut" + }, + "return_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "return" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_value_or_condition" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "_value_or_condition": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "SYMBOL", + "name": "comparison" + }, + { + "type": "SYMBOL", + "name": "logical_condition" + }, + { + "type": "SYMBOL", + "name": "not_condition" + }, + { + "type": "SYMBOL", + "name": "in_range" + } + ] + }, + "continue_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "continue" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "break_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "break" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "emit_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "emit" + }, + { + "type": "FIELD", + "name": "event", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "arguments" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "loop_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "loop" + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + } + ] + }, + "match_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "match" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "match_arm" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "match_expression": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "match" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "{" + }, + { + "type": "SYMBOL", + "name": "match_value_arm" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "match_value_arm" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "match_value_arm": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "pattern", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "match_binding" + }, + { + "type": "STRING", + "value": "_" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "|" + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + } + } + ] + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "match_guard" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "=>" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_value_or_condition" + } + } + ] + }, + "match_arm": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "pattern", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "match_binding" + }, + { + "type": "STRING", + "value": "_" + }, + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "|" + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + } + } + ] + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "match_guard" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "=>" + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "match_binding": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "let" + }, + { + "type": "FIELD", + "name": "binding", + "content": { + "type": "SYMBOL", + "name": "_value_pattern" + } + } + ] + }, + "match_guard": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "if" + }, + { + "type": "FIELD", + "name": "condition", + "content": { + "type": "SYMBOL", + "name": "_condition" + } + } + ] + }, + "while_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "while" + }, + { + "type": "FIELD", + "name": "condition", + "content": { + "type": "SYMBOL", + "name": "_condition" + } + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + } + ] + }, + "if_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "if" + }, + { + "type": "FIELD", + "name": "condition", + "content": { + "type": "SYMBOL", + "name": "_condition" + } + }, + { + "type": "FIELD", + "name": "consequence", + "content": { + "type": "SYMBOL", + "name": "block" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "else" + }, + { + "type": "FIELD", + "name": "alternative", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "if_statement" + }, + { + "type": "SYMBOL", + "name": "block" + } + ] + } + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "for_statement": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "for" + }, + { + "type": "FIELD", + "name": "binding", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "STRING", + "value": "in" + }, + { + "type": "FIELD", + "name": "source", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "SYMBOL", + "name": "count_range" + } + ] + } + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + } + ] + }, + "count_range": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "range" + }, + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "range" + }, + { + "type": "STRING", + "value": ")" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "." + }, + { + "type": "STRING", + "value": "rev" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "." + }, + { + "type": "STRING", + "value": "step_by" + }, + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + } + ] + }, + "macro_invocation": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "macro", + "content": { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "macro_name" + } + }, + { + "type": "STRING", + "value": "!" + }, + { + "type": "SYMBOL", + "name": "arguments" + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "assignment": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "target", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "FIELD", + "name": "operator", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "STRING", + "value": "+=" + }, + { + "type": "STRING", + "value": "-=" + }, + { + "type": "STRING", + "value": "*=" + }, + { + "type": "STRING", + "value": "/=" + }, + { + "type": "STRING", + "value": "%=" + } + ] + } + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_value_or_condition" + } + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "call_statement": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "call_expression" + }, + { + "type": "SYMBOL", + "name": "method_expression" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "_condition": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "logical_condition" + }, + { + "type": "SYMBOL", + "name": "not_condition" + }, + { + "type": "SYMBOL", + "name": "comparison" + }, + { + "type": "SYMBOL", + "name": "in_range" + }, + { + "type": "SYMBOL", + "name": "parenthesized_expression" + }, + { + "type": "SYMBOL", + "name": "call_expression" + }, + { + "type": "SYMBOL", + "name": "method_expression" + }, + { + "type": "SYMBOL", + "name": "field_expression" + }, + { + "type": "SYMBOL", + "name": "index_expression" + }, + { + "type": "SYMBOL", + "name": "place" + }, + { + "type": "SYMBOL", + "name": "path" + }, + { + "type": "SYMBOL", + "name": "boolean" + } + ] + }, + "logical_condition": { + "type": "CHOICE", + "members": [ + { + "type": "PREC_LEFT", + "value": 1, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_condition" + }, + { + "type": "STRING", + "value": "||" + }, + { + "type": "SYMBOL", + "name": "_condition" + } + ] + } + }, + { + "type": "PREC_LEFT", + "value": 2, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_condition" + }, + { + "type": "STRING", + "value": "&&" + }, + { + "type": "SYMBOL", + "name": "_condition" + } + ] + } + } + ] + }, + "not_condition": { + "type": "PREC", + "value": 3, + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "!" + }, + { + "type": "SYMBOL", + "name": "_condition" + } + ] + } + }, + "comparison": { + "type": "PREC_LEFT", + "value": 4, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "==" + }, + { + "type": "STRING", + "value": "!=" + }, + { + "type": "STRING", + "value": "<" + }, + { + "type": "STRING", + "value": "<=" + }, + { + "type": "STRING", + "value": ">" + }, + { + "type": "STRING", + "value": ">=" + } + ] + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + } + }, + "in_range": { + "type": "PREC", + "value": 4, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "STRING", + "value": "in" + }, + { + "type": "SYMBOL", + "name": "range" + } + ] + } + }, + "range": { + "type": "PREC_RIGHT", + "value": 0, + "content": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": ".." + }, + { + "type": "STRING", + "value": "..=" + } + ] + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "BLANK" + } + ] + } + ] + } + }, + "closure_expression": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "move" + }, + { + "type": "STRING", + "value": "|" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "parameter" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "parameter" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": "|" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "->" + }, + { + "type": "SYMBOL", + "name": "type" + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "FIELD", + "name": "body", + "content": { + "type": "SYMBOL", + "name": "block" + } + } + ] + }, + "block_expression": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "{" + }, + { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_statement" + } + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_value_or_condition" + } + }, + { + "type": "STRING", + "value": "}" + } + ] + }, + "_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "block_expression" + }, + { + "type": "SYMBOL", + "name": "match_expression" + }, + { + "type": "SYMBOL", + "name": "closure_expression" + }, + { + "type": "SYMBOL", + "name": "integer" + }, + { + "type": "SYMBOL", + "name": "float" + }, + { + "type": "SYMBOL", + "name": "boolean" + }, + { + "type": "SYMBOL", + "name": "string" + }, + { + "type": "SYMBOL", + "name": "place" + }, + { + "type": "SYMBOL", + "name": "path" + }, + { + "type": "SYMBOL", + "name": "call_expression" + }, + { + "type": "SYMBOL", + "name": "unary_expression" + }, + { + "type": "SYMBOL", + "name": "binary_expression" + }, + { + "type": "SYMBOL", + "name": "cast_expression" + }, + { + "type": "SYMBOL", + "name": "parenthesized_expression" + }, + { + "type": "SYMBOL", + "name": "record_expression" + }, + { + "type": "SYMBOL", + "name": "method_expression" + }, + { + "type": "SYMBOL", + "name": "field_expression" + }, + { + "type": "SYMBOL", + "name": "array_expression" + }, + { + "type": "SYMBOL", + "name": "index_expression" + } + ] + }, + "call_expression": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "function", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "SYMBOL", + "name": "arguments" + } + ] + }, + "arguments": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "argument" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "argument" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "argument": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "argument_name" + } + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "SYMBOL", + "name": "_argument_value" + } + ] + }, + { + "type": "SYMBOL", + "name": "_argument_value" + } + ] + }, + "_argument_value": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "range" + }, + { + "type": "SYMBOL", + "name": "_value_or_condition" + } + ] + }, + "place": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "state", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "STRING", + "value": "." + }, + { + "type": "FIELD", + "name": "field", + "content": { + "type": "ALIAS", + "content": { + "type": "SYMBOL", + "name": "identifier" + }, + "named": true, + "value": "field_identifier" + } + } + ] + }, + "unary_expression": { + "type": "PREC", + "value": 8, + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "-" + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + } + }, + "binary_expression": { + "type": "CHOICE", + "members": [ + { + "type": "PREC_LEFT", + "value": 5, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "+" + }, + { + "type": "STRING", + "value": "-" + } + ] + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + } + }, + { + "type": "PREC_LEFT", + "value": 6, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "*" + }, + { + "type": "STRING", + "value": "/" + }, + { + "type": "STRING", + "value": "%" + } + ] + }, + { + "type": "SYMBOL", + "name": "_expression" + } + ] + } + } + ] + }, + "cast_expression": { + "type": "PREC", + "value": 7, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "STRING", + "value": "as" + }, + { + "type": "SYMBOL", + "name": "type" + } + ] + } + }, + "parenthesized_expression": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "(" + }, + { + "type": "SYMBOL", + "name": "_value_or_condition" + }, + { + "type": "STRING", + "value": ")" + } + ] + }, + "function_type_parameters": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "<" + }, + { + "type": "SYMBOL", + "name": "function_type_parameter" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "function_type_parameter" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ">" + } + ] + }, + "function_type_parameter": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": ":" + }, + { + "type": "FIELD", + "name": "bound", + "content": { + "type": "SYMBOL", + "name": "path" + } + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "+" + }, + { + "type": "FIELD", + "name": "bound", + "content": { + "type": "SYMBOL", + "name": "path" + } + } + ] + } + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + }, + "generic_parameters": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "<" + }, + { + "type": "SYMBOL", + "name": "identifier" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "identifier" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ">" + } + ] + }, + "type_arguments": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "<" + }, + { + "type": "SYMBOL", + "name": "type" + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "SYMBOL", + "name": "type" + } + ] + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "," + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ">" + } + ] + }, + "path": { + "type": "PREC_LEFT", + "value": 0, + "content": { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_path_segment" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "::" + }, + { + "type": "SYMBOL", + "name": "type_arguments" + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "REPEAT", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "::" + }, + { + "type": "SYMBOL", + "name": "_path_segment" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "::" + }, + { + "type": "SYMBOL", + "name": "type_arguments" + } + ] + }, + { + "type": "BLANK" + } + ] + } + ] + } + } + ] + } + }, + "_path_segment": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "identifier" + }, + { + "type": "SYMBOL", + "name": "crate" + }, + { + "type": "SYMBOL", + "name": "self" + }, + { + "type": "SYMBOL", + "name": "super" + } + ] + }, + "crate": { + "type": "STRING", + "value": "crate" + }, + "self": { + "type": "STRING", + "value": "self" + }, + "super": { + "type": "STRING", + "value": "super" + }, + "integer": { + "type": "PATTERN", + "value": "[0-9][0-9_]*" + }, + "float": { + "type": "PATTERN", + "value": "[0-9]+\\.[0-9]+" + }, + "boolean": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "true" + }, + { + "type": "STRING", + "value": "false" + } + ] + }, + "string": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "\"" + }, + { + "type": "REPEAT", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "string_content" + }, + { + "type": "SYMBOL", + "name": "escape_sequence" + }, + { + "type": "SYMBOL", + "name": "brace_escape" + }, + { + "type": "SYMBOL", + "name": "interpolation" + } + ] + } + }, + { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "STRING", + "value": "\"" + } + } + ] + }, + "string_content": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PREC", + "value": 1, + "content": { + "type": "PATTERN", + "value": "[^\"\\\\{}]+" + } + } + }, + "escape_sequence": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "\\" + }, + { + "type": "PATTERN", + "value": "." + } + ] + } + }, + "brace_escape": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PREC", + "value": 2, + "content": { + "type": "CHOICE", + "members": [ + { + "type": "STRING", + "value": "{{" + }, + { + "type": "STRING", + "value": "}}" + } + ] + } + } + }, + "interpolation": { + "type": "SEQ", + "members": [ + { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "STRING", + "value": "{" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "ALIAS", + "content": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "PATTERN", + "value": "[^{}\"]+" + } + }, + "named": true, + "value": "interpolation_content" + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "STRING", + "value": "}" + } + } + ] + }, + "identifier": { + "type": "PATTERN", + "value": "[A-Za-z_][A-Za-z0-9_]*" + } + }, + "extras": [ + { + "type": "PATTERN", + "value": "\\s" + }, + { + "type": "SYMBOL", + "name": "doc_comment" + }, + { + "type": "SYMBOL", + "name": "line_comment" + }, + { + "type": "SYMBOL", + "name": "block_comment" + } + ], + "conflicts": [ + [ + "type", + "applied_type" + ], + [ + "_condition", + "_expression" + ], + [ + "_expression", + "place" + ], + [ + "record_expression", + "_condition" + ], + [ + "record_expression", + "_expression" + ] + ], + "precedences": [], + "externals": [], + "inline": [], + "supertypes": [], + "reserved": {} +} \ No newline at end of file diff --git a/editors/tree-sitter-sand/src/node-types.json b/editors/tree-sitter-sand/src/node-types.json new file mode 100644 index 00000000..84abfa0e --- /dev/null +++ b/editors/tree-sitter-sand/src/node-types.json @@ -0,0 +1,6120 @@ +[ + { + "type": "applied_type", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + { + "type": "argument", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": false, + "types": [ + { + "type": "argument_name", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "range", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "arguments", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "argument", + "named": true + } + ] + } + }, + { + "type": "array_expression", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "data_object", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "array_pattern", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "array_pattern", + "named": true + }, + { + "type": "binding_pattern", + "named": true + }, + { + "type": "record_pattern", + "named": true + } + ] + } + }, + { + "type": "array_type", + "named": true, + "fields": { + "element": { + "multiple": false, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + }, + "length": { + "multiple": false, + "required": true, + "types": [ + { + "type": "integer", + "named": true + }, + { + "type": "path", + "named": true + } + ] + } + } + }, + { + "type": "assignment", + "named": true, + "fields": { + "operator": { + "multiple": false, + "required": true, + "types": [ + { + "type": "%=", + "named": false + }, + { + "type": "*=", + "named": false + }, + { + "type": "+=", + "named": false + }, + { + "type": "-=", + "named": false + }, + { + "type": "/=", + "named": false + }, + { + "type": "=", + "named": false + } + ] + }, + "target": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "attribute", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "attribute_name", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "attribute_arguments", + "named": true + } + ] + } + }, + { + "type": "attribute_argument", + "named": true, + "fields": { + "key": { + "multiple": false, + "required": false, + "types": [ + { + "type": "argument_name", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "range", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "attribute_arguments", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute_argument", + "named": true + } + ] + } + }, + { + "type": "binary_expression", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "binding_pattern", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "mutable_specifier", + "named": true + } + ] + } + }, + { + "type": "block", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "assignment", + "named": true + }, + { + "type": "break_statement", + "named": true + }, + { + "type": "call_statement", + "named": true + }, + { + "type": "continue_statement", + "named": true + }, + { + "type": "destructure_statement", + "named": true + }, + { + "type": "emit_statement", + "named": true + }, + { + "type": "for_statement", + "named": true + }, + { + "type": "if_statement", + "named": true + }, + { + "type": "let_statement", + "named": true + }, + { + "type": "loop_statement", + "named": true + }, + { + "type": "macro_invocation", + "named": true + }, + { + "type": "match_statement", + "named": true + }, + { + "type": "return_statement", + "named": true + }, + { + "type": "while_statement", + "named": true + } + ] + } + }, + { + "type": "block_expression", + "named": true, + "fields": { + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "assignment", + "named": true + }, + { + "type": "break_statement", + "named": true + }, + { + "type": "call_statement", + "named": true + }, + { + "type": "continue_statement", + "named": true + }, + { + "type": "destructure_statement", + "named": true + }, + { + "type": "emit_statement", + "named": true + }, + { + "type": "for_statement", + "named": true + }, + { + "type": "if_statement", + "named": true + }, + { + "type": "let_statement", + "named": true + }, + { + "type": "loop_statement", + "named": true + }, + { + "type": "macro_invocation", + "named": true + }, + { + "type": "match_statement", + "named": true + }, + { + "type": "return_statement", + "named": true + }, + { + "type": "while_statement", + "named": true + } + ] + } + }, + { + "type": "boolean", + "named": true, + "fields": {} + }, + { + "type": "break_statement", + "named": true, + "fields": {} + }, + { + "type": "call_expression", + "named": true, + "fields": { + "function": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "arguments", + "named": true + } + ] + } + }, + { + "type": "call_statement", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "call_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + } + ] + } + }, + { + "type": "cast_expression", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "type", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "closure_expression", + "named": true, + "fields": { + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "parameter", + "named": true + }, + { + "type": "type", + "named": true + } + ] + } + }, + { + "type": "comparison", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "const_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "continue_statement", + "named": true, + "fields": {} + }, + { + "type": "count_range", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "range", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "data_field", + "named": true, + "fields": { + "key": { + "multiple": false, + "required": true, + "types": [ + { + "type": "field_identifier", + "named": true + }, + { + "type": "string", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "data_object", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "data_item", + "named": true, + "fields": { + "kind": { + "multiple": false, + "required": true, + "types": [ + { + "type": "data_kind", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": false, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "data_object", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "data_object", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "data_field", + "named": true + } + ] + } + }, + { + "type": "destructure_statement", + "named": true, + "fields": { + "pattern": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_", + "named": false + }, + { + "type": "array_pattern", + "named": true + }, + { + "type": "record_pattern", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": false, + "types": [ + { + "type": "type", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "emit_statement", + "named": true, + "fields": { + "event": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "arguments", + "named": true + } + ] + } + }, + { + "type": "enum_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "variant", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "event_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "parameters", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "extern_function", + "named": true, + "fields": { + "id": { + "multiple": false, + "required": true, + "types": [ + { + "type": "string", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "field_declaration", + "named": true, + "fields": { + "default": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "field_identifier", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "field_expression", + "named": true, + "fields": { + "field": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "flow_item", + "named": true, + "fields": { + "field": { + "multiple": false, + "required": true, + "types": [ + { + "type": "place", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "hook", + "named": true + }, + { + "type": "transition", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "for_statement", + "named": true, + "fields": { + "binding": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + }, + "source": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "count_range", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "function_item", + "named": true, + "fields": { + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "return_type": { + "multiple": false, + "required": false, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "function_type_parameters", + "named": true + }, + { + "type": "parameters", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "function_type", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + { + "type": "function_type_parameter", + "named": true, + "fields": { + "bound": { + "multiple": true, + "required": false, + "types": [ + { + "type": "path", + "named": true + } + ] + }, + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + } + }, + { + "type": "function_type_parameters", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "function_type_parameter", + "named": true + } + ] + } + }, + { + "type": "generic_parameters", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + { + "type": "hook", + "named": true, + "fields": { + "body": { + "multiple": false, + "required": false, + "types": [ + { + "type": "block", + "named": true + } + ] + }, + "every": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + }, + "function": { + "multiple": false, + "required": false, + "types": [ + { + "type": "path", + "named": true + } + ] + }, + "phase": { + "multiple": false, + "required": true, + "types": [ + { + "type": "hook_phase", + "named": true + } + ] + }, + "state": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "if_statement", + "named": true, + "fields": { + "alternative": { + "multiple": false, + "required": false, + "types": [ + { + "type": "block", + "named": true + }, + { + "type": "if_statement", + "named": true + } + ] + }, + "condition": { + "multiple": false, + "required": true, + "types": [ + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + } + ] + }, + "consequence": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + } + } + }, + { + "type": "impl_item", + "named": true, + "fields": { + "trait": { + "multiple": false, + "required": false, + "types": [ + { + "type": "path", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "function_item", + "named": true + }, + { + "type": "generic_parameters", + "named": true + }, + { + "type": "type_arguments", + "named": true + } + ] + } + }, + { + "type": "in_range", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "range", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "index_expression", + "named": true, + "fields": { + "index": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "inner_attribute", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "attribute_name", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "attribute_arguments", + "named": true + } + ] + } + }, + { + "type": "interpolation", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "interpolation_content", + "named": true + } + ] + } + }, + { + "type": "let_statement", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": false, + "types": [ + { + "type": "type", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "mutable_specifier", + "named": true + } + ] + } + }, + { + "type": "logical_condition", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + } + ] + } + }, + { + "type": "loop_statement", + "named": true, + "fields": { + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + } + } + }, + { + "type": "macro_invocation", + "named": true, + "fields": { + "macro": { + "multiple": false, + "required": true, + "types": [ + { + "type": "macro_name", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "arguments", + "named": true + } + ] + } + }, + { + "type": "match_arm", + "named": true, + "fields": { + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + }, + "pattern": { + "multiple": true, + "required": true, + "types": [ + { + "type": "_", + "named": false + }, + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_binding", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + }, + { + "type": "|", + "named": false + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "match_guard", + "named": true + } + ] + } + }, + { + "type": "match_binding", + "named": true, + "fields": { + "binding": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_", + "named": false + }, + { + "type": "array_pattern", + "named": true + }, + { + "type": "binding_pattern", + "named": true + }, + { + "type": "record_pattern", + "named": true + } + ] + } + } + }, + { + "type": "match_expression", + "named": true, + "fields": { + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "match_value_arm", + "named": true + } + ] + } + }, + { + "type": "match_guard", + "named": true, + "fields": { + "condition": { + "multiple": false, + "required": true, + "types": [ + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + } + ] + } + } + }, + { + "type": "match_statement", + "named": true, + "fields": { + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "match_arm", + "named": true + } + ] + } + }, + { + "type": "match_value_arm", + "named": true, + "fields": { + "pattern": { + "multiple": true, + "required": true, + "types": [ + { + "type": "_", + "named": false + }, + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_binding", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + }, + { + "type": "|", + "named": false + } + ] + }, + "value": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "match_guard", + "named": true + } + ] + } + }, + { + "type": "method_expression", + "named": true, + "fields": { + "method": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "receiver": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "arguments", + "named": true + }, + { + "type": "type_arguments", + "named": true + } + ] + } + }, + { + "type": "mod_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "const_item", + "named": true + }, + { + "type": "data_item", + "named": true + }, + { + "type": "enum_item", + "named": true + }, + { + "type": "event_item", + "named": true + }, + { + "type": "extern_function", + "named": true + }, + { + "type": "flow_item", + "named": true + }, + { + "type": "function_item", + "named": true + }, + { + "type": "impl_item", + "named": true + }, + { + "type": "mod_item", + "named": true + }, + { + "type": "state_item", + "named": true + }, + { + "type": "struct_item", + "named": true + }, + { + "type": "trait_item", + "named": true + }, + { + "type": "use_item", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "mutable_specifier", + "named": true, + "fields": {} + }, + { + "type": "not_condition", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + } + ] + } + }, + { + "type": "parameter", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "mutable_specifier", + "named": true + } + ] + } + }, + { + "type": "parameters", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "parameter", + "named": true + }, + { + "type": "receiver", + "named": true + } + ] + } + }, + { + "type": "parenthesized_expression", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "path", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "crate", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "self", + "named": true + }, + { + "type": "super", + "named": true + }, + { + "type": "type_arguments", + "named": true + } + ] + } + }, + { + "type": "pattern_field", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_pattern", + "named": true + }, + { + "type": "binding_pattern", + "named": true + }, + { + "type": "record_pattern", + "named": true + } + ] + } + }, + { + "type": "place", + "named": true, + "fields": { + "field": { + "multiple": false, + "required": true, + "types": [ + { + "type": "field_identifier", + "named": true + } + ] + }, + "state": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + } + }, + { + "type": "range", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "receiver", + "named": true, + "fields": {} + }, + { + "type": "record_expression", + "named": true, + "fields": { + "type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "record_field", + "named": true + } + ] + } + }, + { + "type": "record_field", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "record_pattern", + "named": true, + "fields": { + "type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "path", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "pattern_field", + "named": true + } + ] + } + }, + { + "type": "return_statement", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "self", + "named": true, + "fields": {} + }, + { + "type": "source_file", + "named": true, + "root": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "const_item", + "named": true + }, + { + "type": "data_item", + "named": true + }, + { + "type": "enum_item", + "named": true + }, + { + "type": "event_item", + "named": true + }, + { + "type": "extern_function", + "named": true + }, + { + "type": "flow_item", + "named": true + }, + { + "type": "function_item", + "named": true + }, + { + "type": "impl_item", + "named": true + }, + { + "type": "inner_attribute", + "named": true + }, + { + "type": "mod_item", + "named": true + }, + { + "type": "state_item", + "named": true + }, + { + "type": "struct_item", + "named": true + }, + { + "type": "trait_item", + "named": true + }, + { + "type": "use_item", + "named": true + } + ] + } + }, + { + "type": "state_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "scope": { + "multiple": false, + "required": true, + "types": [ + { + "type": "scope", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "field_declaration", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "string", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "brace_escape", + "named": true + }, + { + "type": "escape_sequence", + "named": true + }, + { + "type": "interpolation", + "named": true + }, + { + "type": "string_content", + "named": true + } + ] + } + }, + { + "type": "struct_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "field_declaration", + "named": true + }, + { + "type": "generic_parameters", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "trait_item", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "trait_method", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "trait_method", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "return_type": { + "multiple": false, + "required": false, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "parameters", + "named": true + } + ] + } + }, + { + "type": "transition", + "named": true, + "fields": { + "from": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + }, + "guard": { + "multiple": false, + "required": false, + "types": [ + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + } + ] + }, + "priority": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + }, + "to": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "type", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "applied_type", + "named": true + }, + { + "type": "array_type", + "named": true + }, + { + "type": "function_type", + "named": true + }, + { + "type": "path", + "named": true + } + ] + } + }, + { + "type": "type_arguments", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + } + }, + { + "type": "unary_expression", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + }, + { + "type": "use_group", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "use_tree", + "named": true + } + ] + } + }, + { + "type": "use_item", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "attribute", + "named": true + }, + { + "type": "use_tree", + "named": true + }, + { + "type": "visibility", + "named": true + } + ] + } + }, + { + "type": "use_tree", + "named": true, + "fields": { + "alias": { + "multiple": false, + "required": false, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, + "children": { + "multiple": true, + "required": true, + "types": [ + { + "type": "crate", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "self", + "named": true + }, + { + "type": "super", + "named": true + }, + { + "type": "use_group", + "named": true + } + ] + } + }, + { + "type": "variant", + "named": true, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": false, + "types": [ + { + "type": "array_expression", + "named": true + }, + { + "type": "binary_expression", + "named": true + }, + { + "type": "block_expression", + "named": true + }, + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "cast_expression", + "named": true + }, + { + "type": "closure_expression", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "integer", + "named": true + }, + { + "type": "match_expression", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + }, + { + "type": "record_expression", + "named": true + }, + { + "type": "string", + "named": true + }, + { + "type": "unary_expression", + "named": true + } + ] + } + } + }, + { + "type": "while_statement", + "named": true, + "fields": { + "body": { + "multiple": false, + "required": true, + "types": [ + { + "type": "block", + "named": true + } + ] + }, + "condition": { + "multiple": false, + "required": true, + "types": [ + { + "type": "boolean", + "named": true + }, + { + "type": "call_expression", + "named": true + }, + { + "type": "comparison", + "named": true + }, + { + "type": "field_expression", + "named": true + }, + { + "type": "in_range", + "named": true + }, + { + "type": "index_expression", + "named": true + }, + { + "type": "logical_condition", + "named": true + }, + { + "type": "method_expression", + "named": true + }, + { + "type": "not_condition", + "named": true + }, + { + "type": "parenthesized_expression", + "named": true + }, + { + "type": "path", + "named": true + }, + { + "type": "place", + "named": true + } + ] + } + } + }, + { + "type": "!", + "named": false + }, + { + "type": "!=", + "named": false + }, + { + "type": "\"", + "named": false + }, + { + "type": "#", + "named": false + }, + { + "type": "%", + "named": false + }, + { + "type": "%=", + "named": false + }, + { + "type": "&", + "named": false + }, + { + "type": "&&", + "named": false + }, + { + "type": "(", + "named": false + }, + { + "type": ")", + "named": false + }, + { + "type": "*", + "named": false + }, + { + "type": "*=", + "named": false + }, + { + "type": "+", + "named": false + }, + { + "type": "+=", + "named": false + }, + { + "type": ",", + "named": false + }, + { + "type": "-", + "named": false + }, + { + "type": "-=", + "named": false + }, + { + "type": "->", + "named": false + }, + { + "type": ".", + "named": false + }, + { + "type": "..", + "named": false + }, + { + "type": "..=", + "named": false + }, + { + "type": "/", + "named": false + }, + { + "type": "/=", + "named": false + }, + { + "type": ":", + "named": false + }, + { + "type": "::", + "named": false + }, + { + "type": ";", + "named": false + }, + { + "type": "<", + "named": false + }, + { + "type": "<=", + "named": false + }, + { + "type": "=", + "named": false + }, + { + "type": "==", + "named": false + }, + { + "type": "=>", + "named": false + }, + { + "type": ">", + "named": false + }, + { + "type": ">=", + "named": false + }, + { + "type": "[", + "named": false + }, + { + "type": "]", + "named": false + }, + { + "type": "_", + "named": false + }, + { + "type": "argument_name", + "named": true + }, + { + "type": "as", + "named": false + }, + { + "type": "attribute_name", + "named": true + }, + { + "type": "block_comment", + "named": true, + "extra": true + }, + { + "type": "brace_escape", + "named": true + }, + { + "type": "break", + "named": false + }, + { + "type": "const", + "named": false + }, + { + "type": "continue", + "named": false + }, + { + "type": "crate", + "named": true + }, + { + "type": "data_kind", + "named": true + }, + { + "type": "doc_comment", + "named": true, + "extra": true + }, + { + "type": "else", + "named": false + }, + { + "type": "emit", + "named": false + }, + { + "type": "enum", + "named": false + }, + { + "type": "escape_sequence", + "named": true + }, + { + "type": "event", + "named": false + }, + { + "type": "every", + "named": false + }, + { + "type": "extern", + "named": false + }, + { + "type": "false", + "named": false + }, + { + "type": "field_identifier", + "named": true + }, + { + "type": "float", + "named": true + }, + { + "type": "flow", + "named": false + }, + { + "type": "fn", + "named": false + }, + { + "type": "for", + "named": false + }, + { + "type": "hook_phase", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "if", + "named": false + }, + { + "type": "impl", + "named": false + }, + { + "type": "in", + "named": false + }, + { + "type": "integer", + "named": true + }, + { + "type": "interpolation_content", + "named": true + }, + { + "type": "let", + "named": false + }, + { + "type": "line_comment", + "named": true, + "extra": true + }, + { + "type": "loop", + "named": false + }, + { + "type": "macro_name", + "named": true + }, + { + "type": "match", + "named": false + }, + { + "type": "mod", + "named": false + }, + { + "type": "move", + "named": false + }, + { + "type": "mut", + "named": false + }, + { + "type": "on", + "named": false + }, + { + "type": "priority", + "named": false + }, + { + "type": "return", + "named": false + }, + { + "type": "rev", + "named": false + }, + { + "type": "scope", + "named": true + }, + { + "type": "self", + "named": false + }, + { + "type": "state", + "named": false + }, + { + "type": "step_by", + "named": false + }, + { + "type": "string_content", + "named": true + }, + { + "type": "struct", + "named": false + }, + { + "type": "super", + "named": true + }, + { + "type": "trait", + "named": false + }, + { + "type": "true", + "named": false + }, + { + "type": "use", + "named": false + }, + { + "type": "visibility", + "named": true + }, + { + "type": "while", + "named": false + }, + { + "type": "{", + "named": false + }, + { + "type": "|", + "named": false + }, + { + "type": "||", + "named": false + }, + { + "type": "}", + "named": false + } +] \ No newline at end of file diff --git a/editors/tree-sitter-sand/src/parser.c b/editors/tree-sitter-sand/src/parser.c new file mode 100644 index 00000000..246a178f --- /dev/null +++ b/editors/tree-sitter-sand/src/parser.c @@ -0,0 +1,51330 @@ +/* Automatically generated by tree-sitter v0.25.3 (2a835ee029dca1c325e6f1c01dbce40396f6123e) */ + +#include "tree_sitter/parser.h" + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#define LANGUAGE_VERSION 15 +#define STATE_COUNT 1577 +#define LARGE_STATE_COUNT 12 +#define SYMBOL_COUNT 243 +#define ALIAS_COUNT 4 +#define TOKEN_COUNT 113 +#define EXTERNAL_TOKEN_COUNT 0 +#define FIELD_COUNT 37 +#define MAX_ALIAS_SEQUENCE_LENGTH 12 +#define MAX_RESERVED_WORD_SET_SIZE 0 +#define PRODUCTION_ID_COUNT 108 +#define SUPERTYPE_COUNT 0 + +enum ts_symbol_identifiers { + sym_identifier = 1, + sym_doc_comment = 2, + sym_line_comment = 3, + sym_block_comment = 4, + anon_sym_POUND = 5, + anon_sym_LBRACK = 6, + anon_sym_RBRACK = 7, + anon_sym_BANG = 8, + anon_sym_LPAREN = 9, + anon_sym_COMMA = 10, + anon_sym_RPAREN = 11, + anon_sym_EQ = 12, + sym_visibility = 13, + anon_sym_struct = 14, + anon_sym_LBRACE = 15, + anon_sym_RBRACE = 16, + anon_sym_trait = 17, + anon_sym_fn = 18, + anon_sym_DASH_GT = 19, + anon_sym_SEMI = 20, + anon_sym_impl = 21, + anon_sym_for = 22, + anon_sym_COLON = 23, + anon_sym_DOT = 24, + anon_sym_COLON_COLON = 25, + anon_sym_AMP = 26, + anon_sym_mut = 27, + anon_sym_self = 28, + anon_sym_event = 29, + anon_sym_item = 30, + anon_sym_recipe = 31, + anon_sym_tag = 32, + anon_sym_bossbar = 33, + anon_sym_loot = 34, + anon_sym_damage_type = 35, + anon_sym_predicate = 36, + anon_sym_advancement = 37, + anon_sym_dialog = 38, + anon_sym_dimension = 39, + anon_sym_biome = 40, + anon_sym_structure_template = 41, + anon_sym_inventory_transfer = 42, + anon_sym_hud = 43, + anon_sym_menu = 44, + anon_sym_mod = 45, + anon_sym_use = 46, + anon_sym_as = 47, + anon_sym_const = 48, + anon_sym_enum = 49, + anon_sym_player = 50, + anon_sym_global = 51, + anon_sym_entity = 52, + anon_sym_state = 53, + anon_sym_LT = 54, + anon_sym_GT = 55, + anon_sym_flow = 56, + anon_sym_on = 57, + anon_sym_if = 58, + anon_sym_priority = 59, + anon_sym_enter = 60, + anon_sym_exit = 61, + anon_sym_tick = 62, + anon_sym_every = 63, + anon_sym_EQ_GT = 64, + anon_sym_extern = 65, + anon_sym_let = 66, + anon_sym__ = 67, + anon_sym_DOT_DOT = 68, + anon_sym_return = 69, + anon_sym_continue = 70, + anon_sym_break = 71, + anon_sym_emit = 72, + anon_sym_loop = 73, + anon_sym_match = 74, + anon_sym_PIPE = 75, + anon_sym_while = 76, + anon_sym_else = 77, + anon_sym_in = 78, + anon_sym_rev = 79, + anon_sym_step_by = 80, + anon_sym_PLUS_EQ = 81, + anon_sym_DASH_EQ = 82, + anon_sym_STAR_EQ = 83, + anon_sym_SLASH_EQ = 84, + anon_sym_PERCENT_EQ = 85, + anon_sym_PIPE_PIPE = 86, + anon_sym_AMP_AMP = 87, + anon_sym_EQ_EQ = 88, + anon_sym_BANG_EQ = 89, + anon_sym_LT_EQ = 90, + anon_sym_GT_EQ = 91, + anon_sym_DOT_DOT_EQ = 92, + anon_sym_move = 93, + anon_sym_DASH = 94, + anon_sym_PLUS = 95, + anon_sym_STAR = 96, + anon_sym_SLASH = 97, + anon_sym_PERCENT = 98, + sym_crate = 99, + sym_super = 100, + sym_integer = 101, + sym_float = 102, + anon_sym_true = 103, + anon_sym_false = 104, + anon_sym_DQUOTE = 105, + anon_sym_DQUOTE2 = 106, + sym_string_content = 107, + sym_escape_sequence = 108, + sym_brace_escape = 109, + anon_sym_LBRACE2 = 110, + aux_sym_interpolation_token1 = 111, + anon_sym_RBRACE2 = 112, + sym_source_file = 113, + sym_attribute = 114, + sym_inner_attribute = 115, + sym__attribute_body = 116, + sym_attribute_arguments = 117, + sym_attribute_argument = 118, + sym__value = 119, + sym__item = 120, + sym_struct_item = 121, + sym_trait_item = 122, + sym_trait_method = 123, + sym_impl_item = 124, + sym_record_expression = 125, + sym_record_field = 126, + sym_method_expression = 127, + sym_field_expression = 128, + sym_receiver = 129, + sym_event_item = 130, + sym_data_item = 131, + sym_data_object = 132, + sym_data_field = 133, + sym__data_value = 134, + sym_mod_item = 135, + sym_use_item = 136, + sym_use_tree = 137, + sym_use_group = 138, + sym_const_item = 139, + sym_enum_item = 140, + sym_variant = 141, + sym_state_item = 142, + sym_field_declaration = 143, + sym_type = 144, + sym_function_type = 145, + sym_applied_type = 146, + sym_array_type = 147, + sym_array_expression = 148, + sym_index_expression = 149, + sym_flow_item = 150, + sym_transition = 151, + sym_hook = 152, + sym_extern_function = 153, + sym_function_item = 154, + sym_parameters = 155, + sym_parameter = 156, + sym_block = 157, + sym__statement = 158, + sym_let_statement = 159, + sym_destructure_statement = 160, + sym__value_pattern = 161, + sym_binding_pattern = 162, + sym_record_pattern = 163, + sym_pattern_field = 164, + sym_array_pattern = 165, + sym_mutable_specifier = 166, + sym_return_statement = 167, + sym__value_or_condition = 168, + sym_continue_statement = 169, + sym_break_statement = 170, + sym_emit_statement = 171, + sym_loop_statement = 172, + sym_match_statement = 173, + sym_match_expression = 174, + sym_match_value_arm = 175, + sym_match_arm = 176, + sym_match_binding = 177, + sym_match_guard = 178, + sym_while_statement = 179, + sym_if_statement = 180, + sym_for_statement = 181, + sym_count_range = 182, + sym_macro_invocation = 183, + sym_assignment = 184, + sym_call_statement = 185, + sym__condition = 186, + sym_logical_condition = 187, + sym_not_condition = 188, + sym_comparison = 189, + sym_in_range = 190, + sym_range = 191, + sym_closure_expression = 192, + sym_block_expression = 193, + sym__expression = 194, + sym_call_expression = 195, + sym_arguments = 196, + sym_argument = 197, + sym__argument_value = 198, + sym_place = 199, + sym_unary_expression = 200, + sym_binary_expression = 201, + sym_cast_expression = 202, + sym_parenthesized_expression = 203, + sym_function_type_parameters = 204, + sym_function_type_parameter = 205, + sym_generic_parameters = 206, + sym_type_arguments = 207, + sym_path = 208, + sym__path_segment = 209, + sym_self = 210, + sym_boolean = 211, + sym_string = 212, + sym_interpolation = 213, + aux_sym_source_file_repeat1 = 214, + aux_sym_attribute_arguments_repeat1 = 215, + aux_sym_struct_item_repeat1 = 216, + aux_sym_struct_item_repeat2 = 217, + aux_sym_trait_item_repeat1 = 218, + aux_sym_impl_item_repeat1 = 219, + aux_sym_record_expression_repeat1 = 220, + aux_sym_data_object_repeat1 = 221, + aux_sym_mod_item_repeat1 = 222, + aux_sym_use_tree_repeat1 = 223, + aux_sym_use_group_repeat1 = 224, + aux_sym_enum_item_repeat1 = 225, + aux_sym_function_type_repeat1 = 226, + aux_sym_array_expression_repeat1 = 227, + aux_sym_flow_item_repeat1 = 228, + aux_sym_parameters_repeat1 = 229, + aux_sym_block_repeat1 = 230, + aux_sym_record_pattern_repeat1 = 231, + aux_sym_array_pattern_repeat1 = 232, + aux_sym_match_statement_repeat1 = 233, + aux_sym_match_expression_repeat1 = 234, + aux_sym_match_value_arm_repeat1 = 235, + aux_sym_closure_expression_repeat1 = 236, + aux_sym_arguments_repeat1 = 237, + aux_sym_function_type_parameters_repeat1 = 238, + aux_sym_function_type_parameter_repeat1 = 239, + aux_sym_generic_parameters_repeat1 = 240, + aux_sym_path_repeat1 = 241, + aux_sym_string_repeat1 = 242, + alias_sym_argument_name = 243, + alias_sym_attribute_name = 244, + alias_sym_field_identifier = 245, + alias_sym_macro_name = 246, +}; + +static const char * const ts_symbol_names[] = { + [ts_builtin_sym_end] = "end", + [sym_identifier] = "identifier", + [sym_doc_comment] = "doc_comment", + [sym_line_comment] = "line_comment", + [sym_block_comment] = "block_comment", + [anon_sym_POUND] = "#", + [anon_sym_LBRACK] = "[", + [anon_sym_RBRACK] = "]", + [anon_sym_BANG] = "!", + [anon_sym_LPAREN] = "(", + [anon_sym_COMMA] = ",", + [anon_sym_RPAREN] = ")", + [anon_sym_EQ] = "=", + [sym_visibility] = "visibility", + [anon_sym_struct] = "struct", + [anon_sym_LBRACE] = "{", + [anon_sym_RBRACE] = "}", + [anon_sym_trait] = "trait", + [anon_sym_fn] = "fn", + [anon_sym_DASH_GT] = "->", + [anon_sym_SEMI] = ";", + [anon_sym_impl] = "impl", + [anon_sym_for] = "for", + [anon_sym_COLON] = ":", + [anon_sym_DOT] = ".", + [anon_sym_COLON_COLON] = "::", + [anon_sym_AMP] = "&", + [anon_sym_mut] = "mut", + [anon_sym_self] = "self", + [anon_sym_event] = "event", + [anon_sym_item] = "data_kind", + [anon_sym_recipe] = "data_kind", + [anon_sym_tag] = "data_kind", + [anon_sym_bossbar] = "data_kind", + [anon_sym_loot] = "data_kind", + [anon_sym_damage_type] = "data_kind", + [anon_sym_predicate] = "data_kind", + [anon_sym_advancement] = "data_kind", + [anon_sym_dialog] = "data_kind", + [anon_sym_dimension] = "data_kind", + [anon_sym_biome] = "data_kind", + [anon_sym_structure_template] = "data_kind", + [anon_sym_inventory_transfer] = "data_kind", + [anon_sym_hud] = "data_kind", + [anon_sym_menu] = "data_kind", + [anon_sym_mod] = "mod", + [anon_sym_use] = "use", + [anon_sym_as] = "as", + [anon_sym_const] = "const", + [anon_sym_enum] = "enum", + [anon_sym_player] = "scope", + [anon_sym_global] = "scope", + [anon_sym_entity] = "scope", + [anon_sym_state] = "state", + [anon_sym_LT] = "<", + [anon_sym_GT] = ">", + [anon_sym_flow] = "flow", + [anon_sym_on] = "on", + [anon_sym_if] = "if", + [anon_sym_priority] = "priority", + [anon_sym_enter] = "hook_phase", + [anon_sym_exit] = "hook_phase", + [anon_sym_tick] = "hook_phase", + [anon_sym_every] = "every", + [anon_sym_EQ_GT] = "=>", + [anon_sym_extern] = "extern", + [anon_sym_let] = "let", + [anon_sym__] = "_", + [anon_sym_DOT_DOT] = "..", + [anon_sym_return] = "return", + [anon_sym_continue] = "continue", + [anon_sym_break] = "break", + [anon_sym_emit] = "emit", + [anon_sym_loop] = "loop", + [anon_sym_match] = "match", + [anon_sym_PIPE] = "|", + [anon_sym_while] = "while", + [anon_sym_else] = "else", + [anon_sym_in] = "in", + [anon_sym_rev] = "rev", + [anon_sym_step_by] = "step_by", + [anon_sym_PLUS_EQ] = "+=", + [anon_sym_DASH_EQ] = "-=", + [anon_sym_STAR_EQ] = "*=", + [anon_sym_SLASH_EQ] = "/=", + [anon_sym_PERCENT_EQ] = "%=", + [anon_sym_PIPE_PIPE] = "||", + [anon_sym_AMP_AMP] = "&&", + [anon_sym_EQ_EQ] = "==", + [anon_sym_BANG_EQ] = "!=", + [anon_sym_LT_EQ] = "<=", + [anon_sym_GT_EQ] = ">=", + [anon_sym_DOT_DOT_EQ] = "..=", + [anon_sym_move] = "move", + [anon_sym_DASH] = "-", + [anon_sym_PLUS] = "+", + [anon_sym_STAR] = "*", + [anon_sym_SLASH] = "/", + [anon_sym_PERCENT] = "%", + [sym_crate] = "crate", + [sym_super] = "super", + [sym_integer] = "integer", + [sym_float] = "float", + [anon_sym_true] = "true", + [anon_sym_false] = "false", + [anon_sym_DQUOTE] = "\"", + [anon_sym_DQUOTE2] = "\"", + [sym_string_content] = "string_content", + [sym_escape_sequence] = "escape_sequence", + [sym_brace_escape] = "brace_escape", + [anon_sym_LBRACE2] = "{", + [aux_sym_interpolation_token1] = "interpolation_content", + [anon_sym_RBRACE2] = "}", + [sym_source_file] = "source_file", + [sym_attribute] = "attribute", + [sym_inner_attribute] = "inner_attribute", + [sym__attribute_body] = "_attribute_body", + [sym_attribute_arguments] = "attribute_arguments", + [sym_attribute_argument] = "attribute_argument", + [sym__value] = "_value", + [sym__item] = "_item", + [sym_struct_item] = "struct_item", + [sym_trait_item] = "trait_item", + [sym_trait_method] = "trait_method", + [sym_impl_item] = "impl_item", + [sym_record_expression] = "record_expression", + [sym_record_field] = "record_field", + [sym_method_expression] = "method_expression", + [sym_field_expression] = "field_expression", + [sym_receiver] = "receiver", + [sym_event_item] = "event_item", + [sym_data_item] = "data_item", + [sym_data_object] = "data_object", + [sym_data_field] = "data_field", + [sym__data_value] = "_data_value", + [sym_mod_item] = "mod_item", + [sym_use_item] = "use_item", + [sym_use_tree] = "use_tree", + [sym_use_group] = "use_group", + [sym_const_item] = "const_item", + [sym_enum_item] = "enum_item", + [sym_variant] = "variant", + [sym_state_item] = "state_item", + [sym_field_declaration] = "field_declaration", + [sym_type] = "type", + [sym_function_type] = "function_type", + [sym_applied_type] = "applied_type", + [sym_array_type] = "array_type", + [sym_array_expression] = "array_expression", + [sym_index_expression] = "index_expression", + [sym_flow_item] = "flow_item", + [sym_transition] = "transition", + [sym_hook] = "hook", + [sym_extern_function] = "extern_function", + [sym_function_item] = "function_item", + [sym_parameters] = "parameters", + [sym_parameter] = "parameter", + [sym_block] = "block", + [sym__statement] = "_statement", + [sym_let_statement] = "let_statement", + [sym_destructure_statement] = "destructure_statement", + [sym__value_pattern] = "_value_pattern", + [sym_binding_pattern] = "binding_pattern", + [sym_record_pattern] = "record_pattern", + [sym_pattern_field] = "pattern_field", + [sym_array_pattern] = "array_pattern", + [sym_mutable_specifier] = "mutable_specifier", + [sym_return_statement] = "return_statement", + [sym__value_or_condition] = "_value_or_condition", + [sym_continue_statement] = "continue_statement", + [sym_break_statement] = "break_statement", + [sym_emit_statement] = "emit_statement", + [sym_loop_statement] = "loop_statement", + [sym_match_statement] = "match_statement", + [sym_match_expression] = "match_expression", + [sym_match_value_arm] = "match_value_arm", + [sym_match_arm] = "match_arm", + [sym_match_binding] = "match_binding", + [sym_match_guard] = "match_guard", + [sym_while_statement] = "while_statement", + [sym_if_statement] = "if_statement", + [sym_for_statement] = "for_statement", + [sym_count_range] = "count_range", + [sym_macro_invocation] = "macro_invocation", + [sym_assignment] = "assignment", + [sym_call_statement] = "call_statement", + [sym__condition] = "_condition", + [sym_logical_condition] = "logical_condition", + [sym_not_condition] = "not_condition", + [sym_comparison] = "comparison", + [sym_in_range] = "in_range", + [sym_range] = "range", + [sym_closure_expression] = "closure_expression", + [sym_block_expression] = "block_expression", + [sym__expression] = "_expression", + [sym_call_expression] = "call_expression", + [sym_arguments] = "arguments", + [sym_argument] = "argument", + [sym__argument_value] = "_argument_value", + [sym_place] = "place", + [sym_unary_expression] = "unary_expression", + [sym_binary_expression] = "binary_expression", + [sym_cast_expression] = "cast_expression", + [sym_parenthesized_expression] = "parenthesized_expression", + [sym_function_type_parameters] = "function_type_parameters", + [sym_function_type_parameter] = "function_type_parameter", + [sym_generic_parameters] = "generic_parameters", + [sym_type_arguments] = "type_arguments", + [sym_path] = "path", + [sym__path_segment] = "_path_segment", + [sym_self] = "self", + [sym_boolean] = "boolean", + [sym_string] = "string", + [sym_interpolation] = "interpolation", + [aux_sym_source_file_repeat1] = "source_file_repeat1", + [aux_sym_attribute_arguments_repeat1] = "attribute_arguments_repeat1", + [aux_sym_struct_item_repeat1] = "struct_item_repeat1", + [aux_sym_struct_item_repeat2] = "struct_item_repeat2", + [aux_sym_trait_item_repeat1] = "trait_item_repeat1", + [aux_sym_impl_item_repeat1] = "impl_item_repeat1", + [aux_sym_record_expression_repeat1] = "record_expression_repeat1", + [aux_sym_data_object_repeat1] = "data_object_repeat1", + [aux_sym_mod_item_repeat1] = "mod_item_repeat1", + [aux_sym_use_tree_repeat1] = "use_tree_repeat1", + [aux_sym_use_group_repeat1] = "use_group_repeat1", + [aux_sym_enum_item_repeat1] = "enum_item_repeat1", + [aux_sym_function_type_repeat1] = "function_type_repeat1", + [aux_sym_array_expression_repeat1] = "array_expression_repeat1", + [aux_sym_flow_item_repeat1] = "flow_item_repeat1", + [aux_sym_parameters_repeat1] = "parameters_repeat1", + [aux_sym_block_repeat1] = "block_repeat1", + [aux_sym_record_pattern_repeat1] = "record_pattern_repeat1", + [aux_sym_array_pattern_repeat1] = "array_pattern_repeat1", + [aux_sym_match_statement_repeat1] = "match_statement_repeat1", + [aux_sym_match_expression_repeat1] = "match_expression_repeat1", + [aux_sym_match_value_arm_repeat1] = "match_value_arm_repeat1", + [aux_sym_closure_expression_repeat1] = "closure_expression_repeat1", + [aux_sym_arguments_repeat1] = "arguments_repeat1", + [aux_sym_function_type_parameters_repeat1] = "function_type_parameters_repeat1", + [aux_sym_function_type_parameter_repeat1] = "function_type_parameter_repeat1", + [aux_sym_generic_parameters_repeat1] = "generic_parameters_repeat1", + [aux_sym_path_repeat1] = "path_repeat1", + [aux_sym_string_repeat1] = "string_repeat1", + [alias_sym_argument_name] = "argument_name", + [alias_sym_attribute_name] = "attribute_name", + [alias_sym_field_identifier] = "field_identifier", + [alias_sym_macro_name] = "macro_name", +}; + +static const TSSymbol ts_symbol_map[] = { + [ts_builtin_sym_end] = ts_builtin_sym_end, + [sym_identifier] = sym_identifier, + [sym_doc_comment] = sym_doc_comment, + [sym_line_comment] = sym_line_comment, + [sym_block_comment] = sym_block_comment, + [anon_sym_POUND] = anon_sym_POUND, + [anon_sym_LBRACK] = anon_sym_LBRACK, + [anon_sym_RBRACK] = anon_sym_RBRACK, + [anon_sym_BANG] = anon_sym_BANG, + [anon_sym_LPAREN] = anon_sym_LPAREN, + [anon_sym_COMMA] = anon_sym_COMMA, + [anon_sym_RPAREN] = anon_sym_RPAREN, + [anon_sym_EQ] = anon_sym_EQ, + [sym_visibility] = sym_visibility, + [anon_sym_struct] = anon_sym_struct, + [anon_sym_LBRACE] = anon_sym_LBRACE, + [anon_sym_RBRACE] = anon_sym_RBRACE, + [anon_sym_trait] = anon_sym_trait, + [anon_sym_fn] = anon_sym_fn, + [anon_sym_DASH_GT] = anon_sym_DASH_GT, + [anon_sym_SEMI] = anon_sym_SEMI, + [anon_sym_impl] = anon_sym_impl, + [anon_sym_for] = anon_sym_for, + [anon_sym_COLON] = anon_sym_COLON, + [anon_sym_DOT] = anon_sym_DOT, + [anon_sym_COLON_COLON] = anon_sym_COLON_COLON, + [anon_sym_AMP] = anon_sym_AMP, + [anon_sym_mut] = anon_sym_mut, + [anon_sym_self] = anon_sym_self, + [anon_sym_event] = anon_sym_event, + [anon_sym_item] = anon_sym_item, + [anon_sym_recipe] = anon_sym_item, + [anon_sym_tag] = anon_sym_item, + [anon_sym_bossbar] = anon_sym_item, + [anon_sym_loot] = anon_sym_item, + [anon_sym_damage_type] = anon_sym_item, + [anon_sym_predicate] = anon_sym_item, + [anon_sym_advancement] = anon_sym_item, + [anon_sym_dialog] = anon_sym_item, + [anon_sym_dimension] = anon_sym_item, + [anon_sym_biome] = anon_sym_item, + [anon_sym_structure_template] = anon_sym_item, + [anon_sym_inventory_transfer] = anon_sym_item, + [anon_sym_hud] = anon_sym_item, + [anon_sym_menu] = anon_sym_item, + [anon_sym_mod] = anon_sym_mod, + [anon_sym_use] = anon_sym_use, + [anon_sym_as] = anon_sym_as, + [anon_sym_const] = anon_sym_const, + [anon_sym_enum] = anon_sym_enum, + [anon_sym_player] = anon_sym_player, + [anon_sym_global] = anon_sym_player, + [anon_sym_entity] = anon_sym_player, + [anon_sym_state] = anon_sym_state, + [anon_sym_LT] = anon_sym_LT, + [anon_sym_GT] = anon_sym_GT, + [anon_sym_flow] = anon_sym_flow, + [anon_sym_on] = anon_sym_on, + [anon_sym_if] = anon_sym_if, + [anon_sym_priority] = anon_sym_priority, + [anon_sym_enter] = anon_sym_enter, + [anon_sym_exit] = anon_sym_enter, + [anon_sym_tick] = anon_sym_enter, + [anon_sym_every] = anon_sym_every, + [anon_sym_EQ_GT] = anon_sym_EQ_GT, + [anon_sym_extern] = anon_sym_extern, + [anon_sym_let] = anon_sym_let, + [anon_sym__] = anon_sym__, + [anon_sym_DOT_DOT] = anon_sym_DOT_DOT, + [anon_sym_return] = anon_sym_return, + [anon_sym_continue] = anon_sym_continue, + [anon_sym_break] = anon_sym_break, + [anon_sym_emit] = anon_sym_emit, + [anon_sym_loop] = anon_sym_loop, + [anon_sym_match] = anon_sym_match, + [anon_sym_PIPE] = anon_sym_PIPE, + [anon_sym_while] = anon_sym_while, + [anon_sym_else] = anon_sym_else, + [anon_sym_in] = anon_sym_in, + [anon_sym_rev] = anon_sym_rev, + [anon_sym_step_by] = anon_sym_step_by, + [anon_sym_PLUS_EQ] = anon_sym_PLUS_EQ, + [anon_sym_DASH_EQ] = anon_sym_DASH_EQ, + [anon_sym_STAR_EQ] = anon_sym_STAR_EQ, + [anon_sym_SLASH_EQ] = anon_sym_SLASH_EQ, + [anon_sym_PERCENT_EQ] = anon_sym_PERCENT_EQ, + [anon_sym_PIPE_PIPE] = anon_sym_PIPE_PIPE, + [anon_sym_AMP_AMP] = anon_sym_AMP_AMP, + [anon_sym_EQ_EQ] = anon_sym_EQ_EQ, + [anon_sym_BANG_EQ] = anon_sym_BANG_EQ, + [anon_sym_LT_EQ] = anon_sym_LT_EQ, + [anon_sym_GT_EQ] = anon_sym_GT_EQ, + [anon_sym_DOT_DOT_EQ] = anon_sym_DOT_DOT_EQ, + [anon_sym_move] = anon_sym_move, + [anon_sym_DASH] = anon_sym_DASH, + [anon_sym_PLUS] = anon_sym_PLUS, + [anon_sym_STAR] = anon_sym_STAR, + [anon_sym_SLASH] = anon_sym_SLASH, + [anon_sym_PERCENT] = anon_sym_PERCENT, + [sym_crate] = sym_crate, + [sym_super] = sym_super, + [sym_integer] = sym_integer, + [sym_float] = sym_float, + [anon_sym_true] = anon_sym_true, + [anon_sym_false] = anon_sym_false, + [anon_sym_DQUOTE] = anon_sym_DQUOTE, + [anon_sym_DQUOTE2] = anon_sym_DQUOTE, + [sym_string_content] = sym_string_content, + [sym_escape_sequence] = sym_escape_sequence, + [sym_brace_escape] = sym_brace_escape, + [anon_sym_LBRACE2] = anon_sym_LBRACE, + [aux_sym_interpolation_token1] = aux_sym_interpolation_token1, + [anon_sym_RBRACE2] = anon_sym_RBRACE, + [sym_source_file] = sym_source_file, + [sym_attribute] = sym_attribute, + [sym_inner_attribute] = sym_inner_attribute, + [sym__attribute_body] = sym__attribute_body, + [sym_attribute_arguments] = sym_attribute_arguments, + [sym_attribute_argument] = sym_attribute_argument, + [sym__value] = sym__value, + [sym__item] = sym__item, + [sym_struct_item] = sym_struct_item, + [sym_trait_item] = sym_trait_item, + [sym_trait_method] = sym_trait_method, + [sym_impl_item] = sym_impl_item, + [sym_record_expression] = sym_record_expression, + [sym_record_field] = sym_record_field, + [sym_method_expression] = sym_method_expression, + [sym_field_expression] = sym_field_expression, + [sym_receiver] = sym_receiver, + [sym_event_item] = sym_event_item, + [sym_data_item] = sym_data_item, + [sym_data_object] = sym_data_object, + [sym_data_field] = sym_data_field, + [sym__data_value] = sym__data_value, + [sym_mod_item] = sym_mod_item, + [sym_use_item] = sym_use_item, + [sym_use_tree] = sym_use_tree, + [sym_use_group] = sym_use_group, + [sym_const_item] = sym_const_item, + [sym_enum_item] = sym_enum_item, + [sym_variant] = sym_variant, + [sym_state_item] = sym_state_item, + [sym_field_declaration] = sym_field_declaration, + [sym_type] = sym_type, + [sym_function_type] = sym_function_type, + [sym_applied_type] = sym_applied_type, + [sym_array_type] = sym_array_type, + [sym_array_expression] = sym_array_expression, + [sym_index_expression] = sym_index_expression, + [sym_flow_item] = sym_flow_item, + [sym_transition] = sym_transition, + [sym_hook] = sym_hook, + [sym_extern_function] = sym_extern_function, + [sym_function_item] = sym_function_item, + [sym_parameters] = sym_parameters, + [sym_parameter] = sym_parameter, + [sym_block] = sym_block, + [sym__statement] = sym__statement, + [sym_let_statement] = sym_let_statement, + [sym_destructure_statement] = sym_destructure_statement, + [sym__value_pattern] = sym__value_pattern, + [sym_binding_pattern] = sym_binding_pattern, + [sym_record_pattern] = sym_record_pattern, + [sym_pattern_field] = sym_pattern_field, + [sym_array_pattern] = sym_array_pattern, + [sym_mutable_specifier] = sym_mutable_specifier, + [sym_return_statement] = sym_return_statement, + [sym__value_or_condition] = sym__value_or_condition, + [sym_continue_statement] = sym_continue_statement, + [sym_break_statement] = sym_break_statement, + [sym_emit_statement] = sym_emit_statement, + [sym_loop_statement] = sym_loop_statement, + [sym_match_statement] = sym_match_statement, + [sym_match_expression] = sym_match_expression, + [sym_match_value_arm] = sym_match_value_arm, + [sym_match_arm] = sym_match_arm, + [sym_match_binding] = sym_match_binding, + [sym_match_guard] = sym_match_guard, + [sym_while_statement] = sym_while_statement, + [sym_if_statement] = sym_if_statement, + [sym_for_statement] = sym_for_statement, + [sym_count_range] = sym_count_range, + [sym_macro_invocation] = sym_macro_invocation, + [sym_assignment] = sym_assignment, + [sym_call_statement] = sym_call_statement, + [sym__condition] = sym__condition, + [sym_logical_condition] = sym_logical_condition, + [sym_not_condition] = sym_not_condition, + [sym_comparison] = sym_comparison, + [sym_in_range] = sym_in_range, + [sym_range] = sym_range, + [sym_closure_expression] = sym_closure_expression, + [sym_block_expression] = sym_block_expression, + [sym__expression] = sym__expression, + [sym_call_expression] = sym_call_expression, + [sym_arguments] = sym_arguments, + [sym_argument] = sym_argument, + [sym__argument_value] = sym__argument_value, + [sym_place] = sym_place, + [sym_unary_expression] = sym_unary_expression, + [sym_binary_expression] = sym_binary_expression, + [sym_cast_expression] = sym_cast_expression, + [sym_parenthesized_expression] = sym_parenthesized_expression, + [sym_function_type_parameters] = sym_function_type_parameters, + [sym_function_type_parameter] = sym_function_type_parameter, + [sym_generic_parameters] = sym_generic_parameters, + [sym_type_arguments] = sym_type_arguments, + [sym_path] = sym_path, + [sym__path_segment] = sym__path_segment, + [sym_self] = sym_self, + [sym_boolean] = sym_boolean, + [sym_string] = sym_string, + [sym_interpolation] = sym_interpolation, + [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1, + [aux_sym_attribute_arguments_repeat1] = aux_sym_attribute_arguments_repeat1, + [aux_sym_struct_item_repeat1] = aux_sym_struct_item_repeat1, + [aux_sym_struct_item_repeat2] = aux_sym_struct_item_repeat2, + [aux_sym_trait_item_repeat1] = aux_sym_trait_item_repeat1, + [aux_sym_impl_item_repeat1] = aux_sym_impl_item_repeat1, + [aux_sym_record_expression_repeat1] = aux_sym_record_expression_repeat1, + [aux_sym_data_object_repeat1] = aux_sym_data_object_repeat1, + [aux_sym_mod_item_repeat1] = aux_sym_mod_item_repeat1, + [aux_sym_use_tree_repeat1] = aux_sym_use_tree_repeat1, + [aux_sym_use_group_repeat1] = aux_sym_use_group_repeat1, + [aux_sym_enum_item_repeat1] = aux_sym_enum_item_repeat1, + [aux_sym_function_type_repeat1] = aux_sym_function_type_repeat1, + [aux_sym_array_expression_repeat1] = aux_sym_array_expression_repeat1, + [aux_sym_flow_item_repeat1] = aux_sym_flow_item_repeat1, + [aux_sym_parameters_repeat1] = aux_sym_parameters_repeat1, + [aux_sym_block_repeat1] = aux_sym_block_repeat1, + [aux_sym_record_pattern_repeat1] = aux_sym_record_pattern_repeat1, + [aux_sym_array_pattern_repeat1] = aux_sym_array_pattern_repeat1, + [aux_sym_match_statement_repeat1] = aux_sym_match_statement_repeat1, + [aux_sym_match_expression_repeat1] = aux_sym_match_expression_repeat1, + [aux_sym_match_value_arm_repeat1] = aux_sym_match_value_arm_repeat1, + [aux_sym_closure_expression_repeat1] = aux_sym_closure_expression_repeat1, + [aux_sym_arguments_repeat1] = aux_sym_arguments_repeat1, + [aux_sym_function_type_parameters_repeat1] = aux_sym_function_type_parameters_repeat1, + [aux_sym_function_type_parameter_repeat1] = aux_sym_function_type_parameter_repeat1, + [aux_sym_generic_parameters_repeat1] = aux_sym_generic_parameters_repeat1, + [aux_sym_path_repeat1] = aux_sym_path_repeat1, + [aux_sym_string_repeat1] = aux_sym_string_repeat1, + [alias_sym_argument_name] = alias_sym_argument_name, + [alias_sym_attribute_name] = alias_sym_attribute_name, + [alias_sym_field_identifier] = alias_sym_field_identifier, + [alias_sym_macro_name] = alias_sym_macro_name, +}; + +static const TSSymbolMetadata ts_symbol_metadata[] = { + [ts_builtin_sym_end] = { + .visible = false, + .named = true, + }, + [sym_identifier] = { + .visible = true, + .named = true, + }, + [sym_doc_comment] = { + .visible = true, + .named = true, + }, + [sym_line_comment] = { + .visible = true, + .named = true, + }, + [sym_block_comment] = { + .visible = true, + .named = true, + }, + [anon_sym_POUND] = { + .visible = true, + .named = false, + }, + [anon_sym_LBRACK] = { + .visible = true, + .named = false, + }, + [anon_sym_RBRACK] = { + .visible = true, + .named = false, + }, + [anon_sym_BANG] = { + .visible = true, + .named = false, + }, + [anon_sym_LPAREN] = { + .visible = true, + .named = false, + }, + [anon_sym_COMMA] = { + .visible = true, + .named = false, + }, + [anon_sym_RPAREN] = { + .visible = true, + .named = false, + }, + [anon_sym_EQ] = { + .visible = true, + .named = false, + }, + [sym_visibility] = { + .visible = true, + .named = true, + }, + [anon_sym_struct] = { + .visible = true, + .named = false, + }, + [anon_sym_LBRACE] = { + .visible = true, + .named = false, + }, + [anon_sym_RBRACE] = { + .visible = true, + .named = false, + }, + [anon_sym_trait] = { + .visible = true, + .named = false, + }, + [anon_sym_fn] = { + .visible = true, + .named = false, + }, + [anon_sym_DASH_GT] = { + .visible = true, + .named = false, + }, + [anon_sym_SEMI] = { + .visible = true, + .named = false, + }, + [anon_sym_impl] = { + .visible = true, + .named = false, + }, + [anon_sym_for] = { + .visible = true, + .named = false, + }, + [anon_sym_COLON] = { + .visible = true, + .named = false, + }, + [anon_sym_DOT] = { + .visible = true, + .named = false, + }, + [anon_sym_COLON_COLON] = { + .visible = true, + .named = false, + }, + [anon_sym_AMP] = { + .visible = true, + .named = false, + }, + [anon_sym_mut] = { + .visible = true, + .named = false, + }, + [anon_sym_self] = { + .visible = true, + .named = false, + }, + [anon_sym_event] = { + .visible = true, + .named = false, + }, + [anon_sym_item] = { + .visible = true, + .named = true, + }, + [anon_sym_recipe] = { + .visible = true, + .named = true, + }, + [anon_sym_tag] = { + .visible = true, + .named = true, + }, + [anon_sym_bossbar] = { + .visible = true, + .named = true, + }, + [anon_sym_loot] = { + .visible = true, + .named = true, + }, + [anon_sym_damage_type] = { + .visible = true, + .named = true, + }, + [anon_sym_predicate] = { + .visible = true, + .named = true, + }, + [anon_sym_advancement] = { + .visible = true, + .named = true, + }, + [anon_sym_dialog] = { + .visible = true, + .named = true, + }, + [anon_sym_dimension] = { + .visible = true, + .named = true, + }, + [anon_sym_biome] = { + .visible = true, + .named = true, + }, + [anon_sym_structure_template] = { + .visible = true, + .named = true, + }, + [anon_sym_inventory_transfer] = { + .visible = true, + .named = true, + }, + [anon_sym_hud] = { + .visible = true, + .named = true, + }, + [anon_sym_menu] = { + .visible = true, + .named = true, + }, + [anon_sym_mod] = { + .visible = true, + .named = false, + }, + [anon_sym_use] = { + .visible = true, + .named = false, + }, + [anon_sym_as] = { + .visible = true, + .named = false, + }, + [anon_sym_const] = { + .visible = true, + .named = false, + }, + [anon_sym_enum] = { + .visible = true, + .named = false, + }, + [anon_sym_player] = { + .visible = true, + .named = true, + }, + [anon_sym_global] = { + .visible = true, + .named = true, + }, + [anon_sym_entity] = { + .visible = true, + .named = true, + }, + [anon_sym_state] = { + .visible = true, + .named = false, + }, + [anon_sym_LT] = { + .visible = true, + .named = false, + }, + [anon_sym_GT] = { + .visible = true, + .named = false, + }, + [anon_sym_flow] = { + .visible = true, + .named = false, + }, + [anon_sym_on] = { + .visible = true, + .named = false, + }, + [anon_sym_if] = { + .visible = true, + .named = false, + }, + [anon_sym_priority] = { + .visible = true, + .named = false, + }, + [anon_sym_enter] = { + .visible = true, + .named = true, + }, + [anon_sym_exit] = { + .visible = true, + .named = true, + }, + [anon_sym_tick] = { + .visible = true, + .named = true, + }, + [anon_sym_every] = { + .visible = true, + .named = false, + }, + [anon_sym_EQ_GT] = { + .visible = true, + .named = false, + }, + [anon_sym_extern] = { + .visible = true, + .named = false, + }, + [anon_sym_let] = { + .visible = true, + .named = false, + }, + [anon_sym__] = { + .visible = true, + .named = false, + }, + [anon_sym_DOT_DOT] = { + .visible = true, + .named = false, + }, + [anon_sym_return] = { + .visible = true, + .named = false, + }, + [anon_sym_continue] = { + .visible = true, + .named = false, + }, + [anon_sym_break] = { + .visible = true, + .named = false, + }, + [anon_sym_emit] = { + .visible = true, + .named = false, + }, + [anon_sym_loop] = { + .visible = true, + .named = false, + }, + [anon_sym_match] = { + .visible = true, + .named = false, + }, + [anon_sym_PIPE] = { + .visible = true, + .named = false, + }, + [anon_sym_while] = { + .visible = true, + .named = false, + }, + [anon_sym_else] = { + .visible = true, + .named = false, + }, + [anon_sym_in] = { + .visible = true, + .named = false, + }, + [anon_sym_rev] = { + .visible = true, + .named = false, + }, + [anon_sym_step_by] = { + .visible = true, + .named = false, + }, + [anon_sym_PLUS_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_DASH_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_STAR_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_SLASH_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_PERCENT_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_PIPE_PIPE] = { + .visible = true, + .named = false, + }, + [anon_sym_AMP_AMP] = { + .visible = true, + .named = false, + }, + [anon_sym_EQ_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_BANG_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_LT_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_GT_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_DOT_DOT_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym_move] = { + .visible = true, + .named = false, + }, + [anon_sym_DASH] = { + .visible = true, + .named = false, + }, + [anon_sym_PLUS] = { + .visible = true, + .named = false, + }, + [anon_sym_STAR] = { + .visible = true, + .named = false, + }, + [anon_sym_SLASH] = { + .visible = true, + .named = false, + }, + [anon_sym_PERCENT] = { + .visible = true, + .named = false, + }, + [sym_crate] = { + .visible = true, + .named = true, + }, + [sym_super] = { + .visible = true, + .named = true, + }, + [sym_integer] = { + .visible = true, + .named = true, + }, + [sym_float] = { + .visible = true, + .named = true, + }, + [anon_sym_true] = { + .visible = true, + .named = false, + }, + [anon_sym_false] = { + .visible = true, + .named = false, + }, + [anon_sym_DQUOTE] = { + .visible = true, + .named = false, + }, + [anon_sym_DQUOTE2] = { + .visible = true, + .named = false, + }, + [sym_string_content] = { + .visible = true, + .named = true, + }, + [sym_escape_sequence] = { + .visible = true, + .named = true, + }, + [sym_brace_escape] = { + .visible = true, + .named = true, + }, + [anon_sym_LBRACE2] = { + .visible = true, + .named = false, + }, + [aux_sym_interpolation_token1] = { + .visible = true, + .named = true, + }, + [anon_sym_RBRACE2] = { + .visible = true, + .named = false, + }, + [sym_source_file] = { + .visible = true, + .named = true, + }, + [sym_attribute] = { + .visible = true, + .named = true, + }, + [sym_inner_attribute] = { + .visible = true, + .named = true, + }, + [sym__attribute_body] = { + .visible = false, + .named = true, + }, + [sym_attribute_arguments] = { + .visible = true, + .named = true, + }, + [sym_attribute_argument] = { + .visible = true, + .named = true, + }, + [sym__value] = { + .visible = false, + .named = true, + }, + [sym__item] = { + .visible = false, + .named = true, + }, + [sym_struct_item] = { + .visible = true, + .named = true, + }, + [sym_trait_item] = { + .visible = true, + .named = true, + }, + [sym_trait_method] = { + .visible = true, + .named = true, + }, + [sym_impl_item] = { + .visible = true, + .named = true, + }, + [sym_record_expression] = { + .visible = true, + .named = true, + }, + [sym_record_field] = { + .visible = true, + .named = true, + }, + [sym_method_expression] = { + .visible = true, + .named = true, + }, + [sym_field_expression] = { + .visible = true, + .named = true, + }, + [sym_receiver] = { + .visible = true, + .named = true, + }, + [sym_event_item] = { + .visible = true, + .named = true, + }, + [sym_data_item] = { + .visible = true, + .named = true, + }, + [sym_data_object] = { + .visible = true, + .named = true, + }, + [sym_data_field] = { + .visible = true, + .named = true, + }, + [sym__data_value] = { + .visible = false, + .named = true, + }, + [sym_mod_item] = { + .visible = true, + .named = true, + }, + [sym_use_item] = { + .visible = true, + .named = true, + }, + [sym_use_tree] = { + .visible = true, + .named = true, + }, + [sym_use_group] = { + .visible = true, + .named = true, + }, + [sym_const_item] = { + .visible = true, + .named = true, + }, + [sym_enum_item] = { + .visible = true, + .named = true, + }, + [sym_variant] = { + .visible = true, + .named = true, + }, + [sym_state_item] = { + .visible = true, + .named = true, + }, + [sym_field_declaration] = { + .visible = true, + .named = true, + }, + [sym_type] = { + .visible = true, + .named = true, + }, + [sym_function_type] = { + .visible = true, + .named = true, + }, + [sym_applied_type] = { + .visible = true, + .named = true, + }, + [sym_array_type] = { + .visible = true, + .named = true, + }, + [sym_array_expression] = { + .visible = true, + .named = true, + }, + [sym_index_expression] = { + .visible = true, + .named = true, + }, + [sym_flow_item] = { + .visible = true, + .named = true, + }, + [sym_transition] = { + .visible = true, + .named = true, + }, + [sym_hook] = { + .visible = true, + .named = true, + }, + [sym_extern_function] = { + .visible = true, + .named = true, + }, + [sym_function_item] = { + .visible = true, + .named = true, + }, + [sym_parameters] = { + .visible = true, + .named = true, + }, + [sym_parameter] = { + .visible = true, + .named = true, + }, + [sym_block] = { + .visible = true, + .named = true, + }, + [sym__statement] = { + .visible = false, + .named = true, + }, + [sym_let_statement] = { + .visible = true, + .named = true, + }, + [sym_destructure_statement] = { + .visible = true, + .named = true, + }, + [sym__value_pattern] = { + .visible = false, + .named = true, + }, + [sym_binding_pattern] = { + .visible = true, + .named = true, + }, + [sym_record_pattern] = { + .visible = true, + .named = true, + }, + [sym_pattern_field] = { + .visible = true, + .named = true, + }, + [sym_array_pattern] = { + .visible = true, + .named = true, + }, + [sym_mutable_specifier] = { + .visible = true, + .named = true, + }, + [sym_return_statement] = { + .visible = true, + .named = true, + }, + [sym__value_or_condition] = { + .visible = false, + .named = true, + }, + [sym_continue_statement] = { + .visible = true, + .named = true, + }, + [sym_break_statement] = { + .visible = true, + .named = true, + }, + [sym_emit_statement] = { + .visible = true, + .named = true, + }, + [sym_loop_statement] = { + .visible = true, + .named = true, + }, + [sym_match_statement] = { + .visible = true, + .named = true, + }, + [sym_match_expression] = { + .visible = true, + .named = true, + }, + [sym_match_value_arm] = { + .visible = true, + .named = true, + }, + [sym_match_arm] = { + .visible = true, + .named = true, + }, + [sym_match_binding] = { + .visible = true, + .named = true, + }, + [sym_match_guard] = { + .visible = true, + .named = true, + }, + [sym_while_statement] = { + .visible = true, + .named = true, + }, + [sym_if_statement] = { + .visible = true, + .named = true, + }, + [sym_for_statement] = { + .visible = true, + .named = true, + }, + [sym_count_range] = { + .visible = true, + .named = true, + }, + [sym_macro_invocation] = { + .visible = true, + .named = true, + }, + [sym_assignment] = { + .visible = true, + .named = true, + }, + [sym_call_statement] = { + .visible = true, + .named = true, + }, + [sym__condition] = { + .visible = false, + .named = true, + }, + [sym_logical_condition] = { + .visible = true, + .named = true, + }, + [sym_not_condition] = { + .visible = true, + .named = true, + }, + [sym_comparison] = { + .visible = true, + .named = true, + }, + [sym_in_range] = { + .visible = true, + .named = true, + }, + [sym_range] = { + .visible = true, + .named = true, + }, + [sym_closure_expression] = { + .visible = true, + .named = true, + }, + [sym_block_expression] = { + .visible = true, + .named = true, + }, + [sym__expression] = { + .visible = false, + .named = true, + }, + [sym_call_expression] = { + .visible = true, + .named = true, + }, + [sym_arguments] = { + .visible = true, + .named = true, + }, + [sym_argument] = { + .visible = true, + .named = true, + }, + [sym__argument_value] = { + .visible = false, + .named = true, + }, + [sym_place] = { + .visible = true, + .named = true, + }, + [sym_unary_expression] = { + .visible = true, + .named = true, + }, + [sym_binary_expression] = { + .visible = true, + .named = true, + }, + [sym_cast_expression] = { + .visible = true, + .named = true, + }, + [sym_parenthesized_expression] = { + .visible = true, + .named = true, + }, + [sym_function_type_parameters] = { + .visible = true, + .named = true, + }, + [sym_function_type_parameter] = { + .visible = true, + .named = true, + }, + [sym_generic_parameters] = { + .visible = true, + .named = true, + }, + [sym_type_arguments] = { + .visible = true, + .named = true, + }, + [sym_path] = { + .visible = true, + .named = true, + }, + [sym__path_segment] = { + .visible = false, + .named = true, + }, + [sym_self] = { + .visible = true, + .named = true, + }, + [sym_boolean] = { + .visible = true, + .named = true, + }, + [sym_string] = { + .visible = true, + .named = true, + }, + [sym_interpolation] = { + .visible = true, + .named = true, + }, + [aux_sym_source_file_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_attribute_arguments_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_struct_item_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_struct_item_repeat2] = { + .visible = false, + .named = false, + }, + [aux_sym_trait_item_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_impl_item_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_record_expression_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_data_object_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_mod_item_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_use_tree_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_use_group_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_enum_item_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_function_type_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_array_expression_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_flow_item_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_parameters_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_block_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_record_pattern_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_array_pattern_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_match_statement_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_match_expression_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_match_value_arm_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_closure_expression_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_arguments_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_function_type_parameters_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_function_type_parameter_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_generic_parameters_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_path_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_string_repeat1] = { + .visible = false, + .named = false, + }, + [alias_sym_argument_name] = { + .visible = true, + .named = true, + }, + [alias_sym_attribute_name] = { + .visible = true, + .named = true, + }, + [alias_sym_field_identifier] = { + .visible = true, + .named = true, + }, + [alias_sym_macro_name] = { + .visible = true, + .named = true, + }, +}; + +enum ts_field_identifiers { + field_alias = 1, + field_alternative = 2, + field_binding = 3, + field_body = 4, + field_bound = 5, + field_condition = 6, + field_consequence = 7, + field_default = 8, + field_element = 9, + field_event = 10, + field_every = 11, + field_field = 12, + field_from = 13, + field_function = 14, + field_guard = 15, + field_id = 16, + field_index = 17, + field_key = 18, + field_kind = 19, + field_length = 20, + field_macro = 21, + field_method = 22, + field_name = 23, + field_operator = 24, + field_pattern = 25, + field_phase = 26, + field_priority = 27, + field_receiver = 28, + field_return_type = 29, + field_scope = 30, + field_source = 31, + field_state = 32, + field_target = 33, + field_to = 34, + field_trait = 35, + field_type = 36, + field_value = 37, +}; + +static const char * const ts_field_names[] = { + [0] = NULL, + [field_alias] = "alias", + [field_alternative] = "alternative", + [field_binding] = "binding", + [field_body] = "body", + [field_bound] = "bound", + [field_condition] = "condition", + [field_consequence] = "consequence", + [field_default] = "default", + [field_element] = "element", + [field_event] = "event", + [field_every] = "every", + [field_field] = "field", + [field_from] = "from", + [field_function] = "function", + [field_guard] = "guard", + [field_id] = "id", + [field_index] = "index", + [field_key] = "key", + [field_kind] = "kind", + [field_length] = "length", + [field_macro] = "macro", + [field_method] = "method", + [field_name] = "name", + [field_operator] = "operator", + [field_pattern] = "pattern", + [field_phase] = "phase", + [field_priority] = "priority", + [field_receiver] = "receiver", + [field_return_type] = "return_type", + [field_scope] = "scope", + [field_source] = "source", + [field_state] = "state", + [field_target] = "target", + [field_to] = "to", + [field_trait] = "trait", + [field_type] = "type", + [field_value] = "value", +}; + +static const TSMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { + [1] = {.index = 0, .length = 1}, + [2] = {.index = 1, .length = 1}, + [3] = {.index = 2, .length = 2}, + [4] = {.index = 4, .length = 1}, + [5] = {.index = 5, .length = 1}, + [6] = {.index = 6, .length = 2}, + [7] = {.index = 0, .length = 1}, + [8] = {.index = 8, .length = 2}, + [9] = {.index = 10, .length = 1}, + [10] = {.index = 11, .length = 1}, + [11] = {.index = 12, .length = 1}, + [12] = {.index = 13, .length = 2}, + [13] = {.index = 15, .length = 2}, + [14] = {.index = 17, .length = 1}, + [15] = {.index = 18, .length = 3}, + [16] = {.index = 21, .length = 1}, + [17] = {.index = 22, .length = 2}, + [18] = {.index = 24, .length = 1}, + [19] = {.index = 25, .length = 2}, + [20] = {.index = 27, .length = 1}, + [21] = {.index = 28, .length = 2}, + [22] = {.index = 30, .length = 3}, + [23] = {.index = 33, .length = 2}, + [24] = {.index = 35, .length = 2}, + [25] = {.index = 35, .length = 2}, + [26] = {.index = 37, .length = 2}, + [27] = {.index = 39, .length = 1}, + [28] = {.index = 40, .length = 3}, + [29] = {.index = 43, .length = 2}, + [30] = {.index = 45, .length = 2}, + [31] = {.index = 45, .length = 2}, + [32] = {.index = 47, .length = 2}, + [33] = {.index = 49, .length = 2}, + [34] = {.index = 51, .length = 2}, + [35] = {.index = 53, .length = 2}, + [36] = {.index = 55, .length = 1}, + [37] = {.index = 56, .length = 1}, + [38] = {.index = 57, .length = 2}, + [39] = {.index = 59, .length = 3}, + [40] = {.index = 62, .length = 2}, + [41] = {.index = 64, .length = 2}, + [42] = {.index = 64, .length = 2}, + [43] = {.index = 66, .length = 3}, + [44] = {.index = 69, .length = 2}, + [45] = {.index = 71, .length = 1}, + [46] = {.index = 72, .length = 2}, + [47] = {.index = 74, .length = 3}, + [48] = {.index = 77, .length = 2}, + [49] = {.index = 79, .length = 3}, + [50] = {.index = 82, .length = 2}, + [51] = {.index = 84, .length = 2}, + [52] = {.index = 86, .length = 3}, + [53] = {.index = 89, .length = 2}, + [54] = {.index = 91, .length = 1}, + [55] = {.index = 92, .length = 1}, + [56] = {.index = 93, .length = 2}, + [57] = {.index = 95, .length = 2}, + [58] = {.index = 97, .length = 1}, + [59] = {.index = 98, .length = 3}, + [60] = {.index = 101, .length = 3}, + [61] = {.index = 104, .length = 2}, + [62] = {.index = 106, .length = 3}, + [63] = {.index = 109, .length = 2}, + [64] = {.index = 111, .length = 1}, + [65] = {.index = 112, .length = 2}, + [66] = {.index = 114, .length = 1}, + [67] = {.index = 115, .length = 3}, + [68] = {.index = 118, .length = 2}, + [69] = {.index = 120, .length = 3}, + [70] = {.index = 123, .length = 3}, + [71] = {.index = 126, .length = 2}, + [72] = {.index = 128, .length = 1}, + [73] = {.index = 129, .length = 1}, + [74] = {.index = 0, .length = 1}, + [75] = {.index = 130, .length = 3}, + [76] = {.index = 133, .length = 2}, + [77] = {.index = 135, .length = 3}, + [78] = {.index = 138, .length = 3}, + [79] = {.index = 141, .length = 2}, + [80] = {.index = 143, .length = 2}, + [81] = {.index = 145, .length = 2}, + [82] = {.index = 147, .length = 3}, + [83] = {.index = 150, .length = 3}, + [84] = {.index = 153, .length = 2}, + [85] = {.index = 155, .length = 1}, + [86] = {.index = 156, .length = 2}, + [87] = {.index = 158, .length = 1}, + [88] = {.index = 159, .length = 3}, + [89] = {.index = 162, .length = 2}, + [90] = {.index = 109, .length = 2}, + [91] = {.index = 164, .length = 2}, + [92] = {.index = 166, .length = 4}, + [93] = {.index = 170, .length = 3}, + [94] = {.index = 173, .length = 2}, + [95] = {.index = 175, .length = 3}, + [96] = {.index = 178, .length = 1}, + [97] = {.index = 179, .length = 3}, + [98] = {.index = 182, .length = 2}, + [99] = {.index = 184, .length = 3}, + [100] = {.index = 187, .length = 3}, + [101] = {.index = 190, .length = 3}, + [102] = {.index = 193, .length = 3}, + [103] = {.index = 196, .length = 1}, + [104] = {.index = 197, .length = 3}, + [105] = {.index = 200, .length = 4}, + [106] = {.index = 204, .length = 1}, + [107] = {.index = 205, .length = 4}, +}; + +static const TSFieldMapEntry ts_field_map_entries[] = { + [0] = + {field_name, 0}, + [1] = + {field_name, 1}, + [2] = + {field_kind, 0}, + {field_name, 1}, + [4] = + {field_name, 2, .inherited = true}, + [5] = + {field_name, 2}, + [6] = + {field_kind, 1}, + {field_name, 2}, + [8] = + {field_body, 3}, + {field_name, 1}, + [10] = + {field_type, 1}, + [11] = + {field_alias, 2}, + [12] = + {field_name, 3, .inherited = true}, + [13] = + {field_body, 4}, + {field_name, 2}, + [15] = + {field_body, 4}, + {field_name, 1}, + [17] = + {field_type, 2}, + [18] = + {field_kind, 0}, + {field_name, 1}, + {field_type, 3}, + [21] = + {field_alias, 3}, + [22] = + {field_name, 2}, + {field_scope, 0}, + [24] = + {field_name, 3}, + [25] = + {field_kind, 2}, + {field_name, 3}, + [27] = + {field_function, 0}, + [28] = + {field_body, 5}, + {field_name, 2}, + [30] = + {field_kind, 1}, + {field_name, 2}, + {field_type, 4}, + [33] = + {field_name, 3}, + {field_scope, 1}, + [35] = + {field_name, 0}, + {field_type, 2}, + [37] = + {field_bound, 2}, + {field_name, 0}, + [39] = + {field_body, 1}, + [40] = + {field_body, 5}, + {field_name, 1}, + {field_return_type, 4}, + [43] = + {field_trait, 1}, + {field_type, 3}, + [45] = + {field_key, 0}, + {field_value, 2}, + [47] = + {field_name, 0}, + {field_value, 2}, + [49] = + {field_field, 3}, + {field_name, 1}, + [51] = + {field_field, 2}, + {field_state, 0}, + [53] = + {field_body, 5}, + {field_name, 3}, + [55] = + {field_value, 1}, + [56] = + {field_key, 0}, + [57] = + {field_field, 2}, + {field_value, 0}, + [59] = + {field_body, 6}, + {field_name, 2}, + {field_return_type, 5}, + [62] = + {field_field, 4}, + {field_name, 2}, + [64] = + {field_name, 1}, + {field_type, 3}, + [66] = + {field_bound, 2}, + {field_bound, 3, .inherited = true}, + {field_name, 0}, + [69] = + {field_condition, 1}, + {field_consequence, 2}, + [71] = + {field_event, 1}, + [72] = + {field_body, 2}, + {field_condition, 1}, + [74] = + {field_body, 6}, + {field_name, 1}, + {field_return_type, 5}, + [77] = + {field_trait, 2}, + {field_type, 4}, + [79] = + {field_name, 1}, + {field_type, 3}, + {field_value, 5}, + [82] = + {field_id, 1}, + {field_name, 3}, + [84] = + {field_body, 6}, + {field_name, 3}, + [86] = + {field_kind, 2}, + {field_name, 3}, + {field_type, 5}, + [89] = + {field_name, 4}, + {field_scope, 2}, + [91] = + {field_value, 2}, + [92] = + {field_body, 3}, + [93] = + {field_index, 2}, + {field_value, 0}, + [95] = + {field_method, 2}, + {field_receiver, 0}, + [97] = + {field_type, 0}, + [98] = + {field_body, 7}, + {field_name, 2}, + {field_return_type, 6}, + [101] = + {field_name, 2}, + {field_type, 4}, + {field_value, 6}, + [104] = + {field_id, 2}, + {field_name, 4}, + [106] = + {field_default, 4}, + {field_name, 0}, + {field_type, 2}, + [109] = + {field_name, 2}, + {field_type, 4}, + [111] = + {field_bound, 1}, + [112] = + {field_bound, 0, .inherited = true}, + {field_bound, 1, .inherited = true}, + [114] = + {field_macro, 0}, + [115] = + {field_operator, 1}, + {field_target, 0}, + {field_value, 2}, + [118] = + {field_element, 1}, + {field_length, 3}, + [120] = + {field_body, 2}, + {field_phase, 0}, + {field_state, 1}, + [123] = + {field_body, 7}, + {field_name, 3}, + {field_return_type, 6}, + [126] = + {field_field, 5}, + {field_name, 3}, + [128] = + {field_binding, 1}, + [129] = + {field_body, 4}, + [130] = + {field_default, 5}, + {field_name, 1}, + {field_type, 3}, + [133] = + {field_name, 1}, + {field_return_type, 4}, + [135] = + {field_binding, 1}, + {field_body, 4}, + {field_source, 3}, + [138] = + {field_alternative, 4}, + {field_condition, 1}, + {field_consequence, 2}, + [141] = + {field_pattern, 1}, + {field_value, 3}, + [143] = + {field_name, 1}, + {field_value, 3}, + [145] = + {field_from, 0}, + {field_to, 2}, + [147] = + {field_body, 8}, + {field_name, 3}, + {field_return_type, 7}, + [150] = + {field_name, 3}, + {field_type, 5}, + {field_value, 7}, + [153] = + {field_id, 3}, + {field_name, 5}, + [155] = + {field_condition, 1}, + [156] = + {field_pattern, 0}, + {field_value, 2}, + [158] = + {field_body, 5}, + [159] = + {field_default, 6}, + {field_name, 2}, + {field_type, 4}, + [162] = + {field_name, 2}, + {field_value, 4}, + [164] = + {field_body, 2}, + {field_pattern, 0}, + [166] = + {field_body, 4}, + {field_every, 3}, + {field_phase, 0}, + {field_state, 1}, + [170] = + {field_function, 3}, + {field_phase, 0}, + {field_state, 1}, + [173] = + {field_pattern, 0}, + {field_value, 3}, + [175] = + {field_pattern, 0}, + {field_pattern, 1}, + {field_value, 3}, + [178] = + {field_body, 6}, + [179] = + {field_pattern, 1}, + {field_type, 3}, + {field_value, 5}, + [182] = + {field_body, 3}, + {field_pattern, 0}, + [184] = + {field_body, 3}, + {field_pattern, 0}, + {field_pattern, 1}, + [187] = + {field_from, 0}, + {field_guard, 4}, + {field_to, 2}, + [190] = + {field_from, 0}, + {field_priority, 4}, + {field_to, 2}, + [193] = + {field_pattern, 0}, + {field_pattern, 1}, + {field_value, 4}, + [196] = + {field_body, 7}, + [197] = + {field_body, 4}, + {field_pattern, 0}, + {field_pattern, 1}, + [200] = + {field_every, 3}, + {field_function, 5}, + {field_phase, 0}, + {field_state, 1}, + [204] = + {field_body, 8}, + [205] = + {field_from, 0}, + {field_guard, 4}, + {field_priority, 6}, + {field_to, 2}, +}; + +static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { + [0] = {0}, + [1] = { + [0] = alias_sym_attribute_name, + }, + [24] = { + [0] = alias_sym_field_identifier, + }, + [30] = { + [0] = alias_sym_field_identifier, + }, + [34] = { + [2] = alias_sym_field_identifier, + }, + [37] = { + [0] = alias_sym_argument_name, + }, + [41] = { + [1] = alias_sym_field_identifier, + }, + [62] = { + [0] = alias_sym_field_identifier, + }, + [63] = { + [2] = alias_sym_field_identifier, + }, + [66] = { + [0] = alias_sym_macro_name, + }, + [74] = { + [0] = alias_sym_argument_name, + }, + [75] = { + [1] = alias_sym_field_identifier, + }, + [88] = { + [2] = alias_sym_field_identifier, + }, +}; + +static const uint16_t ts_non_terminal_alias_map[] = { + 0, +}; + +static const TSStateId ts_primary_state_ids[STATE_COUNT] = { + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 5, + [6] = 6, + [7] = 7, + [8] = 7, + [9] = 9, + [10] = 9, + [11] = 11, + [12] = 12, + [13] = 12, + [14] = 14, + [15] = 12, + [16] = 14, + [17] = 14, + [18] = 18, + [19] = 19, + [20] = 20, + [21] = 21, + [22] = 22, + [23] = 23, + [24] = 24, + [25] = 21, + [26] = 26, + [27] = 20, + [28] = 22, + [29] = 24, + [30] = 23, + [31] = 31, + [32] = 26, + [33] = 33, + [34] = 34, + [35] = 35, + [36] = 33, + [37] = 34, + [38] = 35, + [39] = 39, + [40] = 40, + [41] = 41, + [42] = 42, + [43] = 42, + [44] = 44, + [45] = 44, + [46] = 46, + [47] = 46, + [48] = 48, + [49] = 49, + [50] = 50, + [51] = 51, + [52] = 52, + [53] = 53, + [54] = 54, + [55] = 55, + [56] = 56, + [57] = 57, + [58] = 58, + [59] = 59, + [60] = 60, + [61] = 61, + [62] = 62, + [63] = 63, + [64] = 64, + [65] = 65, + [66] = 66, + [67] = 67, + [68] = 68, + [69] = 69, + [70] = 70, + [71] = 71, + [72] = 72, + [73] = 73, + [74] = 62, + [75] = 75, + [76] = 70, + [77] = 72, + [78] = 78, + [79] = 58, + [80] = 61, + [81] = 73, + [82] = 78, + [83] = 83, + [84] = 84, + [85] = 85, + [86] = 86, + [87] = 87, + [88] = 88, + [89] = 89, + [90] = 88, + [91] = 91, + [92] = 92, + [93] = 93, + [94] = 94, + [95] = 94, + [96] = 93, + [97] = 88, + [98] = 98, + [99] = 99, + [100] = 93, + [101] = 94, + [102] = 102, + [103] = 103, + [104] = 104, + [105] = 102, + [106] = 104, + [107] = 107, + [108] = 108, + [109] = 109, + [110] = 108, + [111] = 111, + [112] = 112, + [113] = 113, + [114] = 114, + [115] = 113, + [116] = 116, + [117] = 49, + [118] = 48, + [119] = 119, + [120] = 120, + [121] = 121, + [122] = 48, + [123] = 49, + [124] = 124, + [125] = 125, + [126] = 126, + [127] = 127, + [128] = 128, + [129] = 129, + [130] = 130, + [131] = 131, + [132] = 132, + [133] = 133, + [134] = 134, + [135] = 135, + [136] = 136, + [137] = 137, + [138] = 138, + [139] = 139, + [140] = 140, + [141] = 141, + [142] = 142, + [143] = 143, + [144] = 144, + [145] = 145, + [146] = 146, + [147] = 147, + [148] = 148, + [149] = 149, + [150] = 150, + [151] = 151, + [152] = 152, + [153] = 153, + [154] = 154, + [155] = 155, + [156] = 156, + [157] = 157, + [158] = 158, + [159] = 159, + [160] = 160, + [161] = 161, + [162] = 162, + [163] = 146, + [164] = 164, + [165] = 165, + [166] = 166, + [167] = 167, + [168] = 161, + [169] = 162, + [170] = 145, + [171] = 148, + [172] = 172, + [173] = 173, + [174] = 49, + [175] = 167, + [176] = 176, + [177] = 177, + [178] = 151, + [179] = 48, + [180] = 161, + [181] = 162, + [182] = 160, + [183] = 183, + [184] = 161, + [185] = 162, + [186] = 149, + [187] = 187, + [188] = 177, + [189] = 189, + [190] = 190, + [191] = 191, + [192] = 192, + [193] = 193, + [194] = 194, + [195] = 195, + [196] = 196, + [197] = 197, + [198] = 162, + [199] = 199, + [200] = 200, + [201] = 191, + [202] = 202, + [203] = 176, + [204] = 161, + [205] = 162, + [206] = 189, + [207] = 167, + [208] = 202, + [209] = 209, + [210] = 161, + [211] = 211, + [212] = 212, + [213] = 167, + [214] = 214, + [215] = 215, + [216] = 166, + [217] = 165, + [218] = 200, + [219] = 197, + [220] = 220, + [221] = 221, + [222] = 211, + [223] = 164, + [224] = 224, + [225] = 225, + [226] = 226, + [227] = 227, + [228] = 228, + [229] = 229, + [230] = 230, + [231] = 231, + [232] = 232, + [233] = 233, + [234] = 234, + [235] = 235, + [236] = 221, + [237] = 237, + [238] = 238, + [239] = 239, + [240] = 240, + [241] = 241, + [242] = 242, + [243] = 243, + [244] = 244, + [245] = 245, + [246] = 246, + [247] = 247, + [248] = 248, + [249] = 220, + [250] = 250, + [251] = 251, + [252] = 252, + [253] = 253, + [254] = 254, + [255] = 255, + [256] = 256, + [257] = 257, + [258] = 258, + [259] = 259, + [260] = 260, + [261] = 261, + [262] = 224, + [263] = 263, + [264] = 264, + [265] = 265, + [266] = 266, + [267] = 267, + [268] = 268, + [269] = 269, + [270] = 270, + [271] = 271, + [272] = 272, + [273] = 273, + [274] = 274, + [275] = 275, + [276] = 276, + [277] = 277, + [278] = 278, + [279] = 279, + [280] = 280, + [281] = 281, + [282] = 282, + [283] = 283, + [284] = 284, + [285] = 285, + [286] = 286, + [287] = 287, + [288] = 288, + [289] = 289, + [290] = 290, + [291] = 291, + [292] = 292, + [293] = 293, + [294] = 294, + [295] = 295, + [296] = 296, + [297] = 297, + [298] = 298, + [299] = 299, + [300] = 300, + [301] = 301, + [302] = 2, + [303] = 303, + [304] = 304, + [305] = 305, + [306] = 306, + [307] = 307, + [308] = 308, + [309] = 309, + [310] = 310, + [311] = 311, + [312] = 312, + [313] = 313, + [314] = 314, + [315] = 315, + [316] = 316, + [317] = 317, + [318] = 318, + [319] = 214, + [320] = 320, + [321] = 321, + [322] = 296, + [323] = 304, + [324] = 312, + [325] = 318, + [326] = 326, + [327] = 327, + [328] = 328, + [329] = 329, + [330] = 330, + [331] = 331, + [332] = 332, + [333] = 240, + [334] = 334, + [335] = 335, + [336] = 248, + [337] = 250, + [338] = 257, + [339] = 276, + [340] = 284, + [341] = 235, + [342] = 289, + [343] = 295, + [344] = 297, + [345] = 298, + [346] = 299, + [347] = 313, + [348] = 314, + [349] = 315, + [350] = 350, + [351] = 320, + [352] = 352, + [353] = 334, + [354] = 335, + [355] = 350, + [356] = 356, + [357] = 357, + [358] = 358, + [359] = 356, + [360] = 360, + [361] = 361, + [362] = 362, + [363] = 363, + [364] = 364, + [365] = 365, + [366] = 366, + [367] = 367, + [368] = 357, + [369] = 369, + [370] = 370, + [371] = 371, + [372] = 358, + [373] = 352, + [374] = 237, + [375] = 238, + [376] = 239, + [377] = 241, + [378] = 242, + [379] = 243, + [380] = 244, + [381] = 245, + [382] = 246, + [383] = 251, + [384] = 252, + [385] = 253, + [386] = 254, + [387] = 255, + [388] = 256, + [389] = 258, + [390] = 259, + [391] = 260, + [392] = 261, + [393] = 263, + [394] = 264, + [395] = 265, + [396] = 266, + [397] = 267, + [398] = 268, + [399] = 269, + [400] = 270, + [401] = 271, + [402] = 272, + [403] = 273, + [404] = 274, + [405] = 277, + [406] = 278, + [407] = 279, + [408] = 280, + [409] = 281, + [410] = 282, + [411] = 283, + [412] = 285, + [413] = 286, + [414] = 287, + [415] = 415, + [416] = 288, + [417] = 290, + [418] = 291, + [419] = 292, + [420] = 293, + [421] = 294, + [422] = 300, + [423] = 301, + [424] = 303, + [425] = 326, + [426] = 305, + [427] = 306, + [428] = 307, + [429] = 308, + [430] = 309, + [431] = 310, + [432] = 311, + [433] = 316, + [434] = 317, + [435] = 327, + [436] = 328, + [437] = 329, + [438] = 330, + [439] = 360, + [440] = 361, + [441] = 362, + [442] = 363, + [443] = 364, + [444] = 331, + [445] = 365, + [446] = 366, + [447] = 367, + [448] = 3, + [449] = 369, + [450] = 370, + [451] = 371, + [452] = 247, + [453] = 332, + [454] = 321, + [455] = 455, + [456] = 3, + [457] = 2, + [458] = 458, + [459] = 234, + [460] = 460, + [461] = 233, + [462] = 229, + [463] = 463, + [464] = 232, + [465] = 225, + [466] = 228, + [467] = 231, + [468] = 468, + [469] = 226, + [470] = 470, + [471] = 471, + [472] = 227, + [473] = 473, + [474] = 474, + [475] = 470, + [476] = 458, + [477] = 477, + [478] = 473, + [479] = 479, + [480] = 480, + [481] = 471, + [482] = 460, + [483] = 463, + [484] = 477, + [485] = 485, + [486] = 480, + [487] = 487, + [488] = 488, + [489] = 489, + [490] = 490, + [491] = 491, + [492] = 492, + [493] = 493, + [494] = 494, + [495] = 495, + [496] = 496, + [497] = 497, + [498] = 498, + [499] = 499, + [500] = 215, + [501] = 501, + [502] = 502, + [503] = 503, + [504] = 504, + [505] = 505, + [506] = 506, + [507] = 507, + [508] = 508, + [509] = 509, + [510] = 510, + [511] = 511, + [512] = 512, + [513] = 513, + [514] = 514, + [515] = 479, + [516] = 415, + [517] = 517, + [518] = 518, + [519] = 519, + [520] = 215, + [521] = 521, + [522] = 471, + [523] = 460, + [524] = 470, + [525] = 525, + [526] = 463, + [527] = 458, + [528] = 528, + [529] = 529, + [530] = 530, + [531] = 531, + [532] = 532, + [533] = 533, + [534] = 534, + [535] = 535, + [536] = 536, + [537] = 537, + [538] = 538, + [539] = 539, + [540] = 540, + [541] = 480, + [542] = 542, + [543] = 543, + [544] = 544, + [545] = 539, + [546] = 546, + [547] = 149, + [548] = 548, + [549] = 151, + [550] = 119, + [551] = 551, + [552] = 479, + [553] = 145, + [554] = 146, + [555] = 148, + [556] = 556, + [557] = 211, + [558] = 165, + [559] = 559, + [560] = 560, + [561] = 164, + [562] = 200, + [563] = 197, + [564] = 166, + [565] = 565, + [566] = 566, + [567] = 567, + [568] = 568, + [569] = 569, + [570] = 567, + [571] = 571, + [572] = 572, + [573] = 573, + [574] = 573, + [575] = 575, + [576] = 107, + [577] = 577, + [578] = 578, + [579] = 572, + [580] = 577, + [581] = 572, + [582] = 582, + [583] = 573, + [584] = 582, + [585] = 585, + [586] = 582, + [587] = 585, + [588] = 572, + [589] = 582, + [590] = 575, + [591] = 578, + [592] = 592, + [593] = 119, + [594] = 575, + [595] = 573, + [596] = 578, + [597] = 597, + [598] = 598, + [599] = 599, + [600] = 600, + [601] = 601, + [602] = 602, + [603] = 603, + [604] = 600, + [605] = 605, + [606] = 606, + [607] = 607, + [608] = 608, + [609] = 609, + [610] = 610, + [611] = 611, + [612] = 612, + [613] = 613, + [614] = 614, + [615] = 615, + [616] = 598, + [617] = 608, + [618] = 618, + [619] = 600, + [620] = 607, + [621] = 610, + [622] = 622, + [623] = 623, + [624] = 615, + [625] = 625, + [626] = 626, + [627] = 627, + [628] = 615, + [629] = 629, + [630] = 630, + [631] = 460, + [632] = 632, + [633] = 633, + [634] = 634, + [635] = 607, + [636] = 636, + [637] = 598, + [638] = 470, + [639] = 615, + [640] = 640, + [641] = 471, + [642] = 600, + [643] = 607, + [644] = 463, + [645] = 610, + [646] = 598, + [647] = 640, + [648] = 648, + [649] = 649, + [650] = 632, + [651] = 630, + [652] = 613, + [653] = 597, + [654] = 654, + [655] = 655, + [656] = 656, + [657] = 614, + [658] = 622, + [659] = 655, + [660] = 629, + [661] = 648, + [662] = 611, + [663] = 627, + [664] = 606, + [665] = 665, + [666] = 618, + [667] = 632, + [668] = 656, + [669] = 610, + [670] = 665, + [671] = 627, + [672] = 606, + [673] = 665, + [674] = 618, + [675] = 675, + [676] = 599, + [677] = 625, + [678] = 603, + [679] = 649, + [680] = 479, + [681] = 681, + [682] = 682, + [683] = 683, + [684] = 551, + [685] = 138, + [686] = 143, + [687] = 133, + [688] = 124, + [689] = 153, + [690] = 157, + [691] = 116, + [692] = 692, + [693] = 140, + [694] = 144, + [695] = 548, + [696] = 479, + [697] = 479, + [698] = 480, + [699] = 150, + [700] = 154, + [701] = 158, + [702] = 131, + [703] = 132, + [704] = 134, + [705] = 705, + [706] = 125, + [707] = 137, + [708] = 139, + [709] = 141, + [710] = 159, + [711] = 142, + [712] = 155, + [713] = 129, + [714] = 546, + [715] = 147, + [716] = 156, + [717] = 126, + [718] = 152, + [719] = 127, + [720] = 128, + [721] = 130, + [722] = 722, + [723] = 136, + [724] = 135, + [725] = 114, + [726] = 726, + [727] = 727, + [728] = 728, + [729] = 729, + [730] = 730, + [731] = 546, + [732] = 732, + [733] = 733, + [734] = 548, + [735] = 727, + [736] = 736, + [737] = 737, + [738] = 738, + [739] = 548, + [740] = 740, + [741] = 741, + [742] = 742, + [743] = 743, + [744] = 744, + [745] = 740, + [746] = 546, + [747] = 747, + [748] = 747, + [749] = 749, + [750] = 750, + [751] = 751, + [752] = 743, + [753] = 753, + [754] = 742, + [755] = 750, + [756] = 756, + [757] = 749, + [758] = 758, + [759] = 759, + [760] = 760, + [761] = 761, + [762] = 762, + [763] = 763, + [764] = 764, + [765] = 765, + [766] = 766, + [767] = 759, + [768] = 761, + [769] = 769, + [770] = 770, + [771] = 771, + [772] = 772, + [773] = 764, + [774] = 774, + [775] = 775, + [776] = 776, + [777] = 777, + [778] = 778, + [779] = 779, + [780] = 780, + [781] = 781, + [782] = 782, + [783] = 783, + [784] = 762, + [785] = 785, + [786] = 786, + [787] = 787, + [788] = 776, + [789] = 785, + [790] = 770, + [791] = 760, + [792] = 792, + [793] = 782, + [794] = 794, + [795] = 781, + [796] = 771, + [797] = 794, + [798] = 780, + [799] = 799, + [800] = 772, + [801] = 763, + [802] = 779, + [803] = 803, + [804] = 778, + [805] = 766, + [806] = 770, + [807] = 765, + [808] = 758, + [809] = 809, + [810] = 783, + [811] = 811, + [812] = 803, + [813] = 813, + [814] = 814, + [815] = 815, + [816] = 816, + [817] = 817, + [818] = 818, + [819] = 817, + [820] = 816, + [821] = 821, + [822] = 822, + [823] = 823, + [824] = 824, + [825] = 825, + [826] = 826, + [827] = 827, + [828] = 815, + [829] = 829, + [830] = 830, + [831] = 831, + [832] = 832, + [833] = 833, + [834] = 834, + [835] = 835, + [836] = 836, + [837] = 837, + [838] = 838, + [839] = 839, + [840] = 840, + [841] = 841, + [842] = 831, + [843] = 843, + [844] = 844, + [845] = 843, + [846] = 827, + [847] = 847, + [848] = 818, + [849] = 849, + [850] = 850, + [851] = 851, + [852] = 813, + [853] = 853, + [854] = 854, + [855] = 855, + [856] = 856, + [857] = 857, + [858] = 858, + [859] = 844, + [860] = 860, + [861] = 861, + [862] = 854, + [863] = 823, + [864] = 864, + [865] = 860, + [866] = 849, + [867] = 835, + [868] = 868, + [869] = 839, + [870] = 829, + [871] = 855, + [872] = 856, + [873] = 841, + [874] = 833, + [875] = 875, + [876] = 876, + [877] = 861, + [878] = 878, + [879] = 879, + [880] = 880, + [881] = 881, + [882] = 858, + [883] = 883, + [884] = 847, + [885] = 885, + [886] = 837, + [887] = 836, + [888] = 879, + [889] = 826, + [890] = 830, + [891] = 868, + [892] = 814, + [893] = 880, + [894] = 894, + [895] = 895, + [896] = 832, + [897] = 897, + [898] = 898, + [899] = 899, + [900] = 900, + [901] = 900, + [902] = 902, + [903] = 900, + [904] = 904, + [905] = 905, + [906] = 906, + [907] = 907, + [908] = 908, + [909] = 909, + [910] = 910, + [911] = 911, + [912] = 909, + [913] = 913, + [914] = 914, + [915] = 907, + [916] = 916, + [917] = 917, + [918] = 917, + [919] = 914, + [920] = 920, + [921] = 921, + [922] = 922, + [923] = 923, + [924] = 924, + [925] = 925, + [926] = 922, + [927] = 909, + [928] = 928, + [929] = 917, + [930] = 930, + [931] = 914, + [932] = 911, + [933] = 933, + [934] = 934, + [935] = 935, + [936] = 936, + [937] = 935, + [938] = 938, + [939] = 939, + [940] = 940, + [941] = 941, + [942] = 942, + [943] = 943, + [944] = 940, + [945] = 945, + [946] = 946, + [947] = 947, + [948] = 948, + [949] = 949, + [950] = 950, + [951] = 951, + [952] = 952, + [953] = 953, + [954] = 947, + [955] = 949, + [956] = 941, + [957] = 957, + [958] = 958, + [959] = 959, + [960] = 960, + [961] = 948, + [962] = 960, + [963] = 950, + [964] = 933, + [965] = 953, + [966] = 966, + [967] = 967, + [968] = 957, + [969] = 969, + [970] = 970, + [971] = 971, + [972] = 970, + [973] = 973, + [974] = 974, + [975] = 975, + [976] = 976, + [977] = 977, + [978] = 978, + [979] = 979, + [980] = 980, + [981] = 981, + [982] = 982, + [983] = 983, + [984] = 984, + [985] = 985, + [986] = 986, + [987] = 987, + [988] = 988, + [989] = 989, + [990] = 990, + [991] = 991, + [992] = 992, + [993] = 993, + [994] = 994, + [995] = 995, + [996] = 996, + [997] = 997, + [998] = 998, + [999] = 999, + [1000] = 1000, + [1001] = 1001, + [1002] = 1002, + [1003] = 1003, + [1004] = 1004, + [1005] = 1005, + [1006] = 1006, + [1007] = 1007, + [1008] = 1008, + [1009] = 1009, + [1010] = 1010, + [1011] = 1011, + [1012] = 1012, + [1013] = 1013, + [1014] = 1014, + [1015] = 1015, + [1016] = 1016, + [1017] = 1017, + [1018] = 1018, + [1019] = 1019, + [1020] = 1020, + [1021] = 1021, + [1022] = 1022, + [1023] = 1023, + [1024] = 1024, + [1025] = 1025, + [1026] = 1026, + [1027] = 1027, + [1028] = 1028, + [1029] = 1029, + [1030] = 1030, + [1031] = 1031, + [1032] = 1032, + [1033] = 1033, + [1034] = 1034, + [1035] = 1035, + [1036] = 1036, + [1037] = 1037, + [1038] = 1038, + [1039] = 1039, + [1040] = 1040, + [1041] = 1041, + [1042] = 1042, + [1043] = 1043, + [1044] = 1044, + [1045] = 1045, + [1046] = 1046, + [1047] = 1047, + [1048] = 1048, + [1049] = 1049, + [1050] = 1050, + [1051] = 1051, + [1052] = 1052, + [1053] = 1053, + [1054] = 995, + [1055] = 998, + [1056] = 1011, + [1057] = 1057, + [1058] = 1058, + [1059] = 1059, + [1060] = 1060, + [1061] = 971, + [1062] = 1062, + [1063] = 1063, + [1064] = 992, + [1065] = 1006, + [1066] = 1012, + [1067] = 1026, + [1068] = 1045, + [1069] = 1047, + [1070] = 1070, + [1071] = 1071, + [1072] = 1072, + [1073] = 1073, + [1074] = 1074, + [1075] = 1075, + [1076] = 1076, + [1077] = 1077, + [1078] = 970, + [1079] = 1057, + [1080] = 976, + [1081] = 984, + [1082] = 986, + [1083] = 988, + [1084] = 1084, + [1085] = 1085, + [1086] = 993, + [1087] = 999, + [1088] = 1088, + [1089] = 1005, + [1090] = 1090, + [1091] = 1071, + [1092] = 1092, + [1093] = 1022, + [1094] = 1023, + [1095] = 1027, + [1096] = 1030, + [1097] = 1032, + [1098] = 1035, + [1099] = 1099, + [1100] = 1085, + [1101] = 1092, + [1102] = 1072, + [1103] = 1103, + [1104] = 1104, + [1105] = 1105, + [1106] = 1106, + [1107] = 1107, + [1108] = 1108, + [1109] = 1109, + [1110] = 1104, + [1111] = 1111, + [1112] = 1112, + [1113] = 1113, + [1114] = 1114, + [1115] = 1115, + [1116] = 1106, + [1117] = 1117, + [1118] = 1118, + [1119] = 1119, + [1120] = 1074, + [1121] = 1121, + [1122] = 1122, + [1123] = 1123, + [1124] = 1107, + [1125] = 983, + [1126] = 987, + [1127] = 996, + [1128] = 997, + [1129] = 1000, + [1130] = 1001, + [1131] = 1002, + [1132] = 1075, + [1133] = 777, + [1134] = 1008, + [1135] = 1009, + [1136] = 1013, + [1137] = 1014, + [1138] = 1015, + [1139] = 1108, + [1140] = 1076, + [1141] = 1141, + [1142] = 1041, + [1143] = 1044, + [1144] = 1046, + [1145] = 1109, + [1146] = 1048, + [1147] = 1049, + [1148] = 1062, + [1149] = 1123, + [1150] = 1006, + [1151] = 1051, + [1152] = 1152, + [1153] = 1153, + [1154] = 1112, + [1155] = 1085, + [1156] = 1156, + [1157] = 1157, + [1158] = 983, + [1159] = 777, + [1160] = 1052, + [1161] = 1070, + [1162] = 989, + [1163] = 1114, + [1164] = 1164, + [1165] = 1003, + [1166] = 1040, + [1167] = 1167, + [1168] = 1168, + [1169] = 1059, + [1170] = 1085, + [1171] = 1117, + [1172] = 1114, + [1173] = 1164, + [1174] = 983, + [1175] = 1175, + [1176] = 1118, + [1177] = 1009, + [1178] = 1010, + [1179] = 1049, + [1180] = 1119, + [1181] = 1123, + [1182] = 1121, + [1183] = 1122, + [1184] = 1184, + [1185] = 1185, + [1186] = 1060, + [1187] = 1167, + [1188] = 1164, + [1189] = 1189, + [1190] = 1010, + [1191] = 1191, + [1192] = 1192, + [1193] = 1193, + [1194] = 1194, + [1195] = 1195, + [1196] = 1196, + [1197] = 1197, + [1198] = 1198, + [1199] = 1199, + [1200] = 1194, + [1201] = 1201, + [1202] = 1202, + [1203] = 1203, + [1204] = 1204, + [1205] = 1205, + [1206] = 1206, + [1207] = 1207, + [1208] = 1208, + [1209] = 1208, + [1210] = 1210, + [1211] = 1211, + [1212] = 1212, + [1213] = 1213, + [1214] = 1214, + [1215] = 1212, + [1216] = 1216, + [1217] = 1217, + [1218] = 1198, + [1219] = 1219, + [1220] = 1220, + [1221] = 1221, + [1222] = 1222, + [1223] = 1202, + [1224] = 1224, + [1225] = 1225, + [1226] = 1226, + [1227] = 1227, + [1228] = 1228, + [1229] = 1229, + [1230] = 1230, + [1231] = 1231, + [1232] = 1232, + [1233] = 1233, + [1234] = 1234, + [1235] = 1235, + [1236] = 1236, + [1237] = 1237, + [1238] = 1238, + [1239] = 1239, + [1240] = 1214, + [1241] = 1241, + [1242] = 1242, + [1243] = 1243, + [1244] = 1244, + [1245] = 1245, + [1246] = 1224, + [1247] = 1247, + [1248] = 1248, + [1249] = 1249, + [1250] = 1242, + [1251] = 1251, + [1252] = 1197, + [1253] = 1253, + [1254] = 1254, + [1255] = 1255, + [1256] = 1256, + [1257] = 1257, + [1258] = 1258, + [1259] = 1259, + [1260] = 1260, + [1261] = 1256, + [1262] = 1208, + [1263] = 1263, + [1264] = 1254, + [1265] = 1265, + [1266] = 1259, + [1267] = 1267, + [1268] = 1268, + [1269] = 1269, + [1270] = 1203, + [1271] = 1271, + [1272] = 1272, + [1273] = 1273, + [1274] = 1274, + [1275] = 1275, + [1276] = 1276, + [1277] = 1277, + [1278] = 1272, + [1279] = 1221, + [1280] = 1199, + [1281] = 1281, + [1282] = 1260, + [1283] = 1283, + [1284] = 1207, + [1285] = 1274, + [1286] = 1286, + [1287] = 1255, + [1288] = 1288, + [1289] = 1289, + [1290] = 1290, + [1291] = 1291, + [1292] = 1292, + [1293] = 1293, + [1294] = 1294, + [1295] = 1254, + [1296] = 1296, + [1297] = 1235, + [1298] = 1259, + [1299] = 1260, + [1300] = 1204, + [1301] = 1232, + [1302] = 1302, + [1303] = 1303, + [1304] = 1304, + [1305] = 1293, + [1306] = 1306, + [1307] = 1307, + [1308] = 1308, + [1309] = 1309, + [1310] = 1310, + [1311] = 1309, + [1312] = 1257, + [1313] = 1235, + [1314] = 1314, + [1315] = 1315, + [1316] = 1316, + [1317] = 1317, + [1318] = 1318, + [1319] = 1319, + [1320] = 1320, + [1321] = 1321, + [1322] = 1322, + [1323] = 1323, + [1324] = 1324, + [1325] = 1325, + [1326] = 1326, + [1327] = 1327, + [1328] = 1328, + [1329] = 1329, + [1330] = 1330, + [1331] = 1331, + [1332] = 1332, + [1333] = 1333, + [1334] = 1334, + [1335] = 1331, + [1336] = 1336, + [1337] = 1337, + [1338] = 1338, + [1339] = 1339, + [1340] = 1340, + [1341] = 1341, + [1342] = 1342, + [1343] = 1343, + [1344] = 1344, + [1345] = 1345, + [1346] = 1346, + [1347] = 1347, + [1348] = 1348, + [1349] = 1349, + [1350] = 1350, + [1351] = 1351, + [1352] = 1352, + [1353] = 1353, + [1354] = 1354, + [1355] = 1351, + [1356] = 1356, + [1357] = 1357, + [1358] = 1358, + [1359] = 1359, + [1360] = 1360, + [1361] = 1361, + [1362] = 1362, + [1363] = 1363, + [1364] = 1364, + [1365] = 1365, + [1366] = 1366, + [1367] = 1367, + [1368] = 1368, + [1369] = 1369, + [1370] = 1318, + [1371] = 1371, + [1372] = 1372, + [1373] = 1373, + [1374] = 1374, + [1375] = 1375, + [1376] = 1338, + [1377] = 1377, + [1378] = 1378, + [1379] = 1379, + [1380] = 1372, + [1381] = 1381, + [1382] = 1382, + [1383] = 1383, + [1384] = 1384, + [1385] = 1385, + [1386] = 1386, + [1387] = 1387, + [1388] = 1388, + [1389] = 1389, + [1390] = 1390, + [1391] = 1391, + [1392] = 1392, + [1393] = 1393, + [1394] = 1392, + [1395] = 1395, + [1396] = 1349, + [1397] = 1397, + [1398] = 1334, + [1399] = 1388, + [1400] = 1400, + [1401] = 1401, + [1402] = 1402, + [1403] = 1353, + [1404] = 1404, + [1405] = 1405, + [1406] = 1406, + [1407] = 1407, + [1408] = 1408, + [1409] = 1409, + [1410] = 1322, + [1411] = 1411, + [1412] = 1412, + [1413] = 1413, + [1414] = 1414, + [1415] = 1346, + [1416] = 1416, + [1417] = 1321, + [1418] = 1418, + [1419] = 1419, + [1420] = 1420, + [1421] = 1421, + [1422] = 1422, + [1423] = 1423, + [1424] = 1424, + [1425] = 1425, + [1426] = 1426, + [1427] = 1427, + [1428] = 1357, + [1429] = 1340, + [1430] = 1329, + [1431] = 1412, + [1432] = 1411, + [1433] = 1325, + [1434] = 1434, + [1435] = 1378, + [1436] = 1436, + [1437] = 1437, + [1438] = 1438, + [1439] = 1439, + [1440] = 1440, + [1441] = 1314, + [1442] = 1442, + [1443] = 1443, + [1444] = 1422, + [1445] = 1445, + [1446] = 1446, + [1447] = 1447, + [1448] = 1448, + [1449] = 1449, + [1450] = 1421, + [1451] = 1451, + [1452] = 1452, + [1453] = 1453, + [1454] = 1454, + [1455] = 1416, + [1456] = 1395, + [1457] = 1457, + [1458] = 1447, + [1459] = 1448, + [1460] = 1460, + [1461] = 1460, + [1462] = 1462, + [1463] = 1356, + [1464] = 1400, + [1465] = 1465, + [1466] = 1466, + [1467] = 1366, + [1468] = 1468, + [1469] = 1418, + [1470] = 1446, + [1471] = 1471, + [1472] = 1472, + [1473] = 1473, + [1474] = 1474, + [1475] = 1397, + [1476] = 1476, + [1477] = 1477, + [1478] = 1406, + [1479] = 1479, + [1480] = 1480, + [1481] = 1481, + [1482] = 1426, + [1483] = 1473, + [1484] = 1419, + [1485] = 1485, + [1486] = 1486, + [1487] = 1487, + [1488] = 1488, + [1489] = 1489, + [1490] = 1490, + [1491] = 1491, + [1492] = 1492, + [1493] = 1493, + [1494] = 1494, + [1495] = 1495, + [1496] = 1329, + [1497] = 1497, + [1498] = 1498, + [1499] = 1466, + [1500] = 1371, + [1501] = 1343, + [1502] = 1407, + [1503] = 1503, + [1504] = 1462, + [1505] = 1342, + [1506] = 1358, + [1507] = 1409, + [1508] = 1480, + [1509] = 1485, + [1510] = 1384, + [1511] = 1497, + [1512] = 1420, + [1513] = 1341, + [1514] = 1476, + [1515] = 1515, + [1516] = 1385, + [1517] = 1427, + [1518] = 1443, + [1519] = 1328, + [1520] = 1439, + [1521] = 1521, + [1522] = 1329, + [1523] = 1345, + [1524] = 1319, + [1525] = 1390, + [1526] = 1515, + [1527] = 1465, + [1528] = 1481, + [1529] = 1529, + [1530] = 1530, + [1531] = 1531, + [1532] = 1425, + [1533] = 1533, + [1534] = 1534, + [1535] = 1352, + [1536] = 1367, + [1537] = 1537, + [1538] = 1374, + [1539] = 1539, + [1540] = 1537, + [1541] = 1541, + [1542] = 1542, + [1543] = 1543, + [1544] = 1442, + [1545] = 1545, + [1546] = 1503, + [1547] = 1539, + [1548] = 1498, + [1549] = 1347, + [1550] = 1529, + [1551] = 1379, + [1552] = 1350, + [1553] = 1530, + [1554] = 1541, + [1555] = 1555, + [1556] = 1391, + [1557] = 1557, + [1558] = 1465, + [1559] = 1559, + [1560] = 1468, + [1561] = 1534, + [1562] = 1559, + [1563] = 1477, + [1564] = 1521, + [1565] = 1493, + [1566] = 1402, + [1567] = 1354, + [1568] = 1377, + [1569] = 1471, + [1570] = 1316, + [1571] = 1434, + [1572] = 1339, + [1573] = 1449, + [1574] = 1320, + [1575] = 1575, + [1576] = 1576, +}; + +static bool ts_lex(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + if (eof) ADVANCE(24); + ADVANCE_MAP( + '!', 36, + '"', 88, + '#', 33, + '%', 83, + '&', 52, + '(', 37, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 74, + '.', 48, + '/', 81, + ':', 47, + ';', 46, + '<', 54, + '=', 41, + '>', 56, + '[', 34, + '\\', 22, + ']', 35, + '{', 98, + '|', 60, + '}', 105, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(23); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(84); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 1: + ADVANCE_MAP( + '!', 36, + '"', 87, + '#', 33, + '%', 83, + '&', 9, + '(', 37, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 74, + '.', 48, + '/', 81, + ':', 47, + ';', 46, + '<', 54, + '=', 41, + '>', 56, + '[', 34, + ']', 35, + '{', 43, + '|', 19, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(1); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(84); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 2: + ADVANCE_MAP( + '!', 36, + '%', 83, + '&', 9, + '(', 37, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 74, + '.', 48, + '/', 81, + ':', 47, + ';', 46, + '<', 54, + '=', 40, + '>', 56, + '[', 34, + ']', 35, + '{', 43, + '|', 19, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(2); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 3: + ADVANCE_MAP( + '!', 17, + '%', 83, + '&', 51, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 73, + '.', 48, + '/', 81, + ';', 46, + '<', 54, + '=', 41, + '>', 56, + '[', 34, + ']', 35, + '|', 60, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(3); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 4: + if (lookahead == '"') ADVANCE(88); + if (lookahead == '/') ADVANCE(91); + if (lookahead == '\\') ADVANCE(22); + if (lookahead == '{') ADVANCE(99); + if (lookahead == '}') ADVANCE(20); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') ADVANCE(94); + if (lookahead != 0) ADVANCE(95); + END_STATE(); + case 5: + ADVANCE_MAP( + '"', 87, + '%', 82, + '&', 9, + '(', 37, + ')', 39, + '*', 78, + '+', 76, + ',', 38, + '-', 75, + '.', 48, + '/', 80, + ':', 47, + ';', 46, + '<', 53, + '=', 18, + '>', 55, + '[', 34, + ']', 35, + '{', 43, + '|', 19, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(5); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(84); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 6: + ADVANCE_MAP( + '%', 83, + '&', 9, + '(', 37, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 74, + '.', 48, + '/', 81, + ':', 16, + ';', 46, + '<', 53, + '=', 42, + '>', 55, + '[', 34, + ']', 35, + '{', 43, + '|', 19, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(6); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(85); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 7: + ADVANCE_MAP( + '%', 83, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 74, + '.', 48, + '/', 81, + ';', 46, + '<', 53, + '=', 42, + '>', 55, + '[', 34, + ']', 35, + '{', 43, + '|', 60, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(7); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 8: + ADVANCE_MAP( + '%', 82, + '(', 37, + '*', 78, + '+', 76, + ',', 38, + '-', 75, + '.', 49, + '/', 80, + ':', 16, + '<', 53, + '=', 18, + '[', 34, + '{', 43, + '|', 60, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(8); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 9: + if (lookahead == '&') ADVANCE(67); + END_STATE(); + case 10: + if (lookahead == '*') ADVANCE(12); + if (lookahead == '/') ADVANCE(28); + END_STATE(); + case 11: + if (lookahead == '*') ADVANCE(11); + if (lookahead == '/') ADVANCE(32); + if (lookahead != 0) ADVANCE(12); + END_STATE(); + case 12: + if (lookahead == '*') ADVANCE(11); + if (lookahead != 0) ADVANCE(12); + END_STATE(); + case 13: + if (lookahead == '/') ADVANCE(100); + if (lookahead == '}') ADVANCE(105); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') ADVANCE(103); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '{') ADVANCE(104); + END_STATE(); + case 14: + if (lookahead == '/') ADVANCE(10); + if (lookahead == '}') ADVANCE(105); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(15); + END_STATE(); + case 15: + if (lookahead == '/') ADVANCE(10); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(15); + END_STATE(); + case 16: + if (lookahead == ':') ADVANCE(50); + END_STATE(); + case 17: + if (lookahead == '=') ADVANCE(69); + END_STATE(); + case 18: + if (lookahead == '>') ADVANCE(57); + END_STATE(); + case 19: + if (lookahead == '|') ADVANCE(66); + END_STATE(); + case 20: + if (lookahead == '}') ADVANCE(97); + END_STATE(); + case 21: + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(86); + END_STATE(); + case 22: + if (lookahead != 0 && + lookahead != '\n') ADVANCE(96); + END_STATE(); + case 23: + if (eof) ADVANCE(24); + ADVANCE_MAP( + '!', 36, + '"', 87, + '#', 33, + '%', 83, + '&', 52, + '(', 37, + ')', 39, + '*', 79, + '+', 77, + ',', 38, + '-', 74, + '.', 48, + '/', 81, + ':', 47, + ';', 46, + '<', 54, + '=', 41, + '>', 56, + '[', 34, + ']', 35, + '{', 43, + '|', 60, + '}', 44, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(23); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(84); + if (('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + case 24: + ACCEPT_TOKEN(ts_builtin_sym_end); + END_STATE(); + case 25: + ACCEPT_TOKEN(sym_doc_comment); + if (lookahead == '"' || + lookahead == '{' || + lookahead == '}') ADVANCE(27); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(25); + END_STATE(); + case 26: + ACCEPT_TOKEN(sym_doc_comment); + if (lookahead == '"' || + lookahead == '\\' || + lookahead == '{' || + lookahead == '}') ADVANCE(27); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(26); + END_STATE(); + case 27: + ACCEPT_TOKEN(sym_doc_comment); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(27); + END_STATE(); + case 28: + ACCEPT_TOKEN(sym_line_comment); + if (lookahead == '!' || + lookahead == '/') ADVANCE(27); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(31); + END_STATE(); + case 29: + ACCEPT_TOKEN(sym_line_comment); + if (lookahead == '!' || + lookahead == '/') ADVANCE(25); + if (lookahead == '"' || + lookahead == '{' || + lookahead == '}') ADVANCE(31); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(30); + END_STATE(); + case 30: + ACCEPT_TOKEN(sym_line_comment); + if (lookahead == '"' || + lookahead == '{' || + lookahead == '}') ADVANCE(31); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(30); + END_STATE(); + case 31: + ACCEPT_TOKEN(sym_line_comment); + if (lookahead != 0 && + lookahead != '\n') ADVANCE(31); + END_STATE(); + case 32: + ACCEPT_TOKEN(sym_block_comment); + END_STATE(); + case 33: + ACCEPT_TOKEN(anon_sym_POUND); + END_STATE(); + case 34: + ACCEPT_TOKEN(anon_sym_LBRACK); + END_STATE(); + case 35: + ACCEPT_TOKEN(anon_sym_RBRACK); + END_STATE(); + case 36: + ACCEPT_TOKEN(anon_sym_BANG); + if (lookahead == '=') ADVANCE(69); + END_STATE(); + case 37: + ACCEPT_TOKEN(anon_sym_LPAREN); + END_STATE(); + case 38: + ACCEPT_TOKEN(anon_sym_COMMA); + END_STATE(); + case 39: + ACCEPT_TOKEN(anon_sym_RPAREN); + END_STATE(); + case 40: + ACCEPT_TOKEN(anon_sym_EQ); + if (lookahead == '=') ADVANCE(68); + END_STATE(); + case 41: + ACCEPT_TOKEN(anon_sym_EQ); + if (lookahead == '=') ADVANCE(68); + if (lookahead == '>') ADVANCE(57); + END_STATE(); + case 42: + ACCEPT_TOKEN(anon_sym_EQ); + if (lookahead == '>') ADVANCE(57); + END_STATE(); + case 43: + ACCEPT_TOKEN(anon_sym_LBRACE); + END_STATE(); + case 44: + ACCEPT_TOKEN(anon_sym_RBRACE); + END_STATE(); + case 45: + ACCEPT_TOKEN(anon_sym_DASH_GT); + END_STATE(); + case 46: + ACCEPT_TOKEN(anon_sym_SEMI); + END_STATE(); + case 47: + ACCEPT_TOKEN(anon_sym_COLON); + if (lookahead == ':') ADVANCE(50); + END_STATE(); + case 48: + ACCEPT_TOKEN(anon_sym_DOT); + if (lookahead == '.') ADVANCE(59); + END_STATE(); + case 49: + ACCEPT_TOKEN(anon_sym_DOT); + if (lookahead == '.') ADVANCE(58); + END_STATE(); + case 50: + ACCEPT_TOKEN(anon_sym_COLON_COLON); + END_STATE(); + case 51: + ACCEPT_TOKEN(anon_sym_AMP); + END_STATE(); + case 52: + ACCEPT_TOKEN(anon_sym_AMP); + if (lookahead == '&') ADVANCE(67); + END_STATE(); + case 53: + ACCEPT_TOKEN(anon_sym_LT); + END_STATE(); + case 54: + ACCEPT_TOKEN(anon_sym_LT); + if (lookahead == '=') ADVANCE(70); + END_STATE(); + case 55: + ACCEPT_TOKEN(anon_sym_GT); + END_STATE(); + case 56: + ACCEPT_TOKEN(anon_sym_GT); + if (lookahead == '=') ADVANCE(71); + END_STATE(); + case 57: + ACCEPT_TOKEN(anon_sym_EQ_GT); + END_STATE(); + case 58: + ACCEPT_TOKEN(anon_sym_DOT_DOT); + END_STATE(); + case 59: + ACCEPT_TOKEN(anon_sym_DOT_DOT); + if (lookahead == '=') ADVANCE(72); + END_STATE(); + case 60: + ACCEPT_TOKEN(anon_sym_PIPE); + END_STATE(); + case 61: + ACCEPT_TOKEN(anon_sym_PLUS_EQ); + END_STATE(); + case 62: + ACCEPT_TOKEN(anon_sym_DASH_EQ); + END_STATE(); + case 63: + ACCEPT_TOKEN(anon_sym_STAR_EQ); + END_STATE(); + case 64: + ACCEPT_TOKEN(anon_sym_SLASH_EQ); + END_STATE(); + case 65: + ACCEPT_TOKEN(anon_sym_PERCENT_EQ); + END_STATE(); + case 66: + ACCEPT_TOKEN(anon_sym_PIPE_PIPE); + END_STATE(); + case 67: + ACCEPT_TOKEN(anon_sym_AMP_AMP); + END_STATE(); + case 68: + ACCEPT_TOKEN(anon_sym_EQ_EQ); + END_STATE(); + case 69: + ACCEPT_TOKEN(anon_sym_BANG_EQ); + END_STATE(); + case 70: + ACCEPT_TOKEN(anon_sym_LT_EQ); + END_STATE(); + case 71: + ACCEPT_TOKEN(anon_sym_GT_EQ); + END_STATE(); + case 72: + ACCEPT_TOKEN(anon_sym_DOT_DOT_EQ); + END_STATE(); + case 73: + ACCEPT_TOKEN(anon_sym_DASH); + if (lookahead == '=') ADVANCE(62); + END_STATE(); + case 74: + ACCEPT_TOKEN(anon_sym_DASH); + if (lookahead == '=') ADVANCE(62); + if (lookahead == '>') ADVANCE(45); + END_STATE(); + case 75: + ACCEPT_TOKEN(anon_sym_DASH); + if (lookahead == '>') ADVANCE(45); + END_STATE(); + case 76: + ACCEPT_TOKEN(anon_sym_PLUS); + END_STATE(); + case 77: + ACCEPT_TOKEN(anon_sym_PLUS); + if (lookahead == '=') ADVANCE(61); + END_STATE(); + case 78: + ACCEPT_TOKEN(anon_sym_STAR); + END_STATE(); + case 79: + ACCEPT_TOKEN(anon_sym_STAR); + if (lookahead == '=') ADVANCE(63); + END_STATE(); + case 80: + ACCEPT_TOKEN(anon_sym_SLASH); + if (lookahead == '*') ADVANCE(12); + if (lookahead == '/') ADVANCE(28); + END_STATE(); + case 81: + ACCEPT_TOKEN(anon_sym_SLASH); + if (lookahead == '*') ADVANCE(12); + if (lookahead == '/') ADVANCE(28); + if (lookahead == '=') ADVANCE(64); + END_STATE(); + case 82: + ACCEPT_TOKEN(anon_sym_PERCENT); + END_STATE(); + case 83: + ACCEPT_TOKEN(anon_sym_PERCENT); + if (lookahead == '=') ADVANCE(65); + END_STATE(); + case 84: + ACCEPT_TOKEN(sym_integer); + if (lookahead == '.') ADVANCE(21); + if (lookahead == '_') ADVANCE(85); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(84); + END_STATE(); + case 85: + ACCEPT_TOKEN(sym_integer); + if (('0' <= lookahead && lookahead <= '9') || + lookahead == '_') ADVANCE(85); + END_STATE(); + case 86: + ACCEPT_TOKEN(sym_float); + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(86); + END_STATE(); + case 87: + ACCEPT_TOKEN(anon_sym_DQUOTE); + END_STATE(); + case 88: + ACCEPT_TOKEN(anon_sym_DQUOTE2); + END_STATE(); + case 89: + ACCEPT_TOKEN(sym_string_content); + if (lookahead == '\n') ADVANCE(95); + if (lookahead == '!' || + lookahead == '/') ADVANCE(26); + if (lookahead == '"' || + lookahead == '\\' || + lookahead == '{' || + lookahead == '}') ADVANCE(31); + if (lookahead != 0) ADVANCE(90); + END_STATE(); + case 90: + ACCEPT_TOKEN(sym_string_content); + if (lookahead == '\n') ADVANCE(95); + if (lookahead == '"' || + lookahead == '\\' || + lookahead == '{' || + lookahead == '}') ADVANCE(31); + if (lookahead != 0) ADVANCE(90); + END_STATE(); + case 91: + ACCEPT_TOKEN(sym_string_content); + if (lookahead == '*') ADVANCE(93); + if (lookahead == '/') ADVANCE(89); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '\\' && + lookahead != '{' && + lookahead != '}') ADVANCE(95); + END_STATE(); + case 92: + ACCEPT_TOKEN(sym_string_content); + if (lookahead == '*') ADVANCE(92); + if (lookahead == '/') ADVANCE(95); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '\\' && + lookahead != '{' && + lookahead != '}') ADVANCE(93); + END_STATE(); + case 93: + ACCEPT_TOKEN(sym_string_content); + if (lookahead == '*') ADVANCE(92); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '\\' && + lookahead != '{' && + lookahead != '}') ADVANCE(93); + END_STATE(); + case 94: + ACCEPT_TOKEN(sym_string_content); + if (lookahead == '/') ADVANCE(91); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') ADVANCE(94); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '\\' && + lookahead != '{' && + lookahead != '}') ADVANCE(95); + END_STATE(); + case 95: + ACCEPT_TOKEN(sym_string_content); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '\\' && + lookahead != '{' && + lookahead != '}') ADVANCE(95); + END_STATE(); + case 96: + ACCEPT_TOKEN(sym_escape_sequence); + END_STATE(); + case 97: + ACCEPT_TOKEN(sym_brace_escape); + END_STATE(); + case 98: + ACCEPT_TOKEN(anon_sym_LBRACE2); + END_STATE(); + case 99: + ACCEPT_TOKEN(anon_sym_LBRACE2); + if (lookahead == '{') ADVANCE(97); + END_STATE(); + case 100: + ACCEPT_TOKEN(aux_sym_interpolation_token1); + if (lookahead == '*') ADVANCE(102); + if (lookahead == '/') ADVANCE(29); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '{' && + lookahead != '}') ADVANCE(104); + END_STATE(); + case 101: + ACCEPT_TOKEN(aux_sym_interpolation_token1); + if (lookahead == '*') ADVANCE(101); + if (lookahead == '/') ADVANCE(104); + if (lookahead == '"' || + lookahead == '{' || + lookahead == '}') ADVANCE(12); + if (lookahead != 0) ADVANCE(102); + END_STATE(); + case 102: + ACCEPT_TOKEN(aux_sym_interpolation_token1); + if (lookahead == '*') ADVANCE(101); + if (lookahead == '"' || + lookahead == '{' || + lookahead == '}') ADVANCE(12); + if (lookahead != 0) ADVANCE(102); + END_STATE(); + case 103: + ACCEPT_TOKEN(aux_sym_interpolation_token1); + if (lookahead == '/') ADVANCE(100); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') ADVANCE(103); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '{' && + lookahead != '}') ADVANCE(104); + END_STATE(); + case 104: + ACCEPT_TOKEN(aux_sym_interpolation_token1); + if (lookahead != 0 && + lookahead != '"' && + lookahead != '{' && + lookahead != '}') ADVANCE(104); + END_STATE(); + case 105: + ACCEPT_TOKEN(anon_sym_RBRACE2); + END_STATE(); + case 106: + ACCEPT_TOKEN(sym_identifier); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'Z') || + lookahead == '_' || + ('a' <= lookahead && lookahead <= 'z')) ADVANCE(106); + END_STATE(); + default: + return false; + } +} + +static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + ADVANCE_MAP( + '_', 1, + 'a', 2, + 'b', 3, + 'c', 4, + 'd', 5, + 'e', 6, + 'f', 7, + 'g', 8, + 'h', 9, + 'i', 10, + 'l', 11, + 'm', 12, + 'o', 13, + 'p', 14, + 'r', 15, + 's', 16, + 't', 17, + 'u', 18, + 'w', 19, + ); + if (('\t' <= lookahead && lookahead <= '\r') || + lookahead == ' ') SKIP(0); + END_STATE(); + case 1: + ACCEPT_TOKEN(anon_sym__); + END_STATE(); + case 2: + if (lookahead == 'd') ADVANCE(20); + if (lookahead == 's') ADVANCE(21); + END_STATE(); + case 3: + if (lookahead == 'i') ADVANCE(22); + if (lookahead == 'o') ADVANCE(23); + if (lookahead == 'r') ADVANCE(24); + END_STATE(); + case 4: + if (lookahead == 'o') ADVANCE(25); + if (lookahead == 'r') ADVANCE(26); + END_STATE(); + case 5: + if (lookahead == 'a') ADVANCE(27); + if (lookahead == 'i') ADVANCE(28); + END_STATE(); + case 6: + if (lookahead == 'l') ADVANCE(29); + if (lookahead == 'm') ADVANCE(30); + if (lookahead == 'n') ADVANCE(31); + if (lookahead == 'v') ADVANCE(32); + if (lookahead == 'x') ADVANCE(33); + END_STATE(); + case 7: + if (lookahead == 'a') ADVANCE(34); + if (lookahead == 'l') ADVANCE(35); + if (lookahead == 'n') ADVANCE(36); + if (lookahead == 'o') ADVANCE(37); + END_STATE(); + case 8: + if (lookahead == 'l') ADVANCE(38); + END_STATE(); + case 9: + if (lookahead == 'u') ADVANCE(39); + END_STATE(); + case 10: + if (lookahead == 'f') ADVANCE(40); + if (lookahead == 'm') ADVANCE(41); + if (lookahead == 'n') ADVANCE(42); + if (lookahead == 't') ADVANCE(43); + END_STATE(); + case 11: + if (lookahead == 'e') ADVANCE(44); + if (lookahead == 'o') ADVANCE(45); + END_STATE(); + case 12: + if (lookahead == 'a') ADVANCE(46); + if (lookahead == 'e') ADVANCE(47); + if (lookahead == 'o') ADVANCE(48); + if (lookahead == 'u') ADVANCE(49); + END_STATE(); + case 13: + if (lookahead == 'n') ADVANCE(50); + END_STATE(); + case 14: + if (lookahead == 'l') ADVANCE(51); + if (lookahead == 'r') ADVANCE(52); + if (lookahead == 'u') ADVANCE(53); + END_STATE(); + case 15: + if (lookahead == 'e') ADVANCE(54); + END_STATE(); + case 16: + if (lookahead == 'e') ADVANCE(55); + if (lookahead == 't') ADVANCE(56); + if (lookahead == 'u') ADVANCE(57); + END_STATE(); + case 17: + if (lookahead == 'a') ADVANCE(58); + if (lookahead == 'i') ADVANCE(59); + if (lookahead == 'r') ADVANCE(60); + END_STATE(); + case 18: + if (lookahead == 's') ADVANCE(61); + END_STATE(); + case 19: + if (lookahead == 'h') ADVANCE(62); + END_STATE(); + case 20: + if (lookahead == 'v') ADVANCE(63); + END_STATE(); + case 21: + ACCEPT_TOKEN(anon_sym_as); + END_STATE(); + case 22: + if (lookahead == 'o') ADVANCE(64); + END_STATE(); + case 23: + if (lookahead == 's') ADVANCE(65); + END_STATE(); + case 24: + if (lookahead == 'e') ADVANCE(66); + END_STATE(); + case 25: + if (lookahead == 'n') ADVANCE(67); + END_STATE(); + case 26: + if (lookahead == 'a') ADVANCE(68); + END_STATE(); + case 27: + if (lookahead == 'm') ADVANCE(69); + END_STATE(); + case 28: + if (lookahead == 'a') ADVANCE(70); + if (lookahead == 'm') ADVANCE(71); + END_STATE(); + case 29: + if (lookahead == 's') ADVANCE(72); + END_STATE(); + case 30: + if (lookahead == 'i') ADVANCE(73); + END_STATE(); + case 31: + if (lookahead == 't') ADVANCE(74); + if (lookahead == 'u') ADVANCE(75); + END_STATE(); + case 32: + if (lookahead == 'e') ADVANCE(76); + END_STATE(); + case 33: + if (lookahead == 'i') ADVANCE(77); + if (lookahead == 't') ADVANCE(78); + END_STATE(); + case 34: + if (lookahead == 'l') ADVANCE(79); + END_STATE(); + case 35: + if (lookahead == 'o') ADVANCE(80); + END_STATE(); + case 36: + ACCEPT_TOKEN(anon_sym_fn); + END_STATE(); + case 37: + if (lookahead == 'r') ADVANCE(81); + END_STATE(); + case 38: + if (lookahead == 'o') ADVANCE(82); + END_STATE(); + case 39: + if (lookahead == 'd') ADVANCE(83); + END_STATE(); + case 40: + ACCEPT_TOKEN(anon_sym_if); + END_STATE(); + case 41: + if (lookahead == 'p') ADVANCE(84); + END_STATE(); + case 42: + ACCEPT_TOKEN(anon_sym_in); + if (lookahead == 'v') ADVANCE(85); + END_STATE(); + case 43: + if (lookahead == 'e') ADVANCE(86); + END_STATE(); + case 44: + if (lookahead == 't') ADVANCE(87); + END_STATE(); + case 45: + if (lookahead == 'o') ADVANCE(88); + END_STATE(); + case 46: + if (lookahead == 't') ADVANCE(89); + END_STATE(); + case 47: + if (lookahead == 'n') ADVANCE(90); + END_STATE(); + case 48: + if (lookahead == 'd') ADVANCE(91); + if (lookahead == 'v') ADVANCE(92); + END_STATE(); + case 49: + if (lookahead == 't') ADVANCE(93); + END_STATE(); + case 50: + ACCEPT_TOKEN(anon_sym_on); + END_STATE(); + case 51: + if (lookahead == 'a') ADVANCE(94); + END_STATE(); + case 52: + if (lookahead == 'e') ADVANCE(95); + if (lookahead == 'i') ADVANCE(96); + END_STATE(); + case 53: + if (lookahead == 'b') ADVANCE(97); + END_STATE(); + case 54: + if (lookahead == 'c') ADVANCE(98); + if (lookahead == 't') ADVANCE(99); + if (lookahead == 'v') ADVANCE(100); + END_STATE(); + case 55: + if (lookahead == 'l') ADVANCE(101); + END_STATE(); + case 56: + if (lookahead == 'a') ADVANCE(102); + if (lookahead == 'e') ADVANCE(103); + if (lookahead == 'r') ADVANCE(104); + END_STATE(); + case 57: + if (lookahead == 'p') ADVANCE(105); + END_STATE(); + case 58: + if (lookahead == 'g') ADVANCE(106); + END_STATE(); + case 59: + if (lookahead == 'c') ADVANCE(107); + END_STATE(); + case 60: + if (lookahead == 'a') ADVANCE(108); + if (lookahead == 'u') ADVANCE(109); + END_STATE(); + case 61: + if (lookahead == 'e') ADVANCE(110); + END_STATE(); + case 62: + if (lookahead == 'i') ADVANCE(111); + END_STATE(); + case 63: + if (lookahead == 'a') ADVANCE(112); + END_STATE(); + case 64: + if (lookahead == 'm') ADVANCE(113); + END_STATE(); + case 65: + if (lookahead == 's') ADVANCE(114); + END_STATE(); + case 66: + if (lookahead == 'a') ADVANCE(115); + END_STATE(); + case 67: + if (lookahead == 's') ADVANCE(116); + if (lookahead == 't') ADVANCE(117); + END_STATE(); + case 68: + if (lookahead == 't') ADVANCE(118); + END_STATE(); + case 69: + if (lookahead == 'a') ADVANCE(119); + END_STATE(); + case 70: + if (lookahead == 'l') ADVANCE(120); + END_STATE(); + case 71: + if (lookahead == 'e') ADVANCE(121); + END_STATE(); + case 72: + if (lookahead == 'e') ADVANCE(122); + END_STATE(); + case 73: + if (lookahead == 't') ADVANCE(123); + END_STATE(); + case 74: + if (lookahead == 'e') ADVANCE(124); + if (lookahead == 'i') ADVANCE(125); + END_STATE(); + case 75: + if (lookahead == 'm') ADVANCE(126); + END_STATE(); + case 76: + if (lookahead == 'n') ADVANCE(127); + if (lookahead == 'r') ADVANCE(128); + END_STATE(); + case 77: + if (lookahead == 't') ADVANCE(129); + END_STATE(); + case 78: + if (lookahead == 'e') ADVANCE(130); + END_STATE(); + case 79: + if (lookahead == 's') ADVANCE(131); + END_STATE(); + case 80: + if (lookahead == 'w') ADVANCE(132); + END_STATE(); + case 81: + ACCEPT_TOKEN(anon_sym_for); + END_STATE(); + case 82: + if (lookahead == 'b') ADVANCE(133); + END_STATE(); + case 83: + ACCEPT_TOKEN(anon_sym_hud); + END_STATE(); + case 84: + if (lookahead == 'l') ADVANCE(134); + END_STATE(); + case 85: + if (lookahead == 'e') ADVANCE(135); + END_STATE(); + case 86: + if (lookahead == 'm') ADVANCE(136); + END_STATE(); + case 87: + ACCEPT_TOKEN(anon_sym_let); + END_STATE(); + case 88: + if (lookahead == 'p') ADVANCE(137); + if (lookahead == 't') ADVANCE(138); + END_STATE(); + case 89: + if (lookahead == 'c') ADVANCE(139); + END_STATE(); + case 90: + if (lookahead == 'u') ADVANCE(140); + END_STATE(); + case 91: + ACCEPT_TOKEN(anon_sym_mod); + END_STATE(); + case 92: + if (lookahead == 'e') ADVANCE(141); + END_STATE(); + case 93: + ACCEPT_TOKEN(anon_sym_mut); + END_STATE(); + case 94: + if (lookahead == 'y') ADVANCE(142); + END_STATE(); + case 95: + if (lookahead == 'd') ADVANCE(143); + END_STATE(); + case 96: + if (lookahead == 'o') ADVANCE(144); + END_STATE(); + case 97: + ACCEPT_TOKEN(sym_visibility); + END_STATE(); + case 98: + if (lookahead == 'i') ADVANCE(145); + END_STATE(); + case 99: + if (lookahead == 'u') ADVANCE(146); + END_STATE(); + case 100: + ACCEPT_TOKEN(anon_sym_rev); + END_STATE(); + case 101: + if (lookahead == 'f') ADVANCE(147); + END_STATE(); + case 102: + if (lookahead == 't') ADVANCE(148); + END_STATE(); + case 103: + if (lookahead == 'p') ADVANCE(149); + END_STATE(); + case 104: + if (lookahead == 'u') ADVANCE(150); + END_STATE(); + case 105: + if (lookahead == 'e') ADVANCE(151); + END_STATE(); + case 106: + ACCEPT_TOKEN(anon_sym_tag); + END_STATE(); + case 107: + if (lookahead == 'k') ADVANCE(152); + END_STATE(); + case 108: + if (lookahead == 'i') ADVANCE(153); + END_STATE(); + case 109: + if (lookahead == 'e') ADVANCE(154); + END_STATE(); + case 110: + ACCEPT_TOKEN(anon_sym_use); + END_STATE(); + case 111: + if (lookahead == 'l') ADVANCE(155); + END_STATE(); + case 112: + if (lookahead == 'n') ADVANCE(156); + END_STATE(); + case 113: + if (lookahead == 'e') ADVANCE(157); + END_STATE(); + case 114: + if (lookahead == 'b') ADVANCE(158); + END_STATE(); + case 115: + if (lookahead == 'k') ADVANCE(159); + END_STATE(); + case 116: + if (lookahead == 't') ADVANCE(160); + END_STATE(); + case 117: + if (lookahead == 'i') ADVANCE(161); + END_STATE(); + case 118: + if (lookahead == 'e') ADVANCE(162); + END_STATE(); + case 119: + if (lookahead == 'g') ADVANCE(163); + END_STATE(); + case 120: + if (lookahead == 'o') ADVANCE(164); + END_STATE(); + case 121: + if (lookahead == 'n') ADVANCE(165); + END_STATE(); + case 122: + ACCEPT_TOKEN(anon_sym_else); + END_STATE(); + case 123: + ACCEPT_TOKEN(anon_sym_emit); + END_STATE(); + case 124: + if (lookahead == 'r') ADVANCE(166); + END_STATE(); + case 125: + if (lookahead == 't') ADVANCE(167); + END_STATE(); + case 126: + ACCEPT_TOKEN(anon_sym_enum); + END_STATE(); + case 127: + if (lookahead == 't') ADVANCE(168); + END_STATE(); + case 128: + if (lookahead == 'y') ADVANCE(169); + END_STATE(); + case 129: + ACCEPT_TOKEN(anon_sym_exit); + END_STATE(); + case 130: + if (lookahead == 'r') ADVANCE(170); + END_STATE(); + case 131: + if (lookahead == 'e') ADVANCE(171); + END_STATE(); + case 132: + ACCEPT_TOKEN(anon_sym_flow); + END_STATE(); + case 133: + if (lookahead == 'a') ADVANCE(172); + END_STATE(); + case 134: + ACCEPT_TOKEN(anon_sym_impl); + END_STATE(); + case 135: + if (lookahead == 'n') ADVANCE(173); + END_STATE(); + case 136: + ACCEPT_TOKEN(anon_sym_item); + END_STATE(); + case 137: + ACCEPT_TOKEN(anon_sym_loop); + END_STATE(); + case 138: + ACCEPT_TOKEN(anon_sym_loot); + END_STATE(); + case 139: + if (lookahead == 'h') ADVANCE(174); + END_STATE(); + case 140: + ACCEPT_TOKEN(anon_sym_menu); + END_STATE(); + case 141: + ACCEPT_TOKEN(anon_sym_move); + END_STATE(); + case 142: + if (lookahead == 'e') ADVANCE(175); + END_STATE(); + case 143: + if (lookahead == 'i') ADVANCE(176); + END_STATE(); + case 144: + if (lookahead == 'r') ADVANCE(177); + END_STATE(); + case 145: + if (lookahead == 'p') ADVANCE(178); + END_STATE(); + case 146: + if (lookahead == 'r') ADVANCE(179); + END_STATE(); + case 147: + ACCEPT_TOKEN(anon_sym_self); + END_STATE(); + case 148: + if (lookahead == 'e') ADVANCE(180); + END_STATE(); + case 149: + if (lookahead == '_') ADVANCE(181); + END_STATE(); + case 150: + if (lookahead == 'c') ADVANCE(182); + END_STATE(); + case 151: + if (lookahead == 'r') ADVANCE(183); + END_STATE(); + case 152: + ACCEPT_TOKEN(anon_sym_tick); + END_STATE(); + case 153: + if (lookahead == 't') ADVANCE(184); + END_STATE(); + case 154: + ACCEPT_TOKEN(anon_sym_true); + END_STATE(); + case 155: + if (lookahead == 'e') ADVANCE(185); + END_STATE(); + case 156: + if (lookahead == 'c') ADVANCE(186); + END_STATE(); + case 157: + ACCEPT_TOKEN(anon_sym_biome); + END_STATE(); + case 158: + if (lookahead == 'a') ADVANCE(187); + END_STATE(); + case 159: + ACCEPT_TOKEN(anon_sym_break); + END_STATE(); + case 160: + ACCEPT_TOKEN(anon_sym_const); + END_STATE(); + case 161: + if (lookahead == 'n') ADVANCE(188); + END_STATE(); + case 162: + ACCEPT_TOKEN(sym_crate); + END_STATE(); + case 163: + if (lookahead == 'e') ADVANCE(189); + END_STATE(); + case 164: + if (lookahead == 'g') ADVANCE(190); + END_STATE(); + case 165: + if (lookahead == 's') ADVANCE(191); + END_STATE(); + case 166: + ACCEPT_TOKEN(anon_sym_enter); + END_STATE(); + case 167: + if (lookahead == 'y') ADVANCE(192); + END_STATE(); + case 168: + ACCEPT_TOKEN(anon_sym_event); + END_STATE(); + case 169: + ACCEPT_TOKEN(anon_sym_every); + END_STATE(); + case 170: + if (lookahead == 'n') ADVANCE(193); + END_STATE(); + case 171: + ACCEPT_TOKEN(anon_sym_false); + END_STATE(); + case 172: + if (lookahead == 'l') ADVANCE(194); + END_STATE(); + case 173: + if (lookahead == 't') ADVANCE(195); + END_STATE(); + case 174: + ACCEPT_TOKEN(anon_sym_match); + END_STATE(); + case 175: + if (lookahead == 'r') ADVANCE(196); + END_STATE(); + case 176: + if (lookahead == 'c') ADVANCE(197); + END_STATE(); + case 177: + if (lookahead == 'i') ADVANCE(198); + END_STATE(); + case 178: + if (lookahead == 'e') ADVANCE(199); + END_STATE(); + case 179: + if (lookahead == 'n') ADVANCE(200); + END_STATE(); + case 180: + ACCEPT_TOKEN(anon_sym_state); + END_STATE(); + case 181: + if (lookahead == 'b') ADVANCE(201); + END_STATE(); + case 182: + if (lookahead == 't') ADVANCE(202); + END_STATE(); + case 183: + ACCEPT_TOKEN(sym_super); + END_STATE(); + case 184: + ACCEPT_TOKEN(anon_sym_trait); + END_STATE(); + case 185: + ACCEPT_TOKEN(anon_sym_while); + END_STATE(); + case 186: + if (lookahead == 'e') ADVANCE(203); + END_STATE(); + case 187: + if (lookahead == 'r') ADVANCE(204); + END_STATE(); + case 188: + if (lookahead == 'u') ADVANCE(205); + END_STATE(); + case 189: + if (lookahead == '_') ADVANCE(206); + END_STATE(); + case 190: + ACCEPT_TOKEN(anon_sym_dialog); + END_STATE(); + case 191: + if (lookahead == 'i') ADVANCE(207); + END_STATE(); + case 192: + ACCEPT_TOKEN(anon_sym_entity); + END_STATE(); + case 193: + ACCEPT_TOKEN(anon_sym_extern); + END_STATE(); + case 194: + ACCEPT_TOKEN(anon_sym_global); + END_STATE(); + case 195: + if (lookahead == 'o') ADVANCE(208); + END_STATE(); + case 196: + ACCEPT_TOKEN(anon_sym_player); + END_STATE(); + case 197: + if (lookahead == 'a') ADVANCE(209); + END_STATE(); + case 198: + if (lookahead == 't') ADVANCE(210); + END_STATE(); + case 199: + ACCEPT_TOKEN(anon_sym_recipe); + END_STATE(); + case 200: + ACCEPT_TOKEN(anon_sym_return); + END_STATE(); + case 201: + if (lookahead == 'y') ADVANCE(211); + END_STATE(); + case 202: + ACCEPT_TOKEN(anon_sym_struct); + if (lookahead == 'u') ADVANCE(212); + END_STATE(); + case 203: + if (lookahead == 'm') ADVANCE(213); + END_STATE(); + case 204: + ACCEPT_TOKEN(anon_sym_bossbar); + END_STATE(); + case 205: + if (lookahead == 'e') ADVANCE(214); + END_STATE(); + case 206: + if (lookahead == 't') ADVANCE(215); + END_STATE(); + case 207: + if (lookahead == 'o') ADVANCE(216); + END_STATE(); + case 208: + if (lookahead == 'r') ADVANCE(217); + END_STATE(); + case 209: + if (lookahead == 't') ADVANCE(218); + END_STATE(); + case 210: + if (lookahead == 'y') ADVANCE(219); + END_STATE(); + case 211: + ACCEPT_TOKEN(anon_sym_step_by); + END_STATE(); + case 212: + if (lookahead == 'r') ADVANCE(220); + END_STATE(); + case 213: + if (lookahead == 'e') ADVANCE(221); + END_STATE(); + case 214: + ACCEPT_TOKEN(anon_sym_continue); + END_STATE(); + case 215: + if (lookahead == 'y') ADVANCE(222); + END_STATE(); + case 216: + if (lookahead == 'n') ADVANCE(223); + END_STATE(); + case 217: + if (lookahead == 'y') ADVANCE(224); + END_STATE(); + case 218: + if (lookahead == 'e') ADVANCE(225); + END_STATE(); + case 219: + ACCEPT_TOKEN(anon_sym_priority); + END_STATE(); + case 220: + if (lookahead == 'e') ADVANCE(226); + END_STATE(); + case 221: + if (lookahead == 'n') ADVANCE(227); + END_STATE(); + case 222: + if (lookahead == 'p') ADVANCE(228); + END_STATE(); + case 223: + ACCEPT_TOKEN(anon_sym_dimension); + END_STATE(); + case 224: + if (lookahead == '_') ADVANCE(229); + END_STATE(); + case 225: + ACCEPT_TOKEN(anon_sym_predicate); + END_STATE(); + case 226: + if (lookahead == '_') ADVANCE(230); + END_STATE(); + case 227: + if (lookahead == 't') ADVANCE(231); + END_STATE(); + case 228: + if (lookahead == 'e') ADVANCE(232); + END_STATE(); + case 229: + if (lookahead == 't') ADVANCE(233); + END_STATE(); + case 230: + if (lookahead == 't') ADVANCE(234); + END_STATE(); + case 231: + ACCEPT_TOKEN(anon_sym_advancement); + END_STATE(); + case 232: + ACCEPT_TOKEN(anon_sym_damage_type); + END_STATE(); + case 233: + if (lookahead == 'r') ADVANCE(235); + END_STATE(); + case 234: + if (lookahead == 'e') ADVANCE(236); + END_STATE(); + case 235: + if (lookahead == 'a') ADVANCE(237); + END_STATE(); + case 236: + if (lookahead == 'm') ADVANCE(238); + END_STATE(); + case 237: + if (lookahead == 'n') ADVANCE(239); + END_STATE(); + case 238: + if (lookahead == 'p') ADVANCE(240); + END_STATE(); + case 239: + if (lookahead == 's') ADVANCE(241); + END_STATE(); + case 240: + if (lookahead == 'l') ADVANCE(242); + END_STATE(); + case 241: + if (lookahead == 'f') ADVANCE(243); + END_STATE(); + case 242: + if (lookahead == 'a') ADVANCE(244); + END_STATE(); + case 243: + if (lookahead == 'e') ADVANCE(245); + END_STATE(); + case 244: + if (lookahead == 't') ADVANCE(246); + END_STATE(); + case 245: + if (lookahead == 'r') ADVANCE(247); + END_STATE(); + case 246: + if (lookahead == 'e') ADVANCE(248); + END_STATE(); + case 247: + ACCEPT_TOKEN(anon_sym_inventory_transfer); + END_STATE(); + case 248: + ACCEPT_TOKEN(anon_sym_structure_template); + END_STATE(); + default: + return false; + } +} + +static const TSLexerMode ts_lex_modes[STATE_COUNT] = { + [0] = {.lex_state = 0}, + [1] = {.lex_state = 0}, + [2] = {.lex_state = 1}, + [3] = {.lex_state = 1}, + [4] = {.lex_state = 1}, + [5] = {.lex_state = 1}, + [6] = {.lex_state = 1}, + [7] = {.lex_state = 1}, + [8] = {.lex_state = 1}, + [9] = {.lex_state = 1}, + [10] = {.lex_state = 1}, + [11] = {.lex_state = 1}, + [12] = {.lex_state = 1}, + [13] = {.lex_state = 1}, + [14] = {.lex_state = 1}, + [15] = {.lex_state = 1}, + [16] = {.lex_state = 1}, + [17] = {.lex_state = 1}, + [18] = {.lex_state = 0}, + [19] = {.lex_state = 0}, + [20] = {.lex_state = 1}, + [21] = {.lex_state = 1}, + [22] = {.lex_state = 1}, + [23] = {.lex_state = 1}, + [24] = {.lex_state = 1}, + [25] = {.lex_state = 1}, + [26] = {.lex_state = 1}, + [27] = {.lex_state = 1}, + [28] = {.lex_state = 1}, + [29] = {.lex_state = 1}, + [30] = {.lex_state = 1}, + [31] = {.lex_state = 1}, + [32] = {.lex_state = 1}, + [33] = {.lex_state = 1}, + [34] = {.lex_state = 1}, + [35] = {.lex_state = 1}, + [36] = {.lex_state = 1}, + [37] = {.lex_state = 1}, + [38] = {.lex_state = 1}, + [39] = {.lex_state = 1}, + [40] = {.lex_state = 1}, + [41] = {.lex_state = 1}, + [42] = {.lex_state = 1}, + [43] = {.lex_state = 1}, + [44] = {.lex_state = 1}, + [45] = {.lex_state = 1}, + [46] = {.lex_state = 1}, + [47] = {.lex_state = 1}, + [48] = {.lex_state = 5}, + [49] = {.lex_state = 5}, + [50] = {.lex_state = 1}, + [51] = {.lex_state = 1}, + [52] = {.lex_state = 1}, + [53] = {.lex_state = 1}, + [54] = {.lex_state = 1}, + [55] = {.lex_state = 1}, + [56] = {.lex_state = 1}, + [57] = {.lex_state = 1}, + [58] = {.lex_state = 1}, + [59] = {.lex_state = 1}, + [60] = {.lex_state = 1}, + [61] = {.lex_state = 1}, + [62] = {.lex_state = 1}, + [63] = {.lex_state = 1}, + [64] = {.lex_state = 1}, + [65] = {.lex_state = 1}, + [66] = {.lex_state = 1}, + [67] = {.lex_state = 1}, + [68] = {.lex_state = 1}, + [69] = {.lex_state = 1}, + [70] = {.lex_state = 1}, + [71] = {.lex_state = 1}, + [72] = {.lex_state = 1}, + [73] = {.lex_state = 1}, + [74] = {.lex_state = 1}, + [75] = {.lex_state = 1}, + [76] = {.lex_state = 1}, + [77] = {.lex_state = 1}, + [78] = {.lex_state = 1}, + [79] = {.lex_state = 1}, + [80] = {.lex_state = 1}, + [81] = {.lex_state = 1}, + [82] = {.lex_state = 1}, + [83] = {.lex_state = 1}, + [84] = {.lex_state = 1}, + [85] = {.lex_state = 1}, + [86] = {.lex_state = 1}, + [87] = {.lex_state = 1}, + [88] = {.lex_state = 1}, + [89] = {.lex_state = 1}, + [90] = {.lex_state = 1}, + [91] = {.lex_state = 1}, + [92] = {.lex_state = 1}, + [93] = {.lex_state = 1}, + [94] = {.lex_state = 1}, + [95] = {.lex_state = 1}, + [96] = {.lex_state = 1}, + [97] = {.lex_state = 1}, + [98] = {.lex_state = 1}, + [99] = {.lex_state = 1}, + [100] = {.lex_state = 1}, + [101] = {.lex_state = 1}, + [102] = {.lex_state = 1}, + [103] = {.lex_state = 1}, + [104] = {.lex_state = 1}, + [105] = {.lex_state = 1}, + [106] = {.lex_state = 1}, + [107] = {.lex_state = 1}, + [108] = {.lex_state = 1}, + [109] = {.lex_state = 1}, + [110] = {.lex_state = 1}, + [111] = {.lex_state = 1}, + [112] = {.lex_state = 1}, + [113] = {.lex_state = 1}, + [114] = {.lex_state = 1}, + [115] = {.lex_state = 1}, + [116] = {.lex_state = 1}, + [117] = {.lex_state = 1}, + [118] = {.lex_state = 1}, + [119] = {.lex_state = 1}, + [120] = {.lex_state = 1}, + [121] = {.lex_state = 1}, + [122] = {.lex_state = 1}, + [123] = {.lex_state = 1}, + [124] = {.lex_state = 1}, + [125] = {.lex_state = 1}, + [126] = {.lex_state = 1}, + [127] = {.lex_state = 1}, + [128] = {.lex_state = 1}, + [129] = {.lex_state = 1}, + [130] = {.lex_state = 1}, + [131] = {.lex_state = 1}, + [132] = {.lex_state = 1}, + [133] = {.lex_state = 1}, + [134] = {.lex_state = 1}, + [135] = {.lex_state = 1}, + [136] = {.lex_state = 1}, + [137] = {.lex_state = 1}, + [138] = {.lex_state = 1}, + [139] = {.lex_state = 1}, + [140] = {.lex_state = 1}, + [141] = {.lex_state = 1}, + [142] = {.lex_state = 1}, + [143] = {.lex_state = 1}, + [144] = {.lex_state = 1}, + [145] = {.lex_state = 1}, + [146] = {.lex_state = 1}, + [147] = {.lex_state = 1}, + [148] = {.lex_state = 1}, + [149] = {.lex_state = 1}, + [150] = {.lex_state = 1}, + [151] = {.lex_state = 1}, + [152] = {.lex_state = 1}, + [153] = {.lex_state = 1}, + [154] = {.lex_state = 1}, + [155] = {.lex_state = 1}, + [156] = {.lex_state = 1}, + [157] = {.lex_state = 1}, + [158] = {.lex_state = 1}, + [159] = {.lex_state = 1}, + [160] = {.lex_state = 1}, + [161] = {.lex_state = 1}, + [162] = {.lex_state = 1}, + [163] = {.lex_state = 6}, + [164] = {.lex_state = 1}, + [165] = {.lex_state = 1}, + [166] = {.lex_state = 1}, + [167] = {.lex_state = 1}, + [168] = {.lex_state = 1}, + [169] = {.lex_state = 1}, + [170] = {.lex_state = 6}, + [171] = {.lex_state = 6}, + [172] = {.lex_state = 1}, + [173] = {.lex_state = 1}, + [174] = {.lex_state = 1}, + [175] = {.lex_state = 1}, + [176] = {.lex_state = 1}, + [177] = {.lex_state = 1}, + [178] = {.lex_state = 6}, + [179] = {.lex_state = 1}, + [180] = {.lex_state = 1}, + [181] = {.lex_state = 1}, + [182] = {.lex_state = 1}, + [183] = {.lex_state = 1}, + [184] = {.lex_state = 1}, + [185] = {.lex_state = 1}, + [186] = {.lex_state = 6}, + [187] = {.lex_state = 1}, + [188] = {.lex_state = 1}, + [189] = {.lex_state = 1}, + [190] = {.lex_state = 1}, + [191] = {.lex_state = 1}, + [192] = {.lex_state = 1}, + [193] = {.lex_state = 1}, + [194] = {.lex_state = 1}, + [195] = {.lex_state = 1}, + [196] = {.lex_state = 1}, + [197] = {.lex_state = 1}, + [198] = {.lex_state = 1}, + [199] = {.lex_state = 1}, + [200] = {.lex_state = 1}, + [201] = {.lex_state = 1}, + [202] = {.lex_state = 1}, + [203] = {.lex_state = 1}, + [204] = {.lex_state = 1}, + [205] = {.lex_state = 1}, + [206] = {.lex_state = 1}, + [207] = {.lex_state = 1}, + [208] = {.lex_state = 1}, + [209] = {.lex_state = 1}, + [210] = {.lex_state = 1}, + [211] = {.lex_state = 1}, + [212] = {.lex_state = 1}, + [213] = {.lex_state = 1}, + [214] = {.lex_state = 1}, + [215] = {.lex_state = 1}, + [216] = {.lex_state = 6}, + [217] = {.lex_state = 6}, + [218] = {.lex_state = 6}, + [219] = {.lex_state = 6}, + [220] = {.lex_state = 1}, + [221] = {.lex_state = 1}, + [222] = {.lex_state = 6}, + [223] = {.lex_state = 6}, + [224] = {.lex_state = 1}, + [225] = {.lex_state = 1}, + [226] = {.lex_state = 1}, + [227] = {.lex_state = 1}, + [228] = {.lex_state = 1}, + [229] = {.lex_state = 1}, + [230] = {.lex_state = 0}, + [231] = {.lex_state = 1}, + [232] = {.lex_state = 1}, + [233] = {.lex_state = 1}, + [234] = {.lex_state = 1}, + [235] = {.lex_state = 0}, + [236] = {.lex_state = 0}, + [237] = {.lex_state = 0}, + [238] = {.lex_state = 0}, + [239] = {.lex_state = 0}, + [240] = {.lex_state = 0}, + [241] = {.lex_state = 0}, + [242] = {.lex_state = 0}, + [243] = {.lex_state = 0}, + [244] = {.lex_state = 0}, + [245] = {.lex_state = 0}, + [246] = {.lex_state = 0}, + [247] = {.lex_state = 0}, + [248] = {.lex_state = 0}, + [249] = {.lex_state = 0}, + [250] = {.lex_state = 0}, + [251] = {.lex_state = 0}, + [252] = {.lex_state = 0}, + [253] = {.lex_state = 0}, + [254] = {.lex_state = 0}, + [255] = {.lex_state = 0}, + [256] = {.lex_state = 0}, + [257] = {.lex_state = 0}, + [258] = {.lex_state = 0}, + [259] = {.lex_state = 0}, + [260] = {.lex_state = 0}, + [261] = {.lex_state = 0}, + [262] = {.lex_state = 0}, + [263] = {.lex_state = 0}, + [264] = {.lex_state = 0}, + [265] = {.lex_state = 0}, + [266] = {.lex_state = 0}, + [267] = {.lex_state = 0}, + [268] = {.lex_state = 0}, + [269] = {.lex_state = 0}, + [270] = {.lex_state = 0}, + [271] = {.lex_state = 0}, + [272] = {.lex_state = 0}, + [273] = {.lex_state = 0}, + [274] = {.lex_state = 0}, + [275] = {.lex_state = 0}, + [276] = {.lex_state = 0}, + [277] = {.lex_state = 0}, + [278] = {.lex_state = 0}, + [279] = {.lex_state = 0}, + [280] = {.lex_state = 0}, + [281] = {.lex_state = 0}, + [282] = {.lex_state = 0}, + [283] = {.lex_state = 0}, + [284] = {.lex_state = 0}, + [285] = {.lex_state = 0}, + [286] = {.lex_state = 0}, + [287] = {.lex_state = 0}, + [288] = {.lex_state = 0}, + [289] = {.lex_state = 0}, + [290] = {.lex_state = 0}, + [291] = {.lex_state = 0}, + [292] = {.lex_state = 0}, + [293] = {.lex_state = 0}, + [294] = {.lex_state = 0}, + [295] = {.lex_state = 0}, + [296] = {.lex_state = 0}, + [297] = {.lex_state = 0}, + [298] = {.lex_state = 0}, + [299] = {.lex_state = 0}, + [300] = {.lex_state = 0}, + [301] = {.lex_state = 0}, + [302] = {.lex_state = 0}, + [303] = {.lex_state = 0}, + [304] = {.lex_state = 0}, + [305] = {.lex_state = 0}, + [306] = {.lex_state = 0}, + [307] = {.lex_state = 0}, + [308] = {.lex_state = 0}, + [309] = {.lex_state = 0}, + [310] = {.lex_state = 0}, + [311] = {.lex_state = 0}, + [312] = {.lex_state = 0}, + [313] = {.lex_state = 0}, + [314] = {.lex_state = 0}, + [315] = {.lex_state = 0}, + [316] = {.lex_state = 0}, + [317] = {.lex_state = 0}, + [318] = {.lex_state = 0}, + [319] = {.lex_state = 0}, + [320] = {.lex_state = 0}, + [321] = {.lex_state = 0}, + [322] = {.lex_state = 1}, + [323] = {.lex_state = 1}, + [324] = {.lex_state = 1}, + [325] = {.lex_state = 1}, + [326] = {.lex_state = 1}, + [327] = {.lex_state = 1}, + [328] = {.lex_state = 1}, + [329] = {.lex_state = 1}, + [330] = {.lex_state = 1}, + [331] = {.lex_state = 1}, + [332] = {.lex_state = 1}, + [333] = {.lex_state = 1}, + [334] = {.lex_state = 0}, + [335] = {.lex_state = 0}, + [336] = {.lex_state = 1}, + [337] = {.lex_state = 1}, + [338] = {.lex_state = 1}, + [339] = {.lex_state = 1}, + [340] = {.lex_state = 1}, + [341] = {.lex_state = 1}, + [342] = {.lex_state = 1}, + [343] = {.lex_state = 1}, + [344] = {.lex_state = 1}, + [345] = {.lex_state = 1}, + [346] = {.lex_state = 1}, + [347] = {.lex_state = 1}, + [348] = {.lex_state = 1}, + [349] = {.lex_state = 1}, + [350] = {.lex_state = 0}, + [351] = {.lex_state = 1}, + [352] = {.lex_state = 0}, + [353] = {.lex_state = 1}, + [354] = {.lex_state = 1}, + [355] = {.lex_state = 1}, + [356] = {.lex_state = 1}, + [357] = {.lex_state = 1}, + [358] = {.lex_state = 1}, + [359] = {.lex_state = 0}, + [360] = {.lex_state = 1}, + [361] = {.lex_state = 1}, + [362] = {.lex_state = 1}, + [363] = {.lex_state = 1}, + [364] = {.lex_state = 1}, + [365] = {.lex_state = 1}, + [366] = {.lex_state = 1}, + [367] = {.lex_state = 1}, + [368] = {.lex_state = 0}, + [369] = {.lex_state = 1}, + [370] = {.lex_state = 1}, + [371] = {.lex_state = 1}, + [372] = {.lex_state = 0}, + [373] = {.lex_state = 1}, + [374] = {.lex_state = 1}, + [375] = {.lex_state = 1}, + [376] = {.lex_state = 1}, + [377] = {.lex_state = 1}, + [378] = {.lex_state = 1}, + [379] = {.lex_state = 1}, + [380] = {.lex_state = 1}, + [381] = {.lex_state = 1}, + [382] = {.lex_state = 1}, + [383] = {.lex_state = 1}, + [384] = {.lex_state = 1}, + [385] = {.lex_state = 1}, + [386] = {.lex_state = 1}, + [387] = {.lex_state = 1}, + [388] = {.lex_state = 1}, + [389] = {.lex_state = 1}, + [390] = {.lex_state = 1}, + [391] = {.lex_state = 1}, + [392] = {.lex_state = 1}, + [393] = {.lex_state = 1}, + [394] = {.lex_state = 1}, + [395] = {.lex_state = 1}, + [396] = {.lex_state = 1}, + [397] = {.lex_state = 1}, + [398] = {.lex_state = 1}, + [399] = {.lex_state = 1}, + [400] = {.lex_state = 1}, + [401] = {.lex_state = 1}, + [402] = {.lex_state = 1}, + [403] = {.lex_state = 1}, + [404] = {.lex_state = 1}, + [405] = {.lex_state = 1}, + [406] = {.lex_state = 1}, + [407] = {.lex_state = 1}, + [408] = {.lex_state = 1}, + [409] = {.lex_state = 1}, + [410] = {.lex_state = 1}, + [411] = {.lex_state = 1}, + [412] = {.lex_state = 1}, + [413] = {.lex_state = 1}, + [414] = {.lex_state = 1}, + [415] = {.lex_state = 1}, + [416] = {.lex_state = 1}, + [417] = {.lex_state = 1}, + [418] = {.lex_state = 1}, + [419] = {.lex_state = 1}, + [420] = {.lex_state = 1}, + [421] = {.lex_state = 1}, + [422] = {.lex_state = 1}, + [423] = {.lex_state = 1}, + [424] = {.lex_state = 1}, + [425] = {.lex_state = 0}, + [426] = {.lex_state = 1}, + [427] = {.lex_state = 1}, + [428] = {.lex_state = 1}, + [429] = {.lex_state = 1}, + [430] = {.lex_state = 1}, + [431] = {.lex_state = 1}, + [432] = {.lex_state = 1}, + [433] = {.lex_state = 1}, + [434] = {.lex_state = 1}, + [435] = {.lex_state = 0}, + [436] = {.lex_state = 0}, + [437] = {.lex_state = 0}, + [438] = {.lex_state = 0}, + [439] = {.lex_state = 0}, + [440] = {.lex_state = 0}, + [441] = {.lex_state = 0}, + [442] = {.lex_state = 0}, + [443] = {.lex_state = 0}, + [444] = {.lex_state = 0}, + [445] = {.lex_state = 0}, + [446] = {.lex_state = 0}, + [447] = {.lex_state = 0}, + [448] = {.lex_state = 0}, + [449] = {.lex_state = 0}, + [450] = {.lex_state = 0}, + [451] = {.lex_state = 0}, + [452] = {.lex_state = 0}, + [453] = {.lex_state = 0}, + [454] = {.lex_state = 1}, + [455] = {.lex_state = 0}, + [456] = {.lex_state = 3}, + [457] = {.lex_state = 3}, + [458] = {.lex_state = 7}, + [459] = {.lex_state = 7}, + [460] = {.lex_state = 2}, + [461] = {.lex_state = 7}, + [462] = {.lex_state = 7}, + [463] = {.lex_state = 2}, + [464] = {.lex_state = 7}, + [465] = {.lex_state = 7}, + [466] = {.lex_state = 7}, + [467] = {.lex_state = 7}, + [468] = {.lex_state = 2}, + [469] = {.lex_state = 7}, + [470] = {.lex_state = 2}, + [471] = {.lex_state = 2}, + [472] = {.lex_state = 7}, + [473] = {.lex_state = 0}, + [474] = {.lex_state = 2}, + [475] = {.lex_state = 6}, + [476] = {.lex_state = 2}, + [477] = {.lex_state = 0}, + [478] = {.lex_state = 0}, + [479] = {.lex_state = 2}, + [480] = {.lex_state = 2}, + [481] = {.lex_state = 6}, + [482] = {.lex_state = 6}, + [483] = {.lex_state = 6}, + [484] = {.lex_state = 0}, + [485] = {.lex_state = 1}, + [486] = {.lex_state = 1}, + [487] = {.lex_state = 1}, + [488] = {.lex_state = 1}, + [489] = {.lex_state = 1}, + [490] = {.lex_state = 1}, + [491] = {.lex_state = 1}, + [492] = {.lex_state = 1}, + [493] = {.lex_state = 1}, + [494] = {.lex_state = 1}, + [495] = {.lex_state = 1}, + [496] = {.lex_state = 1}, + [497] = {.lex_state = 1}, + [498] = {.lex_state = 1}, + [499] = {.lex_state = 1}, + [500] = {.lex_state = 1}, + [501] = {.lex_state = 1}, + [502] = {.lex_state = 1}, + [503] = {.lex_state = 1}, + [504] = {.lex_state = 1}, + [505] = {.lex_state = 1}, + [506] = {.lex_state = 1}, + [507] = {.lex_state = 1}, + [508] = {.lex_state = 1}, + [509] = {.lex_state = 1}, + [510] = {.lex_state = 1}, + [511] = {.lex_state = 1}, + [512] = {.lex_state = 1}, + [513] = {.lex_state = 2}, + [514] = {.lex_state = 2}, + [515] = {.lex_state = 2}, + [516] = {.lex_state = 1}, + [517] = {.lex_state = 2}, + [518] = {.lex_state = 2}, + [519] = {.lex_state = 1}, + [520] = {.lex_state = 1}, + [521] = {.lex_state = 1}, + [522] = {.lex_state = 5}, + [523] = {.lex_state = 5}, + [524] = {.lex_state = 5}, + [525] = {.lex_state = 0}, + [526] = {.lex_state = 5}, + [527] = {.lex_state = 5}, + [528] = {.lex_state = 1}, + [529] = {.lex_state = 1}, + [530] = {.lex_state = 1}, + [531] = {.lex_state = 1}, + [532] = {.lex_state = 1}, + [533] = {.lex_state = 1}, + [534] = {.lex_state = 1}, + [535] = {.lex_state = 1}, + [536] = {.lex_state = 1}, + [537] = {.lex_state = 1}, + [538] = {.lex_state = 1}, + [539] = {.lex_state = 0}, + [540] = {.lex_state = 1}, + [541] = {.lex_state = 5}, + [542] = {.lex_state = 1}, + [543] = {.lex_state = 1}, + [544] = {.lex_state = 1}, + [545] = {.lex_state = 0}, + [546] = {.lex_state = 5}, + [547] = {.lex_state = 8}, + [548] = {.lex_state = 5}, + [549] = {.lex_state = 8}, + [550] = {.lex_state = 5}, + [551] = {.lex_state = 5}, + [552] = {.lex_state = 5}, + [553] = {.lex_state = 8}, + [554] = {.lex_state = 8}, + [555] = {.lex_state = 8}, + [556] = {.lex_state = 0}, + [557] = {.lex_state = 8}, + [558] = {.lex_state = 8}, + [559] = {.lex_state = 0}, + [560] = {.lex_state = 0}, + [561] = {.lex_state = 8}, + [562] = {.lex_state = 8}, + [563] = {.lex_state = 8}, + [564] = {.lex_state = 8}, + [565] = {.lex_state = 2}, + [566] = {.lex_state = 2}, + [567] = {.lex_state = 0}, + [568] = {.lex_state = 0}, + [569] = {.lex_state = 0}, + [570] = {.lex_state = 0}, + [571] = {.lex_state = 0}, + [572] = {.lex_state = 0}, + [573] = {.lex_state = 0}, + [574] = {.lex_state = 0}, + [575] = {.lex_state = 5}, + [576] = {.lex_state = 8}, + [577] = {.lex_state = 5}, + [578] = {.lex_state = 5}, + [579] = {.lex_state = 0}, + [580] = {.lex_state = 5}, + [581] = {.lex_state = 0}, + [582] = {.lex_state = 0}, + [583] = {.lex_state = 0}, + [584] = {.lex_state = 0}, + [585] = {.lex_state = 5}, + [586] = {.lex_state = 0}, + [587] = {.lex_state = 5}, + [588] = {.lex_state = 0}, + [589] = {.lex_state = 0}, + [590] = {.lex_state = 5}, + [591] = {.lex_state = 5}, + [592] = {.lex_state = 2}, + [593] = {.lex_state = 8}, + [594] = {.lex_state = 5}, + [595] = {.lex_state = 0}, + [596] = {.lex_state = 5}, + [597] = {.lex_state = 0}, + [598] = {.lex_state = 0}, + [599] = {.lex_state = 0}, + [600] = {.lex_state = 0}, + [601] = {.lex_state = 0}, + [602] = {.lex_state = 0}, + [603] = {.lex_state = 0}, + [604] = {.lex_state = 0}, + [605] = {.lex_state = 0}, + [606] = {.lex_state = 0}, + [607] = {.lex_state = 0}, + [608] = {.lex_state = 0}, + [609] = {.lex_state = 0}, + [610] = {.lex_state = 0}, + [611] = {.lex_state = 0}, + [612] = {.lex_state = 0}, + [613] = {.lex_state = 0}, + [614] = {.lex_state = 0}, + [615] = {.lex_state = 0}, + [616] = {.lex_state = 0}, + [617] = {.lex_state = 0}, + [618] = {.lex_state = 0}, + [619] = {.lex_state = 0}, + [620] = {.lex_state = 0}, + [621] = {.lex_state = 0}, + [622] = {.lex_state = 0}, + [623] = {.lex_state = 0}, + [624] = {.lex_state = 0}, + [625] = {.lex_state = 0}, + [626] = {.lex_state = 8}, + [627] = {.lex_state = 0}, + [628] = {.lex_state = 0}, + [629] = {.lex_state = 0}, + [630] = {.lex_state = 0}, + [631] = {.lex_state = 8}, + [632] = {.lex_state = 0}, + [633] = {.lex_state = 8}, + [634] = {.lex_state = 0}, + [635] = {.lex_state = 0}, + [636] = {.lex_state = 8}, + [637] = {.lex_state = 0}, + [638] = {.lex_state = 8}, + [639] = {.lex_state = 0}, + [640] = {.lex_state = 0}, + [641] = {.lex_state = 8}, + [642] = {.lex_state = 0}, + [643] = {.lex_state = 0}, + [644] = {.lex_state = 8}, + [645] = {.lex_state = 0}, + [646] = {.lex_state = 0}, + [647] = {.lex_state = 0}, + [648] = {.lex_state = 0}, + [649] = {.lex_state = 0}, + [650] = {.lex_state = 0}, + [651] = {.lex_state = 0}, + [652] = {.lex_state = 0}, + [653] = {.lex_state = 0}, + [654] = {.lex_state = 0}, + [655] = {.lex_state = 0}, + [656] = {.lex_state = 0}, + [657] = {.lex_state = 0}, + [658] = {.lex_state = 0}, + [659] = {.lex_state = 0}, + [660] = {.lex_state = 0}, + [661] = {.lex_state = 0}, + [662] = {.lex_state = 0}, + [663] = {.lex_state = 0}, + [664] = {.lex_state = 0}, + [665] = {.lex_state = 0}, + [666] = {.lex_state = 0}, + [667] = {.lex_state = 0}, + [668] = {.lex_state = 0}, + [669] = {.lex_state = 0}, + [670] = {.lex_state = 0}, + [671] = {.lex_state = 0}, + [672] = {.lex_state = 0}, + [673] = {.lex_state = 0}, + [674] = {.lex_state = 0}, + [675] = {.lex_state = 0}, + [676] = {.lex_state = 0}, + [677] = {.lex_state = 0}, + [678] = {.lex_state = 0}, + [679] = {.lex_state = 0}, + [680] = {.lex_state = 5}, + [681] = {.lex_state = 5}, + [682] = {.lex_state = 1}, + [683] = {.lex_state = 0}, + [684] = {.lex_state = 1}, + [685] = {.lex_state = 8}, + [686] = {.lex_state = 8}, + [687] = {.lex_state = 8}, + [688] = {.lex_state = 8}, + [689] = {.lex_state = 8}, + [690] = {.lex_state = 8}, + [691] = {.lex_state = 8}, + [692] = {.lex_state = 8}, + [693] = {.lex_state = 8}, + [694] = {.lex_state = 8}, + [695] = {.lex_state = 1}, + [696] = {.lex_state = 1}, + [697] = {.lex_state = 8}, + [698] = {.lex_state = 8}, + [699] = {.lex_state = 8}, + [700] = {.lex_state = 8}, + [701] = {.lex_state = 8}, + [702] = {.lex_state = 8}, + [703] = {.lex_state = 8}, + [704] = {.lex_state = 8}, + [705] = {.lex_state = 5}, + [706] = {.lex_state = 8}, + [707] = {.lex_state = 8}, + [708] = {.lex_state = 8}, + [709] = {.lex_state = 8}, + [710] = {.lex_state = 8}, + [711] = {.lex_state = 8}, + [712] = {.lex_state = 8}, + [713] = {.lex_state = 8}, + [714] = {.lex_state = 1}, + [715] = {.lex_state = 8}, + [716] = {.lex_state = 8}, + [717] = {.lex_state = 8}, + [718] = {.lex_state = 8}, + [719] = {.lex_state = 8}, + [720] = {.lex_state = 8}, + [721] = {.lex_state = 8}, + [722] = {.lex_state = 0}, + [723] = {.lex_state = 8}, + [724] = {.lex_state = 8}, + [725] = {.lex_state = 8}, + [726] = {.lex_state = 1}, + [727] = {.lex_state = 0}, + [728] = {.lex_state = 1}, + [729] = {.lex_state = 1}, + [730] = {.lex_state = 1}, + [731] = {.lex_state = 0}, + [732] = {.lex_state = 5}, + [733] = {.lex_state = 5}, + [734] = {.lex_state = 0}, + [735] = {.lex_state = 0}, + [736] = {.lex_state = 5}, + [737] = {.lex_state = 1}, + [738] = {.lex_state = 1}, + [739] = {.lex_state = 1}, + [740] = {.lex_state = 0}, + [741] = {.lex_state = 0}, + [742] = {.lex_state = 0}, + [743] = {.lex_state = 0}, + [744] = {.lex_state = 0}, + [745] = {.lex_state = 0}, + [746] = {.lex_state = 1}, + [747] = {.lex_state = 1}, + [748] = {.lex_state = 1}, + [749] = {.lex_state = 0}, + [750] = {.lex_state = 0}, + [751] = {.lex_state = 0}, + [752] = {.lex_state = 0}, + [753] = {.lex_state = 0}, + [754] = {.lex_state = 0}, + [755] = {.lex_state = 0}, + [756] = {.lex_state = 0}, + [757] = {.lex_state = 0}, + [758] = {.lex_state = 0}, + [759] = {.lex_state = 1}, + [760] = {.lex_state = 1}, + [761] = {.lex_state = 1}, + [762] = {.lex_state = 1}, + [763] = {.lex_state = 1}, + [764] = {.lex_state = 1}, + [765] = {.lex_state = 1}, + [766] = {.lex_state = 1}, + [767] = {.lex_state = 1}, + [768] = {.lex_state = 1}, + [769] = {.lex_state = 1}, + [770] = {.lex_state = 0}, + [771] = {.lex_state = 1}, + [772] = {.lex_state = 1}, + [773] = {.lex_state = 1}, + [774] = {.lex_state = 3}, + [775] = {.lex_state = 3}, + [776] = {.lex_state = 6}, + [777] = {.lex_state = 1}, + [778] = {.lex_state = 6}, + [779] = {.lex_state = 1}, + [780] = {.lex_state = 0}, + [781] = {.lex_state = 1}, + [782] = {.lex_state = 1}, + [783] = {.lex_state = 1}, + [784] = {.lex_state = 1}, + [785] = {.lex_state = 1}, + [786] = {.lex_state = 1}, + [787] = {.lex_state = 1}, + [788] = {.lex_state = 6}, + [789] = {.lex_state = 1}, + [790] = {.lex_state = 0}, + [791] = {.lex_state = 1}, + [792] = {.lex_state = 3}, + [793] = {.lex_state = 1}, + [794] = {.lex_state = 0}, + [795] = {.lex_state = 1}, + [796] = {.lex_state = 1}, + [797] = {.lex_state = 0}, + [798] = {.lex_state = 0}, + [799] = {.lex_state = 1}, + [800] = {.lex_state = 1}, + [801] = {.lex_state = 1}, + [802] = {.lex_state = 1}, + [803] = {.lex_state = 1}, + [804] = {.lex_state = 6}, + [805] = {.lex_state = 1}, + [806] = {.lex_state = 0}, + [807] = {.lex_state = 1}, + [808] = {.lex_state = 0}, + [809] = {.lex_state = 1}, + [810] = {.lex_state = 1}, + [811] = {.lex_state = 1}, + [812] = {.lex_state = 1}, + [813] = {.lex_state = 4}, + [814] = {.lex_state = 1}, + [815] = {.lex_state = 1}, + [816] = {.lex_state = 1}, + [817] = {.lex_state = 1}, + [818] = {.lex_state = 1}, + [819] = {.lex_state = 1}, + [820] = {.lex_state = 1}, + [821] = {.lex_state = 0}, + [822] = {.lex_state = 1}, + [823] = {.lex_state = 1}, + [824] = {.lex_state = 0}, + [825] = {.lex_state = 1}, + [826] = {.lex_state = 1}, + [827] = {.lex_state = 1}, + [828] = {.lex_state = 1}, + [829] = {.lex_state = 1}, + [830] = {.lex_state = 1}, + [831] = {.lex_state = 1}, + [832] = {.lex_state = 1}, + [833] = {.lex_state = 1}, + [834] = {.lex_state = 1}, + [835] = {.lex_state = 1}, + [836] = {.lex_state = 1}, + [837] = {.lex_state = 0}, + [838] = {.lex_state = 1}, + [839] = {.lex_state = 1}, + [840] = {.lex_state = 1}, + [841] = {.lex_state = 1}, + [842] = {.lex_state = 1}, + [843] = {.lex_state = 1}, + [844] = {.lex_state = 1}, + [845] = {.lex_state = 1}, + [846] = {.lex_state = 1}, + [847] = {.lex_state = 0}, + [848] = {.lex_state = 1}, + [849] = {.lex_state = 1}, + [850] = {.lex_state = 1}, + [851] = {.lex_state = 4}, + [852] = {.lex_state = 4}, + [853] = {.lex_state = 0}, + [854] = {.lex_state = 0}, + [855] = {.lex_state = 0}, + [856] = {.lex_state = 0}, + [857] = {.lex_state = 0}, + [858] = {.lex_state = 0}, + [859] = {.lex_state = 1}, + [860] = {.lex_state = 4}, + [861] = {.lex_state = 1}, + [862] = {.lex_state = 0}, + [863] = {.lex_state = 1}, + [864] = {.lex_state = 1}, + [865] = {.lex_state = 4}, + [866] = {.lex_state = 1}, + [867] = {.lex_state = 1}, + [868] = {.lex_state = 1}, + [869] = {.lex_state = 1}, + [870] = {.lex_state = 1}, + [871] = {.lex_state = 0}, + [872] = {.lex_state = 0}, + [873] = {.lex_state = 1}, + [874] = {.lex_state = 1}, + [875] = {.lex_state = 3}, + [876] = {.lex_state = 0}, + [877] = {.lex_state = 1}, + [878] = {.lex_state = 0}, + [879] = {.lex_state = 1}, + [880] = {.lex_state = 1}, + [881] = {.lex_state = 1}, + [882] = {.lex_state = 0}, + [883] = {.lex_state = 1}, + [884] = {.lex_state = 0}, + [885] = {.lex_state = 1}, + [886] = {.lex_state = 0}, + [887] = {.lex_state = 1}, + [888] = {.lex_state = 1}, + [889] = {.lex_state = 1}, + [890] = {.lex_state = 1}, + [891] = {.lex_state = 1}, + [892] = {.lex_state = 1}, + [893] = {.lex_state = 1}, + [894] = {.lex_state = 1}, + [895] = {.lex_state = 5}, + [896] = {.lex_state = 1}, + [897] = {.lex_state = 0}, + [898] = {.lex_state = 0}, + [899] = {.lex_state = 1}, + [900] = {.lex_state = 0}, + [901] = {.lex_state = 0}, + [902] = {.lex_state = 1}, + [903] = {.lex_state = 0}, + [904] = {.lex_state = 1}, + [905] = {.lex_state = 0}, + [906] = {.lex_state = 8}, + [907] = {.lex_state = 1}, + [908] = {.lex_state = 8}, + [909] = {.lex_state = 0}, + [910] = {.lex_state = 1}, + [911] = {.lex_state = 1}, + [912] = {.lex_state = 0}, + [913] = {.lex_state = 4}, + [914] = {.lex_state = 0}, + [915] = {.lex_state = 1}, + [916] = {.lex_state = 1}, + [917] = {.lex_state = 0}, + [918] = {.lex_state = 0}, + [919] = {.lex_state = 0}, + [920] = {.lex_state = 2}, + [921] = {.lex_state = 5}, + [922] = {.lex_state = 1}, + [923] = {.lex_state = 4}, + [924] = {.lex_state = 1}, + [925] = {.lex_state = 8}, + [926] = {.lex_state = 1}, + [927] = {.lex_state = 0}, + [928] = {.lex_state = 0}, + [929] = {.lex_state = 0}, + [930] = {.lex_state = 1}, + [931] = {.lex_state = 0}, + [932] = {.lex_state = 1}, + [933] = {.lex_state = 1}, + [934] = {.lex_state = 8}, + [935] = {.lex_state = 1}, + [936] = {.lex_state = 5}, + [937] = {.lex_state = 1}, + [938] = {.lex_state = 1}, + [939] = {.lex_state = 5}, + [940] = {.lex_state = 0}, + [941] = {.lex_state = 1}, + [942] = {.lex_state = 8}, + [943] = {.lex_state = 0}, + [944] = {.lex_state = 0}, + [945] = {.lex_state = 1}, + [946] = {.lex_state = 8}, + [947] = {.lex_state = 1}, + [948] = {.lex_state = 1}, + [949] = {.lex_state = 1}, + [950] = {.lex_state = 1}, + [951] = {.lex_state = 1}, + [952] = {.lex_state = 1}, + [953] = {.lex_state = 0}, + [954] = {.lex_state = 1}, + [955] = {.lex_state = 1}, + [956] = {.lex_state = 1}, + [957] = {.lex_state = 1}, + [958] = {.lex_state = 1}, + [959] = {.lex_state = 1}, + [960] = {.lex_state = 0}, + [961] = {.lex_state = 1}, + [962] = {.lex_state = 0}, + [963] = {.lex_state = 1}, + [964] = {.lex_state = 1}, + [965] = {.lex_state = 0}, + [966] = {.lex_state = 8}, + [967] = {.lex_state = 5}, + [968] = {.lex_state = 1}, + [969] = {.lex_state = 5}, + [970] = {.lex_state = 5}, + [971] = {.lex_state = 1}, + [972] = {.lex_state = 5}, + [973] = {.lex_state = 0}, + [974] = {.lex_state = 2}, + [975] = {.lex_state = 1}, + [976] = {.lex_state = 1}, + [977] = {.lex_state = 1}, + [978] = {.lex_state = 1}, + [979] = {.lex_state = 1}, + [980] = {.lex_state = 1}, + [981] = {.lex_state = 0}, + [982] = {.lex_state = 5}, + [983] = {.lex_state = 0}, + [984] = {.lex_state = 1}, + [985] = {.lex_state = 5}, + [986] = {.lex_state = 1}, + [987] = {.lex_state = 5}, + [988] = {.lex_state = 1}, + [989] = {.lex_state = 1}, + [990] = {.lex_state = 1}, + [991] = {.lex_state = 1}, + [992] = {.lex_state = 1}, + [993] = {.lex_state = 1}, + [994] = {.lex_state = 5}, + [995] = {.lex_state = 0}, + [996] = {.lex_state = 1}, + [997] = {.lex_state = 1}, + [998] = {.lex_state = 1}, + [999] = {.lex_state = 1}, + [1000] = {.lex_state = 1}, + [1001] = {.lex_state = 1}, + [1002] = {.lex_state = 1}, + [1003] = {.lex_state = 1}, + [1004] = {.lex_state = 0}, + [1005] = {.lex_state = 0}, + [1006] = {.lex_state = 5}, + [1007] = {.lex_state = 5}, + [1008] = {.lex_state = 1}, + [1009] = {.lex_state = 1}, + [1010] = {.lex_state = 0}, + [1011] = {.lex_state = 1}, + [1012] = {.lex_state = 1}, + [1013] = {.lex_state = 0}, + [1014] = {.lex_state = 1}, + [1015] = {.lex_state = 1}, + [1016] = {.lex_state = 0}, + [1017] = {.lex_state = 5}, + [1018] = {.lex_state = 1}, + [1019] = {.lex_state = 1}, + [1020] = {.lex_state = 2}, + [1021] = {.lex_state = 5}, + [1022] = {.lex_state = 1}, + [1023] = {.lex_state = 1}, + [1024] = {.lex_state = 0}, + [1025] = {.lex_state = 2}, + [1026] = {.lex_state = 1}, + [1027] = {.lex_state = 1}, + [1028] = {.lex_state = 1}, + [1029] = {.lex_state = 1}, + [1030] = {.lex_state = 1}, + [1031] = {.lex_state = 5}, + [1032] = {.lex_state = 1}, + [1033] = {.lex_state = 2}, + [1034] = {.lex_state = 1}, + [1035] = {.lex_state = 1}, + [1036] = {.lex_state = 0}, + [1037] = {.lex_state = 1}, + [1038] = {.lex_state = 1}, + [1039] = {.lex_state = 0}, + [1040] = {.lex_state = 1}, + [1041] = {.lex_state = 1}, + [1042] = {.lex_state = 5}, + [1043] = {.lex_state = 5}, + [1044] = {.lex_state = 1}, + [1045] = {.lex_state = 0}, + [1046] = {.lex_state = 1}, + [1047] = {.lex_state = 1}, + [1048] = {.lex_state = 1}, + [1049] = {.lex_state = 1}, + [1050] = {.lex_state = 0}, + [1051] = {.lex_state = 0}, + [1052] = {.lex_state = 1}, + [1053] = {.lex_state = 0}, + [1054] = {.lex_state = 0}, + [1055] = {.lex_state = 1}, + [1056] = {.lex_state = 1}, + [1057] = {.lex_state = 1}, + [1058] = {.lex_state = 0}, + [1059] = {.lex_state = 1}, + [1060] = {.lex_state = 1}, + [1061] = {.lex_state = 1}, + [1062] = {.lex_state = 1}, + [1063] = {.lex_state = 1}, + [1064] = {.lex_state = 1}, + [1065] = {.lex_state = 5}, + [1066] = {.lex_state = 1}, + [1067] = {.lex_state = 1}, + [1068] = {.lex_state = 0}, + [1069] = {.lex_state = 1}, + [1070] = {.lex_state = 1}, + [1071] = {.lex_state = 1}, + [1072] = {.lex_state = 1}, + [1073] = {.lex_state = 0}, + [1074] = {.lex_state = 1}, + [1075] = {.lex_state = 1}, + [1076] = {.lex_state = 1}, + [1077] = {.lex_state = 0}, + [1078] = {.lex_state = 5}, + [1079] = {.lex_state = 1}, + [1080] = {.lex_state = 1}, + [1081] = {.lex_state = 1}, + [1082] = {.lex_state = 1}, + [1083] = {.lex_state = 1}, + [1084] = {.lex_state = 1}, + [1085] = {.lex_state = 0}, + [1086] = {.lex_state = 1}, + [1087] = {.lex_state = 1}, + [1088] = {.lex_state = 5}, + [1089] = {.lex_state = 0}, + [1090] = {.lex_state = 5}, + [1091] = {.lex_state = 1}, + [1092] = {.lex_state = 5}, + [1093] = {.lex_state = 1}, + [1094] = {.lex_state = 1}, + [1095] = {.lex_state = 1}, + [1096] = {.lex_state = 1}, + [1097] = {.lex_state = 1}, + [1098] = {.lex_state = 1}, + [1099] = {.lex_state = 1}, + [1100] = {.lex_state = 0}, + [1101] = {.lex_state = 5}, + [1102] = {.lex_state = 1}, + [1103] = {.lex_state = 1}, + [1104] = {.lex_state = 1}, + [1105] = {.lex_state = 1}, + [1106] = {.lex_state = 1}, + [1107] = {.lex_state = 1}, + [1108] = {.lex_state = 1}, + [1109] = {.lex_state = 1}, + [1110] = {.lex_state = 1}, + [1111] = {.lex_state = 5}, + [1112] = {.lex_state = 0}, + [1113] = {.lex_state = 1}, + [1114] = {.lex_state = 1}, + [1115] = {.lex_state = 1}, + [1116] = {.lex_state = 1}, + [1117] = {.lex_state = 0}, + [1118] = {.lex_state = 1}, + [1119] = {.lex_state = 1}, + [1120] = {.lex_state = 1}, + [1121] = {.lex_state = 1}, + [1122] = {.lex_state = 1}, + [1123] = {.lex_state = 1}, + [1124] = {.lex_state = 1}, + [1125] = {.lex_state = 0}, + [1126] = {.lex_state = 5}, + [1127] = {.lex_state = 1}, + [1128] = {.lex_state = 1}, + [1129] = {.lex_state = 1}, + [1130] = {.lex_state = 1}, + [1131] = {.lex_state = 1}, + [1132] = {.lex_state = 1}, + [1133] = {.lex_state = 1}, + [1134] = {.lex_state = 1}, + [1135] = {.lex_state = 1}, + [1136] = {.lex_state = 0}, + [1137] = {.lex_state = 1}, + [1138] = {.lex_state = 1}, + [1139] = {.lex_state = 1}, + [1140] = {.lex_state = 1}, + [1141] = {.lex_state = 1}, + [1142] = {.lex_state = 1}, + [1143] = {.lex_state = 1}, + [1144] = {.lex_state = 1}, + [1145] = {.lex_state = 1}, + [1146] = {.lex_state = 1}, + [1147] = {.lex_state = 1}, + [1148] = {.lex_state = 1}, + [1149] = {.lex_state = 1}, + [1150] = {.lex_state = 5}, + [1151] = {.lex_state = 0}, + [1152] = {.lex_state = 1}, + [1153] = {.lex_state = 0}, + [1154] = {.lex_state = 0}, + [1155] = {.lex_state = 0}, + [1156] = {.lex_state = 5}, + [1157] = {.lex_state = 5}, + [1158] = {.lex_state = 0}, + [1159] = {.lex_state = 5}, + [1160] = {.lex_state = 1}, + [1161] = {.lex_state = 1}, + [1162] = {.lex_state = 1}, + [1163] = {.lex_state = 1}, + [1164] = {.lex_state = 0}, + [1165] = {.lex_state = 1}, + [1166] = {.lex_state = 1}, + [1167] = {.lex_state = 1}, + [1168] = {.lex_state = 0}, + [1169] = {.lex_state = 1}, + [1170] = {.lex_state = 0}, + [1171] = {.lex_state = 0}, + [1172] = {.lex_state = 1}, + [1173] = {.lex_state = 0}, + [1174] = {.lex_state = 0}, + [1175] = {.lex_state = 1}, + [1176] = {.lex_state = 1}, + [1177] = {.lex_state = 1}, + [1178] = {.lex_state = 0}, + [1179] = {.lex_state = 1}, + [1180] = {.lex_state = 1}, + [1181] = {.lex_state = 1}, + [1182] = {.lex_state = 1}, + [1183] = {.lex_state = 1}, + [1184] = {.lex_state = 5}, + [1185] = {.lex_state = 2}, + [1186] = {.lex_state = 1}, + [1187] = {.lex_state = 1}, + [1188] = {.lex_state = 0}, + [1189] = {.lex_state = 1}, + [1190] = {.lex_state = 0}, + [1191] = {.lex_state = 0}, + [1192] = {.lex_state = 0}, + [1193] = {.lex_state = 1}, + [1194] = {.lex_state = 1}, + [1195] = {.lex_state = 1}, + [1196] = {.lex_state = 5}, + [1197] = {.lex_state = 1}, + [1198] = {.lex_state = 1}, + [1199] = {.lex_state = 0}, + [1200] = {.lex_state = 1}, + [1201] = {.lex_state = 0}, + [1202] = {.lex_state = 1}, + [1203] = {.lex_state = 0}, + [1204] = {.lex_state = 1}, + [1205] = {.lex_state = 2}, + [1206] = {.lex_state = 0}, + [1207] = {.lex_state = 0}, + [1208] = {.lex_state = 0}, + [1209] = {.lex_state = 0}, + [1210] = {.lex_state = 0}, + [1211] = {.lex_state = 1}, + [1212] = {.lex_state = 1}, + [1213] = {.lex_state = 13}, + [1214] = {.lex_state = 1}, + [1215] = {.lex_state = 1}, + [1216] = {.lex_state = 1}, + [1217] = {.lex_state = 2}, + [1218] = {.lex_state = 1}, + [1219] = {.lex_state = 1}, + [1220] = {.lex_state = 1}, + [1221] = {.lex_state = 1}, + [1222] = {.lex_state = 0}, + [1223] = {.lex_state = 1}, + [1224] = {.lex_state = 1}, + [1225] = {.lex_state = 1}, + [1226] = {.lex_state = 0}, + [1227] = {.lex_state = 1}, + [1228] = {.lex_state = 1}, + [1229] = {.lex_state = 0}, + [1230] = {.lex_state = 1}, + [1231] = {.lex_state = 0}, + [1232] = {.lex_state = 1}, + [1233] = {.lex_state = 0}, + [1234] = {.lex_state = 0}, + [1235] = {.lex_state = 1}, + [1236] = {.lex_state = 0}, + [1237] = {.lex_state = 0}, + [1238] = {.lex_state = 0}, + [1239] = {.lex_state = 1}, + [1240] = {.lex_state = 1}, + [1241] = {.lex_state = 5}, + [1242] = {.lex_state = 1}, + [1243] = {.lex_state = 1}, + [1244] = {.lex_state = 1}, + [1245] = {.lex_state = 1}, + [1246] = {.lex_state = 1}, + [1247] = {.lex_state = 1}, + [1248] = {.lex_state = 1}, + [1249] = {.lex_state = 0}, + [1250] = {.lex_state = 1}, + [1251] = {.lex_state = 2}, + [1252] = {.lex_state = 1}, + [1253] = {.lex_state = 5}, + [1254] = {.lex_state = 1}, + [1255] = {.lex_state = 0}, + [1256] = {.lex_state = 1}, + [1257] = {.lex_state = 1}, + [1258] = {.lex_state = 0}, + [1259] = {.lex_state = 1}, + [1260] = {.lex_state = 1}, + [1261] = {.lex_state = 1}, + [1262] = {.lex_state = 0}, + [1263] = {.lex_state = 1}, + [1264] = {.lex_state = 1}, + [1265] = {.lex_state = 1}, + [1266] = {.lex_state = 1}, + [1267] = {.lex_state = 0}, + [1268] = {.lex_state = 0}, + [1269] = {.lex_state = 1}, + [1270] = {.lex_state = 0}, + [1271] = {.lex_state = 0}, + [1272] = {.lex_state = 1}, + [1273] = {.lex_state = 0}, + [1274] = {.lex_state = 0}, + [1275] = {.lex_state = 0}, + [1276] = {.lex_state = 1}, + [1277] = {.lex_state = 1}, + [1278] = {.lex_state = 1}, + [1279] = {.lex_state = 1}, + [1280] = {.lex_state = 0}, + [1281] = {.lex_state = 1}, + [1282] = {.lex_state = 1}, + [1283] = {.lex_state = 1}, + [1284] = {.lex_state = 0}, + [1285] = {.lex_state = 0}, + [1286] = {.lex_state = 1}, + [1287] = {.lex_state = 0}, + [1288] = {.lex_state = 0}, + [1289] = {.lex_state = 0}, + [1290] = {.lex_state = 0}, + [1291] = {.lex_state = 0}, + [1292] = {.lex_state = 0}, + [1293] = {.lex_state = 0}, + [1294] = {.lex_state = 1}, + [1295] = {.lex_state = 1}, + [1296] = {.lex_state = 1}, + [1297] = {.lex_state = 1}, + [1298] = {.lex_state = 1}, + [1299] = {.lex_state = 1}, + [1300] = {.lex_state = 1}, + [1301] = {.lex_state = 1}, + [1302] = {.lex_state = 5}, + [1303] = {.lex_state = 1}, + [1304] = {.lex_state = 5}, + [1305] = {.lex_state = 0}, + [1306] = {.lex_state = 0}, + [1307] = {.lex_state = 0}, + [1308] = {.lex_state = 1}, + [1309] = {.lex_state = 1}, + [1310] = {.lex_state = 0}, + [1311] = {.lex_state = 1}, + [1312] = {.lex_state = 1}, + [1313] = {.lex_state = 1}, + [1314] = {.lex_state = 1}, + [1315] = {.lex_state = 5}, + [1316] = {.lex_state = 0}, + [1317] = {.lex_state = 0}, + [1318] = {.lex_state = 0}, + [1319] = {.lex_state = 0}, + [1320] = {.lex_state = 0}, + [1321] = {.lex_state = 1}, + [1322] = {.lex_state = 1}, + [1323] = {.lex_state = 0}, + [1324] = {.lex_state = 0}, + [1325] = {.lex_state = 1}, + [1326] = {.lex_state = 0}, + [1327] = {.lex_state = 1}, + [1328] = {.lex_state = 0}, + [1329] = {.lex_state = 0}, + [1330] = {.lex_state = 0}, + [1331] = {.lex_state = 0}, + [1332] = {.lex_state = 0}, + [1333] = {.lex_state = 0}, + [1334] = {.lex_state = 0}, + [1335] = {.lex_state = 0}, + [1336] = {.lex_state = 0}, + [1337] = {.lex_state = 0}, + [1338] = {.lex_state = 0}, + [1339] = {.lex_state = 0}, + [1340] = {.lex_state = 1}, + [1341] = {.lex_state = 0}, + [1342] = {.lex_state = 0}, + [1343] = {.lex_state = 0}, + [1344] = {.lex_state = 0}, + [1345] = {.lex_state = 2}, + [1346] = {.lex_state = 1}, + [1347] = {.lex_state = 0}, + [1348] = {.lex_state = 0}, + [1349] = {.lex_state = 0}, + [1350] = {.lex_state = 0}, + [1351] = {.lex_state = 0}, + [1352] = {.lex_state = 2}, + [1353] = {.lex_state = 1}, + [1354] = {.lex_state = 0}, + [1355] = {.lex_state = 0}, + [1356] = {.lex_state = 1}, + [1357] = {.lex_state = 1}, + [1358] = {.lex_state = 0}, + [1359] = {.lex_state = 0}, + [1360] = {.lex_state = 0}, + [1361] = {.lex_state = 5}, + [1362] = {.lex_state = 1}, + [1363] = {.lex_state = 2}, + [1364] = {.lex_state = 5}, + [1365] = {.lex_state = 0}, + [1366] = {.lex_state = 1}, + [1367] = {.lex_state = 0}, + [1368] = {.lex_state = 0}, + [1369] = {.lex_state = 5}, + [1370] = {.lex_state = 0}, + [1371] = {.lex_state = 0}, + [1372] = {.lex_state = 0}, + [1373] = {.lex_state = 0}, + [1374] = {.lex_state = 0}, + [1375] = {.lex_state = 0}, + [1376] = {.lex_state = 0}, + [1377] = {.lex_state = 0}, + [1378] = {.lex_state = 1}, + [1379] = {.lex_state = 0}, + [1380] = {.lex_state = 0}, + [1381] = {.lex_state = 0}, + [1382] = {.lex_state = 0}, + [1383] = {.lex_state = 0}, + [1384] = {.lex_state = 0}, + [1385] = {.lex_state = 0}, + [1386] = {.lex_state = 0}, + [1387] = {.lex_state = 0}, + [1388] = {.lex_state = 0}, + [1389] = {.lex_state = 0}, + [1390] = {.lex_state = 0}, + [1391] = {.lex_state = 0}, + [1392] = {.lex_state = 0}, + [1393] = {.lex_state = 0}, + [1394] = {.lex_state = 0}, + [1395] = {.lex_state = 0}, + [1396] = {.lex_state = 0}, + [1397] = {.lex_state = 1}, + [1398] = {.lex_state = 0}, + [1399] = {.lex_state = 0}, + [1400] = {.lex_state = 0}, + [1401] = {.lex_state = 0}, + [1402] = {.lex_state = 0}, + [1403] = {.lex_state = 1}, + [1404] = {.lex_state = 1}, + [1405] = {.lex_state = 0}, + [1406] = {.lex_state = 1}, + [1407] = {.lex_state = 0}, + [1408] = {.lex_state = 0}, + [1409] = {.lex_state = 0}, + [1410] = {.lex_state = 1}, + [1411] = {.lex_state = 1}, + [1412] = {.lex_state = 1}, + [1413] = {.lex_state = 1}, + [1414] = {.lex_state = 0}, + [1415] = {.lex_state = 1}, + [1416] = {.lex_state = 0}, + [1417] = {.lex_state = 1}, + [1418] = {.lex_state = 0}, + [1419] = {.lex_state = 0}, + [1420] = {.lex_state = 0}, + [1421] = {.lex_state = 1}, + [1422] = {.lex_state = 1}, + [1423] = {.lex_state = 0}, + [1424] = {.lex_state = 0}, + [1425] = {.lex_state = 1}, + [1426] = {.lex_state = 0}, + [1427] = {.lex_state = 0}, + [1428] = {.lex_state = 1}, + [1429] = {.lex_state = 1}, + [1430] = {.lex_state = 0}, + [1431] = {.lex_state = 1}, + [1432] = {.lex_state = 1}, + [1433] = {.lex_state = 1}, + [1434] = {.lex_state = 0}, + [1435] = {.lex_state = 1}, + [1436] = {.lex_state = 0}, + [1437] = {.lex_state = 5}, + [1438] = {.lex_state = 0}, + [1439] = {.lex_state = 1}, + [1440] = {.lex_state = 0}, + [1441] = {.lex_state = 1}, + [1442] = {.lex_state = 1}, + [1443] = {.lex_state = 0}, + [1444] = {.lex_state = 1}, + [1445] = {.lex_state = 0}, + [1446] = {.lex_state = 0}, + [1447] = {.lex_state = 1}, + [1448] = {.lex_state = 0}, + [1449] = {.lex_state = 0}, + [1450] = {.lex_state = 1}, + [1451] = {.lex_state = 0}, + [1452] = {.lex_state = 0}, + [1453] = {.lex_state = 0}, + [1454] = {.lex_state = 0}, + [1455] = {.lex_state = 0}, + [1456] = {.lex_state = 0}, + [1457] = {.lex_state = 1}, + [1458] = {.lex_state = 1}, + [1459] = {.lex_state = 0}, + [1460] = {.lex_state = 0}, + [1461] = {.lex_state = 0}, + [1462] = {.lex_state = 0}, + [1463] = {.lex_state = 1}, + [1464] = {.lex_state = 0}, + [1465] = {.lex_state = 0}, + [1466] = {.lex_state = 0}, + [1467] = {.lex_state = 1}, + [1468] = {.lex_state = 0}, + [1469] = {.lex_state = 0}, + [1470] = {.lex_state = 0}, + [1471] = {.lex_state = 0}, + [1472] = {.lex_state = 0}, + [1473] = {.lex_state = 0}, + [1474] = {.lex_state = 0}, + [1475] = {.lex_state = 1}, + [1476] = {.lex_state = 0}, + [1477] = {.lex_state = 0}, + [1478] = {.lex_state = 1}, + [1479] = {.lex_state = 0}, + [1480] = {.lex_state = 0}, + [1481] = {.lex_state = 2}, + [1482] = {.lex_state = 0}, + [1483] = {.lex_state = 0}, + [1484] = {.lex_state = 0}, + [1485] = {.lex_state = 0}, + [1486] = {.lex_state = 0}, + [1487] = {.lex_state = 1}, + [1488] = {.lex_state = 0}, + [1489] = {.lex_state = 0}, + [1490] = {.lex_state = 0}, + [1491] = {.lex_state = 0}, + [1492] = {.lex_state = 5}, + [1493] = {.lex_state = 0}, + [1494] = {.lex_state = 0}, + [1495] = {.lex_state = 1}, + [1496] = {.lex_state = 0}, + [1497] = {.lex_state = 0}, + [1498] = {.lex_state = 0}, + [1499] = {.lex_state = 0}, + [1500] = {.lex_state = 0}, + [1501] = {.lex_state = 0}, + [1502] = {.lex_state = 0}, + [1503] = {.lex_state = 0}, + [1504] = {.lex_state = 0}, + [1505] = {.lex_state = 0}, + [1506] = {.lex_state = 0}, + [1507] = {.lex_state = 0}, + [1508] = {.lex_state = 0}, + [1509] = {.lex_state = 0}, + [1510] = {.lex_state = 0}, + [1511] = {.lex_state = 0}, + [1512] = {.lex_state = 0}, + [1513] = {.lex_state = 0}, + [1514] = {.lex_state = 0}, + [1515] = {.lex_state = 0}, + [1516] = {.lex_state = 0}, + [1517] = {.lex_state = 0}, + [1518] = {.lex_state = 0}, + [1519] = {.lex_state = 0}, + [1520] = {.lex_state = 1}, + [1521] = {.lex_state = 0}, + [1522] = {.lex_state = 0}, + [1523] = {.lex_state = 2}, + [1524] = {.lex_state = 0}, + [1525] = {.lex_state = 0}, + [1526] = {.lex_state = 0}, + [1527] = {.lex_state = 0}, + [1528] = {.lex_state = 2}, + [1529] = {.lex_state = 0}, + [1530] = {.lex_state = 0}, + [1531] = {.lex_state = 0}, + [1532] = {.lex_state = 1}, + [1533] = {.lex_state = 0}, + [1534] = {.lex_state = 0}, + [1535] = {.lex_state = 2}, + [1536] = {.lex_state = 0}, + [1537] = {.lex_state = 0}, + [1538] = {.lex_state = 0}, + [1539] = {.lex_state = 0}, + [1540] = {.lex_state = 0}, + [1541] = {.lex_state = 0}, + [1542] = {.lex_state = 0}, + [1543] = {.lex_state = 0}, + [1544] = {.lex_state = 1}, + [1545] = {.lex_state = 0}, + [1546] = {.lex_state = 0}, + [1547] = {.lex_state = 0}, + [1548] = {.lex_state = 0}, + [1549] = {.lex_state = 0}, + [1550] = {.lex_state = 0}, + [1551] = {.lex_state = 0}, + [1552] = {.lex_state = 0}, + [1553] = {.lex_state = 0}, + [1554] = {.lex_state = 0}, + [1555] = {.lex_state = 0}, + [1556] = {.lex_state = 0}, + [1557] = {.lex_state = 0}, + [1558] = {.lex_state = 0}, + [1559] = {.lex_state = 0}, + [1560] = {.lex_state = 0}, + [1561] = {.lex_state = 0}, + [1562] = {.lex_state = 0}, + [1563] = {.lex_state = 0}, + [1564] = {.lex_state = 0}, + [1565] = {.lex_state = 0}, + [1566] = {.lex_state = 0}, + [1567] = {.lex_state = 0}, + [1568] = {.lex_state = 0}, + [1569] = {.lex_state = 0}, + [1570] = {.lex_state = 0}, + [1571] = {.lex_state = 0}, + [1572] = {.lex_state = 0}, + [1573] = {.lex_state = 0}, + [1574] = {.lex_state = 0}, + [1575] = {.lex_state = 0}, + [1576] = {.lex_state = 14}, +}; + +static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { + [STATE(0)] = { + [ts_builtin_sym_end] = ACTIONS(1), + [sym_identifier] = ACTIONS(1), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_POUND] = ACTIONS(1), + [anon_sym_LBRACK] = ACTIONS(1), + [anon_sym_RBRACK] = ACTIONS(1), + [anon_sym_BANG] = ACTIONS(1), + [anon_sym_LPAREN] = ACTIONS(1), + [anon_sym_COMMA] = ACTIONS(1), + [anon_sym_RPAREN] = ACTIONS(1), + [anon_sym_EQ] = ACTIONS(1), + [sym_visibility] = ACTIONS(1), + [anon_sym_struct] = ACTIONS(1), + [anon_sym_LBRACE] = ACTIONS(1), + [anon_sym_RBRACE] = ACTIONS(1), + [anon_sym_trait] = ACTIONS(1), + [anon_sym_fn] = ACTIONS(1), + [anon_sym_DASH_GT] = ACTIONS(1), + [anon_sym_SEMI] = ACTIONS(1), + [anon_sym_impl] = ACTIONS(1), + [anon_sym_for] = ACTIONS(1), + [anon_sym_COLON] = ACTIONS(1), + [anon_sym_DOT] = ACTIONS(1), + [anon_sym_COLON_COLON] = ACTIONS(1), + [anon_sym_AMP] = ACTIONS(1), + [anon_sym_mut] = ACTIONS(1), + [anon_sym_self] = ACTIONS(1), + [anon_sym_event] = ACTIONS(1), + [anon_sym_item] = ACTIONS(1), + [anon_sym_recipe] = ACTIONS(1), + [anon_sym_tag] = ACTIONS(1), + [anon_sym_bossbar] = ACTIONS(1), + [anon_sym_loot] = ACTIONS(1), + [anon_sym_damage_type] = ACTIONS(1), + [anon_sym_predicate] = ACTIONS(1), + [anon_sym_advancement] = ACTIONS(1), + [anon_sym_dialog] = ACTIONS(1), + [anon_sym_dimension] = ACTIONS(1), + [anon_sym_biome] = ACTIONS(1), + [anon_sym_structure_template] = ACTIONS(1), + [anon_sym_inventory_transfer] = ACTIONS(1), + [anon_sym_hud] = ACTIONS(1), + [anon_sym_menu] = ACTIONS(1), + [anon_sym_mod] = ACTIONS(1), + [anon_sym_use] = ACTIONS(1), + [anon_sym_as] = ACTIONS(1), + [anon_sym_const] = ACTIONS(1), + [anon_sym_enum] = ACTIONS(1), + [anon_sym_player] = ACTIONS(1), + [anon_sym_global] = ACTIONS(1), + [anon_sym_entity] = ACTIONS(1), + [anon_sym_state] = ACTIONS(1), + [anon_sym_LT] = ACTIONS(1), + [anon_sym_GT] = ACTIONS(1), + [anon_sym_flow] = ACTIONS(1), + [anon_sym_on] = ACTIONS(1), + [anon_sym_if] = ACTIONS(1), + [anon_sym_priority] = ACTIONS(1), + [anon_sym_enter] = ACTIONS(1), + [anon_sym_exit] = ACTIONS(1), + [anon_sym_tick] = ACTIONS(1), + [anon_sym_every] = ACTIONS(1), + [anon_sym_EQ_GT] = ACTIONS(1), + [anon_sym_extern] = ACTIONS(1), + [anon_sym_let] = ACTIONS(1), + [anon_sym__] = ACTIONS(1), + [anon_sym_DOT_DOT] = ACTIONS(1), + [anon_sym_return] = ACTIONS(1), + [anon_sym_continue] = ACTIONS(1), + [anon_sym_break] = ACTIONS(1), + [anon_sym_emit] = ACTIONS(1), + [anon_sym_loop] = ACTIONS(1), + [anon_sym_match] = ACTIONS(1), + [anon_sym_PIPE] = ACTIONS(1), + [anon_sym_while] = ACTIONS(1), + [anon_sym_else] = ACTIONS(1), + [anon_sym_in] = ACTIONS(1), + [anon_sym_rev] = ACTIONS(1), + [anon_sym_step_by] = ACTIONS(1), + [anon_sym_PLUS_EQ] = ACTIONS(1), + [anon_sym_DASH_EQ] = ACTIONS(1), + [anon_sym_STAR_EQ] = ACTIONS(1), + [anon_sym_SLASH_EQ] = ACTIONS(1), + [anon_sym_PERCENT_EQ] = ACTIONS(1), + [anon_sym_AMP_AMP] = ACTIONS(1), + [anon_sym_EQ_EQ] = ACTIONS(1), + [anon_sym_BANG_EQ] = ACTIONS(1), + [anon_sym_LT_EQ] = ACTIONS(1), + [anon_sym_GT_EQ] = ACTIONS(1), + [anon_sym_DOT_DOT_EQ] = ACTIONS(1), + [anon_sym_move] = ACTIONS(1), + [anon_sym_DASH] = ACTIONS(1), + [anon_sym_PLUS] = ACTIONS(1), + [anon_sym_STAR] = ACTIONS(1), + [anon_sym_SLASH] = ACTIONS(1), + [anon_sym_PERCENT] = ACTIONS(1), + [sym_crate] = ACTIONS(1), + [sym_super] = ACTIONS(1), + [sym_integer] = ACTIONS(1), + [sym_float] = ACTIONS(1), + [anon_sym_true] = ACTIONS(1), + [anon_sym_false] = ACTIONS(1), + [anon_sym_DQUOTE] = ACTIONS(1), + [anon_sym_DQUOTE2] = ACTIONS(1), + [sym_escape_sequence] = ACTIONS(1), + [anon_sym_LBRACE2] = ACTIONS(1), + [anon_sym_RBRACE2] = ACTIONS(1), + }, + [STATE(1)] = { + [sym_source_file] = STATE(1323), + [sym_attribute] = STATE(247), + [sym_inner_attribute] = STATE(18), + [sym__item] = STATE(18), + [sym_struct_item] = STATE(18), + [sym_trait_item] = STATE(18), + [sym_impl_item] = STATE(18), + [sym_event_item] = STATE(18), + [sym_data_item] = STATE(18), + [sym_mod_item] = STATE(18), + [sym_use_item] = STATE(18), + [sym_const_item] = STATE(18), + [sym_enum_item] = STATE(18), + [sym_state_item] = STATE(18), + [sym_flow_item] = STATE(18), + [sym_extern_function] = STATE(18), + [sym_function_item] = STATE(18), + [aux_sym_source_file_repeat1] = STATE(18), + [aux_sym_struct_item_repeat1] = STATE(247), + [ts_builtin_sym_end] = ACTIONS(7), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_POUND] = ACTIONS(9), + [sym_visibility] = ACTIONS(11), + [anon_sym_struct] = ACTIONS(13), + [anon_sym_trait] = ACTIONS(15), + [anon_sym_fn] = ACTIONS(17), + [anon_sym_impl] = ACTIONS(19), + [anon_sym_event] = ACTIONS(21), + [anon_sym_item] = ACTIONS(23), + [anon_sym_recipe] = ACTIONS(23), + [anon_sym_tag] = ACTIONS(23), + [anon_sym_bossbar] = ACTIONS(23), + [anon_sym_loot] = ACTIONS(23), + [anon_sym_damage_type] = ACTIONS(23), + [anon_sym_predicate] = ACTIONS(23), + [anon_sym_advancement] = ACTIONS(23), + [anon_sym_dialog] = ACTIONS(23), + [anon_sym_dimension] = ACTIONS(23), + [anon_sym_biome] = ACTIONS(23), + [anon_sym_structure_template] = ACTIONS(23), + [anon_sym_inventory_transfer] = ACTIONS(23), + [anon_sym_hud] = ACTIONS(23), + [anon_sym_menu] = ACTIONS(23), + [anon_sym_mod] = ACTIONS(25), + [anon_sym_use] = ACTIONS(27), + [anon_sym_const] = ACTIONS(29), + [anon_sym_enum] = ACTIONS(31), + [anon_sym_player] = ACTIONS(33), + [anon_sym_global] = ACTIONS(33), + [anon_sym_entity] = ACTIONS(33), + [anon_sym_flow] = ACTIONS(35), + [anon_sym_extern] = ACTIONS(37), + }, + [STATE(2)] = { + [sym_identifier] = ACTIONS(39), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_POUND] = ACTIONS(41), + [anon_sym_LBRACK] = ACTIONS(41), + [anon_sym_RBRACK] = ACTIONS(41), + [anon_sym_BANG] = ACTIONS(41), + [anon_sym_LPAREN] = ACTIONS(41), + [anon_sym_COMMA] = ACTIONS(41), + [anon_sym_RPAREN] = ACTIONS(41), + [anon_sym_EQ] = ACTIONS(39), + [sym_visibility] = ACTIONS(39), + [anon_sym_struct] = ACTIONS(39), + [anon_sym_LBRACE] = ACTIONS(41), + [anon_sym_RBRACE] = ACTIONS(41), + [anon_sym_trait] = ACTIONS(39), + [anon_sym_fn] = ACTIONS(39), + [anon_sym_DASH_GT] = ACTIONS(41), + [anon_sym_SEMI] = ACTIONS(41), + [anon_sym_impl] = ACTIONS(39), + [anon_sym_for] = ACTIONS(39), + [anon_sym_DOT] = ACTIONS(39), + [anon_sym_self] = ACTIONS(39), + [anon_sym_event] = ACTIONS(39), + [anon_sym_item] = ACTIONS(39), + [anon_sym_recipe] = ACTIONS(39), + [anon_sym_tag] = ACTIONS(39), + [anon_sym_bossbar] = ACTIONS(39), + [anon_sym_loot] = ACTIONS(39), + [anon_sym_damage_type] = ACTIONS(39), + [anon_sym_predicate] = ACTIONS(39), + [anon_sym_advancement] = ACTIONS(39), + [anon_sym_dialog] = ACTIONS(39), + [anon_sym_dimension] = ACTIONS(39), + [anon_sym_biome] = ACTIONS(39), + [anon_sym_structure_template] = ACTIONS(39), + [anon_sym_inventory_transfer] = ACTIONS(39), + [anon_sym_hud] = ACTIONS(39), + [anon_sym_menu] = ACTIONS(39), + [anon_sym_mod] = ACTIONS(39), + [anon_sym_use] = ACTIONS(39), + [anon_sym_as] = ACTIONS(39), + [anon_sym_const] = ACTIONS(39), + [anon_sym_enum] = ACTIONS(39), + [anon_sym_player] = ACTIONS(39), + [anon_sym_global] = ACTIONS(39), + [anon_sym_entity] = ACTIONS(39), + [anon_sym_flow] = ACTIONS(39), + [anon_sym_if] = ACTIONS(39), + [anon_sym_priority] = ACTIONS(39), + [anon_sym_enter] = ACTIONS(39), + [anon_sym_exit] = ACTIONS(39), + [anon_sym_tick] = ACTIONS(39), + [anon_sym_every] = ACTIONS(39), + [anon_sym_EQ_GT] = ACTIONS(41), + [anon_sym_extern] = ACTIONS(39), + [anon_sym_let] = ACTIONS(39), + [anon_sym__] = ACTIONS(39), + [anon_sym_DOT_DOT] = ACTIONS(39), + [anon_sym_return] = ACTIONS(39), + [anon_sym_continue] = ACTIONS(39), + [anon_sym_break] = ACTIONS(39), + [anon_sym_emit] = ACTIONS(39), + [anon_sym_loop] = ACTIONS(39), + [anon_sym_match] = ACTIONS(39), + [anon_sym_while] = ACTIONS(39), + [anon_sym_else] = ACTIONS(39), + [anon_sym_PLUS_EQ] = ACTIONS(41), + [anon_sym_DASH_EQ] = ACTIONS(41), + [anon_sym_STAR_EQ] = ACTIONS(41), + [anon_sym_SLASH_EQ] = ACTIONS(41), + [anon_sym_PERCENT_EQ] = ACTIONS(41), + [anon_sym_PIPE_PIPE] = ACTIONS(41), + [anon_sym_AMP_AMP] = ACTIONS(41), + [anon_sym_DOT_DOT_EQ] = ACTIONS(41), + [anon_sym_move] = ACTIONS(39), + [anon_sym_DASH] = ACTIONS(39), + [anon_sym_PLUS] = ACTIONS(39), + [anon_sym_STAR] = ACTIONS(39), + [anon_sym_SLASH] = ACTIONS(39), + [anon_sym_PERCENT] = ACTIONS(39), + [sym_crate] = ACTIONS(39), + [sym_super] = ACTIONS(39), + [sym_integer] = ACTIONS(39), + [sym_float] = ACTIONS(41), + [anon_sym_true] = ACTIONS(39), + [anon_sym_false] = ACTIONS(39), + [anon_sym_DQUOTE] = ACTIONS(41), + }, + [STATE(3)] = { + [sym_identifier] = ACTIONS(43), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_POUND] = ACTIONS(45), + [anon_sym_LBRACK] = ACTIONS(45), + [anon_sym_RBRACK] = ACTIONS(45), + [anon_sym_BANG] = ACTIONS(45), + [anon_sym_LPAREN] = ACTIONS(45), + [anon_sym_COMMA] = ACTIONS(45), + [anon_sym_RPAREN] = ACTIONS(45), + [anon_sym_EQ] = ACTIONS(43), + [sym_visibility] = ACTIONS(43), + [anon_sym_struct] = ACTIONS(43), + [anon_sym_LBRACE] = ACTIONS(45), + [anon_sym_RBRACE] = ACTIONS(45), + [anon_sym_trait] = ACTIONS(43), + [anon_sym_fn] = ACTIONS(43), + [anon_sym_DASH_GT] = ACTIONS(45), + [anon_sym_SEMI] = ACTIONS(45), + [anon_sym_impl] = ACTIONS(43), + [anon_sym_for] = ACTIONS(43), + [anon_sym_DOT] = ACTIONS(43), + [anon_sym_self] = ACTIONS(43), + [anon_sym_event] = ACTIONS(43), + [anon_sym_item] = ACTIONS(43), + [anon_sym_recipe] = ACTIONS(43), + [anon_sym_tag] = ACTIONS(43), + [anon_sym_bossbar] = ACTIONS(43), + [anon_sym_loot] = ACTIONS(43), + [anon_sym_damage_type] = ACTIONS(43), + [anon_sym_predicate] = ACTIONS(43), + [anon_sym_advancement] = ACTIONS(43), + [anon_sym_dialog] = ACTIONS(43), + [anon_sym_dimension] = ACTIONS(43), + [anon_sym_biome] = ACTIONS(43), + [anon_sym_structure_template] = ACTIONS(43), + [anon_sym_inventory_transfer] = ACTIONS(43), + [anon_sym_hud] = ACTIONS(43), + [anon_sym_menu] = ACTIONS(43), + [anon_sym_mod] = ACTIONS(43), + [anon_sym_use] = ACTIONS(43), + [anon_sym_as] = ACTIONS(43), + [anon_sym_const] = ACTIONS(43), + [anon_sym_enum] = ACTIONS(43), + [anon_sym_player] = ACTIONS(43), + [anon_sym_global] = ACTIONS(43), + [anon_sym_entity] = ACTIONS(43), + [anon_sym_flow] = ACTIONS(43), + [anon_sym_if] = ACTIONS(43), + [anon_sym_priority] = ACTIONS(43), + [anon_sym_enter] = ACTIONS(43), + [anon_sym_exit] = ACTIONS(43), + [anon_sym_tick] = ACTIONS(43), + [anon_sym_every] = ACTIONS(43), + [anon_sym_EQ_GT] = ACTIONS(45), + [anon_sym_extern] = ACTIONS(43), + [anon_sym_let] = ACTIONS(43), + [anon_sym__] = ACTIONS(43), + [anon_sym_DOT_DOT] = ACTIONS(43), + [anon_sym_return] = ACTIONS(43), + [anon_sym_continue] = ACTIONS(43), + [anon_sym_break] = ACTIONS(43), + [anon_sym_emit] = ACTIONS(43), + [anon_sym_loop] = ACTIONS(43), + [anon_sym_match] = ACTIONS(43), + [anon_sym_while] = ACTIONS(43), + [anon_sym_else] = ACTIONS(43), + [anon_sym_PLUS_EQ] = ACTIONS(45), + [anon_sym_DASH_EQ] = ACTIONS(45), + [anon_sym_STAR_EQ] = ACTIONS(45), + [anon_sym_SLASH_EQ] = ACTIONS(45), + [anon_sym_PERCENT_EQ] = ACTIONS(45), + [anon_sym_PIPE_PIPE] = ACTIONS(45), + [anon_sym_AMP_AMP] = ACTIONS(45), + [anon_sym_DOT_DOT_EQ] = ACTIONS(45), + [anon_sym_move] = ACTIONS(43), + [anon_sym_DASH] = ACTIONS(43), + [anon_sym_PLUS] = ACTIONS(43), + [anon_sym_STAR] = ACTIONS(43), + [anon_sym_SLASH] = ACTIONS(43), + [anon_sym_PERCENT] = ACTIONS(43), + [sym_crate] = ACTIONS(43), + [sym_super] = ACTIONS(43), + [sym_integer] = ACTIONS(43), + [sym_float] = ACTIONS(45), + [anon_sym_true] = ACTIONS(43), + [anon_sym_false] = ACTIONS(43), + [anon_sym_DQUOTE] = ACTIONS(45), + }, + [STATE(4)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_data_field] = STATE(1066), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(8), + [sym_let_statement] = STATE(8), + [sym_destructure_statement] = STATE(8), + [sym_return_statement] = STATE(8), + [sym__value_or_condition] = STATE(1429), + [sym_continue_statement] = STATE(8), + [sym_break_statement] = STATE(8), + [sym_emit_statement] = STATE(8), + [sym_loop_statement] = STATE(8), + [sym_match_statement] = STATE(8), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(8), + [sym_if_statement] = STATE(8), + [sym_for_statement] = STATE(8), + [sym_macro_invocation] = STATE(8), + [sym_assignment] = STATE(8), + [sym_call_statement] = STATE(8), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(517), + [aux_sym_block_repeat1] = STATE(8), + [sym_identifier] = ACTIONS(47), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_RBRACE] = ACTIONS(57), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(5)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(6), + [sym_let_statement] = STATE(6), + [sym_destructure_statement] = STATE(6), + [sym_return_statement] = STATE(6), + [sym__value_or_condition] = STATE(1429), + [sym_continue_statement] = STATE(6), + [sym_break_statement] = STATE(6), + [sym_emit_statement] = STATE(6), + [sym_loop_statement] = STATE(6), + [sym_match_statement] = STATE(6), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(6), + [sym_if_statement] = STATE(6), + [sym_for_statement] = STATE(6), + [sym_macro_invocation] = STATE(6), + [sym_assignment] = STATE(6), + [sym_call_statement] = STATE(6), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(518), + [aux_sym_block_repeat1] = STATE(6), + [sym_identifier] = ACTIONS(95), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_RBRACE] = ACTIONS(97), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(6)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(11), + [sym_let_statement] = STATE(11), + [sym_destructure_statement] = STATE(11), + [sym_return_statement] = STATE(11), + [sym__value_or_condition] = STATE(1397), + [sym_continue_statement] = STATE(11), + [sym_break_statement] = STATE(11), + [sym_emit_statement] = STATE(11), + [sym_loop_statement] = STATE(11), + [sym_match_statement] = STATE(11), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(11), + [sym_if_statement] = STATE(11), + [sym_for_statement] = STATE(11), + [sym_macro_invocation] = STATE(11), + [sym_assignment] = STATE(11), + [sym_call_statement] = STATE(11), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(518), + [aux_sym_block_repeat1] = STATE(11), + [sym_identifier] = ACTIONS(95), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_RBRACE] = ACTIONS(99), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(7)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(11), + [sym_let_statement] = STATE(11), + [sym_destructure_statement] = STATE(11), + [sym_return_statement] = STATE(11), + [sym__value_or_condition] = STATE(1475), + [sym_continue_statement] = STATE(11), + [sym_break_statement] = STATE(11), + [sym_emit_statement] = STATE(11), + [sym_loop_statement] = STATE(11), + [sym_match_statement] = STATE(11), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(11), + [sym_if_statement] = STATE(11), + [sym_for_statement] = STATE(11), + [sym_macro_invocation] = STATE(11), + [sym_assignment] = STATE(11), + [sym_call_statement] = STATE(11), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(518), + [aux_sym_block_repeat1] = STATE(11), + [sym_identifier] = ACTIONS(95), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(8)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(11), + [sym_let_statement] = STATE(11), + [sym_destructure_statement] = STATE(11), + [sym_return_statement] = STATE(11), + [sym__value_or_condition] = STATE(1397), + [sym_continue_statement] = STATE(11), + [sym_break_statement] = STATE(11), + [sym_emit_statement] = STATE(11), + [sym_loop_statement] = STATE(11), + [sym_match_statement] = STATE(11), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(11), + [sym_if_statement] = STATE(11), + [sym_for_statement] = STATE(11), + [sym_macro_invocation] = STATE(11), + [sym_assignment] = STATE(11), + [sym_call_statement] = STATE(11), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(518), + [aux_sym_block_repeat1] = STATE(11), + [sym_identifier] = ACTIONS(95), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(9)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(8), + [sym_let_statement] = STATE(8), + [sym_destructure_statement] = STATE(8), + [sym_return_statement] = STATE(8), + [sym__value_or_condition] = STATE(1429), + [sym_continue_statement] = STATE(8), + [sym_break_statement] = STATE(8), + [sym_emit_statement] = STATE(8), + [sym_loop_statement] = STATE(8), + [sym_match_statement] = STATE(8), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(8), + [sym_if_statement] = STATE(8), + [sym_for_statement] = STATE(8), + [sym_macro_invocation] = STATE(8), + [sym_assignment] = STATE(8), + [sym_call_statement] = STATE(8), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(518), + [aux_sym_block_repeat1] = STATE(8), + [sym_identifier] = ACTIONS(95), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(10)] = { + [sym_record_expression] = STATE(518), + [sym_method_expression] = STATE(513), + [sym_field_expression] = STATE(415), + [sym_array_expression] = STATE(518), + [sym_index_expression] = STATE(415), + [sym__statement] = STATE(7), + [sym_let_statement] = STATE(7), + [sym_destructure_statement] = STATE(7), + [sym_return_statement] = STATE(7), + [sym__value_or_condition] = STATE(1340), + [sym_continue_statement] = STATE(7), + [sym_break_statement] = STATE(7), + [sym_emit_statement] = STATE(7), + [sym_loop_statement] = STATE(7), + [sym_match_statement] = STATE(7), + [sym_match_expression] = STATE(518), + [sym_while_statement] = STATE(7), + [sym_if_statement] = STATE(7), + [sym_for_statement] = STATE(7), + [sym_macro_invocation] = STATE(7), + [sym_assignment] = STATE(7), + [sym_call_statement] = STATE(7), + [sym__condition] = STATE(1243), + [sym_logical_condition] = STATE(883), + [sym_not_condition] = STATE(883), + [sym_comparison] = STATE(883), + [sym_in_range] = STATE(883), + [sym_closure_expression] = STATE(518), + [sym_block_expression] = STATE(518), + [sym__expression] = STATE(518), + [sym_call_expression] = STATE(513), + [sym_place] = STATE(415), + [sym_unary_expression] = STATE(518), + [sym_binary_expression] = STATE(518), + [sym_cast_expression] = STATE(518), + [sym_parenthesized_expression] = STATE(415), + [sym_path] = STATE(215), + [sym__path_segment] = STATE(145), + [sym_self] = STATE(145), + [sym_boolean] = STATE(415), + [sym_string] = STATE(518), + [aux_sym_block_repeat1] = STATE(7), + [sym_identifier] = ACTIONS(95), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(49), + [anon_sym_BANG] = ACTIONS(51), + [anon_sym_LPAREN] = ACTIONS(53), + [anon_sym_LBRACE] = ACTIONS(55), + [anon_sym_for] = ACTIONS(59), + [anon_sym_self] = ACTIONS(61), + [anon_sym_if] = ACTIONS(63), + [anon_sym_let] = ACTIONS(65), + [anon_sym_return] = ACTIONS(67), + [anon_sym_continue] = ACTIONS(69), + [anon_sym_break] = ACTIONS(71), + [anon_sym_emit] = ACTIONS(73), + [anon_sym_loop] = ACTIONS(75), + [anon_sym_match] = ACTIONS(77), + [anon_sym_while] = ACTIONS(79), + [anon_sym_move] = ACTIONS(81), + [anon_sym_DASH] = ACTIONS(83), + [sym_crate] = ACTIONS(85), + [sym_super] = ACTIONS(85), + [sym_integer] = ACTIONS(87), + [sym_float] = ACTIONS(89), + [anon_sym_true] = ACTIONS(91), + [anon_sym_false] = ACTIONS(91), + [anon_sym_DQUOTE] = ACTIONS(93), + }, + [STATE(11)] = { + [sym_record_expression] = STATE(592), + [sym_method_expression] = STATE(566), + [sym_field_expression] = STATE(592), + [sym_array_expression] = STATE(592), + [sym_index_expression] = STATE(592), + [sym__statement] = STATE(11), + [sym_let_statement] = STATE(11), + [sym_destructure_statement] = STATE(11), + [sym_return_statement] = STATE(11), + [sym_continue_statement] = STATE(11), + [sym_break_statement] = STATE(11), + [sym_emit_statement] = STATE(11), + [sym_loop_statement] = STATE(11), + [sym_match_statement] = STATE(11), + [sym_match_expression] = STATE(592), + [sym_while_statement] = STATE(11), + [sym_if_statement] = STATE(11), + [sym_for_statement] = STATE(11), + [sym_macro_invocation] = STATE(11), + [sym_assignment] = STATE(11), + [sym_call_statement] = STATE(11), + [sym_closure_expression] = STATE(592), + [sym_block_expression] = STATE(592), + [sym__expression] = STATE(592), + [sym_call_expression] = STATE(566), + [sym_place] = STATE(592), + [sym_unary_expression] = STATE(592), + [sym_binary_expression] = STATE(592), + [sym_cast_expression] = STATE(592), + [sym_parenthesized_expression] = STATE(592), + [sym_path] = STATE(119), + [sym__path_segment] = STATE(170), + [sym_self] = STATE(170), + [sym_boolean] = STATE(592), + [sym_string] = STATE(592), + [aux_sym_block_repeat1] = STATE(11), + [sym_identifier] = ACTIONS(101), + [sym_doc_comment] = ACTIONS(3), + [sym_line_comment] = ACTIONS(5), + [sym_block_comment] = ACTIONS(3), + [anon_sym_LBRACK] = ACTIONS(104), + [anon_sym_BANG] = ACTIONS(107), + [anon_sym_LPAREN] = ACTIONS(109), + [anon_sym_LBRACE] = ACTIONS(112), + [anon_sym_RBRACE] = ACTIONS(107), + [anon_sym_for] = ACTIONS(115), + [anon_sym_self] = ACTIONS(118), + [anon_sym_if] = ACTIONS(121), + [anon_sym_let] = ACTIONS(124), + [anon_sym_return] = ACTIONS(127), + [anon_sym_continue] = ACTIONS(130), + [anon_sym_break] = ACTIONS(133), + [anon_sym_emit] = ACTIONS(136), + [anon_sym_loop] = ACTIONS(139), + [anon_sym_match] = ACTIONS(142), + [anon_sym_while] = ACTIONS(145), + [anon_sym_move] = ACTIONS(148), + [anon_sym_DASH] = ACTIONS(151), + [sym_crate] = ACTIONS(154), + [sym_super] = ACTIONS(154), + [sym_integer] = ACTIONS(157), + [sym_float] = ACTIONS(160), + [anon_sym_true] = ACTIONS(163), + [anon_sym_false] = ACTIONS(163), + [anon_sym_DQUOTE] = ACTIONS(166), + }, +}; + +static const uint16_t ts_small_parse_table[] = { + [0] = 30, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(59), 1, + anon_sym_for, + ACTIONS(63), 1, + anon_sym_if, + ACTIONS(65), 1, + anon_sym_let, + ACTIONS(67), 1, + anon_sym_return, + ACTIONS(69), 1, + anon_sym_continue, + ACTIONS(71), 1, + anon_sym_break, + ACTIONS(73), 1, + anon_sym_emit, + ACTIONS(75), 1, + anon_sym_loop, + ACTIONS(77), 1, + anon_sym_match, + ACTIONS(79), 1, + anon_sym_while, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(95), 1, + sym_identifier, + ACTIONS(169), 1, + anon_sym_RBRACE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(179), 1, + sym_integer, + ACTIONS(181), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(566), 2, + sym_method_expression, + sym_call_expression, + STATE(592), 15, + sym_record_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + STATE(17), 16, + sym__statement, + sym_let_statement, + sym_destructure_statement, + sym_return_statement, + sym_continue_statement, + sym_break_statement, + sym_emit_statement, + sym_loop_statement, + sym_match_statement, + sym_while_statement, + sym_if_statement, + sym_for_statement, + sym_macro_invocation, + sym_assignment, + sym_call_statement, + aux_sym_block_repeat1, + [125] = 30, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(59), 1, + anon_sym_for, + ACTIONS(63), 1, + anon_sym_if, + ACTIONS(65), 1, + anon_sym_let, + ACTIONS(67), 1, + anon_sym_return, + ACTIONS(69), 1, + anon_sym_continue, + ACTIONS(71), 1, + anon_sym_break, + ACTIONS(73), 1, + anon_sym_emit, + ACTIONS(75), 1, + anon_sym_loop, + ACTIONS(77), 1, + anon_sym_match, + ACTIONS(79), 1, + anon_sym_while, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(95), 1, + sym_identifier, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(179), 1, + sym_integer, + ACTIONS(181), 1, + sym_float, + ACTIONS(183), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(566), 2, + sym_method_expression, + sym_call_expression, + STATE(592), 15, + sym_record_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + STATE(14), 16, + sym__statement, + sym_let_statement, + sym_destructure_statement, + sym_return_statement, + sym_continue_statement, + sym_break_statement, + sym_emit_statement, + sym_loop_statement, + sym_match_statement, + sym_while_statement, + sym_if_statement, + sym_for_statement, + sym_macro_invocation, + sym_assignment, + sym_call_statement, + aux_sym_block_repeat1, + [250] = 30, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(59), 1, + anon_sym_for, + ACTIONS(63), 1, + anon_sym_if, + ACTIONS(65), 1, + anon_sym_let, + ACTIONS(67), 1, + anon_sym_return, + ACTIONS(69), 1, + anon_sym_continue, + ACTIONS(71), 1, + anon_sym_break, + ACTIONS(73), 1, + anon_sym_emit, + ACTIONS(75), 1, + anon_sym_loop, + ACTIONS(77), 1, + anon_sym_match, + ACTIONS(79), 1, + anon_sym_while, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(95), 1, + sym_identifier, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(179), 1, + sym_integer, + ACTIONS(181), 1, + sym_float, + ACTIONS(185), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(566), 2, + sym_method_expression, + sym_call_expression, + STATE(592), 15, + sym_record_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + STATE(11), 16, + sym__statement, + sym_let_statement, + sym_destructure_statement, + sym_return_statement, + sym_continue_statement, + sym_break_statement, + sym_emit_statement, + sym_loop_statement, + sym_match_statement, + sym_while_statement, + sym_if_statement, + sym_for_statement, + sym_macro_invocation, + sym_assignment, + sym_call_statement, + aux_sym_block_repeat1, + [375] = 30, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(59), 1, + anon_sym_for, + ACTIONS(63), 1, + anon_sym_if, + ACTIONS(65), 1, + anon_sym_let, + ACTIONS(67), 1, + anon_sym_return, + ACTIONS(69), 1, + anon_sym_continue, + ACTIONS(71), 1, + anon_sym_break, + ACTIONS(73), 1, + anon_sym_emit, + ACTIONS(75), 1, + anon_sym_loop, + ACTIONS(77), 1, + anon_sym_match, + ACTIONS(79), 1, + anon_sym_while, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(95), 1, + sym_identifier, + ACTIONS(97), 1, + anon_sym_RBRACE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(179), 1, + sym_integer, + ACTIONS(181), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(566), 2, + sym_method_expression, + sym_call_expression, + STATE(592), 15, + sym_record_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + STATE(16), 16, + sym__statement, + sym_let_statement, + sym_destructure_statement, + sym_return_statement, + sym_continue_statement, + sym_break_statement, + sym_emit_statement, + sym_loop_statement, + sym_match_statement, + sym_while_statement, + sym_if_statement, + sym_for_statement, + sym_macro_invocation, + sym_assignment, + sym_call_statement, + aux_sym_block_repeat1, + [500] = 30, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(59), 1, + anon_sym_for, + ACTIONS(63), 1, + anon_sym_if, + ACTIONS(65), 1, + anon_sym_let, + ACTIONS(67), 1, + anon_sym_return, + ACTIONS(69), 1, + anon_sym_continue, + ACTIONS(71), 1, + anon_sym_break, + ACTIONS(73), 1, + anon_sym_emit, + ACTIONS(75), 1, + anon_sym_loop, + ACTIONS(77), 1, + anon_sym_match, + ACTIONS(79), 1, + anon_sym_while, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(95), 1, + sym_identifier, + ACTIONS(99), 1, + anon_sym_RBRACE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(179), 1, + sym_integer, + ACTIONS(181), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(566), 2, + sym_method_expression, + sym_call_expression, + STATE(592), 15, + sym_record_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + STATE(11), 16, + sym__statement, + sym_let_statement, + sym_destructure_statement, + sym_return_statement, + sym_continue_statement, + sym_break_statement, + sym_emit_statement, + sym_loop_statement, + sym_match_statement, + sym_while_statement, + sym_if_statement, + sym_for_statement, + sym_macro_invocation, + sym_assignment, + sym_call_statement, + aux_sym_block_repeat1, + [625] = 30, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(59), 1, + anon_sym_for, + ACTIONS(63), 1, + anon_sym_if, + ACTIONS(65), 1, + anon_sym_let, + ACTIONS(67), 1, + anon_sym_return, + ACTIONS(69), 1, + anon_sym_continue, + ACTIONS(71), 1, + anon_sym_break, + ACTIONS(73), 1, + anon_sym_emit, + ACTIONS(75), 1, + anon_sym_loop, + ACTIONS(77), 1, + anon_sym_match, + ACTIONS(79), 1, + anon_sym_while, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(95), 1, + sym_identifier, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(179), 1, + sym_integer, + ACTIONS(181), 1, + sym_float, + ACTIONS(187), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(566), 2, + sym_method_expression, + sym_call_expression, + STATE(592), 15, + sym_record_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + STATE(11), 16, + sym__statement, + sym_let_statement, + sym_destructure_statement, + sym_return_statement, + sym_continue_statement, + sym_break_statement, + sym_emit_statement, + sym_loop_statement, + sym_match_statement, + sym_while_statement, + sym_if_statement, + sym_for_statement, + sym_macro_invocation, + sym_assignment, + sym_call_statement, + aux_sym_block_repeat1, + [750] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(9), 1, + anon_sym_POUND, + ACTIONS(11), 1, + sym_visibility, + ACTIONS(13), 1, + anon_sym_struct, + ACTIONS(15), 1, + anon_sym_trait, + ACTIONS(17), 1, + anon_sym_fn, + ACTIONS(19), 1, + anon_sym_impl, + ACTIONS(21), 1, + anon_sym_event, + ACTIONS(25), 1, + anon_sym_mod, + ACTIONS(27), 1, + anon_sym_use, + ACTIONS(29), 1, + anon_sym_const, + ACTIONS(31), 1, + anon_sym_enum, + ACTIONS(35), 1, + anon_sym_flow, + ACTIONS(37), 1, + anon_sym_extern, + ACTIONS(189), 1, + ts_builtin_sym_end, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(247), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(33), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(23), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(19), 16, + sym_inner_attribute, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_source_file_repeat1, + [844] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(191), 1, + ts_builtin_sym_end, + ACTIONS(193), 1, + anon_sym_POUND, + ACTIONS(196), 1, + sym_visibility, + ACTIONS(199), 1, + anon_sym_struct, + ACTIONS(202), 1, + anon_sym_trait, + ACTIONS(205), 1, + anon_sym_fn, + ACTIONS(208), 1, + anon_sym_impl, + ACTIONS(211), 1, + anon_sym_event, + ACTIONS(217), 1, + anon_sym_mod, + ACTIONS(220), 1, + anon_sym_use, + ACTIONS(223), 1, + anon_sym_const, + ACTIONS(226), 1, + anon_sym_enum, + ACTIONS(232), 1, + anon_sym_flow, + ACTIONS(235), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(247), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(229), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(214), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(19), 16, + sym_inner_attribute, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_source_file_repeat1, + [938] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(244), 1, + anon_sym_RBRACE, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1031] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(270), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(23), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1124] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(272), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1217] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(274), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1310] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(276), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(27), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1403] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(278), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(30), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1496] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(280), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(28), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1589] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(282), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1682] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(284), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1775] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(286), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(20), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1868] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(288), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [1961] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(290), 1, + anon_sym_POUND, + ACTIONS(293), 1, + sym_visibility, + ACTIONS(296), 1, + anon_sym_struct, + ACTIONS(299), 1, + anon_sym_RBRACE, + ACTIONS(301), 1, + anon_sym_trait, + ACTIONS(304), 1, + anon_sym_fn, + ACTIONS(307), 1, + anon_sym_impl, + ACTIONS(310), 1, + anon_sym_event, + ACTIONS(316), 1, + anon_sym_mod, + ACTIONS(319), 1, + anon_sym_use, + ACTIONS(322), 1, + anon_sym_const, + ACTIONS(325), 1, + anon_sym_enum, + ACTIONS(331), 1, + anon_sym_flow, + ACTIONS(334), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(328), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(313), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(31), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [2054] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(240), 1, + sym_visibility, + ACTIONS(242), 1, + anon_sym_struct, + ACTIONS(246), 1, + anon_sym_trait, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(250), 1, + anon_sym_impl, + ACTIONS(252), 1, + anon_sym_event, + ACTIONS(256), 1, + anon_sym_mod, + ACTIONS(258), 1, + anon_sym_use, + ACTIONS(260), 1, + anon_sym_const, + ACTIONS(262), 1, + anon_sym_enum, + ACTIONS(266), 1, + anon_sym_flow, + ACTIONS(268), 1, + anon_sym_extern, + ACTIONS(337), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(452), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(264), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(254), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + STATE(22), 15, + sym__item, + sym_struct_item, + sym_trait_item, + sym_impl_item, + sym_event_item, + sym_data_item, + sym_mod_item, + sym_use_item, + sym_const_item, + sym_enum_item, + sym_state_item, + sym_flow_item, + sym_extern_function, + sym_function_item, + aux_sym_mod_item_repeat1, + [2147] = 27, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(341), 1, + anon_sym_RPAREN, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1290), 1, + sym_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2253] = 27, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + ACTIONS(353), 1, + anon_sym_RPAREN, + STATE(215), 1, + sym_path, + STATE(1171), 1, + sym_argument, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2359] = 27, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + ACTIONS(355), 1, + anon_sym_RPAREN, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1290), 1, + sym_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2465] = 27, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + ACTIONS(357), 1, + anon_sym_RPAREN, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1290), 1, + sym_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2571] = 27, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + ACTIONS(359), 1, + anon_sym_RPAREN, + STATE(215), 1, + sym_path, + STATE(1117), 1, + sym_argument, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2677] = 27, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + ACTIONS(361), 1, + anon_sym_RPAREN, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1290), 1, + sym_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2783] = 26, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(339), 1, + sym_identifier, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1290), 1, + sym_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(85), 2, + sym_crate, + sym_super, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1289), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2886] = 24, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(1288), 3, + sym__value_or_condition, + sym_range, + sym__argument_value, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [2984] = 25, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(349), 1, + sym_integer, + ACTIONS(351), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1324), 1, + sym_range, + STATE(1376), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(525), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3083] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(363), 1, + anon_sym_RBRACK, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(367), 1, + sym_integer, + ACTIONS(369), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1005), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(539), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3177] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(371), 1, + anon_sym_RBRACK, + ACTIONS(373), 1, + sym_integer, + ACTIONS(375), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1089), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(545), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3271] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(377), 1, + anon_sym_RBRACK, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1236), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3365] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(383), 1, + anon_sym_RBRACK, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1236), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3459] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(385), 1, + anon_sym_RBRACK, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1236), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3553] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(387), 1, + anon_sym_RBRACK, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1236), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3647] = 19, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(391), 1, + anon_sym_priority, + ACTIONS(393), 1, + sym_integer, + ACTIONS(395), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(389), 8, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + STATE(548), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [3733] = 19, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(399), 1, + anon_sym_priority, + ACTIONS(401), 1, + sym_integer, + ACTIONS(403), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(397), 8, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + STATE(546), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [3819] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(405), 1, + anon_sym_LBRACE, + STATE(215), 1, + sym_path, + STATE(531), 1, + sym_block, + STATE(1227), 1, + sym__value_or_condition, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [3912] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + STATE(1236), 2, + sym_data_object, + sym__value_or_condition, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4003] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(405), 1, + anon_sym_LBRACE, + STATE(215), 1, + sym_path, + STATE(534), 1, + sym_block, + STATE(1243), 1, + sym__condition, + STATE(1263), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4096] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(405), 1, + anon_sym_LBRACE, + STATE(215), 1, + sym_path, + STATE(529), 1, + sym_block, + STATE(1243), 1, + sym__condition, + STATE(1281), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4189] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(407), 1, + anon_sym_SEMI, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1375), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4282] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + ACTIONS(405), 1, + anon_sym_LBRACE, + STATE(215), 1, + sym_path, + STATE(521), 1, + sym_block, + STATE(1243), 1, + sym__condition, + STATE(1265), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4375] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1227), 1, + sym__value_or_condition, + STATE(1243), 1, + sym__condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4465] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(412), 1, + anon_sym_LBRACK, + ACTIONS(415), 1, + anon_sym_LPAREN, + ACTIONS(418), 1, + anon_sym_LBRACE, + ACTIONS(421), 1, + anon_sym_RBRACE, + ACTIONS(423), 1, + anon_sym_self, + ACTIONS(429), 1, + anon_sym_match, + ACTIONS(432), 1, + anon_sym_move, + ACTIONS(435), 1, + anon_sym_DASH, + ACTIONS(438), 1, + sym_integer, + ACTIONS(441), 1, + sym_float, + ACTIONS(447), 1, + anon_sym_DQUOTE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(444), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(409), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(426), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [4551] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(450), 1, + anon_sym_RBRACE, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(61), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [4637] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1296), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4727] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1423), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [4817] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(458), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [4903] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(460), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(72), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [4989] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1332), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5079] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1333), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5169] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1263), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5259] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1265), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5349] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1401), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5439] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1281), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5529] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1368), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5619] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(462), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(82), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [5705] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1414), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5795] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(464), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [5881] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1376), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [5971] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(466), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(77), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6057] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(476), 1, + anon_sym_RBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(482), 1, + anon_sym__, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(490), 1, + sym_integer, + ACTIONS(492), 1, + sym_float, + ACTIONS(496), 1, + anon_sym_DQUOTE, + STATE(593), 1, + sym_path, + STATE(1008), 1, + sym_match_value_arm, + STATE(1031), 1, + sym_match_binding, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(98), 2, + sym_match_arm, + aux_sym_match_statement_repeat1, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(636), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6149] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(498), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(78), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6235] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(500), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6321] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(502), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6407] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(504), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(80), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6493] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(506), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6579] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1338), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [6669] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(454), 1, + sym_integer, + ACTIONS(456), 1, + sym_float, + ACTIONS(508), 1, + anon_sym_RBRACE, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + ACTIONS(452), 3, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + STATE(57), 3, + sym_transition, + sym_hook, + aux_sym_flow_item_repeat1, + STATE(751), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [6755] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(379), 1, + sym_integer, + ACTIONS(381), 1, + sym_float, + STATE(215), 1, + sym_path, + STATE(1243), 1, + sym__condition, + STATE(1360), 1, + sym__value_or_condition, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(883), 4, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(519), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [6845] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(510), 1, + anon_sym_BANG, + ACTIONS(512), 1, + sym_integer, + ACTIONS(514), 1, + sym_float, + STATE(520), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(951), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(567), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [6930] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(516), 1, + sym_identifier, + ACTIONS(518), 1, + anon_sym_RPAREN, + ACTIONS(520), 1, + sym_integer, + ACTIONS(522), 1, + sym_float, + STATE(119), 1, + sym_path, + STATE(1275), 1, + sym_attribute_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1206), 2, + sym__value, + sym_range, + STATE(683), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [7021] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(524), 1, + anon_sym_BANG, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(215), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(1111), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7106] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(516), 1, + sym_identifier, + ACTIONS(520), 1, + sym_integer, + ACTIONS(522), 1, + sym_float, + ACTIONS(530), 1, + anon_sym_RPAREN, + STATE(119), 1, + sym_path, + STATE(1077), 1, + sym_attribute_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1206), 2, + sym__value, + sym_range, + STATE(683), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [7197] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(510), 1, + anon_sym_BANG, + ACTIONS(512), 1, + sym_integer, + ACTIONS(514), 1, + sym_float, + STATE(520), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(736), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(567), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7282] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(510), 1, + anon_sym_BANG, + ACTIONS(512), 1, + sym_integer, + ACTIONS(514), 1, + sym_float, + STATE(520), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(958), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(567), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7367] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(500), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(736), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(516), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7452] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(535), 1, + anon_sym_LBRACK, + ACTIONS(538), 1, + anon_sym_LPAREN, + ACTIONS(541), 1, + anon_sym_LBRACE, + ACTIONS(544), 1, + anon_sym_RBRACE, + ACTIONS(546), 1, + anon_sym_self, + ACTIONS(549), 1, + anon_sym_let, + ACTIONS(552), 1, + anon_sym__, + ACTIONS(555), 1, + anon_sym_match, + ACTIONS(558), 1, + anon_sym_move, + ACTIONS(561), 1, + anon_sym_DASH, + ACTIONS(564), 1, + sym_integer, + ACTIONS(567), 1, + sym_float, + ACTIONS(573), 1, + anon_sym_DQUOTE, + STATE(593), 1, + sym_path, + STATE(1090), 1, + sym_match_binding, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(570), 2, + anon_sym_true, + anon_sym_false, + STATE(91), 2, + sym_match_arm, + aux_sym_match_statement_repeat1, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(532), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(633), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [7541] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(500), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(952), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(516), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7626] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(500), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(777), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(516), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7711] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(510), 1, + anon_sym_BANG, + ACTIONS(512), 1, + sym_integer, + ACTIONS(514), 1, + sym_float, + STATE(520), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(733), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(567), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7796] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(51), 1, + anon_sym_BANG, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(500), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(733), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(516), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7881] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(510), 1, + anon_sym_BANG, + ACTIONS(512), 1, + sym_integer, + ACTIONS(514), 1, + sym_float, + STATE(520), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(1133), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(567), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [7966] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(524), 1, + anon_sym_BANG, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(215), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(736), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [8051] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(576), 1, + anon_sym_RBRACE, + ACTIONS(578), 1, + anon_sym__, + ACTIONS(580), 1, + sym_integer, + ACTIONS(582), 1, + sym_float, + STATE(593), 1, + sym_path, + STATE(1090), 1, + sym_match_binding, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(91), 2, + sym_match_arm, + aux_sym_match_statement_repeat1, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(633), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8140] = 23, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(516), 1, + sym_identifier, + ACTIONS(520), 1, + sym_integer, + ACTIONS(522), 1, + sym_float, + ACTIONS(584), 1, + anon_sym_RPAREN, + STATE(119), 1, + sym_path, + STATE(1275), 1, + sym_attribute_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1206), 2, + sym__value, + sym_range, + STATE(683), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8231] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(524), 1, + anon_sym_BANG, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(215), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(1159), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [8316] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(524), 1, + anon_sym_BANG, + ACTIONS(526), 1, + sym_integer, + ACTIONS(528), 1, + sym_float, + STATE(215), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(733), 5, + sym__condition, + sym_logical_condition, + sym_not_condition, + sym_comparison, + sym_in_range, + STATE(415), 7, + sym_method_expression, + sym_field_expression, + sym_index_expression, + sym_call_expression, + sym_place, + sym_parenthesized_expression, + sym_boolean, + STATE(570), 10, + sym_record_expression, + sym_array_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_string, + [8401] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(586), 1, + anon_sym_RBRACE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1228), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8489] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(516), 1, + sym_identifier, + ACTIONS(520), 1, + sym_integer, + ACTIONS(522), 1, + sym_float, + STATE(119), 1, + sym_path, + STATE(1275), 1, + sym_attribute_argument, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1206), 2, + sym__value, + sym_range, + STATE(683), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8577] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + ACTIONS(594), 1, + anon_sym_RBRACE, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1228), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8665] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + ACTIONS(596), 1, + anon_sym_RBRACE, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1228), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8753] = 22, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + ACTIONS(598), 1, + anon_sym_RBRACE, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1228), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8841] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(606), 1, + anon_sym_COLON_COLON, + STATE(142), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(604), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(600), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [8898] = 21, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1134), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [8983] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(343), 1, + anon_sym_DOT_DOT, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(347), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(520), 1, + sym_integer, + ACTIONS(522), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1273), 2, + sym__value, + sym_range, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(683), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9066] = 21, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1008), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9151] = 21, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(608), 1, + anon_sym_LPAREN, + ACTIONS(610), 1, + anon_sym_DOT_DOT, + ACTIONS(612), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(616), 1, + sym_integer, + ACTIONS(618), 1, + sym_float, + STATE(550), 1, + sym_path, + STATE(1211), 1, + sym_count_range, + STATE(1327), 1, + sym_range, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(682), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9236] = 21, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(480), 1, + anon_sym_let, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(588), 1, + anon_sym__, + ACTIONS(590), 1, + sym_integer, + ACTIONS(592), 1, + sym_float, + STATE(593), 1, + sym_path, + STATE(1007), 1, + sym_match_binding, + STATE(1228), 1, + sym_match_value_arm, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(626), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9321] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(620), 1, + anon_sym_DOT_DOT, + ACTIONS(622), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(624), 1, + sym_integer, + ACTIONS(626), 1, + sym_float, + STATE(119), 1, + sym_path, + STATE(732), 1, + sym_range, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(735), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9403] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(630), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(628), 28, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_fn, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_COLON, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [9453] = 20, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(632), 1, + anon_sym_DOT_DOT, + ACTIONS(634), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(636), 1, + sym_integer, + ACTIONS(638), 1, + sym_float, + STATE(119), 1, + sym_path, + STATE(732), 1, + sym_range, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(727), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9535] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(642), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(640), 28, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_fn, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_COLON, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [9585] = 18, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(644), 1, + sym_integer, + ACTIONS(646), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(397), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(731), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9662] = 18, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(648), 1, + sym_integer, + ACTIONS(650), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(389), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(734), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9739] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(656), 1, + anon_sym_LBRACE, + ACTIONS(658), 1, + anon_sym_DOT, + STATE(153), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(654), 9, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(652), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [9796] = 18, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(661), 1, + sym_integer, + ACTIONS(663), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1220), 2, + sym_data_object, + sym__data_value, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(729), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9873] = 18, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(365), 1, + anon_sym_LBRACE, + ACTIONS(661), 1, + sym_integer, + ACTIONS(663), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1216), 2, + sym_data_object, + sym__data_value, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(729), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [9950] = 18, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(665), 1, + sym_integer, + ACTIONS(667), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(389), 2, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(695), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [10027] = 18, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(669), 1, + sym_integer, + ACTIONS(671), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + ACTIONS(397), 2, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(714), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [10104] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(675), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(673), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10152] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(679), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(677), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10200] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(683), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(681), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10248] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(687), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(685), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10296] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(691), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(689), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10344] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(695), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(693), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10392] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(699), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(697), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10440] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(703), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(701), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10488] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(707), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(705), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10536] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(713), 9, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(711), 25, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10588] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(719), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(717), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10636] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(723), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(721), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10684] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(727), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(725), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10732] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(731), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(729), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10780] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(735), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(733), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10828] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(739), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(737), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10876] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(743), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(741), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10924] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(747), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(745), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [10972] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(751), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(749), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11020] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(755), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(753), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11068] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(759), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(757), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11116] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(765), 1, + anon_sym_COLON_COLON, + STATE(146), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(763), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(761), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11168] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(771), 1, + anon_sym_COLON_COLON, + STATE(149), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(769), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(767), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11220] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(775), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(773), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11268] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(771), 1, + anon_sym_COLON_COLON, + STATE(151), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(779), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(777), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11320] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(785), 1, + anon_sym_COLON_COLON, + STATE(149), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(783), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(781), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11372] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(790), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(788), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11420] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(771), 1, + anon_sym_COLON_COLON, + STATE(149), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(794), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(792), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11472] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(798), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(796), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11520] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(802), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(800), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11568] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(806), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(804), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11616] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(810), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(808), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11664] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(814), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(812), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11712] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(818), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(816), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11760] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(822), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(820), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11808] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(826), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(824), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [11856] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(828), 1, + sym_integer, + ACTIONS(830), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(757), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [11929] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(832), 1, + sym_integer, + ACTIONS(834), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(479), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12002] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(836), 1, + sym_integer, + ACTIONS(838), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(480), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12075] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(840), 1, + anon_sym_COLON_COLON, + STATE(186), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(769), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(767), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [12126] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(844), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(842), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [12173] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(848), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(846), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [12220] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(852), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(850), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [12267] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(854), 1, + sym_integer, + ACTIONS(856), 1, + sym_float, + STATE(593), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(687), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12340] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(858), 1, + sym_integer, + ACTIONS(860), 1, + sym_float, + STATE(593), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(697), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12413] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(862), 1, + sym_integer, + ACTIONS(864), 1, + sym_float, + STATE(593), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(698), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12486] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(866), 1, + anon_sym_COLON_COLON, + STATE(163), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(763), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(761), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [12537] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(840), 1, + anon_sym_COLON_COLON, + STATE(178), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(779), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(777), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [12588] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(868), 1, + sym_integer, + ACTIONS(870), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(738), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12661] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(872), 1, + sym_integer, + ACTIONS(874), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(753), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12734] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(876), 1, + sym_integer, + ACTIONS(878), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(746), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12807] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(880), 1, + sym_integer, + ACTIONS(882), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(133), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12880] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(884), 1, + sym_integer, + ACTIONS(886), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(747), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [12953] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(888), 1, + sym_integer, + ACTIONS(890), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(551), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13026] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(840), 1, + anon_sym_COLON_COLON, + STATE(186), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(794), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(792), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [13077] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(892), 1, + sym_integer, + ACTIONS(894), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(739), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13150] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(896), 1, + sym_integer, + ACTIONS(898), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(680), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13223] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(900), 1, + sym_integer, + ACTIONS(902), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(486), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13296] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(904), 1, + sym_integer, + ACTIONS(906), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(749), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13369] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(908), 1, + sym_integer, + ACTIONS(910), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(726), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13442] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(912), 1, + sym_integer, + ACTIONS(914), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(515), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13515] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(900), 1, + sym_integer, + ACTIONS(902), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(486), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13588] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(916), 1, + anon_sym_COLON_COLON, + STATE(186), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(783), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(781), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [13639] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(919), 1, + sym_integer, + ACTIONS(921), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(705), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13712] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(923), 1, + sym_integer, + ACTIONS(925), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(684), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13785] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(927), 1, + sym_integer, + ACTIONS(929), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(740), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13858] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(931), 1, + sym_integer, + ACTIONS(933), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(730), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [13931] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(935), 1, + sym_integer, + ACTIONS(937), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(743), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14004] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(939), 1, + sym_integer, + ACTIONS(941), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(728), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14077] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(943), 1, + sym_integer, + ACTIONS(945), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(744), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14150] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(470), 1, + anon_sym_LBRACK, + ACTIONS(472), 1, + anon_sym_LPAREN, + ACTIONS(474), 1, + anon_sym_LBRACE, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(484), 1, + anon_sym_match, + ACTIONS(486), 1, + anon_sym_move, + ACTIONS(488), 1, + anon_sym_DASH, + ACTIONS(496), 1, + anon_sym_DQUOTE, + ACTIONS(947), 1, + sym_integer, + ACTIONS(949), 1, + sym_float, + STATE(593), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(494), 2, + anon_sym_true, + anon_sym_false, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(692), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14223] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(951), 1, + sym_integer, + ACTIONS(953), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(756), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14296] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(955), 1, + sym_integer, + ACTIONS(957), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(741), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14369] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(961), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(959), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [14416] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(963), 1, + sym_integer, + ACTIONS(965), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(541), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14489] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(967), 1, + sym_integer, + ACTIONS(969), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(722), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14562] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(971), 1, + anon_sym_COLON_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(783), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(781), 24, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [14611] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(974), 1, + sym_integer, + ACTIONS(976), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(752), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14684] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(978), 1, + sym_integer, + ACTIONS(980), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(755), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14757] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(982), 1, + sym_integer, + ACTIONS(984), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(748), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14830] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(986), 1, + sym_integer, + ACTIONS(988), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(552), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14903] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(963), 1, + sym_integer, + ACTIONS(965), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(541), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [14976] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(990), 1, + sym_integer, + ACTIONS(992), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(745), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15049] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(81), 1, + anon_sym_move, + ACTIONS(83), 1, + anon_sym_DASH, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(880), 1, + sym_integer, + ACTIONS(882), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(133), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15122] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(994), 1, + sym_integer, + ACTIONS(996), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(750), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15195] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(998), 1, + sym_integer, + ACTIONS(1000), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(737), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15268] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(1002), 1, + sym_integer, + ACTIONS(1004), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(696), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15341] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1008), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1006), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [15388] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(614), 1, + anon_sym_DASH, + ACTIONS(1010), 1, + sym_integer, + ACTIONS(1012), 1, + sym_float, + STATE(550), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(681), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15461] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(49), 1, + anon_sym_LBRACK, + ACTIONS(53), 1, + anon_sym_LPAREN, + ACTIONS(55), 1, + anon_sym_LBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(173), 1, + anon_sym_move, + ACTIONS(175), 1, + anon_sym_DASH, + ACTIONS(345), 1, + anon_sym_match, + ACTIONS(880), 1, + sym_integer, + ACTIONS(882), 1, + sym_float, + STATE(119), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(91), 2, + anon_sym_true, + anon_sym_false, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(133), 17, + sym_record_expression, + sym_method_expression, + sym_field_expression, + sym_array_expression, + sym_index_expression, + sym_match_expression, + sym_closure_expression, + sym_block_expression, + sym__expression, + sym_call_expression, + sym_place, + sym_unary_expression, + sym_binary_expression, + sym_cast_expression, + sym_parenthesized_expression, + sym_boolean, + sym_string, + [15534] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1016), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1014), 33, + anon_sym_POUND, + anon_sym_RBRACK, + anon_sym_COMMA, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [15580] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(656), 1, + anon_sym_LBRACE, + ACTIONS(658), 1, + anon_sym_DOT, + STATE(153), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1018), 3, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(654), 9, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(652), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [15636] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(852), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(850), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [15682] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(848), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(846), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [15728] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1020), 1, + anon_sym_COLON_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(783), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(781), 25, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [15776] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(961), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(959), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [15822] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1025), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1023), 33, + anon_sym_POUND, + anon_sym_RBRACK, + anon_sym_COMMA, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [15868] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1029), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1027), 33, + anon_sym_POUND, + anon_sym_RBRACK, + anon_sym_COMMA, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [15914] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1008), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1006), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [15960] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(844), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(842), 26, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_for, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + [16006] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1033), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1031), 33, + anon_sym_POUND, + anon_sym_RBRACK, + anon_sym_COMMA, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16052] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1037), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1035), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16097] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1041), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1039), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16142] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1045), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1043), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16187] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1049), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1047), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16232] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1053), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1051), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16277] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1057), 1, + anon_sym_POUND, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(230), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(1055), 30, + sym_visibility, + anon_sym_struct, + anon_sym_trait, + anon_sym_fn, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + sym_identifier, + [16324] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1062), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1060), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16369] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1066), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1064), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16414] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1070), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1068), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16459] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1074), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1072), 23, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [16504] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1078), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1076), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16548] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1029), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1027), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16592] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1082), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1080), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16636] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1086), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1084), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16680] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1090), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1088), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16724] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1094), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1092), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16768] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1098), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1096), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16812] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1102), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1100), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16856] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1106), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1104), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16900] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1110), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1108), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16944] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1114), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1112), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [16988] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1118), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1116), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17032] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(1120), 1, + sym_visibility, + ACTIONS(1122), 1, + anon_sym_struct, + ACTIONS(1124), 1, + anon_sym_trait, + ACTIONS(1126), 1, + anon_sym_fn, + ACTIONS(1128), 1, + anon_sym_event, + ACTIONS(1132), 1, + anon_sym_mod, + ACTIONS(1134), 1, + anon_sym_use, + ACTIONS(1136), 1, + anon_sym_const, + ACTIONS(1138), 1, + anon_sym_enum, + ACTIONS(1142), 1, + anon_sym_flow, + ACTIONS(1144), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(230), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(1140), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(1130), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + [17102] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1148), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1146), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17146] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1025), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1023), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17190] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1152), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1150), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17234] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1156), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1154), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17278] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1160), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1158), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17322] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1164), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1162), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17366] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1168), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1166), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17410] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1172), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1170), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17454] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1176), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1174), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17498] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1180), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1178), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17542] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1184), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1182), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17586] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1188), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1186), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17630] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1192), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1190), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17674] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1196), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1194), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17718] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1033), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1031), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17762] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1200), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1198), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17806] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1204), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1202), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17850] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1208), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1206), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17894] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1212), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1210), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17938] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1216), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1214), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [17982] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1220), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1218), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18026] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1224), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1222), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18070] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1228), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1226), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18114] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1232), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1230), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18158] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1236), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1234), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18202] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1240), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1238), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18246] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1244), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1242), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18290] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1248), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1246), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18334] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1252), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1250), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18378] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1256), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1254), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18422] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1260), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1258), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18466] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1264), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1262), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18510] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1268), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1266), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18554] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1272), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1270), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18598] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1276), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1274), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18642] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1280), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1278), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18686] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1284), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1282), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18730] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1288), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1286), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18774] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1292), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1290), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18818] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1296), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1294), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18862] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1300), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1298), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18906] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1304), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1302), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18950] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1308), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1306), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [18994] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1312), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1310), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19038] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1316), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1314), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19082] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1320), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1318), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19126] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1324), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1322), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19170] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1328), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1326), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19214] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1332), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1330), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19258] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1336), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1334), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19302] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1340), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1338), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19346] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1344), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1342), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19390] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1348), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1346), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19434] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1352), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1350), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19478] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(39), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(41), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19522] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1356), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1354), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19566] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1360), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1358), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19610] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1364), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1362), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19654] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1368), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1366), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19698] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1372), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1370), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19742] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1376), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1374), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19786] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1380), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1378), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19830] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1384), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1382), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19874] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1388), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1386), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19918] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1392), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1390), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [19962] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1396), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1394), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20006] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1400), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1398), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20050] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1404), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1402), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20094] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1408), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1406), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20138] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1412), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1410), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20182] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1416), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1414), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20226] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1016), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1014), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20270] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1420), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1418), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20314] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1424), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1422), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20358] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1332), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1330), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20402] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1360), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1358), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20446] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1392), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1390), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20490] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1416), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1414), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20534] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1428), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1426), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20578] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1432), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1430), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20622] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1436), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1434), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20666] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1440), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1438), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20710] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1444), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1442), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20754] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1448), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1446), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20798] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1452), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1450), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20842] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1094), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1092), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20886] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1456), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1454), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20930] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1460), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1458), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [20974] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1148), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1146), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21018] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1152), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1150), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21062] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1180), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1178), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21106] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1252), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1250), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21150] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1284), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1282), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21194] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1078), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1076), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21238] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1304), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1302), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21282] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1328), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1326), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21326] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1336), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1334), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21370] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1340), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1338), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21414] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1344), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1342), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21458] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1396), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1394), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21502] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1400), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1398), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21546] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1404), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1402), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21590] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1464), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1462), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21634] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1420), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1418), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21678] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1468), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1466), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21722] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1456), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1454), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21766] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1460), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1458), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21810] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1464), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1462), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21854] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1472), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1470), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21898] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1476), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1474), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21942] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1480), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1478), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [21986] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1472), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1470), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22030] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1484), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1482), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22074] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1488), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1486), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22118] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1492), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1490), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22162] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1496), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1494), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22206] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1500), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1498), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22250] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1504), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1502), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22294] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1508), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1506), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22338] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1512), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1510), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22382] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1476), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1474), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22426] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1516), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1514), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22470] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1520), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1518), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22514] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1524), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1522), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22558] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1480), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1478), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22602] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1468), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1466), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22646] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1082), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1080), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22690] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1086), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1084), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22734] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1090), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1088), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22778] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1098), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1096), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22822] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1102), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1100), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22866] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1106), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1104), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22910] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1110), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1108), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22954] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1114), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1112), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [22998] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1118), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1116), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23042] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1156), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1154), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23086] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1160), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1158), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23130] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1164), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1162), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23174] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1168), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1166), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23218] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1172), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1170), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23262] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1176), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1174), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23306] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1184), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1182), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23350] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1188), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1186), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23394] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1192), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1190), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23438] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1196), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1194), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23482] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1200), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1198), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23526] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1204), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1202), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23570] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1208), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1206), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23614] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1212), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1210), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23658] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1216), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1214), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23702] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1220), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1218), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23746] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1224), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1222), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23790] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1228), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1226), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23834] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1232), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1230), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23878] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1236), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1234), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23922] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1240), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1238), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [23966] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1244), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1242), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24010] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1256), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1254), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24054] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1260), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1258), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24098] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1264), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1262), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24142] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1268), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1266), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24186] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1272), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1270), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24230] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1276), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1274), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24274] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1280), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1278), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24318] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1288), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1286), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24362] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1292), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1290), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24406] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1296), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1294), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24450] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1018), 4, + anon_sym_LBRACE, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(654), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(652), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [24496] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1300), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1298), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24540] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1308), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1306), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24584] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1312), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1310), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24628] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1316), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1314), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24672] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1320), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1318), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24716] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1324), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1322), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24760] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1348), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1346), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24804] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1352), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1350), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24848] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1356), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1354), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24892] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1428), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1426), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24936] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1364), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1362), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [24980] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1368), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1366), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25024] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1372), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1370), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25068] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1376), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1374), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25112] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1380), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1378), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25156] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1384), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1382), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25200] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1388), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1386), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25244] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1408), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1406), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25288] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1412), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1410), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25332] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1432), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1430), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25376] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1436), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1434), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25420] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1440), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1438), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25464] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1444), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1442), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25508] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1484), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1482), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25552] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1488), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1486), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25596] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1492), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1490), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25640] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1496), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1494), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25684] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1500), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1498), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25728] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1448), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1446), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25772] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1504), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1502), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25816] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1508), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1506), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25860] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1512), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1510), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25904] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(43), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(45), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25948] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1516), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1514), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [25992] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1520), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1518), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [26036] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1524), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1522), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [26080] = 17, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(1526), 1, + sym_visibility, + ACTIONS(1528), 1, + anon_sym_struct, + ACTIONS(1530), 1, + anon_sym_trait, + ACTIONS(1532), 1, + anon_sym_fn, + ACTIONS(1534), 1, + anon_sym_event, + ACTIONS(1538), 1, + anon_sym_mod, + ACTIONS(1540), 1, + anon_sym_use, + ACTIONS(1542), 1, + anon_sym_const, + ACTIONS(1544), 1, + anon_sym_enum, + ACTIONS(1548), 1, + anon_sym_flow, + ACTIONS(1550), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(230), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + ACTIONS(1546), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(1536), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + [26150] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1452), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1450), 31, + ts_builtin_sym_end, + anon_sym_POUND, + sym_visibility, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [26194] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1424), 1, + anon_sym_struct, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1422), 31, + anon_sym_POUND, + sym_visibility, + anon_sym_RBRACE, + anon_sym_trait, + anon_sym_fn, + anon_sym_impl, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + [26238] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1554), 1, + anon_sym_POUND, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1552), 30, + sym_visibility, + anon_sym_struct, + anon_sym_trait, + anon_sym_fn, + anon_sym_event, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + anon_sym_mod, + anon_sym_use, + anon_sym_const, + anon_sym_enum, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + anon_sym_flow, + anon_sym_extern, + sym_identifier, + [26281] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(43), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(45), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [26324] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(39), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(41), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [26367] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1556), 1, + anon_sym_LT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1041), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1039), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26411] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1074), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1072), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26452] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1562), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1560), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1558), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [26495] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1070), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1068), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26536] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1053), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1051), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26577] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1564), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1037), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1035), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [26620] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1066), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1064), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26661] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1037), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1035), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26702] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1049), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1047), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26743] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1062), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1060), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26784] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1568), 1, + anon_sym_BANG, + ACTIONS(1572), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1570), 8, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1566), 19, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [26829] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1041), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1039), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26870] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1578), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1576), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1574), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [26913] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1580), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1070), 10, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1068), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [26956] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1045), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1043), 21, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [26997] = 14, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1122), 1, + anon_sym_struct, + ACTIONS(1124), 1, + anon_sym_trait, + ACTIONS(1126), 1, + anon_sym_fn, + ACTIONS(1128), 1, + anon_sym_event, + ACTIONS(1132), 1, + anon_sym_mod, + ACTIONS(1134), 1, + anon_sym_use, + ACTIONS(1136), 1, + anon_sym_const, + ACTIONS(1138), 1, + anon_sym_enum, + ACTIONS(1142), 1, + anon_sym_flow, + ACTIONS(1144), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1140), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(1130), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + [27057] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1568), 1, + anon_sym_BANG, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1570), 8, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1566), 19, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [27099] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1582), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1576), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1574), 19, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [27141] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1584), 1, + anon_sym_LT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1041), 9, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1039), 18, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [27183] = 14, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1587), 1, + anon_sym_struct, + ACTIONS(1589), 1, + anon_sym_trait, + ACTIONS(1591), 1, + anon_sym_fn, + ACTIONS(1593), 1, + anon_sym_event, + ACTIONS(1597), 1, + anon_sym_mod, + ACTIONS(1599), 1, + anon_sym_use, + ACTIONS(1601), 1, + anon_sym_const, + ACTIONS(1603), 1, + anon_sym_enum, + ACTIONS(1607), 1, + anon_sym_flow, + ACTIONS(1609), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1605), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(1595), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + [27243] = 14, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1528), 1, + anon_sym_struct, + ACTIONS(1530), 1, + anon_sym_trait, + ACTIONS(1532), 1, + anon_sym_fn, + ACTIONS(1534), 1, + anon_sym_event, + ACTIONS(1538), 1, + anon_sym_mod, + ACTIONS(1540), 1, + anon_sym_use, + ACTIONS(1542), 1, + anon_sym_const, + ACTIONS(1544), 1, + anon_sym_enum, + ACTIONS(1548), 1, + anon_sym_flow, + ACTIONS(1550), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1546), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(1536), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + [27303] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1617), 3, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1613), 6, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1611), 16, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [27351] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1613), 9, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1611), 16, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + [27397] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1619), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1070), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1068), 19, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [27439] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1621), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1560), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1558), 19, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [27481] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1623), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1037), 8, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1035), 19, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + anon_sym_GT, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [27523] = 14, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1625), 1, + anon_sym_struct, + ACTIONS(1627), 1, + anon_sym_trait, + ACTIONS(1629), 1, + anon_sym_fn, + ACTIONS(1631), 1, + anon_sym_event, + ACTIONS(1635), 1, + anon_sym_mod, + ACTIONS(1637), 1, + anon_sym_use, + ACTIONS(1639), 1, + anon_sym_const, + ACTIONS(1641), 1, + anon_sym_enum, + ACTIONS(1645), 1, + anon_sym_flow, + ACTIONS(1647), 1, + anon_sym_extern, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1643), 3, + anon_sym_player, + anon_sym_global, + anon_sym_entity, + ACTIONS(1633), 15, + anon_sym_item, + anon_sym_recipe, + anon_sym_tag, + anon_sym_bossbar, + anon_sym_loot, + anon_sym_damage_type, + anon_sym_predicate, + anon_sym_advancement, + anon_sym_dialog, + anon_sym_dimension, + anon_sym_biome, + anon_sym_structure_template, + anon_sym_inventory_transfer, + anon_sym_hud, + anon_sym_menu, + [27583] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1653), 1, + anon_sym_else, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1651), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1649), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27624] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1613), 7, + anon_sym_EQ, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1611), 17, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_if, + anon_sym_priority, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [27669] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1659), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1657), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27707] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1663), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1661), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27745] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1667), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1665), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27783] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1671), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1669), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27821] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1675), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1673), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27859] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1679), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1677), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27897] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1683), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1681), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27935] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1687), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1685), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [27973] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1691), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1689), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28011] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1695), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1693), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28049] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1699), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1697), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28087] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1703), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1701), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28125] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1707), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1705), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28163] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(656), 1, + anon_sym_LBRACE, + ACTIONS(1709), 1, + anon_sym_DOT, + STATE(153), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(654), 3, + anon_sym_LT, + anon_sym_GT, + anon_sym_SLASH, + ACTIONS(1018), 8, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(652), 11, + anon_sym_LBRACK, + anon_sym_as, + anon_sym_in, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [28211] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1714), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1712), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28249] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1718), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1716), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28287] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1722), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1720), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28325] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1726), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1724), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28363] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1730), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1728), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28401] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1734), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1732), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28439] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1738), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1736), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28477] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1742), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1740), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28515] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1746), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1744), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28553] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1750), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1748), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28591] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1754), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1752), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28629] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1758), 8, + anon_sym_LBRACK, + anon_sym_BANG, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1756), 18, + anon_sym_for, + anon_sym_self, + anon_sym_if, + anon_sym_let, + anon_sym_return, + anon_sym_continue, + anon_sym_break, + anon_sym_emit, + anon_sym_loop, + anon_sym_match, + anon_sym_while, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [28667] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1760), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1018), 2, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(654), 8, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(652), 14, + anon_sym_LBRACK, + anon_sym_RBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [28708] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1762), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1570), 5, + anon_sym_DOT, + anon_sym_LT, + anon_sym_GT, + anon_sym_DOT_DOT, + anon_sym_SLASH, + ACTIONS(1566), 19, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_in, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DOT_DOT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [28747] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1613), 3, + anon_sym_DOT_DOT, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1764), 3, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1611), 15, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_EQ, + anon_sym_RBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + anon_sym_if, + anon_sym_priority, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_DOT_DOT_EQ, + [28791] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(654), 3, + anon_sym_LT, + anon_sym_GT, + anon_sym_SLASH, + ACTIONS(1018), 8, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(652), 12, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_in, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [28828] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1766), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(654), 8, + anon_sym_EQ, + anon_sym_LT, + anon_sym_GT, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(652), 14, + anon_sym_LBRACK, + anon_sym_RBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_in, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [28865] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1768), 1, + anon_sym_EQ, + ACTIONS(1770), 1, + anon_sym_RBRACE, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1776), 1, + anon_sym_in, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1774), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1782), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1617), 3, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1780), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + ACTIONS(1778), 5, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + [28917] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1617), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1776), 1, + anon_sym_in, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1774), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1784), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1786), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1780), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + ACTIONS(1770), 5, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + [28965] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(1709), 1, + anon_sym_DOT, + ACTIONS(1788), 1, + anon_sym_LBRACE, + STATE(153), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1018), 2, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(654), 3, + anon_sym_LT, + anon_sym_GT, + anon_sym_SLASH, + ACTIONS(652), 11, + anon_sym_LBRACK, + anon_sym_as, + anon_sym_in, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29007] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1795), 1, + anon_sym_COMMA, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1793), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1791), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29040] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1797), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1070), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1068), 16, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_DOT, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29073] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1799), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1560), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1558), 16, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_DOT, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29106] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1801), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1576), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1574), 16, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_DOT, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29139] = 14, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1617), 1, + anon_sym_SLASH, + ACTIONS(1776), 1, + anon_sym_in, + ACTIONS(1803), 1, + anon_sym_DOT_DOT, + ACTIONS(1805), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1770), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + ACTIONS(1774), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1784), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1786), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1780), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [29190] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1807), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1037), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1035), 16, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_DOT, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29223] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1041), 1, + anon_sym_SLASH, + ACTIONS(1809), 1, + anon_sym_LT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1039), 17, + anon_sym_LBRACK, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_DOT, + anon_sym_as, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29256] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1813), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1811), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29287] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1819), 1, + anon_sym_COMMA, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1817), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1815), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29320] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1823), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1821), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29351] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1829), 1, + anon_sym_COMMA, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1827), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1825), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29384] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1833), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1831), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29415] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1837), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1835), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29446] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1843), 1, + anon_sym_COMMA, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1841), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1839), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29479] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1847), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1845), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29510] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1851), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1849), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29541] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1855), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1853), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29572] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1859), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1857), 12, + anon_sym_self, + anon_sym_enter, + anon_sym_exit, + anon_sym_tick, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29603] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1617), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1776), 1, + anon_sym_in, + ACTIONS(1861), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1770), 2, + anon_sym_RBRACK, + anon_sym_COMMA, + ACTIONS(1774), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1784), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1786), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1780), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [29651] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1865), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1863), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29681] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1613), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1611), 14, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29717] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1871), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1869), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29747] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1875), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1873), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29777] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1879), 7, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_DASH, + sym_float, + anon_sym_DQUOTE, + ACTIONS(1877), 11, + anon_sym_self, + anon_sym_let, + anon_sym__, + anon_sym_match, + anon_sym_move, + sym_crate, + sym_super, + sym_integer, + anon_sym_true, + anon_sym_false, + sym_identifier, + [29807] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1617), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1776), 1, + anon_sym_in, + ACTIONS(1881), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1770), 2, + anon_sym_RBRACK, + anon_sym_COMMA, + ACTIONS(1774), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1784), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1786), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1780), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [29855] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(1887), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1883), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1885), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(389), 9, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [29894] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(783), 1, + anon_sym_SLASH, + ACTIONS(1889), 1, + anon_sym_COLON_COLON, + STATE(547), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(781), 14, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29927] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(1887), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1883), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1885), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1892), 9, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [29966] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(794), 1, + anon_sym_SLASH, + ACTIONS(1894), 1, + anon_sym_COLON_COLON, + STATE(547), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(792), 14, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [29999] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(658), 1, + anon_sym_DOT, + ACTIONS(1896), 1, + anon_sym_LBRACE, + STATE(153), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(654), 2, + anon_sym_DOT_DOT, + anon_sym_SLASH, + ACTIONS(652), 11, + anon_sym_LBRACK, + anon_sym_as, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DOT_DOT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30036] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(1887), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1883), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1885), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1899), 9, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [30075] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(1887), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1885), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1611), 11, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DASH, + anon_sym_PLUS, + [30112] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(763), 1, + anon_sym_SLASH, + ACTIONS(1901), 1, + anon_sym_COLON_COLON, + STATE(554), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(761), 14, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30145] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(769), 1, + anon_sym_SLASH, + ACTIONS(1894), 1, + anon_sym_COLON_COLON, + STATE(547), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(767), 14, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30178] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(779), 1, + anon_sym_SLASH, + ACTIONS(1894), 1, + anon_sym_COLON_COLON, + STATE(549), 1, + aux_sym_path_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(777), 14, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30211] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1903), 1, + sym_identifier, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1907), 1, + anon_sym_RBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1911), 1, + anon_sym__, + STATE(1362), 1, + sym_path, + STATE(1408), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1192), 4, + sym__value_pattern, + sym_binding_pattern, + sym_record_pattern, + sym_array_pattern, + [30257] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1008), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1006), 15, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30285] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(848), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(846), 15, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30313] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1903), 1, + sym_identifier, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1913), 1, + anon_sym_RBRACK, + ACTIONS(1915), 1, + anon_sym__, + STATE(1362), 1, + sym_path, + STATE(1408), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1201), 4, + sym__value_pattern, + sym_binding_pattern, + sym_record_pattern, + sym_array_pattern, + [30359] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1903), 1, + sym_identifier, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1915), 1, + anon_sym__, + ACTIONS(1917), 1, + anon_sym_RBRACK, + STATE(1362), 1, + sym_path, + STATE(1408), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1201), 4, + sym__value_pattern, + sym_binding_pattern, + sym_record_pattern, + sym_array_pattern, + [30405] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(844), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(842), 15, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30433] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(783), 1, + anon_sym_SLASH, + ACTIONS(1919), 1, + anon_sym_COLON_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(781), 14, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30463] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(961), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(959), 15, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30491] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(852), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(850), 15, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_LBRACE, + anon_sym_DOT, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_LT, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30519] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1922), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1570), 3, + anon_sym_DOT, + anon_sym_DOT_DOT, + anon_sym_SLASH, + ACTIONS(1566), 12, + anon_sym_LBRACK, + anon_sym_LPAREN, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_COLON_COLON, + anon_sym_as, + anon_sym_DOT_DOT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30549] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1760), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(654), 5, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(652), 9, + anon_sym_LBRACK, + anon_sym_EQ, + anon_sym_DOT, + anon_sym_as, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + [30578] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1617), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1926), 1, + anon_sym_in, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1784), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1786), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1924), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1928), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [30619] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1903), 1, + sym_identifier, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1930), 1, + anon_sym__, + STATE(1362), 1, + sym_path, + STATE(1408), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1253), 4, + sym__value_pattern, + sym_binding_pattern, + sym_record_pattern, + sym_array_pattern, + [30662] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1903), 1, + sym_identifier, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1932), 1, + anon_sym__, + STATE(1362), 1, + sym_path, + STATE(1408), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1245), 4, + sym__value_pattern, + sym_binding_pattern, + sym_record_pattern, + sym_array_pattern, + [30705] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1615), 1, + anon_sym_as, + ACTIONS(1617), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1776), 1, + anon_sym_in, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1774), 2, + anon_sym_LT, + anon_sym_GT, + ACTIONS(1784), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1786), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1780), 4, + anon_sym_EQ_EQ, + anon_sym_BANG_EQ, + anon_sym_LT_EQ, + anon_sym_GT_EQ, + [30746] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1903), 1, + sym_identifier, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1915), 1, + anon_sym__, + STATE(1362), 1, + sym_path, + STATE(1408), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1201), 4, + sym__value_pattern, + sym_binding_pattern, + sym_record_pattern, + sym_array_pattern, + [30789] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1936), 1, + anon_sym_RPAREN, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [30829] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1940), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1100), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [30869] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1942), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1155), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [30909] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1944), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [30949] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(604), 1, + anon_sym_SLASH, + ACTIONS(1946), 1, + anon_sym_LPAREN, + ACTIONS(1948), 1, + anon_sym_COLON_COLON, + STATE(711), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(600), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [30981] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1950), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31021] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1952), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31061] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1954), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31101] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1956), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31141] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1958), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31181] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1960), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31221] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1962), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1170), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31261] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1964), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31301] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1966), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31341] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1968), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31381] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1970), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31421] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1972), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31461] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1974), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31501] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1976), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31541] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1978), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31581] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1980), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(1764), 3, + anon_sym_STAR, + anon_sym_SLASH, + anon_sym_PERCENT, + ACTIONS(1778), 6, + anon_sym_EQ, + anon_sym_PLUS_EQ, + anon_sym_DASH_EQ, + anon_sym_STAR_EQ, + anon_sym_SLASH_EQ, + anon_sym_PERCENT_EQ, + [31615] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(654), 1, + anon_sym_SLASH, + ACTIONS(1946), 1, + anon_sym_LPAREN, + ACTIONS(1982), 1, + anon_sym_LBRACE, + ACTIONS(1984), 1, + anon_sym_DOT, + STATE(689), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(652), 9, + anon_sym_LBRACK, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [31649] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1987), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31689] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1989), 1, + anon_sym_RPAREN, + STATE(458), 1, + sym_path, + STATE(1085), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31729] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + ACTIONS(1991), 1, + anon_sym_GT, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31769] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1300), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31806] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(1995), 1, + anon_sym_fn, + STATE(233), 1, + sym_type, + STATE(476), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31843] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1345), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31880] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(465), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31917] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1020), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31954] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1494), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [31991] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1553), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32028] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(1995), 1, + anon_sym_fn, + STATE(225), 1, + sym_type, + STATE(476), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32065] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1033), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32102] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1235), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32139] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(1995), 1, + anon_sym_fn, + STATE(227), 1, + sym_type, + STATE(476), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32176] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1036), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32213] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1363), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32250] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(1995), 1, + anon_sym_fn, + STATE(229), 1, + sym_type, + STATE(476), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32287] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1242), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32324] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1088), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32361] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1223), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32398] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1092), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32435] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(715), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32472] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(461), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32509] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1036), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32546] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1282), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32583] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(465), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32620] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(472), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32657] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(462), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32694] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1246), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32731] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1905), 1, + anon_sym_LBRACK, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(1999), 1, + sym_identifier, + ACTIONS(2001), 1, + anon_sym__, + STATE(1359), 1, + sym_mutable_specifier, + STATE(1362), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(177), 2, + sym_crate, + sym_super, + STATE(170), 2, + sym__path_segment, + sym_self, + STATE(1251), 2, + sym_record_pattern, + sym_array_pattern, + [32772] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(147), 1, + sym_type, + STATE(458), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32809] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1481), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32846] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(2007), 1, + anon_sym_as, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2011), 1, + anon_sym_EQ_GT, + ACTIONS(2013), 1, + anon_sym_PIPE, + ACTIONS(2019), 1, + anon_sym_SLASH, + STATE(925), 1, + aux_sym_match_value_arm_repeat1, + STATE(1369), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2015), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2017), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [32889] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1264), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32926] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(2021), 1, + anon_sym_fn, + STATE(147), 1, + sym_type, + STATE(527), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [32963] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1301), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33000] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1200), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33037] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2023), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1560), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1558), 10, + anon_sym_LBRACK, + anon_sym_COMMA, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [33064] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1006), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33101] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(2007), 1, + anon_sym_as, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2013), 1, + anon_sym_PIPE, + ACTIONS(2019), 1, + anon_sym_SLASH, + ACTIONS(2025), 1, + anon_sym_EQ_GT, + STATE(906), 1, + aux_sym_match_value_arm_repeat1, + STATE(1364), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2015), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2017), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [33144] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1185), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33181] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(472), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33218] = 13, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(2007), 1, + anon_sym_as, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2013), 1, + anon_sym_PIPE, + ACTIONS(2019), 1, + anon_sym_SLASH, + ACTIONS(2027), 1, + anon_sym_EQ_GT, + STATE(908), 1, + aux_sym_match_value_arm_repeat1, + STATE(1315), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2015), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2017), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [33261] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(2021), 1, + anon_sym_fn, + STATE(233), 1, + sym_type, + STATE(527), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33298] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2029), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1576), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1574), 10, + anon_sym_LBRACK, + anon_sym_COMMA, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [33325] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(1995), 1, + anon_sym_fn, + STATE(147), 1, + sym_type, + STATE(476), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(145), 2, + sym__path_segment, + sym_self, + ACTIONS(85), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33362] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1191), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33399] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2031), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1070), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1068), 10, + anon_sym_LBRACK, + anon_sym_COMMA, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [33426] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(2021), 1, + anon_sym_fn, + STATE(225), 1, + sym_type, + STATE(527), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33463] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(2021), 1, + anon_sym_fn, + STATE(227), 1, + sym_type, + STATE(527), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33500] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2033), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1037), 2, + anon_sym_DASH, + anon_sym_SLASH, + ACTIONS(1035), 10, + anon_sym_LBRACK, + anon_sym_COMMA, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [33527] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1993), 1, + anon_sym_LBRACK, + ACTIONS(2021), 1, + anon_sym_fn, + STATE(229), 1, + sym_type, + STATE(527), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(226), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33564] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(461), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33601] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1997), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1191), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(553), 2, + sym__path_segment, + sym_self, + ACTIONS(468), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33638] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1214), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33675] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1352), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33712] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1065), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33749] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1194), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33786] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1202), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33823] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1204), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33860] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1217), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33897] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1215), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33934] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1218), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [33971] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1101), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34008] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1224), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34045] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1212), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34082] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1232), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34119] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1240), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34156] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1250), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34193] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1254), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34230] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1313), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34267] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1259), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34304] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1260), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34341] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1150), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34378] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1198), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34415] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(462), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34452] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1266), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34489] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1295), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34526] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1297), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34563] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1298), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34600] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1299), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34637] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1205), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34674] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1523), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34711] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1528), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34748] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1530), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34785] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(1934), 1, + anon_sym_LBRACK, + ACTIONS(1938), 1, + anon_sym_fn, + STATE(458), 1, + sym_path, + STATE(1535), 1, + sym_type, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + STATE(469), 3, + sym_function_type, + sym_applied_type, + sym_array_type, + [34822] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1613), 1, + anon_sym_DOT_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1611), 6, + anon_sym_LBRACE, + anon_sym_every, + anon_sym_EQ_GT, + anon_sym_DOT_DOT_EQ, + anon_sym_DASH, + anon_sym_PLUS, + [34857] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2041), 1, + anon_sym_every, + ACTIONS(2043), 1, + anon_sym_EQ_GT, + STATE(533), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [34897] = 12, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2047), 1, + anon_sym_DOT_DOT, + ACTIONS(2049), 1, + anon_sym_DOT_DOT_EQ, + STATE(512), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [34937] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1803), 1, + anon_sym_DOT_DOT, + ACTIONS(1805), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2051), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [34975] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(2061), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2057), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2059), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1899), 3, + anon_sym_LBRACE, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [35008] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(735), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(733), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35031] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(755), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(753), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35054] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(713), 1, + anon_sym_SLASH, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(711), 8, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35081] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(675), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(673), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35104] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(802), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(800), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35127] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(818), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(816), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35150] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(642), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(640), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35173] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(2007), 1, + anon_sym_as, + ACTIONS(2019), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2015), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2017), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2063), 3, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + [35206] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(743), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(741), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35229] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(759), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(757), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35252] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(2061), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2057), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2059), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1892), 3, + anon_sym_LBRACE, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [35285] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(2061), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2059), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1611), 5, + anon_sym_LBRACE, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + anon_sym_DASH, + anon_sym_PLUS, + [35316] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(2007), 1, + anon_sym_as, + ACTIONS(2019), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2017), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(1611), 5, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + [35347] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1613), 1, + anon_sym_SLASH, + ACTIONS(2003), 1, + anon_sym_LBRACK, + ACTIONS(2005), 1, + anon_sym_DOT, + ACTIONS(2007), 1, + anon_sym_as, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1611), 7, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35376] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(790), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(788), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35399] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(806), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(804), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35422] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(822), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(820), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35445] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(703), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(701), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35468] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(707), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(705), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35491] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(719), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(717), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35514] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2065), 1, + anon_sym_EQ_GT, + STATE(536), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [35551] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(679), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(677), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35574] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(731), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(729), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35597] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(739), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(737), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35620] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(747), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(745), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35643] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(826), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(824), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35666] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(751), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(749), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35689] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(810), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(808), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35712] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(695), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(693), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35735] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1867), 1, + anon_sym_as, + ACTIONS(2061), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2057), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2059), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(389), 3, + anon_sym_LBRACE, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [35768] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(775), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(773), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35791] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(814), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(812), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35814] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(683), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(681), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35837] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(798), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(796), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35860] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(687), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(685), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35883] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(691), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(689), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35906] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(699), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(697), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35929] = 11, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2067), 1, + anon_sym_SEMI, + ACTIONS(2069), 1, + anon_sym_if, + ACTIONS(2071), 1, + anon_sym_priority, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [35966] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(727), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(725), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [35989] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(723), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(721), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [36012] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(630), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(628), 10, + anon_sym_LBRACK, + anon_sym_DOT, + anon_sym_as, + anon_sym_if, + anon_sym_EQ_GT, + anon_sym_PIPE, + anon_sym_DASH, + anon_sym_PLUS, + anon_sym_STAR, + anon_sym_PERCENT, + [36035] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2073), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [36067] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(2075), 1, + anon_sym_DOT_DOT, + ACTIONS(2077), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36101] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2079), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [36133] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2081), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [36165] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2083), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [36197] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(389), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36229] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2085), 10, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [36249] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2087), 10, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [36269] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1892), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36301] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(715), 1, + anon_sym_DOT, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(2089), 1, + anon_sym_DOT_DOT, + ACTIONS(2091), 1, + anon_sym_DOT_DOT_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36335] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2093), 10, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_LBRACE, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + [36355] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2095), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [36387] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(2097), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [36418] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1892), 1, + anon_sym_LBRACE, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [36449] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2099), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36480] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2101), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36511] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2103), 1, + anon_sym_LT, + STATE(858), 1, + sym_generic_parameters, + STATE(956), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [36540] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2105), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36571] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2107), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36602] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2109), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36633] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(389), 1, + anon_sym_LBRACE, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [36664] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(2111), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [36695] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2037), 1, + anon_sym_SLASH, + ACTIONS(2113), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2035), 2, + anon_sym_STAR, + anon_sym_PERCENT, + ACTIONS(2045), 2, + anon_sym_DASH, + anon_sym_PLUS, + [36726] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2115), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36757] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2117), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36788] = 10, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(1980), 1, + anon_sym_DASH, + ACTIONS(2053), 1, + anon_sym_PLUS, + ACTIONS(2119), 1, + anon_sym_DASH_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36821] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2121), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36852] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2123), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36883] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2103), 1, + anon_sym_LT, + STATE(882), 1, + sym_generic_parameters, + STATE(941), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [36912] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2125), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36943] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2127), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [36974] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(709), 1, + anon_sym_LBRACK, + ACTIONS(1655), 1, + anon_sym_as, + ACTIONS(1764), 1, + anon_sym_SLASH, + ACTIONS(1772), 1, + anon_sym_DOT, + ACTIONS(2129), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2053), 2, + anon_sym_DASH, + anon_sym_PLUS, + ACTIONS(2055), 2, + anon_sym_STAR, + anon_sym_PERCENT, + [37005] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1436), 1, + sym_path, + STATE(1467), 1, + sym_place, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [37031] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2133), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37059] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2135), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37087] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2133), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(760), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37115] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2137), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(772), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37143] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2139), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(783), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37171] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2141), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37199] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2141), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(781), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37227] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2143), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37255] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2145), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37283] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2145), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(791), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37311] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2147), 1, + anon_sym_POUND, + ACTIONS(2150), 1, + sym_visibility, + ACTIONS(2153), 1, + anon_sym_RBRACE, + ACTIONS(2155), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37339] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(2160), 1, + anon_sym_LT, + STATE(555), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(562), 2, + sym__path_segment, + sym_self, + ACTIONS(2158), 3, + sym_crate, + sym_super, + sym_identifier, + [37365] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2162), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(773), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37393] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2164), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37421] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2166), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37449] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2168), 1, + sym_identifier, + ACTIONS(2170), 1, + anon_sym_RPAREN, + ACTIONS(2172), 1, + anon_sym_AMP, + ACTIONS(2174), 1, + anon_sym_mut, + ACTIONS(2176), 1, + anon_sym_self, + STATE(1482), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(1237), 2, + sym_receiver, + sym_parameter, + [37479] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2168), 1, + sym_identifier, + ACTIONS(2172), 1, + anon_sym_AMP, + ACTIONS(2174), 1, + anon_sym_mut, + ACTIONS(2176), 1, + anon_sym_self, + ACTIONS(2178), 1, + anon_sym_RPAREN, + STATE(1482), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(981), 2, + sym_receiver, + sym_parameter, + [37509] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2180), 1, + sym_integer, + STATE(1573), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [37535] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2182), 1, + anon_sym_AMP_AMP, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2087), 7, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_priority, + anon_sym_PIPE_PIPE, + [37555] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2184), 1, + sym_integer, + STATE(1331), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [37581] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2186), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37609] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1436), 1, + sym_path, + STATE(1520), 1, + sym_place, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [37635] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2188), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37663] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2190), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(767), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37691] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2192), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37719] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2192), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(800), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37747] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2194), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(802), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37775] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2198), 1, + anon_sym_RBRACE, + STATE(1244), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [37801] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2202), 1, + anon_sym_LBRACE, + STATE(979), 1, + sym_use_group, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(930), 2, + sym__path_segment, + sym_self, + ACTIONS(2200), 3, + sym_crate, + sym_super, + sym_identifier, + [37827] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2204), 1, + sym_integer, + STATE(1449), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [37853] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2206), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(779), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37881] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2210), 1, + anon_sym_LT, + STATE(171), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(218), 2, + sym__path_segment, + sym_self, + ACTIONS(2208), 3, + sym_crate, + sym_super, + sym_identifier, + [37907] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2212), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37935] = 9, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2168), 1, + sym_identifier, + ACTIONS(2172), 1, + anon_sym_AMP, + ACTIONS(2174), 1, + anon_sym_mut, + ACTIONS(2176), 1, + anon_sym_self, + ACTIONS(2214), 1, + anon_sym_RPAREN, + STATE(1482), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(1237), 2, + sym_receiver, + sym_parameter, + [37965] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2216), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(759), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [37993] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1412), 1, + sym_place, + STATE(1436), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38019] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2218), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38047] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2220), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(764), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38075] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1431), 1, + sym_place, + STATE(1436), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38101] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1436), 1, + sym_path, + STATE(1439), 1, + sym_place, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38127] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2202), 1, + anon_sym_LBRACE, + STATE(1018), 1, + sym_use_group, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(930), 2, + sym__path_segment, + sym_self, + ACTIONS(2200), 3, + sym_crate, + sym_super, + sym_identifier, + [38153] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2222), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38181] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2224), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(810), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38209] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2226), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38237] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2226), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(766), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38265] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2228), 1, + sym_integer, + STATE(1335), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38291] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2230), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38319] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(2234), 1, + anon_sym_LT, + STATE(148), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(200), 2, + sym__path_segment, + sym_self, + ACTIONS(2232), 3, + sym_crate, + sym_super, + sym_identifier, + [38345] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2166), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(795), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38373] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1366), 1, + sym_place, + STATE(1436), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38399] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2236), 1, + anon_sym_RBRACE, + STATE(1244), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [38425] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2137), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(769), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38453] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(2238), 1, + anon_sym_RBRACE, + STATE(978), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [38479] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(248), 1, + anon_sym_fn, + ACTIONS(2131), 1, + sym_visibility, + ACTIONS(2186), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(805), 2, + sym_function_item, + aux_sym_impl_item_repeat1, + STATE(905), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38507] = 6, + ACTIONS(2240), 1, + anon_sym_DQUOTE2, + ACTIONS(2242), 1, + sym_string_content, + ACTIONS(2246), 1, + anon_sym_LBRACE2, + ACTIONS(2244), 2, + sym_escape_sequence, + sym_brace_escape, + STATE(865), 2, + sym_interpolation, + aux_sym_string_repeat1, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + [38530] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2252), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38557] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2254), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38584] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2256), 1, + anon_sym_RBRACE, + STATE(1002), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38611] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2258), 1, + anon_sym_RBRACE, + STATE(997), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38638] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2260), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38665] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2262), 1, + anon_sym_RBRACE, + STATE(1128), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38692] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2264), 1, + anon_sym_RBRACE, + STATE(1131), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38719] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1050), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38742] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2268), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2266), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [38761] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2270), 1, + anon_sym_RBRACE, + STATE(971), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38788] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(969), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [38811] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2274), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2272), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [38830] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2276), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38857] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2278), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38884] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2280), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38911] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2282), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38938] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2284), 1, + anon_sym_RBRACE, + STATE(1124), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38965] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2286), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [38992] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2288), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39019] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2290), 1, + anon_sym_RBRACE, + STATE(988), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39046] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2294), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2292), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [39065] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2296), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39092] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2298), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39119] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1187), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [39142] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2302), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2300), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [39161] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2304), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39188] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2308), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2306), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [39207] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2310), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39234] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2312), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39261] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2314), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39288] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2316), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39315] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2318), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39342] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2320), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39369] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1003), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [39392] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2322), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39419] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2324), 1, + anon_sym_RBRACE, + STATE(1091), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39446] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2328), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2326), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [39465] = 6, + ACTIONS(2330), 1, + anon_sym_DQUOTE2, + ACTIONS(2332), 1, + sym_string_content, + ACTIONS(2338), 1, + anon_sym_LBRACE2, + ACTIONS(2335), 2, + sym_escape_sequence, + sym_brace_escape, + STATE(851), 2, + sym_interpolation, + aux_sym_string_repeat1, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + [39488] = 6, + ACTIONS(2246), 1, + anon_sym_LBRACE2, + ACTIONS(2341), 1, + anon_sym_DQUOTE2, + ACTIONS(2343), 1, + sym_string_content, + ACTIONS(2345), 2, + sym_escape_sequence, + sym_brace_escape, + STATE(860), 2, + sym_interpolation, + aux_sym_string_repeat1, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + [39511] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1244), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39534] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1416), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39557] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1459), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39580] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1538), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39603] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1381), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [39626] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(955), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [39649] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2347), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39676] = 6, + ACTIONS(2246), 1, + anon_sym_LBRACE2, + ACTIONS(2349), 1, + anon_sym_DQUOTE2, + ACTIONS(2351), 1, + sym_string_content, + ACTIONS(2353), 2, + sym_escape_sequence, + sym_brace_escape, + STATE(851), 2, + sym_interpolation, + aux_sym_string_repeat1, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + [39699] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2355), 1, + anon_sym_RBRACE, + STATE(1023), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39726] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1455), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39749] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2357), 1, + anon_sym_RBRACE, + STATE(1061), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39776] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2361), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2359), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [39795] = 6, + ACTIONS(2246), 1, + anon_sym_LBRACE2, + ACTIONS(2351), 1, + sym_string_content, + ACTIONS(2363), 1, + anon_sym_DQUOTE2, + ACTIONS(2353), 2, + sym_escape_sequence, + sym_brace_escape, + STATE(851), 2, + sym_interpolation, + aux_sym_string_repeat1, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + [39818] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2365), 1, + anon_sym_RBRACE, + STATE(1071), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39845] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2367), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39872] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2369), 1, + anon_sym_RBRACE, + STATE(1076), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39899] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2371), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39926] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2373), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [39953] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1448), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39976] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1374), 1, + sym_use_tree, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(899), 2, + sym__path_segment, + sym_self, + ACTIONS(2196), 3, + sym_crate, + sym_super, + sym_identifier, + [39999] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2375), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40026] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2377), 1, + anon_sym_RBRACE, + STATE(1083), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40053] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2168), 1, + sym_identifier, + ACTIONS(2172), 1, + anon_sym_AMP, + ACTIONS(2174), 1, + anon_sym_mut, + ACTIONS(2176), 1, + anon_sym_self, + STATE(1482), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(1237), 2, + sym_receiver, + sym_parameter, + [40080] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1021), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [40103] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2379), 1, + anon_sym_RBRACE, + STATE(1094), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40130] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1440), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [40153] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2381), 1, + anon_sym_RBRACE, + STATE(1097), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40180] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2383), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40207] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2387), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2385), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [40226] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(949), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [40249] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1018), 2, + anon_sym_PIPE_PIPE, + anon_sym_AMP_AMP, + ACTIONS(1770), 5, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_RBRACE, + anon_sym_SEMI, + [40268] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1165), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [40291] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2391), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2389), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [40310] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + STATE(1167), 1, + sym_path, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(170), 2, + sym__path_segment, + sym_self, + ACTIONS(177), 3, + sym_crate, + sym_super, + sym_identifier, + [40333] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2393), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40360] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2395), 1, + anon_sym_RBRACE, + STATE(1032), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40387] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2397), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40414] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2399), 1, + anon_sym_RBRACE, + STATE(1107), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40441] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2401), 1, + anon_sym_RBRACE, + STATE(1140), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40468] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2403), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40495] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2405), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40522] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2409), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2407), 6, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_COLON, + anon_sym_if, + anon_sym_EQ_GT, + [40541] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1566), 2, + anon_sym_LBRACE, + anon_sym_COLON_COLON, + ACTIONS(2411), 5, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_if, + anon_sym_EQ_GT, + [40560] = 8, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + ACTIONS(2413), 1, + anon_sym_RBRACE, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40587] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(930), 2, + sym__path_segment, + sym_self, + ACTIONS(2200), 3, + sym_crate, + sym_super, + sym_identifier, + [40607] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2248), 1, + sym_identifier, + ACTIONS(2250), 1, + sym_visibility, + STATE(1230), 1, + sym_field_declaration, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(928), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40631] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2417), 1, + anon_sym_COLON_COLON, + ACTIONS(2419), 1, + anon_sym_as, + STATE(904), 1, + aux_sym_use_tree_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2415), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [40653] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(171), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(218), 2, + sym__path_segment, + sym_self, + ACTIONS(2208), 3, + sym_crate, + sym_super, + sym_identifier, + [40673] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(61), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(200), 2, + sym__path_segment, + sym_self, + ACTIONS(2232), 3, + sym_crate, + sym_super, + sym_identifier, + [40693] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2423), 1, + anon_sym_COLON_COLON, + STATE(902), 1, + aux_sym_use_tree_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2421), 4, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_as, + [40713] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(478), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(562), 2, + sym__path_segment, + sym_self, + ACTIONS(2158), 3, + sym_crate, + sym_super, + sym_identifier, + [40733] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2428), 1, + anon_sym_COLON_COLON, + ACTIONS(2430), 1, + anon_sym_as, + STATE(902), 1, + aux_sym_use_tree_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2426), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [40755] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(1532), 1, + anon_sym_fn, + ACTIONS(2432), 1, + sym_visibility, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(230), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [40776] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2013), 1, + anon_sym_PIPE, + ACTIONS(2434), 1, + anon_sym_EQ_GT, + STATE(946), 1, + aux_sym_match_value_arm_repeat1, + STATE(1437), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40799] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + ACTIONS(2438), 1, + anon_sym_RBRACE, + STATE(1219), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40822] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2013), 1, + anon_sym_PIPE, + ACTIONS(2440), 1, + anon_sym_EQ_GT, + STATE(946), 1, + aux_sym_match_value_arm_repeat1, + STATE(1361), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40845] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2444), 1, + anon_sym_PIPE, + STATE(1173), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40868] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2448), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2446), 4, + anon_sym_self, + sym_crate, + sym_super, + sym_identifier, + [40885] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(57), 1, + anon_sym_RBRACE, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + STATE(1066), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40908] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2450), 1, + anon_sym_PIPE, + STATE(1164), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40931] = 3, + ACTIONS(2454), 2, + sym_string_content, + anon_sym_LBRACE2, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + ACTIONS(2452), 3, + anon_sym_DQUOTE2, + sym_escape_sequence, + sym_brace_escape, + [40946] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2456), 1, + anon_sym_PIPE, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40969] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + ACTIONS(2458), 1, + anon_sym_RBRACE, + STATE(1219), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [40992] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2462), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2460), 4, + anon_sym_self, + sym_crate, + sym_super, + sym_identifier, + [41009] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2464), 1, + anon_sym_PIPE, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41032] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2466), 1, + anon_sym_PIPE, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41055] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2468), 1, + anon_sym_PIPE, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41078] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2470), 1, + anon_sym_EQ, + ACTIONS(2472), 1, + anon_sym_SEMI, + ACTIONS(2474), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(1566), 2, + anon_sym_LBRACE, + anon_sym_COLON_COLON, + [41099] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2476), 5, + anon_sym_RBRACK, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_if, + anon_sym_EQ_GT, + [41114] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + ACTIONS(2478), 1, + anon_sym_RBRACE, + STATE(1219), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41137] = 3, + ACTIONS(2482), 2, + sym_string_content, + anon_sym_LBRACE2, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + ACTIONS(2480), 3, + anon_sym_DQUOTE2, + sym_escape_sequence, + sym_brace_escape, + [41152] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2486), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2484), 4, + anon_sym_self, + sym_crate, + sym_super, + sym_identifier, + [41169] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2013), 1, + anon_sym_PIPE, + ACTIONS(2488), 1, + anon_sym_EQ_GT, + STATE(946), 1, + aux_sym_match_value_arm_repeat1, + STATE(1492), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41192] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + ACTIONS(2490), 1, + anon_sym_RBRACE, + STATE(1219), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41215] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2492), 1, + anon_sym_PIPE, + STATE(1188), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41238] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(238), 1, + anon_sym_POUND, + ACTIONS(2494), 1, + sym_identifier, + ACTIONS(2496), 1, + sym_visibility, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(230), 2, + sym_attribute, + aux_sym_struct_item_repeat1, + [41259] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2498), 1, + anon_sym_PIPE, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41282] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2421), 5, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + anon_sym_COLON_COLON, + anon_sym_as, + [41297] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + ACTIONS(2500), 1, + anon_sym_PIPE, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41320] = 7, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + ACTIONS(2502), 1, + anon_sym_RBRACE, + STATE(1012), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41343] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2504), 1, + anon_sym_RBRACE, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41361] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2508), 1, + sym_identifier, + ACTIONS(2510), 1, + anon_sym_RBRACE, + ACTIONS(2512), 1, + anon_sym_DOT_DOT, + STATE(1029), 1, + sym_pattern_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41381] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2514), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(957), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41399] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2518), 1, + anon_sym_PLUS, + STATE(936), 1, + aux_sym_function_type_parameter_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2516), 2, + anon_sym_COMMA, + anon_sym_GT, + [41417] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2521), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(968), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41435] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2523), 1, + anon_sym_if, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(498), 2, + sym_block, + sym_if_statement, + [41453] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2527), 1, + anon_sym_PLUS, + STATE(936), 1, + aux_sym_function_type_parameter_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2525), 2, + anon_sym_COMMA, + anon_sym_GT, + [41471] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2531), 1, + anon_sym_LT, + STATE(1059), 1, + sym_parameters, + STATE(1274), 1, + sym_function_type_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41491] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(2533), 1, + anon_sym_LBRACE, + ACTIONS(2535), 1, + anon_sym_for, + STATE(1415), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41511] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2508), 1, + sym_identifier, + ACTIONS(2537), 1, + anon_sym_RBRACE, + ACTIONS(2539), 1, + anon_sym_DOT_DOT, + STATE(1248), 1, + sym_pattern_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41531] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1909), 1, + anon_sym_mut, + ACTIONS(2442), 1, + sym_identifier, + STATE(1267), 1, + sym_parameter, + STATE(1426), 1, + sym_mutable_specifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41551] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2531), 1, + anon_sym_LT, + STATE(1169), 1, + sym_parameters, + STATE(1285), 1, + sym_function_type_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41571] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + ACTIONS(2436), 1, + sym_identifier, + STATE(1219), 1, + sym_data_field, + STATE(1452), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41591] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2541), 1, + anon_sym_PIPE, + STATE(946), 1, + aux_sym_match_value_arm_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2063), 2, + anon_sym_if, + anon_sym_EQ_GT, + [41609] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2544), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(964), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41627] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2546), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(950), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41645] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(2548), 1, + anon_sym_LBRACE, + ACTIONS(2550), 1, + anon_sym_for, + STATE(1428), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41665] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2552), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41683] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2554), 1, + anon_sym_PIPE_PIPE, + ACTIONS(2556), 1, + anon_sym_AMP_AMP, + STATE(511), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41703] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2182), 1, + anon_sym_AMP_AMP, + ACTIONS(2558), 1, + anon_sym_SEMI, + ACTIONS(2560), 1, + anon_sym_priority, + ACTIONS(2562), 1, + anon_sym_PIPE_PIPE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41723] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2531), 1, + anon_sym_LT, + STATE(993), 1, + sym_parameters, + STATE(1199), 1, + sym_function_type_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41743] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2564), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(933), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41761] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(2566), 1, + anon_sym_LBRACE, + ACTIONS(2568), 1, + anon_sym_for, + STATE(1357), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41781] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(2570), 1, + anon_sym_LBRACE, + ACTIONS(2572), 1, + anon_sym_for, + STATE(1346), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41801] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2574), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41819] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2554), 1, + anon_sym_PIPE_PIPE, + ACTIONS(2556), 1, + anon_sym_AMP_AMP, + STATE(485), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41839] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2576), 1, + anon_sym_RBRACE, + ACTIONS(2578), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41857] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2531), 1, + anon_sym_LT, + STATE(1011), 1, + sym_parameters, + STATE(1203), 1, + sym_function_type_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41877] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2581), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(963), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41895] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2531), 1, + anon_sym_LT, + STATE(1056), 1, + sym_parameters, + STATE(1270), 1, + sym_function_type_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41915] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2583), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41933] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2585), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [41951] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2531), 1, + anon_sym_LT, + STATE(1086), 1, + sym_parameters, + STATE(1280), 1, + sym_function_type_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41971] = 6, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2508), 1, + sym_identifier, + ACTIONS(2587), 1, + anon_sym_RBRACE, + ACTIONS(2589), 1, + anon_sym_DOT_DOT, + STATE(1248), 1, + sym_pattern_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [41991] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2591), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2594), 2, + anon_sym_RPAREN, + anon_sym_GT, + [42009] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2506), 1, + anon_sym_fn, + ACTIONS(2596), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + STATE(959), 2, + sym_trait_method, + aux_sym_trait_item_repeat1, + [42027] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2527), 1, + anon_sym_PLUS, + STATE(939), 1, + aux_sym_function_type_parameter_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2598), 2, + anon_sym_COMMA, + anon_sym_GT, + [42045] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1944), 1, + anon_sym_GT, + ACTIONS(2600), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42062] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2401), 1, + anon_sym_RBRACE, + ACTIONS(2602), 1, + anon_sym_COMMA, + STATE(1132), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42079] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1976), 1, + anon_sym_GT, + ACTIONS(2604), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42096] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2606), 1, + anon_sym_RBRACK, + ACTIONS(2608), 1, + anon_sym_LPAREN, + STATE(1383), 1, + sym_attribute_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42113] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2610), 1, + anon_sym_EQ, + ACTIONS(2612), 1, + anon_sym_SEMI, + ACTIONS(2614), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42130] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2616), 3, + anon_sym_LBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + [42143] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2478), 1, + anon_sym_RBRACE, + ACTIONS(2618), 1, + anon_sym_COMMA, + STATE(1099), 1, + aux_sym_data_object_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42160] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2620), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [42173] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2622), 1, + anon_sym_COMMA, + ACTIONS(2624), 1, + anon_sym_RBRACE, + STATE(1105), 1, + aux_sym_use_group_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42190] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2626), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [42203] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2628), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [42216] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2630), 1, + anon_sym_COMMA, + ACTIONS(2632), 1, + anon_sym_RPAREN, + STATE(1153), 1, + aux_sym_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42233] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2636), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2634), 2, + anon_sym_COMMA, + anon_sym_GT, + [42248] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1936), 1, + anon_sym_RPAREN, + ACTIONS(2638), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42265] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2642), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42282] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2644), 1, + anon_sym_COMMA, + ACTIONS(2646), 1, + anon_sym_GT, + STATE(1157), 1, + aux_sym_function_type_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42299] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2642), 1, + anon_sym_RBRACE, + ACTIONS(2648), 1, + anon_sym_COMMA, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42316] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1950), 1, + anon_sym_GT, + ACTIONS(2650), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42333] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2652), 1, + anon_sym_COMMA, + ACTIONS(2654), 1, + anon_sym_RBRACE, + STATE(1116), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42350] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2103), 1, + anon_sym_LT, + ACTIONS(2656), 1, + anon_sym_LBRACE, + STATE(1444), 1, + sym_generic_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42367] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2658), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [42380] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2660), 1, + anon_sym_COMMA, + ACTIONS(2663), 1, + anon_sym_RBRACE, + STATE(991), 1, + aux_sym_use_group_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42397] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + ACTIONS(2667), 1, + anon_sym_DASH_GT, + STATE(313), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42414] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + ACTIONS(2669), 1, + anon_sym_DASH_GT, + STATE(243), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42431] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2671), 1, + anon_sym_COMMA, + ACTIONS(2673), 1, + anon_sym_GT, + STATE(1184), 1, + aux_sym_generic_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42448] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2675), 1, + anon_sym_SEMI, + STATE(1466), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42465] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2413), 1, + anon_sym_RBRACE, + ACTIONS(2677), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42482] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2413), 1, + anon_sym_RBRACE, + ACTIONS(2677), 1, + anon_sym_COMMA, + STATE(1041), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42499] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2679), 1, + anon_sym_LBRACE, + ACTIONS(2681), 1, + anon_sym_COLON, + STATE(435), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42516] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2683), 1, + anon_sym_RBRACE, + STATE(1145), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42533] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2685), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42550] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2685), 1, + anon_sym_RBRACE, + ACTIONS(2687), 1, + anon_sym_COMMA, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42567] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2689), 1, + anon_sym_COMMA, + ACTIONS(2691), 1, + anon_sym_RBRACE, + STATE(1046), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42584] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(2693), 1, + anon_sym_LBRACE, + STATE(1544), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42601] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2695), 1, + anon_sym_RBRACK, + ACTIONS(2697), 1, + anon_sym_COMMA, + STATE(1004), 1, + aux_sym_array_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42618] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2700), 1, + anon_sym_RBRACK, + ACTIONS(2702), 1, + anon_sym_COMMA, + STATE(1154), 1, + aux_sym_array_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42635] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2704), 1, + anon_sym_COMMA, + ACTIONS(2706), 1, + anon_sym_GT, + STATE(972), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42652] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2011), 1, + anon_sym_EQ_GT, + STATE(1369), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42669] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2708), 1, + anon_sym_COMMA, + ACTIONS(2710), 1, + anon_sym_RBRACE, + STATE(1048), 1, + aux_sym_match_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42686] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2712), 1, + anon_sym_DASH_GT, + STATE(132), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42703] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2466), 1, + anon_sym_PIPE, + ACTIONS(2714), 1, + anon_sym_COMMA, + STATE(1053), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42720] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + ACTIONS(2716), 1, + anon_sym_DASH_GT, + STATE(453), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42737] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2718), 1, + anon_sym_COMMA, + ACTIONS(2720), 1, + anon_sym_RBRACE, + STATE(976), 1, + aux_sym_data_object_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42754] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(355), 1, + anon_sym_RPAREN, + ACTIONS(2722), 1, + anon_sym_COMMA, + STATE(1058), 1, + aux_sym_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42771] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + ACTIONS(2726), 1, + anon_sym_RBRACE, + STATE(1303), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42788] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2726), 1, + anon_sym_RBRACE, + ACTIONS(2728), 1, + anon_sym_COMMA, + STATE(1063), 1, + aux_sym_record_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42805] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(518), 1, + anon_sym_RPAREN, + ACTIONS(2730), 1, + anon_sym_COMMA, + STATE(1168), 1, + aux_sym_attribute_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42822] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2732), 1, + anon_sym_COMMA, + ACTIONS(2734), 1, + anon_sym_GT, + STATE(994), 1, + aux_sym_generic_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42839] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2736), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [42852] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2738), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [42865] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2742), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2740), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [42880] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2744), 3, + anon_sym_COMMA, + anon_sym_GT, + anon_sym_PLUS, + [42893] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2403), 1, + anon_sym_RBRACE, + ACTIONS(2746), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42910] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2403), 1, + anon_sym_RBRACE, + ACTIONS(2746), 1, + anon_sym_COMMA, + STATE(1180), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42927] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1913), 1, + anon_sym_RBRACK, + ACTIONS(2748), 1, + anon_sym_COMMA, + STATE(1073), 1, + aux_sym_array_pattern_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42944] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2752), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2750), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [42959] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2754), 1, + anon_sym_COMMA, + ACTIONS(2756), 1, + anon_sym_RBRACE, + STATE(986), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42976] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2758), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [42993] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2762), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2760), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [43008] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2764), 1, + anon_sym_COMMA, + ACTIONS(2766), 1, + anon_sym_RBRACE, + STATE(1084), 1, + aux_sym_record_pattern_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43025] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2758), 1, + anon_sym_RBRACE, + ACTIONS(2768), 1, + anon_sym_COMMA, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43042] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2027), 1, + anon_sym_EQ_GT, + STATE(1315), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43059] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2770), 1, + anon_sym_COMMA, + ACTIONS(2772), 1, + anon_sym_RBRACE, + STATE(1183), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43076] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2776), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2774), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [43091] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2778), 1, + anon_sym_COMMA, + ACTIONS(2781), 1, + anon_sym_RBRACE, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43108] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2280), 1, + anon_sym_RBRACE, + ACTIONS(2783), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43125] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2785), 3, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_PIPE, + [43138] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2787), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [43151] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2789), 3, + anon_sym_LBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + [43164] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2791), 1, + anon_sym_COMMA, + ACTIONS(2794), 1, + anon_sym_RPAREN, + STATE(1039), 1, + aux_sym_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43181] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2103), 1, + anon_sym_LT, + ACTIONS(2796), 1, + anon_sym_LBRACE, + STATE(1458), 1, + sym_generic_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43198] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2371), 1, + anon_sym_RBRACE, + ACTIONS(2798), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43215] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2800), 1, + sym_identifier, + ACTIONS(2802), 1, + anon_sym_GT, + STATE(1241), 1, + sym_function_type_parameter, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43232] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2804), 1, + anon_sym_COMMA, + ACTIONS(2807), 1, + anon_sym_GT, + STATE(1043), 1, + aux_sym_function_type_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43249] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2809), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43266] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2811), 1, + anon_sym_SEMI, + STATE(1370), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43283] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2375), 1, + anon_sym_RBRACE, + ACTIONS(2813), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43300] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2679), 1, + anon_sym_LBRACE, + ACTIONS(2815), 1, + anon_sym_COLON, + STATE(359), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43317] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(586), 1, + anon_sym_RBRACE, + ACTIONS(2817), 1, + anon_sym_COMMA, + STATE(1115), 1, + aux_sym_match_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43334] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2819), 1, + anon_sym_DASH_GT, + STATE(126), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43351] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + ACTIONS(2821), 1, + anon_sym_SEMI, + STATE(1474), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43368] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2823), 1, + anon_sym_SEMI, + STATE(1473), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43385] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2825), 1, + anon_sym_LBRACE, + ACTIONS(2827), 1, + anon_sym_COLON, + STATE(323), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43402] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2829), 1, + anon_sym_COMMA, + ACTIONS(2832), 1, + anon_sym_PIPE, + STATE(1053), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43419] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2834), 1, + anon_sym_SEMI, + STATE(1499), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43436] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2825), 1, + anon_sym_LBRACE, + ACTIONS(2836), 1, + anon_sym_COLON, + STATE(327), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43453] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2838), 1, + anon_sym_DASH_GT, + STATE(332), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43470] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2840), 1, + anon_sym_RBRACE, + STATE(1067), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43487] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2842), 1, + anon_sym_COMMA, + ACTIONS(2845), 1, + anon_sym_RPAREN, + STATE(1058), 1, + aux_sym_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43504] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2847), 1, + anon_sym_DASH_GT, + STATE(341), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43521] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2849), 1, + anon_sym_RBRACE, + STATE(1074), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43538] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2369), 1, + anon_sym_RBRACE, + ACTIONS(2851), 1, + anon_sym_COMMA, + STATE(1075), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43555] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + ACTIONS(2853), 1, + anon_sym_RBRACE, + STATE(1303), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43572] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2855), 1, + anon_sym_COMMA, + ACTIONS(2858), 1, + anon_sym_RBRACE, + STATE(1063), 1, + aux_sym_record_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43589] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2860), 1, + anon_sym_DASH_GT, + STATE(347), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43606] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2862), 1, + anon_sym_COMMA, + ACTIONS(2864), 1, + anon_sym_GT, + STATE(1078), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43623] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2866), 1, + anon_sym_COMMA, + ACTIONS(2868), 1, + anon_sym_RBRACE, + STATE(1080), 1, + aux_sym_data_object_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43640] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2870), 1, + anon_sym_COMMA, + ACTIONS(2872), 1, + anon_sym_RBRACE, + STATE(1082), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43657] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(2874), 1, + anon_sym_SEMI, + STATE(1318), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43674] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2825), 1, + anon_sym_LBRACE, + ACTIONS(2876), 1, + anon_sym_COLON, + STATE(356), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43691] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2103), 1, + anon_sym_LT, + ACTIONS(2878), 1, + anon_sym_LBRACE, + STATE(1432), 1, + sym_generic_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43708] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2379), 1, + anon_sym_RBRACE, + ACTIONS(2880), 1, + anon_sym_COMMA, + STATE(1093), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43725] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2882), 1, + anon_sym_DASH_GT, + STATE(362), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43742] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2884), 1, + anon_sym_RBRACK, + ACTIONS(2886), 1, + anon_sym_COMMA, + STATE(1073), 1, + aux_sym_array_pattern_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43759] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2889), 1, + anon_sym_COMMA, + ACTIONS(2891), 1, + anon_sym_RBRACE, + STATE(1096), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43776] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2383), 1, + anon_sym_RBRACE, + ACTIONS(2893), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43793] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2383), 1, + anon_sym_RBRACE, + ACTIONS(2893), 1, + anon_sym_COMMA, + STATE(1098), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43810] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2895), 1, + anon_sym_COMMA, + ACTIONS(2897), 1, + anon_sym_RPAREN, + STATE(1016), 1, + aux_sym_attribute_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43827] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1987), 1, + anon_sym_GT, + ACTIONS(2899), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43844] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2901), 1, + anon_sym_RBRACE, + STATE(1026), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43861] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2490), 1, + anon_sym_RBRACE, + ACTIONS(2903), 1, + anon_sym_COMMA, + STATE(1099), 1, + aux_sym_data_object_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43878] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2905), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43895] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2905), 1, + anon_sym_RBRACE, + ACTIONS(2907), 1, + anon_sym_COMMA, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43912] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2909), 1, + anon_sym_COMMA, + ACTIONS(2911), 1, + anon_sym_RBRACE, + STATE(1106), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43929] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2587), 1, + anon_sym_RBRACE, + ACTIONS(2913), 1, + anon_sym_COMMA, + STATE(1141), 1, + aux_sym_record_pattern_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43946] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2915), 1, + anon_sym_COMMA, + ACTIONS(2917), 1, + anon_sym_RPAREN, + STATE(983), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43963] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2919), 1, + anon_sym_DASH_GT, + STATE(379), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43980] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2921), 1, + anon_sym_RBRACE, + STATE(1109), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [43997] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2594), 3, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_GT, + [44010] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2923), 1, + anon_sym_RBRACK, + ACTIONS(2925), 1, + anon_sym_COMMA, + STATE(1112), 1, + aux_sym_array_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44027] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2009), 1, + anon_sym_if, + ACTIONS(2025), 1, + anon_sym_EQ_GT, + STATE(1364), 1, + sym_match_guard, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44044] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2355), 1, + anon_sym_RBRACE, + ACTIONS(2927), 1, + anon_sym_COMMA, + STATE(1022), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44061] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2929), 1, + anon_sym_COMMA, + ACTIONS(2931), 1, + anon_sym_GT, + STATE(987), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44078] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2252), 1, + anon_sym_RBRACE, + ACTIONS(2933), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44095] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2252), 1, + anon_sym_RBRACE, + ACTIONS(2933), 1, + anon_sym_COMMA, + STATE(1119), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44112] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2935), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44129] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2935), 1, + anon_sym_RBRACE, + ACTIONS(2937), 1, + anon_sym_COMMA, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44146] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2939), 1, + anon_sym_COMMA, + ACTIONS(2941), 1, + anon_sym_RBRACE, + STATE(1122), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44163] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2254), 1, + anon_sym_RBRACE, + ACTIONS(2943), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44180] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2945), 1, + anon_sym_COMMA, + ACTIONS(2948), 1, + anon_sym_RBRACE, + STATE(1099), 1, + aux_sym_data_object_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44197] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2950), 1, + anon_sym_COMMA, + ACTIONS(2952), 1, + anon_sym_RPAREN, + STATE(1125), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44214] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2954), 1, + anon_sym_COMMA, + ACTIONS(2956), 1, + anon_sym_GT, + STATE(1126), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44231] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + ACTIONS(2958), 1, + anon_sym_DASH_GT, + STATE(441), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44248] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2960), 3, + anon_sym_COMMA, + anon_sym_RBRACE, + anon_sym_SEMI, + [44261] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2962), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44278] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2198), 1, + anon_sym_RBRACE, + ACTIONS(2964), 1, + anon_sym_COMMA, + STATE(991), 1, + aux_sym_use_group_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44295] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2260), 1, + anon_sym_RBRACE, + ACTIONS(2966), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44312] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2262), 1, + anon_sym_RBRACE, + ACTIONS(2968), 1, + anon_sym_COMMA, + STATE(1127), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44329] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(2970), 1, + anon_sym_DASH_GT, + STATE(400), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44346] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2972), 1, + anon_sym_COMMA, + ACTIONS(2974), 1, + anon_sym_RBRACE, + STATE(1130), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44363] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(2976), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44380] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2978), 1, + anon_sym_EQ_GT, + ACTIONS(2980), 1, + anon_sym_PIPE_PIPE, + ACTIONS(2982), 1, + anon_sym_AMP_AMP, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44397] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(383), 1, + anon_sym_RBRACK, + ACTIONS(2984), 1, + anon_sym_COMMA, + STATE(1004), 1, + aux_sym_array_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44414] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2986), 1, + anon_sym_COMMA, + ACTIONS(2989), 1, + anon_sym_RBRACE, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44431] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(2993), 1, + anon_sym_DASH_GT, + STATE(699), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44448] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2995), 1, + anon_sym_COMMA, + ACTIONS(2998), 1, + anon_sym_RBRACE, + STATE(1115), 1, + aux_sym_match_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44465] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2322), 1, + anon_sym_RBRACE, + ACTIONS(3000), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44482] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3002), 1, + anon_sym_COMMA, + ACTIONS(3004), 1, + anon_sym_RPAREN, + STATE(1136), 1, + aux_sym_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44499] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3006), 1, + anon_sym_COMMA, + ACTIONS(3008), 1, + anon_sym_RBRACE, + STATE(1138), 1, + aux_sym_record_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44516] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2276), 1, + anon_sym_RBRACE, + ACTIONS(3010), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44533] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3012), 1, + anon_sym_COMMA, + ACTIONS(3014), 1, + anon_sym_RBRACE, + STATE(1030), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44550] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(3016), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44567] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2278), 1, + anon_sym_RBRACE, + ACTIONS(3018), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44584] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(3020), 1, + anon_sym_DASH_GT, + STATE(138), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44601] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2258), 1, + anon_sym_RBRACE, + ACTIONS(3022), 1, + anon_sym_COMMA, + STATE(996), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44618] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1954), 1, + anon_sym_RPAREN, + ACTIONS(3024), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44635] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1956), 1, + anon_sym_GT, + ACTIONS(3026), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44652] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2288), 1, + anon_sym_RBRACE, + ACTIONS(3028), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44669] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2288), 1, + anon_sym_RBRACE, + ACTIONS(3028), 1, + anon_sym_COMMA, + STATE(1142), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44686] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(3030), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44703] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3030), 1, + anon_sym_RBRACE, + ACTIONS(3032), 1, + anon_sym_COMMA, + STATE(1113), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44720] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3034), 1, + anon_sym_COMMA, + ACTIONS(3036), 1, + anon_sym_RBRACE, + STATE(1144), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44737] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2405), 1, + anon_sym_RBRACE, + ACTIONS(3038), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44754] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2556), 1, + anon_sym_AMP_AMP, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2087), 2, + anon_sym_LBRACE, + anon_sym_PIPE_PIPE, + [44769] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3040), 1, + anon_sym_COMMA, + ACTIONS(3042), 1, + anon_sym_RBRACE, + STATE(1146), 1, + aux_sym_match_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44786] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3044), 1, + anon_sym_DASH_GT, + STATE(703), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44803] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(361), 1, + anon_sym_RPAREN, + ACTIONS(3046), 1, + anon_sym_COMMA, + STATE(1058), 1, + aux_sym_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44820] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + ACTIONS(3048), 1, + anon_sym_RBRACE, + STATE(1303), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44837] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3048), 1, + anon_sym_RBRACE, + ACTIONS(3050), 1, + anon_sym_COMMA, + STATE(1063), 1, + aux_sym_record_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44854] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + ACTIONS(3052), 1, + anon_sym_DASH_GT, + STATE(270), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44871] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2405), 1, + anon_sym_RBRACE, + ACTIONS(3038), 1, + anon_sym_COMMA, + STATE(1035), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44888] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3054), 1, + anon_sym_COMMA, + ACTIONS(3057), 1, + anon_sym_RBRACE, + STATE(1141), 1, + aux_sym_record_pattern_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44905] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2304), 1, + anon_sym_RBRACE, + ACTIONS(3059), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44922] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(3061), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44939] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2310), 1, + anon_sym_RBRACE, + ACTIONS(3063), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44956] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3065), 1, + anon_sym_COMMA, + ACTIONS(3067), 1, + anon_sym_RBRACE, + STATE(1001), 1, + aux_sym_enum_item_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44973] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(596), 1, + anon_sym_RBRACE, + ACTIONS(3069), 1, + anon_sym_COMMA, + STATE(1115), 1, + aux_sym_match_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [44990] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3071), 1, + anon_sym_DASH_GT, + STATE(717), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45007] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + ACTIONS(3073), 1, + anon_sym_RBRACE, + STATE(1303), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45024] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3075), 1, + anon_sym_DASH_GT, + STATE(685), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45041] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3077), 1, + anon_sym_COMMA, + ACTIONS(3079), 1, + anon_sym_GT, + STATE(970), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45058] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + ACTIONS(3081), 1, + anon_sym_SEMI, + STATE(1483), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45075] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3083), 3, + anon_sym_LBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + [45088] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2214), 1, + anon_sym_RPAREN, + ACTIONS(3085), 1, + anon_sym_COMMA, + STATE(1039), 1, + aux_sym_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45105] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(377), 1, + anon_sym_RBRACK, + ACTIONS(3087), 1, + anon_sym_COMMA, + STATE(1004), 1, + aux_sym_array_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45122] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3089), 1, + anon_sym_COMMA, + ACTIONS(3091), 1, + anon_sym_RPAREN, + STATE(1158), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45139] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2800), 1, + sym_identifier, + ACTIONS(3093), 1, + anon_sym_GT, + STATE(1241), 1, + sym_function_type_parameter, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45156] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3093), 1, + anon_sym_GT, + ACTIONS(3095), 1, + anon_sym_COMMA, + STATE(1043), 1, + aux_sym_function_type_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45173] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1958), 1, + anon_sym_RPAREN, + ACTIONS(3097), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45190] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2982), 1, + anon_sym_AMP_AMP, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2087), 2, + anon_sym_EQ_GT, + anon_sym_PIPE_PIPE, + [45205] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2679), 1, + anon_sym_LBRACE, + ACTIONS(3099), 1, + anon_sym_COLON, + STATE(304), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45222] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2103), 1, + anon_sym_LT, + ACTIONS(3101), 1, + anon_sym_LBRACE, + STATE(1411), 1, + sym_generic_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45239] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2103), 1, + anon_sym_LT, + ACTIONS(3103), 1, + anon_sym_LBRACE, + STATE(1422), 1, + sym_generic_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45256] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + ACTIONS(3105), 1, + anon_sym_DASH_GT, + STATE(150), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45273] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3107), 1, + anon_sym_COMMA, + ACTIONS(3109), 1, + anon_sym_PIPE, + STATE(1010), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45290] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(3111), 1, + anon_sym_LBRACE, + STATE(1442), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45307] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2103), 1, + anon_sym_LT, + ACTIONS(3113), 1, + anon_sym_LBRACE, + STATE(1447), 1, + sym_generic_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45324] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(3115), 1, + anon_sym_LBRACE, + STATE(1463), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45341] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3117), 1, + anon_sym_COMMA, + ACTIONS(3120), 1, + anon_sym_RPAREN, + STATE(1168), 1, + aux_sym_attribute_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45358] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + ACTIONS(3122), 1, + anon_sym_DASH_GT, + STATE(235), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45375] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3124), 1, + anon_sym_COMMA, + ACTIONS(3126), 1, + anon_sym_RPAREN, + STATE(1174), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45392] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3128), 1, + anon_sym_COMMA, + ACTIONS(3130), 1, + anon_sym_RPAREN, + STATE(1013), 1, + aux_sym_arguments_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45409] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3132), 1, + anon_sym_DASH_GT, + STATE(150), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45426] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3134), 1, + anon_sym_COMMA, + ACTIONS(3136), 1, + anon_sym_PIPE, + STATE(1178), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45443] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1972), 1, + anon_sym_RPAREN, + ACTIONS(3138), 1, + anon_sym_COMMA, + STATE(967), 1, + aux_sym_function_type_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45460] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3142), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3140), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [45475] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3144), 1, + anon_sym_COMMA, + ACTIONS(3146), 1, + anon_sym_RBRACE, + STATE(1015), 1, + aux_sym_record_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45492] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3148), 1, + anon_sym_DASH_GT, + STATE(132), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45509] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2464), 1, + anon_sym_PIPE, + ACTIONS(3150), 1, + anon_sym_COMMA, + STATE(1053), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45526] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3152), 1, + anon_sym_DASH_GT, + STATE(126), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45543] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2397), 1, + anon_sym_RBRACE, + ACTIONS(3154), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45560] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + ACTIONS(3156), 1, + anon_sym_DASH_GT, + STATE(138), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45577] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(3158), 1, + anon_sym_RBRACE, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45594] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2320), 1, + anon_sym_RBRACE, + ACTIONS(3160), 1, + anon_sym_COMMA, + STATE(1034), 1, + aux_sym_struct_item_repeat2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45611] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3162), 1, + anon_sym_COMMA, + ACTIONS(3165), 1, + anon_sym_GT, + STATE(1184), 1, + aux_sym_generic_parameters_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45628] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3169), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3167), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [45643] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + ACTIONS(3171), 1, + anon_sym_RBRACE, + STATE(1120), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45660] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + ACTIONS(3173), 1, + anon_sym_LBRACE, + STATE(1356), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45677] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3175), 1, + anon_sym_COMMA, + ACTIONS(3177), 1, + anon_sym_PIPE, + STATE(1190), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45694] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3179), 3, + anon_sym_LBRACE, + anon_sym_DASH_GT, + anon_sym_SEMI, + [45707] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2498), 1, + anon_sym_PIPE, + ACTIONS(3181), 1, + anon_sym_COMMA, + STATE(1053), 1, + aux_sym_closure_expression_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45724] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3183), 3, + anon_sym_COMMA, + anon_sym_RPAREN, + anon_sym_PIPE, + [45737] = 5, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3185), 1, + anon_sym_RBRACK, + ACTIONS(3187), 1, + anon_sym_COMMA, + STATE(1024), 1, + aux_sym_array_pattern_repeat1, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45754] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(531), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45768] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2825), 1, + anon_sym_LBRACE, + STATE(351), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45782] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3189), 2, + anon_sym_RBRACE, + anon_sym_fn, + [45794] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2673), 1, + anon_sym_GT, + ACTIONS(3191), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45808] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3193), 1, + anon_sym_LBRACE, + ACTIONS(3195), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45822] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + STATE(258), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45836] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(1139), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45850] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2679), 1, + anon_sym_LBRACE, + STATE(320), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45864] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2884), 2, + anon_sym_RBRACK, + anon_sym_COMMA, + [45876] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2825), 1, + anon_sym_LBRACE, + STATE(363), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45890] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(992), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45904] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(369), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45918] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3197), 1, + anon_sym_EQ, + ACTIONS(3199), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45932] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3201), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [45944] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + STATE(1176), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45958] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2234), 1, + anon_sym_LT, + STATE(165), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45972] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + STATE(217), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [45986] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3203), 1, + anon_sym_mut, + ACTIONS(3205), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46000] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(512), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46014] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + STATE(252), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46028] = 3, + ACTIONS(3207), 1, + aux_sym_interpolation_token1, + ACTIONS(3209), 1, + anon_sym_RBRACE2, + ACTIONS(5), 3, + sym_doc_comment, + sym_line_comment, + sym_block_comment, + [46040] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + STATE(291), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46054] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(384), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46068] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3211), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46080] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3213), 1, + anon_sym_EQ, + ACTIONS(3215), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46094] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(389), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46108] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2948), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46120] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3217), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46132] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3219), 1, + anon_sym_LBRACE, + ACTIONS(3221), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46146] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3223), 1, + sym_identifier, + ACTIONS(3225), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46160] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2679), 1, + anon_sym_LBRACE, + STATE(442), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46174] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2825), 1, + anon_sym_LBRACE, + STATE(401), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46188] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2989), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46200] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3227), 1, + sym_identifier, + STATE(1405), 1, + sym__attribute_body, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46214] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3229), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46226] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2998), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46238] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3231), 1, + anon_sym_LBRACK, + ACTIONS(3233), 1, + anon_sym_BANG, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46252] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2781), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46264] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3235), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [46276] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(406), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46290] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3237), 1, + anon_sym_DASH_GT, + ACTIONS(3239), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46304] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3241), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [46316] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(138), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46330] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2695), 2, + anon_sym_RBRACK, + anon_sym_COMMA, + [46342] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2794), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [46354] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + STATE(1303), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46368] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3243), 1, + anon_sym_LBRACE, + ACTIONS(3245), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46382] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(418), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46396] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2807), 2, + anon_sym_COMMA, + anon_sym_GT, + [46408] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + STATE(306), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46422] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2182), 1, + anon_sym_AMP_AMP, + ACTIONS(2562), 1, + anon_sym_PIPE_PIPE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46436] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2663), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46448] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3247), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46460] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2679), 1, + anon_sym_LBRACE, + STATE(271), 1, + sym_data_object, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46474] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2537), 1, + anon_sym_RBRACE, + ACTIONS(3249), 1, + anon_sym_COMMA, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46488] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3057), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46500] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(1233), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46514] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(427), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46528] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3251), 1, + anon_sym_EQ, + ACTIONS(3253), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46542] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3255), 1, + anon_sym_LBRACE, + ACTIONS(3257), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46556] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3259), 2, + anon_sym_if, + anon_sym_EQ_GT, + [46568] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(717), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46582] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1946), 1, + anon_sym_LPAREN, + STATE(719), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46596] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + STATE(1569), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46610] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + STATE(1402), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46624] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3261), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [46636] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(686), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46650] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(688), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46664] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + STATE(1471), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46678] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2160), 1, + anon_sym_LT, + STATE(558), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46692] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3263), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46704] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(126), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46718] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3265), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46730] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(143), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46744] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2832), 2, + anon_sym_COMMA, + anon_sym_PIPE, + [46756] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3267), 1, + anon_sym_rev, + ACTIONS(3269), 1, + anon_sym_step_by, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46770] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3271), 1, + anon_sym_COMMA, + ACTIONS(3273), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46784] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(1064), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46798] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2508), 1, + sym_identifier, + STATE(1248), 1, + sym_pattern_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46812] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3275), 1, + anon_sym_LBRACE, + ACTIONS(3277), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46826] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3279), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [46838] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(1072), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46852] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3120), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [46864] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(534), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46878] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(521), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46892] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3281), 1, + anon_sym_LBRACE, + ACTIONS(3283), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46906] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3285), 1, + anon_sym_LBRACE, + ACTIONS(3287), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46920] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(1108), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46934] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3289), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [46946] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(124), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46960] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(508), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46974] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2724), 1, + sym_identifier, + STATE(1118), 1, + sym_record_field, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [46988] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2529), 1, + anon_sym_LPAREN, + STATE(1102), 1, + sym_parameters, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47002] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2039), 1, + anon_sym_LBRACE, + STATE(529), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47016] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + STATE(127), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47030] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3291), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [47042] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3293), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [47054] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2845), 2, + anon_sym_COMMA, + anon_sym_RPAREN, + [47066] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(602), 1, + anon_sym_LPAREN, + STATE(1317), 1, + sym_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47080] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3227), 1, + sym_identifier, + STATE(1389), 1, + sym__attribute_body, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47094] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + STATE(1255), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47108] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3295), 1, + anon_sym_LBRACE, + ACTIONS(3297), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47122] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(126), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47136] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3299), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [47148] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(138), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47162] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(143), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47176] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(124), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47190] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + STATE(449), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47204] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2665), 1, + anon_sym_LBRACE, + STATE(278), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47218] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3165), 2, + anon_sym_COMMA, + anon_sym_GT, + [47230] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(2858), 2, + anon_sym_COMMA, + anon_sym_RBRACE, + [47242] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3191), 1, + sym_identifier, + ACTIONS(3301), 1, + anon_sym_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47256] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2210), 1, + anon_sym_LT, + STATE(1287), 1, + sym_type_arguments, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47270] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2800), 1, + sym_identifier, + STATE(985), 1, + sym_function_type_parameter, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47284] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2640), 1, + sym_identifier, + STATE(1225), 1, + sym_variant, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47298] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + ACTIONS(3303), 2, + anon_sym_RBRACE, + anon_sym_fn, + [47310] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + STATE(1521), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47324] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2800), 1, + sym_identifier, + STATE(1241), 1, + sym_function_type_parameter, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47338] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + STATE(1564), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47352] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(93), 1, + anon_sym_DQUOTE, + STATE(1566), 1, + sym_string, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47366] = 4, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2991), 1, + anon_sym_LBRACE, + STATE(685), 1, + sym_block, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47380] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3305), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47391] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3307), 1, + anon_sym_EQ_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47402] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3309), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47413] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3311), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47424] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3313), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47435] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3315), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47446] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3317), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47457] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3319), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47468] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3321), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47479] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3323), 1, + ts_builtin_sym_end, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47490] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3325), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47501] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3327), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47512] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3329), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47523] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3331), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47534] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3333), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47545] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3335), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47556] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3337), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47567] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(387), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47578] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3339), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47589] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3341), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47600] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3343), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47611] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(385), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47622] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3345), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47633] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3347), 1, + anon_sym_in, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47644] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3349), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47655] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3351), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47666] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3353), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47677] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3355), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47688] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3357), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47699] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3359), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47710] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3361), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47721] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3363), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47732] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3365), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47743] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3367), 1, + anon_sym_on, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47754] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3369), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47765] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3371), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47776] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3373), 1, + anon_sym_state, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47787] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3375), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47798] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3377), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47809] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3379), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47820] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3381), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47831] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3383), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47842] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3385), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47853] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3387), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47864] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3389), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47875] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3391), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47886] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3393), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47897] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3395), 1, + anon_sym_EQ_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47908] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3397), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47919] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3399), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47930] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3401), 1, + anon_sym_EQ_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47941] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3403), 1, + anon_sym_self, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47952] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3405), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47963] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3407), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47974] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3409), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47985] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3411), 1, + anon_sym_EQ_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [47996] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3413), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48007] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3415), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48018] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3417), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48029] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3419), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48040] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3421), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48051] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3423), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48062] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3425), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48073] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3427), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48084] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3429), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48095] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3431), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48106] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3433), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48117] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3435), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48128] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3437), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48139] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3439), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48150] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3441), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48161] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3443), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48172] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3445), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48183] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1532), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48194] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3447), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48205] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3449), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48216] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3451), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48227] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3453), 1, + anon_sym_on, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48238] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3455), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48249] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3457), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48260] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3459), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48271] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3461), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48282] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3463), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48293] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3465), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48304] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3467), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48315] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3469), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48326] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3471), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48337] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3473), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48348] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3475), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48359] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3477), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48370] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3273), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48381] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3479), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48392] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3481), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48403] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3483), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48414] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3485), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48425] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3487), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48436] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3489), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48447] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3491), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48458] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3493), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48469] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(2766), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48480] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3495), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48491] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3497), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48502] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3499), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48513] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3501), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48524] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3503), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48535] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3505), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48546] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3507), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48557] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3509), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48568] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3511), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48579] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3513), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48590] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3515), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48601] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3517), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48612] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3519), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48623] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3521), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48634] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3523), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48645] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3525), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48656] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3527), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48667] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3529), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48678] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3531), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48689] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3533), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48700] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3535), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48711] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3537), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48722] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3539), 1, + anon_sym_DOT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48733] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3541), 1, + anon_sym_EQ_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48744] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3191), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48755] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3543), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48766] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3545), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48777] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3547), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48788] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3549), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48799] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3551), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48810] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3553), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48821] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3555), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48832] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3557), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48843] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3559), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48854] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3561), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48865] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3563), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48876] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3565), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48887] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3567), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48898] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1766), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48909] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3569), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48920] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3571), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48931] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3573), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48942] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3575), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48953] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3577), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48964] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3579), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48975] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3581), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48986] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3583), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [48997] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3585), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49008] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3587), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49019] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3589), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49030] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3591), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49041] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3593), 1, + anon_sym_PIPE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49052] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3595), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49063] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3597), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49074] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3599), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49085] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3601), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49096] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3603), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49107] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3605), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49118] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3607), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49129] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3609), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49140] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3611), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49151] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3613), 1, + anon_sym_RBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49162] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3615), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49173] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3617), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49184] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3619), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49195] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3621), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49206] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3623), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49217] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3625), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49228] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3627), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49239] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3629), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49250] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3631), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49261] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3633), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49272] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3635), 1, + anon_sym_step_by, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49283] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3637), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49294] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3639), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49305] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3641), 1, + anon_sym_LBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49316] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3643), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49327] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3645), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49338] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3647), 1, + anon_sym_EQ_GT, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49349] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3649), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49360] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3651), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49371] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3653), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49382] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3655), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49393] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3657), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49404] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3659), 1, + anon_sym_on, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49415] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3661), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49426] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3663), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49437] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3665), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49448] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3667), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49459] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3669), 1, + anon_sym_state, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49470] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3671), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49481] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3673), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49492] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3675), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49503] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3677), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49514] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3679), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49525] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3681), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49536] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3683), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49547] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3685), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49558] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3687), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49569] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3689), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49580] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3691), 1, + anon_sym_RPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49591] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3693), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49602] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3695), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49613] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3697), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49624] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3699), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49635] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3701), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49646] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3703), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49657] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3705), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49668] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3707), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49679] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3709), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49690] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3711), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49701] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3713), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49712] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3715), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49723] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3717), 1, + anon_sym_PIPE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49734] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3719), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49745] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3721), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49756] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3723), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49767] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3725), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49778] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3727), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49789] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(1629), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49800] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3729), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49811] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3731), 1, + anon_sym_EQ, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49822] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3733), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49833] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3735), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49844] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3737), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49855] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3739), 1, + anon_sym_state, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49866] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3741), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49877] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3743), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49888] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3745), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49899] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3747), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49910] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3749), 1, + anon_sym_LBRACE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49921] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3751), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49932] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3753), 1, + anon_sym_state, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49943] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3755), 1, + anon_sym_state, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49954] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3757), 1, + anon_sym_on, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49965] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3759), 1, + anon_sym_on, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49976] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3761), 1, + anon_sym_LPAREN, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49987] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3763), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [49998] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3765), 1, + anon_sym_state, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50009] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3767), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50020] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3769), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50031] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3231), 1, + anon_sym_LBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50042] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3771), 1, + anon_sym_on, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50053] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3773), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50064] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3775), 1, + anon_sym_PIPE, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50075] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3777), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50086] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3779), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50097] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3781), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50108] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3783), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50119] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3785), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50130] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3787), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50141] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3789), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50152] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3791), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50163] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3793), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50174] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3795), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50185] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3797), 1, + anon_sym_fn, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50196] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3799), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50207] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3801), 1, + anon_sym_SEMI, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50218] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3803), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50229] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3805), 1, + anon_sym_RBRACK, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50240] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3807), 1, + sym_identifier, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50251] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3809), 1, + anon_sym_COLON, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, + [50262] = 3, + ACTIONS(5), 1, + sym_line_comment, + ACTIONS(3811), 1, + anon_sym_RBRACE2, + ACTIONS(3), 2, + sym_doc_comment, + sym_block_comment, +}; + +static const uint32_t ts_small_parse_table_map[] = { + [SMALL_STATE(12)] = 0, + [SMALL_STATE(13)] = 125, + [SMALL_STATE(14)] = 250, + [SMALL_STATE(15)] = 375, + [SMALL_STATE(16)] = 500, + [SMALL_STATE(17)] = 625, + [SMALL_STATE(18)] = 750, + [SMALL_STATE(19)] = 844, + [SMALL_STATE(20)] = 938, + [SMALL_STATE(21)] = 1031, + [SMALL_STATE(22)] = 1124, + [SMALL_STATE(23)] = 1217, + [SMALL_STATE(24)] = 1310, + [SMALL_STATE(25)] = 1403, + [SMALL_STATE(26)] = 1496, + [SMALL_STATE(27)] = 1589, + [SMALL_STATE(28)] = 1682, + [SMALL_STATE(29)] = 1775, + [SMALL_STATE(30)] = 1868, + [SMALL_STATE(31)] = 1961, + [SMALL_STATE(32)] = 2054, + [SMALL_STATE(33)] = 2147, + [SMALL_STATE(34)] = 2253, + [SMALL_STATE(35)] = 2359, + [SMALL_STATE(36)] = 2465, + [SMALL_STATE(37)] = 2571, + [SMALL_STATE(38)] = 2677, + [SMALL_STATE(39)] = 2783, + [SMALL_STATE(40)] = 2886, + [SMALL_STATE(41)] = 2984, + [SMALL_STATE(42)] = 3083, + [SMALL_STATE(43)] = 3177, + [SMALL_STATE(44)] = 3271, + [SMALL_STATE(45)] = 3365, + [SMALL_STATE(46)] = 3459, + [SMALL_STATE(47)] = 3553, + [SMALL_STATE(48)] = 3647, + [SMALL_STATE(49)] = 3733, + [SMALL_STATE(50)] = 3819, + [SMALL_STATE(51)] = 3912, + [SMALL_STATE(52)] = 4003, + [SMALL_STATE(53)] = 4096, + [SMALL_STATE(54)] = 4189, + [SMALL_STATE(55)] = 4282, + [SMALL_STATE(56)] = 4375, + [SMALL_STATE(57)] = 4465, + [SMALL_STATE(58)] = 4551, + [SMALL_STATE(59)] = 4637, + [SMALL_STATE(60)] = 4727, + [SMALL_STATE(61)] = 4817, + [SMALL_STATE(62)] = 4903, + [SMALL_STATE(63)] = 4989, + [SMALL_STATE(64)] = 5079, + [SMALL_STATE(65)] = 5169, + [SMALL_STATE(66)] = 5259, + [SMALL_STATE(67)] = 5349, + [SMALL_STATE(68)] = 5439, + [SMALL_STATE(69)] = 5529, + [SMALL_STATE(70)] = 5619, + [SMALL_STATE(71)] = 5705, + [SMALL_STATE(72)] = 5795, + [SMALL_STATE(73)] = 5881, + [SMALL_STATE(74)] = 5971, + [SMALL_STATE(75)] = 6057, + [SMALL_STATE(76)] = 6149, + [SMALL_STATE(77)] = 6235, + [SMALL_STATE(78)] = 6321, + [SMALL_STATE(79)] = 6407, + [SMALL_STATE(80)] = 6493, + [SMALL_STATE(81)] = 6579, + [SMALL_STATE(82)] = 6669, + [SMALL_STATE(83)] = 6755, + [SMALL_STATE(84)] = 6845, + [SMALL_STATE(85)] = 6930, + [SMALL_STATE(86)] = 7021, + [SMALL_STATE(87)] = 7106, + [SMALL_STATE(88)] = 7197, + [SMALL_STATE(89)] = 7282, + [SMALL_STATE(90)] = 7367, + [SMALL_STATE(91)] = 7452, + [SMALL_STATE(92)] = 7541, + [SMALL_STATE(93)] = 7626, + [SMALL_STATE(94)] = 7711, + [SMALL_STATE(95)] = 7796, + [SMALL_STATE(96)] = 7881, + [SMALL_STATE(97)] = 7966, + [SMALL_STATE(98)] = 8051, + [SMALL_STATE(99)] = 8140, + [SMALL_STATE(100)] = 8231, + [SMALL_STATE(101)] = 8316, + [SMALL_STATE(102)] = 8401, + [SMALL_STATE(103)] = 8489, + [SMALL_STATE(104)] = 8577, + [SMALL_STATE(105)] = 8665, + [SMALL_STATE(106)] = 8753, + [SMALL_STATE(107)] = 8841, + [SMALL_STATE(108)] = 8898, + [SMALL_STATE(109)] = 8983, + [SMALL_STATE(110)] = 9066, + [SMALL_STATE(111)] = 9151, + [SMALL_STATE(112)] = 9236, + [SMALL_STATE(113)] = 9321, + [SMALL_STATE(114)] = 9403, + [SMALL_STATE(115)] = 9453, + [SMALL_STATE(116)] = 9535, + [SMALL_STATE(117)] = 9585, + [SMALL_STATE(118)] = 9662, + [SMALL_STATE(119)] = 9739, + [SMALL_STATE(120)] = 9796, + [SMALL_STATE(121)] = 9873, + [SMALL_STATE(122)] = 9950, + [SMALL_STATE(123)] = 10027, + [SMALL_STATE(124)] = 10104, + [SMALL_STATE(125)] = 10152, + [SMALL_STATE(126)] = 10200, + [SMALL_STATE(127)] = 10248, + [SMALL_STATE(128)] = 10296, + [SMALL_STATE(129)] = 10344, + [SMALL_STATE(130)] = 10392, + [SMALL_STATE(131)] = 10440, + [SMALL_STATE(132)] = 10488, + [SMALL_STATE(133)] = 10536, + [SMALL_STATE(134)] = 10588, + [SMALL_STATE(135)] = 10636, + [SMALL_STATE(136)] = 10684, + [SMALL_STATE(137)] = 10732, + [SMALL_STATE(138)] = 10780, + [SMALL_STATE(139)] = 10828, + [SMALL_STATE(140)] = 10876, + [SMALL_STATE(141)] = 10924, + [SMALL_STATE(142)] = 10972, + [SMALL_STATE(143)] = 11020, + [SMALL_STATE(144)] = 11068, + [SMALL_STATE(145)] = 11116, + [SMALL_STATE(146)] = 11168, + [SMALL_STATE(147)] = 11220, + [SMALL_STATE(148)] = 11268, + [SMALL_STATE(149)] = 11320, + [SMALL_STATE(150)] = 11372, + [SMALL_STATE(151)] = 11420, + [SMALL_STATE(152)] = 11472, + [SMALL_STATE(153)] = 11520, + [SMALL_STATE(154)] = 11568, + [SMALL_STATE(155)] = 11616, + [SMALL_STATE(156)] = 11664, + [SMALL_STATE(157)] = 11712, + [SMALL_STATE(158)] = 11760, + [SMALL_STATE(159)] = 11808, + [SMALL_STATE(160)] = 11856, + [SMALL_STATE(161)] = 11929, + [SMALL_STATE(162)] = 12002, + [SMALL_STATE(163)] = 12075, + [SMALL_STATE(164)] = 12126, + [SMALL_STATE(165)] = 12173, + [SMALL_STATE(166)] = 12220, + [SMALL_STATE(167)] = 12267, + [SMALL_STATE(168)] = 12340, + [SMALL_STATE(169)] = 12413, + [SMALL_STATE(170)] = 12486, + [SMALL_STATE(171)] = 12537, + [SMALL_STATE(172)] = 12588, + [SMALL_STATE(173)] = 12661, + [SMALL_STATE(174)] = 12734, + [SMALL_STATE(175)] = 12807, + [SMALL_STATE(176)] = 12880, + [SMALL_STATE(177)] = 12953, + [SMALL_STATE(178)] = 13026, + [SMALL_STATE(179)] = 13077, + [SMALL_STATE(180)] = 13150, + [SMALL_STATE(181)] = 13223, + [SMALL_STATE(182)] = 13296, + [SMALL_STATE(183)] = 13369, + [SMALL_STATE(184)] = 13442, + [SMALL_STATE(185)] = 13515, + [SMALL_STATE(186)] = 13588, + [SMALL_STATE(187)] = 13639, + [SMALL_STATE(188)] = 13712, + [SMALL_STATE(189)] = 13785, + [SMALL_STATE(190)] = 13858, + [SMALL_STATE(191)] = 13931, + [SMALL_STATE(192)] = 14004, + [SMALL_STATE(193)] = 14077, + [SMALL_STATE(194)] = 14150, + [SMALL_STATE(195)] = 14223, + [SMALL_STATE(196)] = 14296, + [SMALL_STATE(197)] = 14369, + [SMALL_STATE(198)] = 14416, + [SMALL_STATE(199)] = 14489, + [SMALL_STATE(200)] = 14562, + [SMALL_STATE(201)] = 14611, + [SMALL_STATE(202)] = 14684, + [SMALL_STATE(203)] = 14757, + [SMALL_STATE(204)] = 14830, + [SMALL_STATE(205)] = 14903, + [SMALL_STATE(206)] = 14976, + [SMALL_STATE(207)] = 15049, + [SMALL_STATE(208)] = 15122, + [SMALL_STATE(209)] = 15195, + [SMALL_STATE(210)] = 15268, + [SMALL_STATE(211)] = 15341, + [SMALL_STATE(212)] = 15388, + [SMALL_STATE(213)] = 15461, + [SMALL_STATE(214)] = 15534, + [SMALL_STATE(215)] = 15580, + [SMALL_STATE(216)] = 15636, + [SMALL_STATE(217)] = 15682, + [SMALL_STATE(218)] = 15728, + [SMALL_STATE(219)] = 15776, + [SMALL_STATE(220)] = 15822, + [SMALL_STATE(221)] = 15868, + [SMALL_STATE(222)] = 15914, + [SMALL_STATE(223)] = 15960, + [SMALL_STATE(224)] = 16006, + [SMALL_STATE(225)] = 16052, + [SMALL_STATE(226)] = 16097, + [SMALL_STATE(227)] = 16142, + [SMALL_STATE(228)] = 16187, + [SMALL_STATE(229)] = 16232, + [SMALL_STATE(230)] = 16277, + [SMALL_STATE(231)] = 16324, + [SMALL_STATE(232)] = 16369, + [SMALL_STATE(233)] = 16414, + [SMALL_STATE(234)] = 16459, + [SMALL_STATE(235)] = 16504, + [SMALL_STATE(236)] = 16548, + [SMALL_STATE(237)] = 16592, + [SMALL_STATE(238)] = 16636, + [SMALL_STATE(239)] = 16680, + [SMALL_STATE(240)] = 16724, + [SMALL_STATE(241)] = 16768, + [SMALL_STATE(242)] = 16812, + [SMALL_STATE(243)] = 16856, + [SMALL_STATE(244)] = 16900, + [SMALL_STATE(245)] = 16944, + [SMALL_STATE(246)] = 16988, + [SMALL_STATE(247)] = 17032, + [SMALL_STATE(248)] = 17102, + [SMALL_STATE(249)] = 17146, + [SMALL_STATE(250)] = 17190, + [SMALL_STATE(251)] = 17234, + [SMALL_STATE(252)] = 17278, + [SMALL_STATE(253)] = 17322, + [SMALL_STATE(254)] = 17366, + [SMALL_STATE(255)] = 17410, + [SMALL_STATE(256)] = 17454, + [SMALL_STATE(257)] = 17498, + [SMALL_STATE(258)] = 17542, + [SMALL_STATE(259)] = 17586, + [SMALL_STATE(260)] = 17630, + [SMALL_STATE(261)] = 17674, + [SMALL_STATE(262)] = 17718, + [SMALL_STATE(263)] = 17762, + [SMALL_STATE(264)] = 17806, + [SMALL_STATE(265)] = 17850, + [SMALL_STATE(266)] = 17894, + [SMALL_STATE(267)] = 17938, + [SMALL_STATE(268)] = 17982, + [SMALL_STATE(269)] = 18026, + [SMALL_STATE(270)] = 18070, + [SMALL_STATE(271)] = 18114, + [SMALL_STATE(272)] = 18158, + [SMALL_STATE(273)] = 18202, + [SMALL_STATE(274)] = 18246, + [SMALL_STATE(275)] = 18290, + [SMALL_STATE(276)] = 18334, + [SMALL_STATE(277)] = 18378, + [SMALL_STATE(278)] = 18422, + [SMALL_STATE(279)] = 18466, + [SMALL_STATE(280)] = 18510, + [SMALL_STATE(281)] = 18554, + [SMALL_STATE(282)] = 18598, + [SMALL_STATE(283)] = 18642, + [SMALL_STATE(284)] = 18686, + [SMALL_STATE(285)] = 18730, + [SMALL_STATE(286)] = 18774, + [SMALL_STATE(287)] = 18818, + [SMALL_STATE(288)] = 18862, + [SMALL_STATE(289)] = 18906, + [SMALL_STATE(290)] = 18950, + [SMALL_STATE(291)] = 18994, + [SMALL_STATE(292)] = 19038, + [SMALL_STATE(293)] = 19082, + [SMALL_STATE(294)] = 19126, + [SMALL_STATE(295)] = 19170, + [SMALL_STATE(296)] = 19214, + [SMALL_STATE(297)] = 19258, + [SMALL_STATE(298)] = 19302, + [SMALL_STATE(299)] = 19346, + [SMALL_STATE(300)] = 19390, + [SMALL_STATE(301)] = 19434, + [SMALL_STATE(302)] = 19478, + [SMALL_STATE(303)] = 19522, + [SMALL_STATE(304)] = 19566, + [SMALL_STATE(305)] = 19610, + [SMALL_STATE(306)] = 19654, + [SMALL_STATE(307)] = 19698, + [SMALL_STATE(308)] = 19742, + [SMALL_STATE(309)] = 19786, + [SMALL_STATE(310)] = 19830, + [SMALL_STATE(311)] = 19874, + [SMALL_STATE(312)] = 19918, + [SMALL_STATE(313)] = 19962, + [SMALL_STATE(314)] = 20006, + [SMALL_STATE(315)] = 20050, + [SMALL_STATE(316)] = 20094, + [SMALL_STATE(317)] = 20138, + [SMALL_STATE(318)] = 20182, + [SMALL_STATE(319)] = 20226, + [SMALL_STATE(320)] = 20270, + [SMALL_STATE(321)] = 20314, + [SMALL_STATE(322)] = 20358, + [SMALL_STATE(323)] = 20402, + [SMALL_STATE(324)] = 20446, + [SMALL_STATE(325)] = 20490, + [SMALL_STATE(326)] = 20534, + [SMALL_STATE(327)] = 20578, + [SMALL_STATE(328)] = 20622, + [SMALL_STATE(329)] = 20666, + [SMALL_STATE(330)] = 20710, + [SMALL_STATE(331)] = 20754, + [SMALL_STATE(332)] = 20798, + [SMALL_STATE(333)] = 20842, + [SMALL_STATE(334)] = 20886, + [SMALL_STATE(335)] = 20930, + [SMALL_STATE(336)] = 20974, + [SMALL_STATE(337)] = 21018, + [SMALL_STATE(338)] = 21062, + [SMALL_STATE(339)] = 21106, + [SMALL_STATE(340)] = 21150, + [SMALL_STATE(341)] = 21194, + [SMALL_STATE(342)] = 21238, + [SMALL_STATE(343)] = 21282, + [SMALL_STATE(344)] = 21326, + [SMALL_STATE(345)] = 21370, + [SMALL_STATE(346)] = 21414, + [SMALL_STATE(347)] = 21458, + [SMALL_STATE(348)] = 21502, + [SMALL_STATE(349)] = 21546, + [SMALL_STATE(350)] = 21590, + [SMALL_STATE(351)] = 21634, + [SMALL_STATE(352)] = 21678, + [SMALL_STATE(353)] = 21722, + [SMALL_STATE(354)] = 21766, + [SMALL_STATE(355)] = 21810, + [SMALL_STATE(356)] = 21854, + [SMALL_STATE(357)] = 21898, + [SMALL_STATE(358)] = 21942, + [SMALL_STATE(359)] = 21986, + [SMALL_STATE(360)] = 22030, + [SMALL_STATE(361)] = 22074, + [SMALL_STATE(362)] = 22118, + [SMALL_STATE(363)] = 22162, + [SMALL_STATE(364)] = 22206, + [SMALL_STATE(365)] = 22250, + [SMALL_STATE(366)] = 22294, + [SMALL_STATE(367)] = 22338, + [SMALL_STATE(368)] = 22382, + [SMALL_STATE(369)] = 22426, + [SMALL_STATE(370)] = 22470, + [SMALL_STATE(371)] = 22514, + [SMALL_STATE(372)] = 22558, + [SMALL_STATE(373)] = 22602, + [SMALL_STATE(374)] = 22646, + [SMALL_STATE(375)] = 22690, + [SMALL_STATE(376)] = 22734, + [SMALL_STATE(377)] = 22778, + [SMALL_STATE(378)] = 22822, + [SMALL_STATE(379)] = 22866, + [SMALL_STATE(380)] = 22910, + [SMALL_STATE(381)] = 22954, + [SMALL_STATE(382)] = 22998, + [SMALL_STATE(383)] = 23042, + [SMALL_STATE(384)] = 23086, + [SMALL_STATE(385)] = 23130, + [SMALL_STATE(386)] = 23174, + [SMALL_STATE(387)] = 23218, + [SMALL_STATE(388)] = 23262, + [SMALL_STATE(389)] = 23306, + [SMALL_STATE(390)] = 23350, + [SMALL_STATE(391)] = 23394, + [SMALL_STATE(392)] = 23438, + [SMALL_STATE(393)] = 23482, + [SMALL_STATE(394)] = 23526, + [SMALL_STATE(395)] = 23570, + [SMALL_STATE(396)] = 23614, + [SMALL_STATE(397)] = 23658, + [SMALL_STATE(398)] = 23702, + [SMALL_STATE(399)] = 23746, + [SMALL_STATE(400)] = 23790, + [SMALL_STATE(401)] = 23834, + [SMALL_STATE(402)] = 23878, + [SMALL_STATE(403)] = 23922, + [SMALL_STATE(404)] = 23966, + [SMALL_STATE(405)] = 24010, + [SMALL_STATE(406)] = 24054, + [SMALL_STATE(407)] = 24098, + [SMALL_STATE(408)] = 24142, + [SMALL_STATE(409)] = 24186, + [SMALL_STATE(410)] = 24230, + [SMALL_STATE(411)] = 24274, + [SMALL_STATE(412)] = 24318, + [SMALL_STATE(413)] = 24362, + [SMALL_STATE(414)] = 24406, + [SMALL_STATE(415)] = 24450, + [SMALL_STATE(416)] = 24496, + [SMALL_STATE(417)] = 24540, + [SMALL_STATE(418)] = 24584, + [SMALL_STATE(419)] = 24628, + [SMALL_STATE(420)] = 24672, + [SMALL_STATE(421)] = 24716, + [SMALL_STATE(422)] = 24760, + [SMALL_STATE(423)] = 24804, + [SMALL_STATE(424)] = 24848, + [SMALL_STATE(425)] = 24892, + [SMALL_STATE(426)] = 24936, + [SMALL_STATE(427)] = 24980, + [SMALL_STATE(428)] = 25024, + [SMALL_STATE(429)] = 25068, + [SMALL_STATE(430)] = 25112, + [SMALL_STATE(431)] = 25156, + [SMALL_STATE(432)] = 25200, + [SMALL_STATE(433)] = 25244, + [SMALL_STATE(434)] = 25288, + [SMALL_STATE(435)] = 25332, + [SMALL_STATE(436)] = 25376, + [SMALL_STATE(437)] = 25420, + [SMALL_STATE(438)] = 25464, + [SMALL_STATE(439)] = 25508, + [SMALL_STATE(440)] = 25552, + [SMALL_STATE(441)] = 25596, + [SMALL_STATE(442)] = 25640, + [SMALL_STATE(443)] = 25684, + [SMALL_STATE(444)] = 25728, + [SMALL_STATE(445)] = 25772, + [SMALL_STATE(446)] = 25816, + [SMALL_STATE(447)] = 25860, + [SMALL_STATE(448)] = 25904, + [SMALL_STATE(449)] = 25948, + [SMALL_STATE(450)] = 25992, + [SMALL_STATE(451)] = 26036, + [SMALL_STATE(452)] = 26080, + [SMALL_STATE(453)] = 26150, + [SMALL_STATE(454)] = 26194, + [SMALL_STATE(455)] = 26238, + [SMALL_STATE(456)] = 26281, + [SMALL_STATE(457)] = 26324, + [SMALL_STATE(458)] = 26367, + [SMALL_STATE(459)] = 26411, + [SMALL_STATE(460)] = 26452, + [SMALL_STATE(461)] = 26495, + [SMALL_STATE(462)] = 26536, + [SMALL_STATE(463)] = 26577, + [SMALL_STATE(464)] = 26620, + [SMALL_STATE(465)] = 26661, + [SMALL_STATE(466)] = 26702, + [SMALL_STATE(467)] = 26743, + [SMALL_STATE(468)] = 26784, + [SMALL_STATE(469)] = 26829, + [SMALL_STATE(470)] = 26870, + [SMALL_STATE(471)] = 26913, + [SMALL_STATE(472)] = 26956, + [SMALL_STATE(473)] = 26997, + [SMALL_STATE(474)] = 27057, + [SMALL_STATE(475)] = 27099, + [SMALL_STATE(476)] = 27141, + [SMALL_STATE(477)] = 27183, + [SMALL_STATE(478)] = 27243, + [SMALL_STATE(479)] = 27303, + [SMALL_STATE(480)] = 27351, + [SMALL_STATE(481)] = 27397, + [SMALL_STATE(482)] = 27439, + [SMALL_STATE(483)] = 27481, + [SMALL_STATE(484)] = 27523, + [SMALL_STATE(485)] = 27583, + [SMALL_STATE(486)] = 27624, + [SMALL_STATE(487)] = 27669, + [SMALL_STATE(488)] = 27707, + [SMALL_STATE(489)] = 27745, + [SMALL_STATE(490)] = 27783, + [SMALL_STATE(491)] = 27821, + [SMALL_STATE(492)] = 27859, + [SMALL_STATE(493)] = 27897, + [SMALL_STATE(494)] = 27935, + [SMALL_STATE(495)] = 27973, + [SMALL_STATE(496)] = 28011, + [SMALL_STATE(497)] = 28049, + [SMALL_STATE(498)] = 28087, + [SMALL_STATE(499)] = 28125, + [SMALL_STATE(500)] = 28163, + [SMALL_STATE(501)] = 28211, + [SMALL_STATE(502)] = 28249, + [SMALL_STATE(503)] = 28287, + [SMALL_STATE(504)] = 28325, + [SMALL_STATE(505)] = 28363, + [SMALL_STATE(506)] = 28401, + [SMALL_STATE(507)] = 28439, + [SMALL_STATE(508)] = 28477, + [SMALL_STATE(509)] = 28515, + [SMALL_STATE(510)] = 28553, + [SMALL_STATE(511)] = 28591, + [SMALL_STATE(512)] = 28629, + [SMALL_STATE(513)] = 28667, + [SMALL_STATE(514)] = 28708, + [SMALL_STATE(515)] = 28747, + [SMALL_STATE(516)] = 28791, + [SMALL_STATE(517)] = 28828, + [SMALL_STATE(518)] = 28865, + [SMALL_STATE(519)] = 28917, + [SMALL_STATE(520)] = 28965, + [SMALL_STATE(521)] = 29007, + [SMALL_STATE(522)] = 29040, + [SMALL_STATE(523)] = 29073, + [SMALL_STATE(524)] = 29106, + [SMALL_STATE(525)] = 29139, + [SMALL_STATE(526)] = 29190, + [SMALL_STATE(527)] = 29223, + [SMALL_STATE(528)] = 29256, + [SMALL_STATE(529)] = 29287, + [SMALL_STATE(530)] = 29320, + [SMALL_STATE(531)] = 29351, + [SMALL_STATE(532)] = 29384, + [SMALL_STATE(533)] = 29415, + [SMALL_STATE(534)] = 29446, + [SMALL_STATE(535)] = 29479, + [SMALL_STATE(536)] = 29510, + [SMALL_STATE(537)] = 29541, + [SMALL_STATE(538)] = 29572, + [SMALL_STATE(539)] = 29603, + [SMALL_STATE(540)] = 29651, + [SMALL_STATE(541)] = 29681, + [SMALL_STATE(542)] = 29717, + [SMALL_STATE(543)] = 29747, + [SMALL_STATE(544)] = 29777, + [SMALL_STATE(545)] = 29807, + [SMALL_STATE(546)] = 29855, + [SMALL_STATE(547)] = 29894, + [SMALL_STATE(548)] = 29927, + [SMALL_STATE(549)] = 29966, + [SMALL_STATE(550)] = 29999, + [SMALL_STATE(551)] = 30036, + [SMALL_STATE(552)] = 30075, + [SMALL_STATE(553)] = 30112, + [SMALL_STATE(554)] = 30145, + [SMALL_STATE(555)] = 30178, + [SMALL_STATE(556)] = 30211, + [SMALL_STATE(557)] = 30257, + [SMALL_STATE(558)] = 30285, + [SMALL_STATE(559)] = 30313, + [SMALL_STATE(560)] = 30359, + [SMALL_STATE(561)] = 30405, + [SMALL_STATE(562)] = 30433, + [SMALL_STATE(563)] = 30463, + [SMALL_STATE(564)] = 30491, + [SMALL_STATE(565)] = 30519, + [SMALL_STATE(566)] = 30549, + [SMALL_STATE(567)] = 30578, + [SMALL_STATE(568)] = 30619, + [SMALL_STATE(569)] = 30662, + [SMALL_STATE(570)] = 30705, + [SMALL_STATE(571)] = 30746, + [SMALL_STATE(572)] = 30789, + [SMALL_STATE(573)] = 30829, + [SMALL_STATE(574)] = 30869, + [SMALL_STATE(575)] = 30909, + [SMALL_STATE(576)] = 30949, + [SMALL_STATE(577)] = 30981, + [SMALL_STATE(578)] = 31021, + [SMALL_STATE(579)] = 31061, + [SMALL_STATE(580)] = 31101, + [SMALL_STATE(581)] = 31141, + [SMALL_STATE(582)] = 31181, + [SMALL_STATE(583)] = 31221, + [SMALL_STATE(584)] = 31261, + [SMALL_STATE(585)] = 31301, + [SMALL_STATE(586)] = 31341, + [SMALL_STATE(587)] = 31381, + [SMALL_STATE(588)] = 31421, + [SMALL_STATE(589)] = 31461, + [SMALL_STATE(590)] = 31501, + [SMALL_STATE(591)] = 31541, + [SMALL_STATE(592)] = 31581, + [SMALL_STATE(593)] = 31615, + [SMALL_STATE(594)] = 31649, + [SMALL_STATE(595)] = 31689, + [SMALL_STATE(596)] = 31729, + [SMALL_STATE(597)] = 31769, + [SMALL_STATE(598)] = 31806, + [SMALL_STATE(599)] = 31843, + [SMALL_STATE(600)] = 31880, + [SMALL_STATE(601)] = 31917, + [SMALL_STATE(602)] = 31954, + [SMALL_STATE(603)] = 31991, + [SMALL_STATE(604)] = 32028, + [SMALL_STATE(605)] = 32065, + [SMALL_STATE(606)] = 32102, + [SMALL_STATE(607)] = 32139, + [SMALL_STATE(608)] = 32176, + [SMALL_STATE(609)] = 32213, + [SMALL_STATE(610)] = 32250, + [SMALL_STATE(611)] = 32287, + [SMALL_STATE(612)] = 32324, + [SMALL_STATE(613)] = 32361, + [SMALL_STATE(614)] = 32398, + [SMALL_STATE(615)] = 32435, + [SMALL_STATE(616)] = 32472, + [SMALL_STATE(617)] = 32509, + [SMALL_STATE(618)] = 32546, + [SMALL_STATE(619)] = 32583, + [SMALL_STATE(620)] = 32620, + [SMALL_STATE(621)] = 32657, + [SMALL_STATE(622)] = 32694, + [SMALL_STATE(623)] = 32731, + [SMALL_STATE(624)] = 32772, + [SMALL_STATE(625)] = 32809, + [SMALL_STATE(626)] = 32846, + [SMALL_STATE(627)] = 32889, + [SMALL_STATE(628)] = 32926, + [SMALL_STATE(629)] = 32963, + [SMALL_STATE(630)] = 33000, + [SMALL_STATE(631)] = 33037, + [SMALL_STATE(632)] = 33064, + [SMALL_STATE(633)] = 33101, + [SMALL_STATE(634)] = 33144, + [SMALL_STATE(635)] = 33181, + [SMALL_STATE(636)] = 33218, + [SMALL_STATE(637)] = 33261, + [SMALL_STATE(638)] = 33298, + [SMALL_STATE(639)] = 33325, + [SMALL_STATE(640)] = 33362, + [SMALL_STATE(641)] = 33399, + [SMALL_STATE(642)] = 33426, + [SMALL_STATE(643)] = 33463, + [SMALL_STATE(644)] = 33500, + [SMALL_STATE(645)] = 33527, + [SMALL_STATE(646)] = 33564, + [SMALL_STATE(647)] = 33601, + [SMALL_STATE(648)] = 33638, + [SMALL_STATE(649)] = 33675, + [SMALL_STATE(650)] = 33712, + [SMALL_STATE(651)] = 33749, + [SMALL_STATE(652)] = 33786, + [SMALL_STATE(653)] = 33823, + [SMALL_STATE(654)] = 33860, + [SMALL_STATE(655)] = 33897, + [SMALL_STATE(656)] = 33934, + [SMALL_STATE(657)] = 33971, + [SMALL_STATE(658)] = 34008, + [SMALL_STATE(659)] = 34045, + [SMALL_STATE(660)] = 34082, + [SMALL_STATE(661)] = 34119, + [SMALL_STATE(662)] = 34156, + [SMALL_STATE(663)] = 34193, + [SMALL_STATE(664)] = 34230, + [SMALL_STATE(665)] = 34267, + [SMALL_STATE(666)] = 34304, + [SMALL_STATE(667)] = 34341, + [SMALL_STATE(668)] = 34378, + [SMALL_STATE(669)] = 34415, + [SMALL_STATE(670)] = 34452, + [SMALL_STATE(671)] = 34489, + [SMALL_STATE(672)] = 34526, + [SMALL_STATE(673)] = 34563, + [SMALL_STATE(674)] = 34600, + [SMALL_STATE(675)] = 34637, + [SMALL_STATE(676)] = 34674, + [SMALL_STATE(677)] = 34711, + [SMALL_STATE(678)] = 34748, + [SMALL_STATE(679)] = 34785, + [SMALL_STATE(680)] = 34822, + [SMALL_STATE(681)] = 34857, + [SMALL_STATE(682)] = 34897, + [SMALL_STATE(683)] = 34937, + [SMALL_STATE(684)] = 34975, + [SMALL_STATE(685)] = 35008, + [SMALL_STATE(686)] = 35031, + [SMALL_STATE(687)] = 35054, + [SMALL_STATE(688)] = 35081, + [SMALL_STATE(689)] = 35104, + [SMALL_STATE(690)] = 35127, + [SMALL_STATE(691)] = 35150, + [SMALL_STATE(692)] = 35173, + [SMALL_STATE(693)] = 35206, + [SMALL_STATE(694)] = 35229, + [SMALL_STATE(695)] = 35252, + [SMALL_STATE(696)] = 35285, + [SMALL_STATE(697)] = 35316, + [SMALL_STATE(698)] = 35347, + [SMALL_STATE(699)] = 35376, + [SMALL_STATE(700)] = 35399, + [SMALL_STATE(701)] = 35422, + [SMALL_STATE(702)] = 35445, + [SMALL_STATE(703)] = 35468, + [SMALL_STATE(704)] = 35491, + [SMALL_STATE(705)] = 35514, + [SMALL_STATE(706)] = 35551, + [SMALL_STATE(707)] = 35574, + [SMALL_STATE(708)] = 35597, + [SMALL_STATE(709)] = 35620, + [SMALL_STATE(710)] = 35643, + [SMALL_STATE(711)] = 35666, + [SMALL_STATE(712)] = 35689, + [SMALL_STATE(713)] = 35712, + [SMALL_STATE(714)] = 35735, + [SMALL_STATE(715)] = 35768, + [SMALL_STATE(716)] = 35791, + [SMALL_STATE(717)] = 35814, + [SMALL_STATE(718)] = 35837, + [SMALL_STATE(719)] = 35860, + [SMALL_STATE(720)] = 35883, + [SMALL_STATE(721)] = 35906, + [SMALL_STATE(722)] = 35929, + [SMALL_STATE(723)] = 35966, + [SMALL_STATE(724)] = 35989, + [SMALL_STATE(725)] = 36012, + [SMALL_STATE(726)] = 36035, + [SMALL_STATE(727)] = 36067, + [SMALL_STATE(728)] = 36101, + [SMALL_STATE(729)] = 36133, + [SMALL_STATE(730)] = 36165, + [SMALL_STATE(731)] = 36197, + [SMALL_STATE(732)] = 36229, + [SMALL_STATE(733)] = 36249, + [SMALL_STATE(734)] = 36269, + [SMALL_STATE(735)] = 36301, + [SMALL_STATE(736)] = 36335, + [SMALL_STATE(737)] = 36355, + [SMALL_STATE(738)] = 36387, + [SMALL_STATE(739)] = 36418, + [SMALL_STATE(740)] = 36449, + [SMALL_STATE(741)] = 36480, + [SMALL_STATE(742)] = 36511, + [SMALL_STATE(743)] = 36540, + [SMALL_STATE(744)] = 36571, + [SMALL_STATE(745)] = 36602, + [SMALL_STATE(746)] = 36633, + [SMALL_STATE(747)] = 36664, + [SMALL_STATE(748)] = 36695, + [SMALL_STATE(749)] = 36726, + [SMALL_STATE(750)] = 36757, + [SMALL_STATE(751)] = 36788, + [SMALL_STATE(752)] = 36821, + [SMALL_STATE(753)] = 36852, + [SMALL_STATE(754)] = 36883, + [SMALL_STATE(755)] = 36912, + [SMALL_STATE(756)] = 36943, + [SMALL_STATE(757)] = 36974, + [SMALL_STATE(758)] = 37005, + [SMALL_STATE(759)] = 37031, + [SMALL_STATE(760)] = 37059, + [SMALL_STATE(761)] = 37087, + [SMALL_STATE(762)] = 37115, + [SMALL_STATE(763)] = 37143, + [SMALL_STATE(764)] = 37171, + [SMALL_STATE(765)] = 37199, + [SMALL_STATE(766)] = 37227, + [SMALL_STATE(767)] = 37255, + [SMALL_STATE(768)] = 37283, + [SMALL_STATE(769)] = 37311, + [SMALL_STATE(770)] = 37339, + [SMALL_STATE(771)] = 37365, + [SMALL_STATE(772)] = 37393, + [SMALL_STATE(773)] = 37421, + [SMALL_STATE(774)] = 37449, + [SMALL_STATE(775)] = 37479, + [SMALL_STATE(776)] = 37509, + [SMALL_STATE(777)] = 37535, + [SMALL_STATE(778)] = 37555, + [SMALL_STATE(779)] = 37581, + [SMALL_STATE(780)] = 37609, + [SMALL_STATE(781)] = 37635, + [SMALL_STATE(782)] = 37663, + [SMALL_STATE(783)] = 37691, + [SMALL_STATE(784)] = 37719, + [SMALL_STATE(785)] = 37747, + [SMALL_STATE(786)] = 37775, + [SMALL_STATE(787)] = 37801, + [SMALL_STATE(788)] = 37827, + [SMALL_STATE(789)] = 37853, + [SMALL_STATE(790)] = 37881, + [SMALL_STATE(791)] = 37907, + [SMALL_STATE(792)] = 37935, + [SMALL_STATE(793)] = 37965, + [SMALL_STATE(794)] = 37993, + [SMALL_STATE(795)] = 38019, + [SMALL_STATE(796)] = 38047, + [SMALL_STATE(797)] = 38075, + [SMALL_STATE(798)] = 38101, + [SMALL_STATE(799)] = 38127, + [SMALL_STATE(800)] = 38153, + [SMALL_STATE(801)] = 38181, + [SMALL_STATE(802)] = 38209, + [SMALL_STATE(803)] = 38237, + [SMALL_STATE(804)] = 38265, + [SMALL_STATE(805)] = 38291, + [SMALL_STATE(806)] = 38319, + [SMALL_STATE(807)] = 38345, + [SMALL_STATE(808)] = 38373, + [SMALL_STATE(809)] = 38399, + [SMALL_STATE(810)] = 38425, + [SMALL_STATE(811)] = 38453, + [SMALL_STATE(812)] = 38479, + [SMALL_STATE(813)] = 38507, + [SMALL_STATE(814)] = 38530, + [SMALL_STATE(815)] = 38557, + [SMALL_STATE(816)] = 38584, + [SMALL_STATE(817)] = 38611, + [SMALL_STATE(818)] = 38638, + [SMALL_STATE(819)] = 38665, + [SMALL_STATE(820)] = 38692, + [SMALL_STATE(821)] = 38719, + [SMALL_STATE(822)] = 38742, + [SMALL_STATE(823)] = 38761, + [SMALL_STATE(824)] = 38788, + [SMALL_STATE(825)] = 38811, + [SMALL_STATE(826)] = 38830, + [SMALL_STATE(827)] = 38857, + [SMALL_STATE(828)] = 38884, + [SMALL_STATE(829)] = 38911, + [SMALL_STATE(830)] = 38938, + [SMALL_STATE(831)] = 38965, + [SMALL_STATE(832)] = 38992, + [SMALL_STATE(833)] = 39019, + [SMALL_STATE(834)] = 39046, + [SMALL_STATE(835)] = 39065, + [SMALL_STATE(836)] = 39092, + [SMALL_STATE(837)] = 39119, + [SMALL_STATE(838)] = 39142, + [SMALL_STATE(839)] = 39161, + [SMALL_STATE(840)] = 39188, + [SMALL_STATE(841)] = 39207, + [SMALL_STATE(842)] = 39234, + [SMALL_STATE(843)] = 39261, + [SMALL_STATE(844)] = 39288, + [SMALL_STATE(845)] = 39315, + [SMALL_STATE(846)] = 39342, + [SMALL_STATE(847)] = 39369, + [SMALL_STATE(848)] = 39392, + [SMALL_STATE(849)] = 39419, + [SMALL_STATE(850)] = 39446, + [SMALL_STATE(851)] = 39465, + [SMALL_STATE(852)] = 39488, + [SMALL_STATE(853)] = 39511, + [SMALL_STATE(854)] = 39534, + [SMALL_STATE(855)] = 39557, + [SMALL_STATE(856)] = 39580, + [SMALL_STATE(857)] = 39603, + [SMALL_STATE(858)] = 39626, + [SMALL_STATE(859)] = 39649, + [SMALL_STATE(860)] = 39676, + [SMALL_STATE(861)] = 39699, + [SMALL_STATE(862)] = 39726, + [SMALL_STATE(863)] = 39749, + [SMALL_STATE(864)] = 39776, + [SMALL_STATE(865)] = 39795, + [SMALL_STATE(866)] = 39818, + [SMALL_STATE(867)] = 39845, + [SMALL_STATE(868)] = 39872, + [SMALL_STATE(869)] = 39899, + [SMALL_STATE(870)] = 39926, + [SMALL_STATE(871)] = 39953, + [SMALL_STATE(872)] = 39976, + [SMALL_STATE(873)] = 39999, + [SMALL_STATE(874)] = 40026, + [SMALL_STATE(875)] = 40053, + [SMALL_STATE(876)] = 40080, + [SMALL_STATE(877)] = 40103, + [SMALL_STATE(878)] = 40130, + [SMALL_STATE(879)] = 40153, + [SMALL_STATE(880)] = 40180, + [SMALL_STATE(881)] = 40207, + [SMALL_STATE(882)] = 40226, + [SMALL_STATE(883)] = 40249, + [SMALL_STATE(884)] = 40268, + [SMALL_STATE(885)] = 40291, + [SMALL_STATE(886)] = 40310, + [SMALL_STATE(887)] = 40333, + [SMALL_STATE(888)] = 40360, + [SMALL_STATE(889)] = 40387, + [SMALL_STATE(890)] = 40414, + [SMALL_STATE(891)] = 40441, + [SMALL_STATE(892)] = 40468, + [SMALL_STATE(893)] = 40495, + [SMALL_STATE(894)] = 40522, + [SMALL_STATE(895)] = 40541, + [SMALL_STATE(896)] = 40560, + [SMALL_STATE(897)] = 40587, + [SMALL_STATE(898)] = 40607, + [SMALL_STATE(899)] = 40631, + [SMALL_STATE(900)] = 40653, + [SMALL_STATE(901)] = 40673, + [SMALL_STATE(902)] = 40693, + [SMALL_STATE(903)] = 40713, + [SMALL_STATE(904)] = 40733, + [SMALL_STATE(905)] = 40755, + [SMALL_STATE(906)] = 40776, + [SMALL_STATE(907)] = 40799, + [SMALL_STATE(908)] = 40822, + [SMALL_STATE(909)] = 40845, + [SMALL_STATE(910)] = 40868, + [SMALL_STATE(911)] = 40885, + [SMALL_STATE(912)] = 40908, + [SMALL_STATE(913)] = 40931, + [SMALL_STATE(914)] = 40946, + [SMALL_STATE(915)] = 40969, + [SMALL_STATE(916)] = 40992, + [SMALL_STATE(917)] = 41009, + [SMALL_STATE(918)] = 41032, + [SMALL_STATE(919)] = 41055, + [SMALL_STATE(920)] = 41078, + [SMALL_STATE(921)] = 41099, + [SMALL_STATE(922)] = 41114, + [SMALL_STATE(923)] = 41137, + [SMALL_STATE(924)] = 41152, + [SMALL_STATE(925)] = 41169, + [SMALL_STATE(926)] = 41192, + [SMALL_STATE(927)] = 41215, + [SMALL_STATE(928)] = 41238, + [SMALL_STATE(929)] = 41259, + [SMALL_STATE(930)] = 41282, + [SMALL_STATE(931)] = 41297, + [SMALL_STATE(932)] = 41320, + [SMALL_STATE(933)] = 41343, + [SMALL_STATE(934)] = 41361, + [SMALL_STATE(935)] = 41381, + [SMALL_STATE(936)] = 41399, + [SMALL_STATE(937)] = 41417, + [SMALL_STATE(938)] = 41435, + [SMALL_STATE(939)] = 41453, + [SMALL_STATE(940)] = 41471, + [SMALL_STATE(941)] = 41491, + [SMALL_STATE(942)] = 41511, + [SMALL_STATE(943)] = 41531, + [SMALL_STATE(944)] = 41551, + [SMALL_STATE(945)] = 41571, + [SMALL_STATE(946)] = 41591, + [SMALL_STATE(947)] = 41609, + [SMALL_STATE(948)] = 41627, + [SMALL_STATE(949)] = 41645, + [SMALL_STATE(950)] = 41665, + [SMALL_STATE(951)] = 41683, + [SMALL_STATE(952)] = 41703, + [SMALL_STATE(953)] = 41723, + [SMALL_STATE(954)] = 41743, + [SMALL_STATE(955)] = 41761, + [SMALL_STATE(956)] = 41781, + [SMALL_STATE(957)] = 41801, + [SMALL_STATE(958)] = 41819, + [SMALL_STATE(959)] = 41839, + [SMALL_STATE(960)] = 41857, + [SMALL_STATE(961)] = 41877, + [SMALL_STATE(962)] = 41895, + [SMALL_STATE(963)] = 41915, + [SMALL_STATE(964)] = 41933, + [SMALL_STATE(965)] = 41951, + [SMALL_STATE(966)] = 41971, + [SMALL_STATE(967)] = 41991, + [SMALL_STATE(968)] = 42009, + [SMALL_STATE(969)] = 42027, + [SMALL_STATE(970)] = 42045, + [SMALL_STATE(971)] = 42062, + [SMALL_STATE(972)] = 42079, + [SMALL_STATE(973)] = 42096, + [SMALL_STATE(974)] = 42113, + [SMALL_STATE(975)] = 42130, + [SMALL_STATE(976)] = 42143, + [SMALL_STATE(977)] = 42160, + [SMALL_STATE(978)] = 42173, + [SMALL_STATE(979)] = 42190, + [SMALL_STATE(980)] = 42203, + [SMALL_STATE(981)] = 42216, + [SMALL_STATE(982)] = 42233, + [SMALL_STATE(983)] = 42248, + [SMALL_STATE(984)] = 42265, + [SMALL_STATE(985)] = 42282, + [SMALL_STATE(986)] = 42299, + [SMALL_STATE(987)] = 42316, + [SMALL_STATE(988)] = 42333, + [SMALL_STATE(989)] = 42350, + [SMALL_STATE(990)] = 42367, + [SMALL_STATE(991)] = 42380, + [SMALL_STATE(992)] = 42397, + [SMALL_STATE(993)] = 42414, + [SMALL_STATE(994)] = 42431, + [SMALL_STATE(995)] = 42448, + [SMALL_STATE(996)] = 42465, + [SMALL_STATE(997)] = 42482, + [SMALL_STATE(998)] = 42499, + [SMALL_STATE(999)] = 42516, + [SMALL_STATE(1000)] = 42533, + [SMALL_STATE(1001)] = 42550, + [SMALL_STATE(1002)] = 42567, + [SMALL_STATE(1003)] = 42584, + [SMALL_STATE(1004)] = 42601, + [SMALL_STATE(1005)] = 42618, + [SMALL_STATE(1006)] = 42635, + [SMALL_STATE(1007)] = 42652, + [SMALL_STATE(1008)] = 42669, + [SMALL_STATE(1009)] = 42686, + [SMALL_STATE(1010)] = 42703, + [SMALL_STATE(1011)] = 42720, + [SMALL_STATE(1012)] = 42737, + [SMALL_STATE(1013)] = 42754, + [SMALL_STATE(1014)] = 42771, + [SMALL_STATE(1015)] = 42788, + [SMALL_STATE(1016)] = 42805, + [SMALL_STATE(1017)] = 42822, + [SMALL_STATE(1018)] = 42839, + [SMALL_STATE(1019)] = 42852, + [SMALL_STATE(1020)] = 42865, + [SMALL_STATE(1021)] = 42880, + [SMALL_STATE(1022)] = 42893, + [SMALL_STATE(1023)] = 42910, + [SMALL_STATE(1024)] = 42927, + [SMALL_STATE(1025)] = 42944, + [SMALL_STATE(1026)] = 42959, + [SMALL_STATE(1027)] = 42976, + [SMALL_STATE(1028)] = 42993, + [SMALL_STATE(1029)] = 43008, + [SMALL_STATE(1030)] = 43025, + [SMALL_STATE(1031)] = 43042, + [SMALL_STATE(1032)] = 43059, + [SMALL_STATE(1033)] = 43076, + [SMALL_STATE(1034)] = 43091, + [SMALL_STATE(1035)] = 43108, + [SMALL_STATE(1036)] = 43125, + [SMALL_STATE(1037)] = 43138, + [SMALL_STATE(1038)] = 43151, + [SMALL_STATE(1039)] = 43164, + [SMALL_STATE(1040)] = 43181, + [SMALL_STATE(1041)] = 43198, + [SMALL_STATE(1042)] = 43215, + [SMALL_STATE(1043)] = 43232, + [SMALL_STATE(1044)] = 43249, + [SMALL_STATE(1045)] = 43266, + [SMALL_STATE(1046)] = 43283, + [SMALL_STATE(1047)] = 43300, + [SMALL_STATE(1048)] = 43317, + [SMALL_STATE(1049)] = 43334, + [SMALL_STATE(1050)] = 43351, + [SMALL_STATE(1051)] = 43368, + [SMALL_STATE(1052)] = 43385, + [SMALL_STATE(1053)] = 43402, + [SMALL_STATE(1054)] = 43419, + [SMALL_STATE(1055)] = 43436, + [SMALL_STATE(1056)] = 43453, + [SMALL_STATE(1057)] = 43470, + [SMALL_STATE(1058)] = 43487, + [SMALL_STATE(1059)] = 43504, + [SMALL_STATE(1060)] = 43521, + [SMALL_STATE(1061)] = 43538, + [SMALL_STATE(1062)] = 43555, + [SMALL_STATE(1063)] = 43572, + [SMALL_STATE(1064)] = 43589, + [SMALL_STATE(1065)] = 43606, + [SMALL_STATE(1066)] = 43623, + [SMALL_STATE(1067)] = 43640, + [SMALL_STATE(1068)] = 43657, + [SMALL_STATE(1069)] = 43674, + [SMALL_STATE(1070)] = 43691, + [SMALL_STATE(1071)] = 43708, + [SMALL_STATE(1072)] = 43725, + [SMALL_STATE(1073)] = 43742, + [SMALL_STATE(1074)] = 43759, + [SMALL_STATE(1075)] = 43776, + [SMALL_STATE(1076)] = 43793, + [SMALL_STATE(1077)] = 43810, + [SMALL_STATE(1078)] = 43827, + [SMALL_STATE(1079)] = 43844, + [SMALL_STATE(1080)] = 43861, + [SMALL_STATE(1081)] = 43878, + [SMALL_STATE(1082)] = 43895, + [SMALL_STATE(1083)] = 43912, + [SMALL_STATE(1084)] = 43929, + [SMALL_STATE(1085)] = 43946, + [SMALL_STATE(1086)] = 43963, + [SMALL_STATE(1087)] = 43980, + [SMALL_STATE(1088)] = 43997, + [SMALL_STATE(1089)] = 44010, + [SMALL_STATE(1090)] = 44027, + [SMALL_STATE(1091)] = 44044, + [SMALL_STATE(1092)] = 44061, + [SMALL_STATE(1093)] = 44078, + [SMALL_STATE(1094)] = 44095, + [SMALL_STATE(1095)] = 44112, + [SMALL_STATE(1096)] = 44129, + [SMALL_STATE(1097)] = 44146, + [SMALL_STATE(1098)] = 44163, + [SMALL_STATE(1099)] = 44180, + [SMALL_STATE(1100)] = 44197, + [SMALL_STATE(1101)] = 44214, + [SMALL_STATE(1102)] = 44231, + [SMALL_STATE(1103)] = 44248, + [SMALL_STATE(1104)] = 44261, + [SMALL_STATE(1105)] = 44278, + [SMALL_STATE(1106)] = 44295, + [SMALL_STATE(1107)] = 44312, + [SMALL_STATE(1108)] = 44329, + [SMALL_STATE(1109)] = 44346, + [SMALL_STATE(1110)] = 44363, + [SMALL_STATE(1111)] = 44380, + [SMALL_STATE(1112)] = 44397, + [SMALL_STATE(1113)] = 44414, + [SMALL_STATE(1114)] = 44431, + [SMALL_STATE(1115)] = 44448, + [SMALL_STATE(1116)] = 44465, + [SMALL_STATE(1117)] = 44482, + [SMALL_STATE(1118)] = 44499, + [SMALL_STATE(1119)] = 44516, + [SMALL_STATE(1120)] = 44533, + [SMALL_STATE(1121)] = 44550, + [SMALL_STATE(1122)] = 44567, + [SMALL_STATE(1123)] = 44584, + [SMALL_STATE(1124)] = 44601, + [SMALL_STATE(1125)] = 44618, + [SMALL_STATE(1126)] = 44635, + [SMALL_STATE(1127)] = 44652, + [SMALL_STATE(1128)] = 44669, + [SMALL_STATE(1129)] = 44686, + [SMALL_STATE(1130)] = 44703, + [SMALL_STATE(1131)] = 44720, + [SMALL_STATE(1132)] = 44737, + [SMALL_STATE(1133)] = 44754, + [SMALL_STATE(1134)] = 44769, + [SMALL_STATE(1135)] = 44786, + [SMALL_STATE(1136)] = 44803, + [SMALL_STATE(1137)] = 44820, + [SMALL_STATE(1138)] = 44837, + [SMALL_STATE(1139)] = 44854, + [SMALL_STATE(1140)] = 44871, + [SMALL_STATE(1141)] = 44888, + [SMALL_STATE(1142)] = 44905, + [SMALL_STATE(1143)] = 44922, + [SMALL_STATE(1144)] = 44939, + [SMALL_STATE(1145)] = 44956, + [SMALL_STATE(1146)] = 44973, + [SMALL_STATE(1147)] = 44990, + [SMALL_STATE(1148)] = 45007, + [SMALL_STATE(1149)] = 45024, + [SMALL_STATE(1150)] = 45041, + [SMALL_STATE(1151)] = 45058, + [SMALL_STATE(1152)] = 45075, + [SMALL_STATE(1153)] = 45088, + [SMALL_STATE(1154)] = 45105, + [SMALL_STATE(1155)] = 45122, + [SMALL_STATE(1156)] = 45139, + [SMALL_STATE(1157)] = 45156, + [SMALL_STATE(1158)] = 45173, + [SMALL_STATE(1159)] = 45190, + [SMALL_STATE(1160)] = 45205, + [SMALL_STATE(1161)] = 45222, + [SMALL_STATE(1162)] = 45239, + [SMALL_STATE(1163)] = 45256, + [SMALL_STATE(1164)] = 45273, + [SMALL_STATE(1165)] = 45290, + [SMALL_STATE(1166)] = 45307, + [SMALL_STATE(1167)] = 45324, + [SMALL_STATE(1168)] = 45341, + [SMALL_STATE(1169)] = 45358, + [SMALL_STATE(1170)] = 45375, + [SMALL_STATE(1171)] = 45392, + [SMALL_STATE(1172)] = 45409, + [SMALL_STATE(1173)] = 45426, + [SMALL_STATE(1174)] = 45443, + [SMALL_STATE(1175)] = 45460, + [SMALL_STATE(1176)] = 45475, + [SMALL_STATE(1177)] = 45492, + [SMALL_STATE(1178)] = 45509, + [SMALL_STATE(1179)] = 45526, + [SMALL_STATE(1180)] = 45543, + [SMALL_STATE(1181)] = 45560, + [SMALL_STATE(1182)] = 45577, + [SMALL_STATE(1183)] = 45594, + [SMALL_STATE(1184)] = 45611, + [SMALL_STATE(1185)] = 45628, + [SMALL_STATE(1186)] = 45643, + [SMALL_STATE(1187)] = 45660, + [SMALL_STATE(1188)] = 45677, + [SMALL_STATE(1189)] = 45694, + [SMALL_STATE(1190)] = 45707, + [SMALL_STATE(1191)] = 45724, + [SMALL_STATE(1192)] = 45737, + [SMALL_STATE(1193)] = 45754, + [SMALL_STATE(1194)] = 45768, + [SMALL_STATE(1195)] = 45782, + [SMALL_STATE(1196)] = 45794, + [SMALL_STATE(1197)] = 45808, + [SMALL_STATE(1198)] = 45822, + [SMALL_STATE(1199)] = 45836, + [SMALL_STATE(1200)] = 45850, + [SMALL_STATE(1201)] = 45864, + [SMALL_STATE(1202)] = 45876, + [SMALL_STATE(1203)] = 45890, + [SMALL_STATE(1204)] = 45904, + [SMALL_STATE(1205)] = 45918, + [SMALL_STATE(1206)] = 45932, + [SMALL_STATE(1207)] = 45944, + [SMALL_STATE(1208)] = 45958, + [SMALL_STATE(1209)] = 45972, + [SMALL_STATE(1210)] = 45986, + [SMALL_STATE(1211)] = 46000, + [SMALL_STATE(1212)] = 46014, + [SMALL_STATE(1213)] = 46028, + [SMALL_STATE(1214)] = 46040, + [SMALL_STATE(1215)] = 46054, + [SMALL_STATE(1216)] = 46068, + [SMALL_STATE(1217)] = 46080, + [SMALL_STATE(1218)] = 46094, + [SMALL_STATE(1219)] = 46108, + [SMALL_STATE(1220)] = 46120, + [SMALL_STATE(1221)] = 46132, + [SMALL_STATE(1222)] = 46146, + [SMALL_STATE(1223)] = 46160, + [SMALL_STATE(1224)] = 46174, + [SMALL_STATE(1225)] = 46188, + [SMALL_STATE(1226)] = 46200, + [SMALL_STATE(1227)] = 46214, + [SMALL_STATE(1228)] = 46226, + [SMALL_STATE(1229)] = 46238, + [SMALL_STATE(1230)] = 46252, + [SMALL_STATE(1231)] = 46264, + [SMALL_STATE(1232)] = 46276, + [SMALL_STATE(1233)] = 46290, + [SMALL_STATE(1234)] = 46304, + [SMALL_STATE(1235)] = 46316, + [SMALL_STATE(1236)] = 46330, + [SMALL_STATE(1237)] = 46342, + [SMALL_STATE(1238)] = 46354, + [SMALL_STATE(1239)] = 46368, + [SMALL_STATE(1240)] = 46382, + [SMALL_STATE(1241)] = 46396, + [SMALL_STATE(1242)] = 46408, + [SMALL_STATE(1243)] = 46422, + [SMALL_STATE(1244)] = 46436, + [SMALL_STATE(1245)] = 46448, + [SMALL_STATE(1246)] = 46460, + [SMALL_STATE(1247)] = 46474, + [SMALL_STATE(1248)] = 46488, + [SMALL_STATE(1249)] = 46500, + [SMALL_STATE(1250)] = 46514, + [SMALL_STATE(1251)] = 46528, + [SMALL_STATE(1252)] = 46542, + [SMALL_STATE(1253)] = 46556, + [SMALL_STATE(1254)] = 46568, + [SMALL_STATE(1255)] = 46582, + [SMALL_STATE(1256)] = 46596, + [SMALL_STATE(1257)] = 46610, + [SMALL_STATE(1258)] = 46624, + [SMALL_STATE(1259)] = 46636, + [SMALL_STATE(1260)] = 46650, + [SMALL_STATE(1261)] = 46664, + [SMALL_STATE(1262)] = 46678, + [SMALL_STATE(1263)] = 46692, + [SMALL_STATE(1264)] = 46704, + [SMALL_STATE(1265)] = 46718, + [SMALL_STATE(1266)] = 46730, + [SMALL_STATE(1267)] = 46744, + [SMALL_STATE(1268)] = 46756, + [SMALL_STATE(1269)] = 46770, + [SMALL_STATE(1270)] = 46784, + [SMALL_STATE(1271)] = 46798, + [SMALL_STATE(1272)] = 46812, + [SMALL_STATE(1273)] = 46826, + [SMALL_STATE(1274)] = 46838, + [SMALL_STATE(1275)] = 46852, + [SMALL_STATE(1276)] = 46864, + [SMALL_STATE(1277)] = 46878, + [SMALL_STATE(1278)] = 46892, + [SMALL_STATE(1279)] = 46906, + [SMALL_STATE(1280)] = 46920, + [SMALL_STATE(1281)] = 46934, + [SMALL_STATE(1282)] = 46946, + [SMALL_STATE(1283)] = 46960, + [SMALL_STATE(1284)] = 46974, + [SMALL_STATE(1285)] = 46988, + [SMALL_STATE(1286)] = 47002, + [SMALL_STATE(1287)] = 47016, + [SMALL_STATE(1288)] = 47030, + [SMALL_STATE(1289)] = 47042, + [SMALL_STATE(1290)] = 47054, + [SMALL_STATE(1291)] = 47066, + [SMALL_STATE(1292)] = 47080, + [SMALL_STATE(1293)] = 47094, + [SMALL_STATE(1294)] = 47108, + [SMALL_STATE(1295)] = 47122, + [SMALL_STATE(1296)] = 47136, + [SMALL_STATE(1297)] = 47148, + [SMALL_STATE(1298)] = 47162, + [SMALL_STATE(1299)] = 47176, + [SMALL_STATE(1300)] = 47190, + [SMALL_STATE(1301)] = 47204, + [SMALL_STATE(1302)] = 47218, + [SMALL_STATE(1303)] = 47230, + [SMALL_STATE(1304)] = 47242, + [SMALL_STATE(1305)] = 47256, + [SMALL_STATE(1306)] = 47270, + [SMALL_STATE(1307)] = 47284, + [SMALL_STATE(1308)] = 47298, + [SMALL_STATE(1309)] = 47310, + [SMALL_STATE(1310)] = 47324, + [SMALL_STATE(1311)] = 47338, + [SMALL_STATE(1312)] = 47352, + [SMALL_STATE(1313)] = 47366, + [SMALL_STATE(1314)] = 47380, + [SMALL_STATE(1315)] = 47391, + [SMALL_STATE(1316)] = 47402, + [SMALL_STATE(1317)] = 47413, + [SMALL_STATE(1318)] = 47424, + [SMALL_STATE(1319)] = 47435, + [SMALL_STATE(1320)] = 47446, + [SMALL_STATE(1321)] = 47457, + [SMALL_STATE(1322)] = 47468, + [SMALL_STATE(1323)] = 47479, + [SMALL_STATE(1324)] = 47490, + [SMALL_STATE(1325)] = 47501, + [SMALL_STATE(1326)] = 47512, + [SMALL_STATE(1327)] = 47523, + [SMALL_STATE(1328)] = 47534, + [SMALL_STATE(1329)] = 47545, + [SMALL_STATE(1330)] = 47556, + [SMALL_STATE(1331)] = 47567, + [SMALL_STATE(1332)] = 47578, + [SMALL_STATE(1333)] = 47589, + [SMALL_STATE(1334)] = 47600, + [SMALL_STATE(1335)] = 47611, + [SMALL_STATE(1336)] = 47622, + [SMALL_STATE(1337)] = 47633, + [SMALL_STATE(1338)] = 47644, + [SMALL_STATE(1339)] = 47655, + [SMALL_STATE(1340)] = 47666, + [SMALL_STATE(1341)] = 47677, + [SMALL_STATE(1342)] = 47688, + [SMALL_STATE(1343)] = 47699, + [SMALL_STATE(1344)] = 47710, + [SMALL_STATE(1345)] = 47721, + [SMALL_STATE(1346)] = 47732, + [SMALL_STATE(1347)] = 47743, + [SMALL_STATE(1348)] = 47754, + [SMALL_STATE(1349)] = 47765, + [SMALL_STATE(1350)] = 47776, + [SMALL_STATE(1351)] = 47787, + [SMALL_STATE(1352)] = 47798, + [SMALL_STATE(1353)] = 47809, + [SMALL_STATE(1354)] = 47820, + [SMALL_STATE(1355)] = 47831, + [SMALL_STATE(1356)] = 47842, + [SMALL_STATE(1357)] = 47853, + [SMALL_STATE(1358)] = 47864, + [SMALL_STATE(1359)] = 47875, + [SMALL_STATE(1360)] = 47886, + [SMALL_STATE(1361)] = 47897, + [SMALL_STATE(1362)] = 47908, + [SMALL_STATE(1363)] = 47919, + [SMALL_STATE(1364)] = 47930, + [SMALL_STATE(1365)] = 47941, + [SMALL_STATE(1366)] = 47952, + [SMALL_STATE(1367)] = 47963, + [SMALL_STATE(1368)] = 47974, + [SMALL_STATE(1369)] = 47985, + [SMALL_STATE(1370)] = 47996, + [SMALL_STATE(1371)] = 48007, + [SMALL_STATE(1372)] = 48018, + [SMALL_STATE(1373)] = 48029, + [SMALL_STATE(1374)] = 48040, + [SMALL_STATE(1375)] = 48051, + [SMALL_STATE(1376)] = 48062, + [SMALL_STATE(1377)] = 48073, + [SMALL_STATE(1378)] = 48084, + [SMALL_STATE(1379)] = 48095, + [SMALL_STATE(1380)] = 48106, + [SMALL_STATE(1381)] = 48117, + [SMALL_STATE(1382)] = 48128, + [SMALL_STATE(1383)] = 48139, + [SMALL_STATE(1384)] = 48150, + [SMALL_STATE(1385)] = 48161, + [SMALL_STATE(1386)] = 48172, + [SMALL_STATE(1387)] = 48183, + [SMALL_STATE(1388)] = 48194, + [SMALL_STATE(1389)] = 48205, + [SMALL_STATE(1390)] = 48216, + [SMALL_STATE(1391)] = 48227, + [SMALL_STATE(1392)] = 48238, + [SMALL_STATE(1393)] = 48249, + [SMALL_STATE(1394)] = 48260, + [SMALL_STATE(1395)] = 48271, + [SMALL_STATE(1396)] = 48282, + [SMALL_STATE(1397)] = 48293, + [SMALL_STATE(1398)] = 48304, + [SMALL_STATE(1399)] = 48315, + [SMALL_STATE(1400)] = 48326, + [SMALL_STATE(1401)] = 48337, + [SMALL_STATE(1402)] = 48348, + [SMALL_STATE(1403)] = 48359, + [SMALL_STATE(1404)] = 48370, + [SMALL_STATE(1405)] = 48381, + [SMALL_STATE(1406)] = 48392, + [SMALL_STATE(1407)] = 48403, + [SMALL_STATE(1408)] = 48414, + [SMALL_STATE(1409)] = 48425, + [SMALL_STATE(1410)] = 48436, + [SMALL_STATE(1411)] = 48447, + [SMALL_STATE(1412)] = 48458, + [SMALL_STATE(1413)] = 48469, + [SMALL_STATE(1414)] = 48480, + [SMALL_STATE(1415)] = 48491, + [SMALL_STATE(1416)] = 48502, + [SMALL_STATE(1417)] = 48513, + [SMALL_STATE(1418)] = 48524, + [SMALL_STATE(1419)] = 48535, + [SMALL_STATE(1420)] = 48546, + [SMALL_STATE(1421)] = 48557, + [SMALL_STATE(1422)] = 48568, + [SMALL_STATE(1423)] = 48579, + [SMALL_STATE(1424)] = 48590, + [SMALL_STATE(1425)] = 48601, + [SMALL_STATE(1426)] = 48612, + [SMALL_STATE(1427)] = 48623, + [SMALL_STATE(1428)] = 48634, + [SMALL_STATE(1429)] = 48645, + [SMALL_STATE(1430)] = 48656, + [SMALL_STATE(1431)] = 48667, + [SMALL_STATE(1432)] = 48678, + [SMALL_STATE(1433)] = 48689, + [SMALL_STATE(1434)] = 48700, + [SMALL_STATE(1435)] = 48711, + [SMALL_STATE(1436)] = 48722, + [SMALL_STATE(1437)] = 48733, + [SMALL_STATE(1438)] = 48744, + [SMALL_STATE(1439)] = 48755, + [SMALL_STATE(1440)] = 48766, + [SMALL_STATE(1441)] = 48777, + [SMALL_STATE(1442)] = 48788, + [SMALL_STATE(1443)] = 48799, + [SMALL_STATE(1444)] = 48810, + [SMALL_STATE(1445)] = 48821, + [SMALL_STATE(1446)] = 48832, + [SMALL_STATE(1447)] = 48843, + [SMALL_STATE(1448)] = 48854, + [SMALL_STATE(1449)] = 48865, + [SMALL_STATE(1450)] = 48876, + [SMALL_STATE(1451)] = 48887, + [SMALL_STATE(1452)] = 48898, + [SMALL_STATE(1453)] = 48909, + [SMALL_STATE(1454)] = 48920, + [SMALL_STATE(1455)] = 48931, + [SMALL_STATE(1456)] = 48942, + [SMALL_STATE(1457)] = 48953, + [SMALL_STATE(1458)] = 48964, + [SMALL_STATE(1459)] = 48975, + [SMALL_STATE(1460)] = 48986, + [SMALL_STATE(1461)] = 48997, + [SMALL_STATE(1462)] = 49008, + [SMALL_STATE(1463)] = 49019, + [SMALL_STATE(1464)] = 49030, + [SMALL_STATE(1465)] = 49041, + [SMALL_STATE(1466)] = 49052, + [SMALL_STATE(1467)] = 49063, + [SMALL_STATE(1468)] = 49074, + [SMALL_STATE(1469)] = 49085, + [SMALL_STATE(1470)] = 49096, + [SMALL_STATE(1471)] = 49107, + [SMALL_STATE(1472)] = 49118, + [SMALL_STATE(1473)] = 49129, + [SMALL_STATE(1474)] = 49140, + [SMALL_STATE(1475)] = 49151, + [SMALL_STATE(1476)] = 49162, + [SMALL_STATE(1477)] = 49173, + [SMALL_STATE(1478)] = 49184, + [SMALL_STATE(1479)] = 49195, + [SMALL_STATE(1480)] = 49206, + [SMALL_STATE(1481)] = 49217, + [SMALL_STATE(1482)] = 49228, + [SMALL_STATE(1483)] = 49239, + [SMALL_STATE(1484)] = 49250, + [SMALL_STATE(1485)] = 49261, + [SMALL_STATE(1486)] = 49272, + [SMALL_STATE(1487)] = 49283, + [SMALL_STATE(1488)] = 49294, + [SMALL_STATE(1489)] = 49305, + [SMALL_STATE(1490)] = 49316, + [SMALL_STATE(1491)] = 49327, + [SMALL_STATE(1492)] = 49338, + [SMALL_STATE(1493)] = 49349, + [SMALL_STATE(1494)] = 49360, + [SMALL_STATE(1495)] = 49371, + [SMALL_STATE(1496)] = 49382, + [SMALL_STATE(1497)] = 49393, + [SMALL_STATE(1498)] = 49404, + [SMALL_STATE(1499)] = 49415, + [SMALL_STATE(1500)] = 49426, + [SMALL_STATE(1501)] = 49437, + [SMALL_STATE(1502)] = 49448, + [SMALL_STATE(1503)] = 49459, + [SMALL_STATE(1504)] = 49470, + [SMALL_STATE(1505)] = 49481, + [SMALL_STATE(1506)] = 49492, + [SMALL_STATE(1507)] = 49503, + [SMALL_STATE(1508)] = 49514, + [SMALL_STATE(1509)] = 49525, + [SMALL_STATE(1510)] = 49536, + [SMALL_STATE(1511)] = 49547, + [SMALL_STATE(1512)] = 49558, + [SMALL_STATE(1513)] = 49569, + [SMALL_STATE(1514)] = 49580, + [SMALL_STATE(1515)] = 49591, + [SMALL_STATE(1516)] = 49602, + [SMALL_STATE(1517)] = 49613, + [SMALL_STATE(1518)] = 49624, + [SMALL_STATE(1519)] = 49635, + [SMALL_STATE(1520)] = 49646, + [SMALL_STATE(1521)] = 49657, + [SMALL_STATE(1522)] = 49668, + [SMALL_STATE(1523)] = 49679, + [SMALL_STATE(1524)] = 49690, + [SMALL_STATE(1525)] = 49701, + [SMALL_STATE(1526)] = 49712, + [SMALL_STATE(1527)] = 49723, + [SMALL_STATE(1528)] = 49734, + [SMALL_STATE(1529)] = 49745, + [SMALL_STATE(1530)] = 49756, + [SMALL_STATE(1531)] = 49767, + [SMALL_STATE(1532)] = 49778, + [SMALL_STATE(1533)] = 49789, + [SMALL_STATE(1534)] = 49800, + [SMALL_STATE(1535)] = 49811, + [SMALL_STATE(1536)] = 49822, + [SMALL_STATE(1537)] = 49833, + [SMALL_STATE(1538)] = 49844, + [SMALL_STATE(1539)] = 49855, + [SMALL_STATE(1540)] = 49866, + [SMALL_STATE(1541)] = 49877, + [SMALL_STATE(1542)] = 49888, + [SMALL_STATE(1543)] = 49899, + [SMALL_STATE(1544)] = 49910, + [SMALL_STATE(1545)] = 49921, + [SMALL_STATE(1546)] = 49932, + [SMALL_STATE(1547)] = 49943, + [SMALL_STATE(1548)] = 49954, + [SMALL_STATE(1549)] = 49965, + [SMALL_STATE(1550)] = 49976, + [SMALL_STATE(1551)] = 49987, + [SMALL_STATE(1552)] = 49998, + [SMALL_STATE(1553)] = 50009, + [SMALL_STATE(1554)] = 50020, + [SMALL_STATE(1555)] = 50031, + [SMALL_STATE(1556)] = 50042, + [SMALL_STATE(1557)] = 50053, + [SMALL_STATE(1558)] = 50064, + [SMALL_STATE(1559)] = 50075, + [SMALL_STATE(1560)] = 50086, + [SMALL_STATE(1561)] = 50097, + [SMALL_STATE(1562)] = 50108, + [SMALL_STATE(1563)] = 50119, + [SMALL_STATE(1564)] = 50130, + [SMALL_STATE(1565)] = 50141, + [SMALL_STATE(1566)] = 50152, + [SMALL_STATE(1567)] = 50163, + [SMALL_STATE(1568)] = 50174, + [SMALL_STATE(1569)] = 50185, + [SMALL_STATE(1570)] = 50196, + [SMALL_STATE(1571)] = 50207, + [SMALL_STATE(1572)] = 50218, + [SMALL_STATE(1573)] = 50229, + [SMALL_STATE(1574)] = 50240, + [SMALL_STATE(1575)] = 50251, + [SMALL_STATE(1576)] = 50262, +}; + +static const TSParseActionEntry ts_parse_actions[] = { + [0] = {.entry = {.count = 0, .reusable = false}}, + [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), + [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), + [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT_EXTRA(), + [7] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1229), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(473), + [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1371), + [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1343), + [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1407), + [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(742), + [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1392), + [23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1456), + [25] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1349), + [27] = {.entry = {.count = 1, .reusable = true}}, SHIFT(862), + [29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1316), + [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1462), + [33] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1503), + [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1534), + [37] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1309), + [39] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_block, 2, 0, 0), + [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block, 2, 0, 0), + [43] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_block, 3, 0, 0), + [45] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block, 3, 0, 0), + [47] = {.entry = {.count = 1, .reusable = false}}, SHIFT(468), + [49] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), + [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), + [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73), + [55] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(220), + [59] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1393), + [61] = {.entry = {.count = 1, .reusable = false}}, SHIFT(197), + [63] = {.entry = {.count = 1, .reusable = false}}, SHIFT(89), + [65] = {.entry = {.count = 1, .reusable = false}}, SHIFT(623), + [67] = {.entry = {.count = 1, .reusable = false}}, SHIFT(54), + [69] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1445), + [71] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1451), + [73] = {.entry = {.count = 1, .reusable = false}}, SHIFT(821), + [75] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1283), + [77] = {.entry = {.count = 1, .reusable = false}}, SHIFT(172), + [79] = {.entry = {.count = 1, .reusable = false}}, SHIFT(84), + [81] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1558), + [83] = {.entry = {.count = 1, .reusable = true}}, SHIFT(207), + [85] = {.entry = {.count = 1, .reusable = false}}, SHIFT(145), + [87] = {.entry = {.count = 1, .reusable = false}}, SHIFT(518), + [89] = {.entry = {.count = 1, .reusable = true}}, SHIFT(518), + [91] = {.entry = {.count = 1, .reusable = false}}, SHIFT(140), + [93] = {.entry = {.count = 1, .reusable = true}}, SHIFT(852), + [95] = {.entry = {.count = 1, .reusable = false}}, SHIFT(474), + [97] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), + [99] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), + [101] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(474), + [104] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(42), + [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), + [109] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(73), + [112] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(9), + [115] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(1393), + [118] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(219), + [121] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(89), + [124] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(623), + [127] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(54), + [130] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(1445), + [133] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(1451), + [136] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(821), + [139] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(1283), + [142] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(172), + [145] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(84), + [148] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(1465), + [151] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(213), + [154] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(170), + [157] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(592), + [160] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(592), + [163] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(140), + [166] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_block_repeat1, 2, 0, 0), SHIFT_REPEAT(852), + [169] = {.entry = {.count = 1, .reusable = true}}, SHIFT(457), + [171] = {.entry = {.count = 1, .reusable = false}}, SHIFT(219), + [173] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1465), + [175] = {.entry = {.count = 1, .reusable = true}}, SHIFT(213), + [177] = {.entry = {.count = 1, .reusable = false}}, SHIFT(170), + [179] = {.entry = {.count = 1, .reusable = false}}, SHIFT(592), + [181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(592), + [183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(302), + [185] = {.entry = {.count = 1, .reusable = true}}, SHIFT(448), + [187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(456), + [189] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0), + [191] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), + [193] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1229), + [196] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(473), + [199] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1371), + [202] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1343), + [205] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1407), + [208] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(742), + [211] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1392), + [214] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1456), + [217] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1349), + [220] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(862), + [223] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1316), + [226] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1462), + [229] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1503), + [232] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1534), + [235] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(1309), + [238] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1555), + [240] = {.entry = {.count = 1, .reusable = true}}, SHIFT(478), + [242] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1500), + [244] = {.entry = {.count = 1, .reusable = true}}, SHIFT(321), + [246] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1501), + [248] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1502), + [250] = {.entry = {.count = 1, .reusable = true}}, SHIFT(754), + [252] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1394), + [254] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1395), + [256] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1396), + [258] = {.entry = {.count = 1, .reusable = true}}, SHIFT(854), + [260] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1570), + [262] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1504), + [264] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1546), + [266] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1561), + [268] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1311), + [270] = {.entry = {.count = 1, .reusable = true}}, SHIFT(295), + [272] = {.entry = {.count = 1, .reusable = true}}, SHIFT(272), + [274] = {.entry = {.count = 1, .reusable = true}}, SHIFT(443), + [276] = {.entry = {.count = 1, .reusable = true}}, SHIFT(337), + [278] = {.entry = {.count = 1, .reusable = true}}, SHIFT(343), + [280] = {.entry = {.count = 1, .reusable = true}}, SHIFT(381), + [282] = {.entry = {.count = 1, .reusable = true}}, SHIFT(454), + [284] = {.entry = {.count = 1, .reusable = true}}, SHIFT(402), + [286] = {.entry = {.count = 1, .reusable = true}}, SHIFT(250), + [288] = {.entry = {.count = 1, .reusable = true}}, SHIFT(364), + [290] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1555), + [293] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(478), + [296] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1500), + [299] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), + [301] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1501), + [304] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1502), + [307] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(754), + [310] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1394), + [313] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1395), + [316] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1396), + [319] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(854), + [322] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1570), + [325] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1504), + [328] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1546), + [331] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1561), + [334] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_mod_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1311), + [337] = {.entry = {.count = 1, .reusable = true}}, SHIFT(245), + [339] = {.entry = {.count = 1, .reusable = false}}, SHIFT(514), + [341] = {.entry = {.count = 1, .reusable = true}}, SHIFT(720), + [343] = {.entry = {.count = 1, .reusable = false}}, SHIFT(117), + [345] = {.entry = {.count = 1, .reusable = false}}, SHIFT(176), + [347] = {.entry = {.count = 1, .reusable = true}}, SHIFT(117), + [349] = {.entry = {.count = 1, .reusable = false}}, SHIFT(525), + [351] = {.entry = {.count = 1, .reusable = true}}, SHIFT(525), + [353] = {.entry = {.count = 1, .reusable = true}}, SHIFT(152), + [355] = {.entry = {.count = 1, .reusable = true}}, SHIFT(134), + [357] = {.entry = {.count = 1, .reusable = true}}, SHIFT(128), + [359] = {.entry = {.count = 1, .reusable = true}}, SHIFT(718), + [361] = {.entry = {.count = 1, .reusable = true}}, SHIFT(704), + [363] = {.entry = {.count = 1, .reusable = true}}, SHIFT(136), + [365] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), + [367] = {.entry = {.count = 1, .reusable = false}}, SHIFT(539), + [369] = {.entry = {.count = 1, .reusable = true}}, SHIFT(539), + [371] = {.entry = {.count = 1, .reusable = true}}, SHIFT(723), + [373] = {.entry = {.count = 1, .reusable = false}}, SHIFT(545), + [375] = {.entry = {.count = 1, .reusable = true}}, SHIFT(545), + [377] = {.entry = {.count = 1, .reusable = true}}, SHIFT(157), + [379] = {.entry = {.count = 1, .reusable = false}}, SHIFT(519), + [381] = {.entry = {.count = 1, .reusable = true}}, SHIFT(519), + [383] = {.entry = {.count = 1, .reusable = true}}, SHIFT(690), + [385] = {.entry = {.count = 1, .reusable = true}}, SHIFT(154), + [387] = {.entry = {.count = 1, .reusable = true}}, SHIFT(700), + [389] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_range, 2, 0, 0), + [391] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_range, 2, 0, 0), + [393] = {.entry = {.count = 1, .reusable = false}}, SHIFT(548), + [395] = {.entry = {.count = 1, .reusable = true}}, SHIFT(548), + [397] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_range, 1, 0, 0), + [399] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_range, 1, 0, 0), + [401] = {.entry = {.count = 1, .reusable = false}}, SHIFT(546), + [403] = {.entry = {.count = 1, .reusable = true}}, SHIFT(546), + [405] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), + [407] = {.entry = {.count = 1, .reusable = true}}, SHIFT(505), + [409] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(170), + [412] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(42), + [415] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(73), + [418] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(9), + [421] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), + [423] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(219), + [426] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(212), + [429] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(176), + [432] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1465), + [435] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(213), + [438] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(751), + [441] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(751), + [444] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(140), + [447] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_flow_item_repeat1, 2, 0, 0), SHIFT_REPEAT(852), + [450] = {.entry = {.count = 1, .reusable = true}}, SHIFT(294), + [452] = {.entry = {.count = 1, .reusable = false}}, SHIFT(212), + [454] = {.entry = {.count = 1, .reusable = false}}, SHIFT(751), + [456] = {.entry = {.count = 1, .reusable = true}}, SHIFT(751), + [458] = {.entry = {.count = 1, .reusable = true}}, SHIFT(310), + [460] = {.entry = {.count = 1, .reusable = true}}, SHIFT(239), + [462] = {.entry = {.count = 1, .reusable = true}}, SHIFT(255), + [464] = {.entry = {.count = 1, .reusable = true}}, SHIFT(266), + [466] = {.entry = {.count = 1, .reusable = true}}, SHIFT(376), + [468] = {.entry = {.count = 1, .reusable = false}}, SHIFT(553), + [470] = {.entry = {.count = 1, .reusable = true}}, SHIFT(43), + [472] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), + [474] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [476] = {.entry = {.count = 1, .reusable = true}}, SHIFT(493), + [478] = {.entry = {.count = 1, .reusable = false}}, SHIFT(563), + [480] = {.entry = {.count = 1, .reusable = false}}, SHIFT(568), + [482] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1031), + [484] = {.entry = {.count = 1, .reusable = false}}, SHIFT(203), + [486] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1527), + [488] = {.entry = {.count = 1, .reusable = true}}, SHIFT(167), + [490] = {.entry = {.count = 1, .reusable = false}}, SHIFT(636), + [492] = {.entry = {.count = 1, .reusable = true}}, SHIFT(636), + [494] = {.entry = {.count = 1, .reusable = false}}, SHIFT(693), + [496] = {.entry = {.count = 1, .reusable = true}}, SHIFT(813), + [498] = {.entry = {.count = 1, .reusable = true}}, SHIFT(387), + [500] = {.entry = {.count = 1, .reusable = true}}, SHIFT(396), + [502] = {.entry = {.count = 1, .reusable = true}}, SHIFT(410), + [504] = {.entry = {.count = 1, .reusable = true}}, SHIFT(421), + [506] = {.entry = {.count = 1, .reusable = true}}, SHIFT(431), + [508] = {.entry = {.count = 1, .reusable = true}}, SHIFT(282), + [510] = {.entry = {.count = 1, .reusable = true}}, SHIFT(88), + [512] = {.entry = {.count = 1, .reusable = false}}, SHIFT(567), + [514] = {.entry = {.count = 1, .reusable = true}}, SHIFT(567), + [516] = {.entry = {.count = 1, .reusable = false}}, SHIFT(565), + [518] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1424), + [520] = {.entry = {.count = 1, .reusable = false}}, SHIFT(683), + [522] = {.entry = {.count = 1, .reusable = true}}, SHIFT(683), + [524] = {.entry = {.count = 1, .reusable = true}}, SHIFT(97), + [526] = {.entry = {.count = 1, .reusable = false}}, SHIFT(570), + [528] = {.entry = {.count = 1, .reusable = true}}, SHIFT(570), + [530] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1542), + [532] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(553), + [535] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(43), + [538] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(81), + [541] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(10), + [544] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), + [546] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(563), + [549] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(568), + [552] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(1090), + [555] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(203), + [558] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(1527), + [561] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(167), + [564] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(633), + [567] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(633), + [570] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(693), + [573] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_statement_repeat1, 2, 0, 0), SHIFT_REPEAT(813), + [576] = {.entry = {.count = 1, .reusable = true}}, SHIFT(503), + [578] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1090), + [580] = {.entry = {.count = 1, .reusable = false}}, SHIFT(633), + [582] = {.entry = {.count = 1, .reusable = true}}, SHIFT(633), + [584] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1479), + [586] = {.entry = {.count = 1, .reusable = true}}, SHIFT(156), + [588] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1007), + [590] = {.entry = {.count = 1, .reusable = false}}, SHIFT(626), + [592] = {.entry = {.count = 1, .reusable = true}}, SHIFT(626), + [594] = {.entry = {.count = 1, .reusable = true}}, SHIFT(724), + [596] = {.entry = {.count = 1, .reusable = true}}, SHIFT(716), + [598] = {.entry = {.count = 1, .reusable = true}}, SHIFT(135), + [600] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_expression, 3, 0, 38), + [602] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), + [604] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_field_expression, 3, 0, 38), + [606] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1305), + [608] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), + [610] = {.entry = {.count = 1, .reusable = false}}, SHIFT(174), + [612] = {.entry = {.count = 1, .reusable = true}}, SHIFT(174), + [614] = {.entry = {.count = 1, .reusable = true}}, SHIFT(175), + [616] = {.entry = {.count = 1, .reusable = false}}, SHIFT(682), + [618] = {.entry = {.count = 1, .reusable = true}}, SHIFT(682), + [620] = {.entry = {.count = 1, .reusable = false}}, SHIFT(123), + [622] = {.entry = {.count = 1, .reusable = true}}, SHIFT(123), + [624] = {.entry = {.count = 1, .reusable = false}}, SHIFT(735), + [626] = {.entry = {.count = 1, .reusable = true}}, SHIFT(735), + [628] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 2, 0, 0), + [630] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string, 2, 0, 0), + [632] = {.entry = {.count = 1, .reusable = false}}, SHIFT(49), + [634] = {.entry = {.count = 1, .reusable = true}}, SHIFT(49), + [636] = {.entry = {.count = 1, .reusable = false}}, SHIFT(727), + [638] = {.entry = {.count = 1, .reusable = true}}, SHIFT(727), + [640] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string, 3, 0, 0), + [642] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_string, 3, 0, 0), + [644] = {.entry = {.count = 1, .reusable = false}}, SHIFT(731), + [646] = {.entry = {.count = 1, .reusable = true}}, SHIFT(731), + [648] = {.entry = {.count = 1, .reusable = false}}, SHIFT(734), + [650] = {.entry = {.count = 1, .reusable = true}}, SHIFT(734), + [652] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__expression, 1, 0, 0), + [654] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__expression, 1, 0, 0), + [656] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1207), + [658] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym__expression, 1, 0, 0), SHIFT(1384), + [661] = {.entry = {.count = 1, .reusable = false}}, SHIFT(729), + [663] = {.entry = {.count = 1, .reusable = true}}, SHIFT(729), + [665] = {.entry = {.count = 1, .reusable = false}}, SHIFT(695), + [667] = {.entry = {.count = 1, .reusable = true}}, SHIFT(695), + [669] = {.entry = {.count = 1, .reusable = false}}, SHIFT(714), + [671] = {.entry = {.count = 1, .reusable = true}}, SHIFT(714), + [673] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_closure_expression, 9, 0, 106), + [675] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_closure_expression, 9, 0, 106), + [677] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_expression, 3, 0, 0), + [679] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_expression, 3, 0, 0), + [681] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_closure_expression, 6, 0, 87), + [683] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_closure_expression, 6, 0, 87), + [685] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_method_expression, 6, 0, 57), + [687] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_method_expression, 6, 0, 57), + [689] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 5, 0, 0), + [691] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_arguments, 5, 0, 0), + [693] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_expression, 4, 0, 58), + [695] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_expression, 4, 0, 58), + [697] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_expression, 6, 0, 58), + [699] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_expression, 6, 0, 58), + [701] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_expression, 5, 0, 36), + [703] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_expression, 5, 0, 36), + [705] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_closure_expression, 5, 0, 73), + [707] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_closure_expression, 5, 0, 73), + [709] = {.entry = {.count = 1, .reusable = true}}, SHIFT(182), + [711] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_unary_expression, 2, 0, 0), + [713] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_unary_expression, 2, 0, 0), + [715] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1505), + [717] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 4, 0, 0), + [719] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_arguments, 4, 0, 0), + [721] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_expression, 7, 0, 36), + [723] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_expression, 7, 0, 36), + [725] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_expression, 2, 0, 0), + [727] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_expression, 2, 0, 0), + [729] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_expression, 5, 0, 58), + [731] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_expression, 5, 0, 58), + [733] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_closure_expression, 7, 0, 96), + [735] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_closure_expression, 7, 0, 96), + [737] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parenthesized_expression, 3, 0, 0), + [739] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_parenthesized_expression, 3, 0, 0), + [741] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_boolean, 1, 0, 0), + [743] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_boolean, 1, 0, 0), + [745] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_index_expression, 4, 0, 56), + [747] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_index_expression, 4, 0, 56), + [749] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_method_expression, 4, 0, 57), + [751] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_method_expression, 4, 0, 57), + [753] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_closure_expression, 8, 0, 103), + [755] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_closure_expression, 8, 0, 103), + [757] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block_expression, 4, 0, 54), + [759] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_block_expression, 4, 0, 54), + [761] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_path, 1, 0, 0), + [763] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_path, 1, 0, 0), + [765] = {.entry = {.count = 1, .reusable = true}}, SHIFT(806), + [767] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_path, 2, 0, 0), + [769] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_path, 2, 0, 0), + [771] = {.entry = {.count = 1, .reusable = true}}, SHIFT(901), + [773] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_cast_expression, 3, 0, 0), + [775] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_cast_expression, 3, 0, 0), + [777] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_path, 3, 0, 0), + [779] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_path, 3, 0, 0), + [781] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), + [783] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), + [785] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), SHIFT_REPEAT(901), + [788] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_closure_expression, 4, 0, 55), + [790] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_closure_expression, 4, 0, 55), + [792] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_path, 4, 0, 0), + [794] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_path, 4, 0, 0), + [796] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 2, 0, 0), + [798] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_arguments, 2, 0, 0), + [800] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_call_expression, 2, 0, 20), + [802] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_call_expression, 2, 0, 20), + [804] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_expression, 5, 0, 0), + [806] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_expression, 5, 0, 0), + [808] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 3, 0, 0), + [810] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_arguments, 3, 0, 0), + [812] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_expression, 6, 0, 36), + [814] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_expression, 6, 0, 36), + [816] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_expression, 4, 0, 0), + [818] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_expression, 4, 0, 0), + [820] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_place, 3, 0, 34), + [822] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_place, 3, 0, 34), + [824] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_block_expression, 3, 0, 36), + [826] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_block_expression, 3, 0, 36), + [828] = {.entry = {.count = 1, .reusable = false}}, SHIFT(757), + [830] = {.entry = {.count = 1, .reusable = true}}, SHIFT(757), + [832] = {.entry = {.count = 1, .reusable = false}}, SHIFT(479), + [834] = {.entry = {.count = 1, .reusable = true}}, SHIFT(479), + [836] = {.entry = {.count = 1, .reusable = false}}, SHIFT(480), + [838] = {.entry = {.count = 1, .reusable = true}}, SHIFT(480), + [840] = {.entry = {.count = 1, .reusable = true}}, SHIFT(900), + [842] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_arguments, 4, 0, 0), + [844] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_arguments, 4, 0, 0), + [846] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 4, 0, 0), + [848] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_path_repeat1, 4, 0, 0), + [850] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_arguments, 5, 0, 0), + [852] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_arguments, 5, 0, 0), + [854] = {.entry = {.count = 1, .reusable = false}}, SHIFT(687), + [856] = {.entry = {.count = 1, .reusable = true}}, SHIFT(687), + [858] = {.entry = {.count = 1, .reusable = false}}, SHIFT(697), + [860] = {.entry = {.count = 1, .reusable = true}}, SHIFT(697), + [862] = {.entry = {.count = 1, .reusable = false}}, SHIFT(698), + [864] = {.entry = {.count = 1, .reusable = true}}, SHIFT(698), + [866] = {.entry = {.count = 1, .reusable = true}}, SHIFT(790), + [868] = {.entry = {.count = 1, .reusable = false}}, SHIFT(738), + [870] = {.entry = {.count = 1, .reusable = true}}, SHIFT(738), + [872] = {.entry = {.count = 1, .reusable = false}}, SHIFT(753), + [874] = {.entry = {.count = 1, .reusable = true}}, SHIFT(753), + [876] = {.entry = {.count = 1, .reusable = false}}, SHIFT(746), + [878] = {.entry = {.count = 1, .reusable = true}}, SHIFT(746), + [880] = {.entry = {.count = 1, .reusable = false}}, SHIFT(133), + [882] = {.entry = {.count = 1, .reusable = true}}, SHIFT(133), + [884] = {.entry = {.count = 1, .reusable = false}}, SHIFT(747), + [886] = {.entry = {.count = 1, .reusable = true}}, SHIFT(747), + [888] = {.entry = {.count = 1, .reusable = false}}, SHIFT(551), + [890] = {.entry = {.count = 1, .reusable = true}}, SHIFT(551), + [892] = {.entry = {.count = 1, .reusable = false}}, SHIFT(739), + [894] = {.entry = {.count = 1, .reusable = true}}, SHIFT(739), + [896] = {.entry = {.count = 1, .reusable = false}}, SHIFT(680), + [898] = {.entry = {.count = 1, .reusable = true}}, SHIFT(680), + [900] = {.entry = {.count = 1, .reusable = false}}, SHIFT(486), + [902] = {.entry = {.count = 1, .reusable = true}}, SHIFT(486), + [904] = {.entry = {.count = 1, .reusable = false}}, SHIFT(749), + [906] = {.entry = {.count = 1, .reusable = true}}, SHIFT(749), + [908] = {.entry = {.count = 1, .reusable = false}}, SHIFT(726), + [910] = {.entry = {.count = 1, .reusable = true}}, SHIFT(726), + [912] = {.entry = {.count = 1, .reusable = false}}, SHIFT(515), + [914] = {.entry = {.count = 1, .reusable = true}}, SHIFT(515), + [916] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), SHIFT_REPEAT(900), + [919] = {.entry = {.count = 1, .reusable = false}}, SHIFT(705), + [921] = {.entry = {.count = 1, .reusable = true}}, SHIFT(705), + [923] = {.entry = {.count = 1, .reusable = false}}, SHIFT(684), + [925] = {.entry = {.count = 1, .reusable = true}}, SHIFT(684), + [927] = {.entry = {.count = 1, .reusable = false}}, SHIFT(740), + [929] = {.entry = {.count = 1, .reusable = true}}, SHIFT(740), + [931] = {.entry = {.count = 1, .reusable = false}}, SHIFT(730), + [933] = {.entry = {.count = 1, .reusable = true}}, SHIFT(730), + [935] = {.entry = {.count = 1, .reusable = false}}, SHIFT(743), + [937] = {.entry = {.count = 1, .reusable = true}}, SHIFT(743), + [939] = {.entry = {.count = 1, .reusable = false}}, SHIFT(728), + [941] = {.entry = {.count = 1, .reusable = true}}, SHIFT(728), + [943] = {.entry = {.count = 1, .reusable = false}}, SHIFT(744), + [945] = {.entry = {.count = 1, .reusable = true}}, SHIFT(744), + [947] = {.entry = {.count = 1, .reusable = false}}, SHIFT(692), + [949] = {.entry = {.count = 1, .reusable = true}}, SHIFT(692), + [951] = {.entry = {.count = 1, .reusable = false}}, SHIFT(756), + [953] = {.entry = {.count = 1, .reusable = true}}, SHIFT(756), + [955] = {.entry = {.count = 1, .reusable = false}}, SHIFT(741), + [957] = {.entry = {.count = 1, .reusable = true}}, SHIFT(741), + [959] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_self, 1, 0, 0), + [961] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_self, 1, 0, 0), + [963] = {.entry = {.count = 1, .reusable = false}}, SHIFT(541), + [965] = {.entry = {.count = 1, .reusable = true}}, SHIFT(541), + [967] = {.entry = {.count = 1, .reusable = false}}, SHIFT(722), + [969] = {.entry = {.count = 1, .reusable = true}}, SHIFT(722), + [971] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), SHIFT_REPEAT(1208), + [974] = {.entry = {.count = 1, .reusable = false}}, SHIFT(752), + [976] = {.entry = {.count = 1, .reusable = true}}, SHIFT(752), + [978] = {.entry = {.count = 1, .reusable = false}}, SHIFT(755), + [980] = {.entry = {.count = 1, .reusable = true}}, SHIFT(755), + [982] = {.entry = {.count = 1, .reusable = false}}, SHIFT(748), + [984] = {.entry = {.count = 1, .reusable = true}}, SHIFT(748), + [986] = {.entry = {.count = 1, .reusable = false}}, SHIFT(552), + [988] = {.entry = {.count = 1, .reusable = true}}, SHIFT(552), + [990] = {.entry = {.count = 1, .reusable = false}}, SHIFT(745), + [992] = {.entry = {.count = 1, .reusable = true}}, SHIFT(745), + [994] = {.entry = {.count = 1, .reusable = false}}, SHIFT(750), + [996] = {.entry = {.count = 1, .reusable = true}}, SHIFT(750), + [998] = {.entry = {.count = 1, .reusable = false}}, SHIFT(737), + [1000] = {.entry = {.count = 1, .reusable = true}}, SHIFT(737), + [1002] = {.entry = {.count = 1, .reusable = false}}, SHIFT(696), + [1004] = {.entry = {.count = 1, .reusable = true}}, SHIFT(696), + [1006] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type_arguments, 3, 0, 0), + [1008] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type_arguments, 3, 0, 0), + [1010] = {.entry = {.count = 1, .reusable = false}}, SHIFT(681), + [1012] = {.entry = {.count = 1, .reusable = true}}, SHIFT(681), + [1014] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_object, 3, 0, 0), + [1016] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_object, 3, 0, 0), + [1018] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__condition, 1, 0, 0), + [1020] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), SHIFT_REPEAT(1209), + [1023] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_object, 2, 0, 0), + [1025] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_object, 2, 0, 0), + [1027] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_object, 4, 0, 0), + [1029] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_object, 4, 0, 0), + [1031] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_object, 5, 0, 0), + [1033] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_object, 5, 0, 0), + [1035] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type, 6, 0, 0), + [1037] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_type, 6, 0, 0), + [1039] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_type, 1, 0, 0), + [1041] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_type, 1, 0, 0), + [1043] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type, 7, 0, 0), + [1045] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_type, 7, 0, 0), + [1047] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_applied_type, 6, 0, 7), + [1049] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_applied_type, 6, 0, 7), + [1051] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type, 8, 0, 0), + [1053] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_type, 8, 0, 0), + [1055] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_struct_item_repeat1, 2, 0, 0), + [1057] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_struct_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1555), + [1060] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_type, 5, 0, 68), + [1062] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_type, 5, 0, 68), + [1064] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_applied_type, 4, 0, 7), + [1066] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_applied_type, 4, 0, 7), + [1068] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type, 5, 0, 0), + [1070] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_type, 5, 0, 0), + [1072] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_applied_type, 5, 0, 7), + [1074] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_applied_type, 5, 0, 7), + [1076] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 5, 0, 12), + [1078] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 5, 0, 12), + [1080] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 6, 0, 2), + [1082] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 6, 0, 2), + [1084] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 6, 0, 17), + [1086] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 6, 0, 17), + [1088] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_flow_item, 6, 0, 33), + [1090] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_flow_item, 6, 0, 33), + [1092] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 4, 0, 9), + [1094] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 4, 0, 9), + [1096] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 6, 0, 18), + [1098] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 6, 0, 18), + [1100] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_item, 6, 0, 18), + [1102] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_trait_item, 6, 0, 18), + [1104] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 6, 0, 35), + [1106] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 6, 0, 35), + [1108] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_event_item, 6, 0, 18), + [1110] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_event_item, 6, 0, 18), + [1112] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 6, 0, 18), + [1114] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 6, 0, 18), + [1116] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 6, 0, 18), + [1118] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 6, 0, 18), + [1120] = {.entry = {.count = 1, .reusable = true}}, SHIFT(477), + [1122] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1358), + [1124] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1409), + [1126] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1480), + [1128] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1334), + [1130] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1388), + [1132] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1464), + [1134] = {.entry = {.count = 1, .reusable = true}}, SHIFT(871), + [1136] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1339), + [1138] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1485), + [1140] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1539), + [1142] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1559), + [1144] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1257), + [1146] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_event_item, 4, 0, 2), + [1148] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_event_item, 4, 0, 2), + [1150] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 4, 0, 2), + [1152] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 4, 0, 2), + [1154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 7, 0, 5), + [1156] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 7, 0, 5), + [1158] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 7, 0, 39), + [1160] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 7, 0, 39), + [1162] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 7, 0, 5), + [1164] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 7, 0, 5), + [1166] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 7, 0, 23), + [1168] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 7, 0, 23), + [1170] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_flow_item, 7, 0, 40), + [1172] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_flow_item, 7, 0, 40), + [1174] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 7, 0, 2), + [1176] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 7, 0, 2), + [1178] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 4, 0, 2), + [1180] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 4, 0, 2), + [1182] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 7, 0, 47), + [1184] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 7, 0, 47), + [1186] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 7, 0, 48), + [1188] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 7, 0, 48), + [1190] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 7, 0, 14), + [1192] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 7, 0, 14), + [1194] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 7, 0, 29), + [1196] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 7, 0, 29), + [1198] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_const_item, 7, 0, 49), + [1200] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_const_item, 7, 0, 49), + [1202] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 7, 0, 2), + [1204] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 7, 0, 2), + [1206] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 7, 0, 17), + [1208] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 7, 0, 17), + [1210] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_flow_item, 7, 0, 33), + [1212] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_flow_item, 7, 0, 33), + [1214] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extern_function, 7, 0, 50), + [1216] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_extern_function, 7, 0, 50), + [1218] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 7, 0, 18), + [1220] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 7, 0, 18), + [1222] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_item, 7, 0, 18), + [1224] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_trait_item, 7, 0, 18), + [1226] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 7, 0, 51), + [1228] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 7, 0, 51), + [1230] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_item, 7, 0, 52), + [1232] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_item, 7, 0, 52), + [1234] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 7, 0, 18), + [1236] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 7, 0, 18), + [1238] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 7, 0, 18), + [1240] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 7, 0, 18), + [1242] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 7, 0, 53), + [1244] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 7, 0, 53), + [1246] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_inner_attribute, 5, 0, 11), + [1248] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_inner_attribute, 5, 0, 11), + [1250] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 5, 0, 5), + [1252] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 5, 0, 5), + [1254] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 8, 0, 5), + [1256] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 8, 0, 5), + [1258] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 8, 0, 59), + [1260] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 8, 0, 59), + [1262] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_const_item, 8, 0, 60), + [1264] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_const_item, 8, 0, 60), + [1266] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 8, 0, 5), + [1268] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 8, 0, 5), + [1270] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 8, 0, 23), + [1272] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 8, 0, 23), + [1274] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_flow_item, 8, 0, 40), + [1276] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_flow_item, 8, 0, 40), + [1278] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extern_function, 8, 0, 61), + [1280] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_extern_function, 8, 0, 61), + [1282] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_item, 5, 0, 5), + [1284] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_trait_item, 5, 0, 5), + [1286] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 8, 0, 2), + [1288] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 8, 0, 2), + [1290] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 8, 0, 48), + [1292] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 8, 0, 48), + [1294] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 8, 0, 29), + [1296] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 8, 0, 29), + [1298] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 8, 0, 17), + [1300] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 8, 0, 17), + [1302] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_event_item, 5, 0, 5), + [1304] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_event_item, 5, 0, 5), + [1306] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 8, 0, 18), + [1308] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 8, 0, 18), + [1310] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 8, 0, 70), + [1312] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 8, 0, 70), + [1314] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 8, 0, 18), + [1316] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 8, 0, 18), + [1318] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 8, 0, 53), + [1320] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 8, 0, 53), + [1322] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_flow_item, 8, 0, 71), + [1324] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_flow_item, 8, 0, 71), + [1326] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 5, 0, 5), + [1328] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 5, 0, 5), + [1330] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_event_item, 3, 0, 2), + [1332] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_event_item, 3, 0, 2), + [1334] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 5, 0, 5), + [1336] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 5, 0, 5), + [1338] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 5, 0, 2), + [1340] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 5, 0, 2), + [1342] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_item, 5, 0, 2), + [1344] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_trait_item, 5, 0, 2), + [1346] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 9, 0, 5), + [1348] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 9, 0, 5), + [1350] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 9, 0, 23), + [1352] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 9, 0, 23), + [1354] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 9, 0, 48), + [1356] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 9, 0, 48), + [1358] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_item, 3, 0, 3), + [1360] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_item, 3, 0, 3), + [1362] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 9, 0, 18), + [1364] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 9, 0, 18), + [1366] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 9, 0, 82), + [1368] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 9, 0, 82), + [1370] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_const_item, 9, 0, 83), + [1372] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_const_item, 9, 0, 83), + [1374] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 9, 0, 18), + [1376] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 9, 0, 18), + [1378] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 9, 0, 53), + [1380] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 9, 0, 53), + [1382] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_flow_item, 9, 0, 71), + [1384] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_flow_item, 9, 0, 71), + [1386] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_extern_function, 9, 0, 84), + [1388] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_extern_function, 9, 0, 84), + [1390] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 3, 0, 2), + [1392] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 3, 0, 2), + [1394] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 5, 0, 13), + [1396] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 5, 0, 13), + [1398] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 5, 0, 14), + [1400] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 5, 0, 14), + [1402] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 5, 0, 9), + [1404] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 5, 0, 9), + [1406] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 10, 0, 18), + [1408] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 10, 0, 18), + [1410] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 10, 0, 53), + [1412] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 10, 0, 53), + [1414] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_item, 3, 0, 0), + [1416] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_use_item, 3, 0, 0), + [1418] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_item, 5, 0, 15), + [1420] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_item, 5, 0, 15), + [1422] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 5, 0, 2), + [1424] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 5, 0, 2), + [1426] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_event_item, 4, 0, 5), + [1428] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_event_item, 4, 0, 5), + [1430] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_item, 4, 0, 6), + [1432] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_item, 4, 0, 6), + [1434] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 4, 0, 5), + [1436] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 4, 0, 5), + [1438] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_item, 4, 0, 0), + [1440] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_use_item, 4, 0, 0), + [1442] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 4, 0, 2), + [1444] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 4, 0, 2), + [1446] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_item, 4, 0, 2), + [1448] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_trait_item, 4, 0, 2), + [1450] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 4, 0, 8), + [1452] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 4, 0, 8), + [1454] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 5, 0, 2), + [1456] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 5, 0, 2), + [1458] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 5, 0, 17), + [1460] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 5, 0, 17), + [1462] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_event_item, 5, 0, 18), + [1464] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_event_item, 5, 0, 18), + [1466] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 6, 0, 9), + [1468] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 6, 0, 9), + [1470] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_item, 5, 0, 19), + [1472] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_item, 5, 0, 19), + [1474] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 5, 0, 18), + [1476] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 5, 0, 18), + [1478] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_item, 5, 0, 0), + [1480] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_use_item, 5, 0, 0), + [1482] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 6, 0, 5), + [1484] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 6, 0, 5), + [1486] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_item, 6, 0, 5), + [1488] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_trait_item, 6, 0, 5), + [1490] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 6, 0, 21), + [1492] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 6, 0, 21), + [1494] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_item, 6, 0, 22), + [1496] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_data_item, 6, 0, 22), + [1498] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mod_item, 6, 0, 5), + [1500] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mod_item, 6, 0, 5), + [1502] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_item, 6, 0, 5), + [1504] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_enum_item, 6, 0, 5), + [1506] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_state_item, 6, 0, 23), + [1508] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_state_item, 6, 0, 23), + [1510] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_struct_item, 6, 0, 2), + [1512] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_struct_item, 6, 0, 2), + [1514] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_item, 6, 0, 28), + [1516] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_item, 6, 0, 28), + [1518] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 6, 0, 14), + [1520] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 6, 0, 14), + [1522] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_impl_item, 6, 0, 29), + [1524] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_impl_item, 6, 0, 29), + [1526] = {.entry = {.count = 1, .reusable = true}}, SHIFT(484), + [1528] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1506), + [1530] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1507), + [1532] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1508), + [1534] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1398), + [1536] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1399), + [1538] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1400), + [1540] = {.entry = {.count = 1, .reusable = true}}, SHIFT(855), + [1542] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1572), + [1544] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1509), + [1546] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1547), + [1548] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1562), + [1550] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1312), + [1552] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_attribute, 4, 0, 4), + [1554] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute, 4, 0, 4), + [1556] = {.entry = {.count = 1, .reusable = true}}, SHIFT(614), + [1558] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type, 3, 0, 0), + [1560] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_type, 3, 0, 0), + [1562] = {.entry = {.count = 1, .reusable = true}}, SHIFT(598), + [1564] = {.entry = {.count = 1, .reusable = true}}, SHIFT(610), + [1566] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__path_segment, 1, 0, 0), + [1568] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1291), + [1570] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__path_segment, 1, 0, 0), + [1572] = {.entry = {.count = 1, .reusable = false}}, SHIFT(121), + [1574] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type, 4, 0, 0), + [1576] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_type, 4, 0, 0), + [1578] = {.entry = {.count = 1, .reusable = true}}, SHIFT(604), + [1580] = {.entry = {.count = 1, .reusable = true}}, SHIFT(607), + [1582] = {.entry = {.count = 1, .reusable = true}}, SHIFT(600), + [1584] = {.entry = {.count = 2, .reusable = false}}, REDUCE(sym_type, 1, 0, 0), SHIFT(657), + [1587] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1385), + [1589] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1427), + [1591] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1443), + [1593] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1469), + [1595] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1484), + [1597] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1512), + [1599] = {.entry = {.count = 1, .reusable = true}}, SHIFT(872), + [1601] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1320), + [1603] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1328), + [1605] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1350), + [1607] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1354), + [1609] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1261), + [1611] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_binary_expression, 3, 0, 0), + [1613] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_binary_expression, 3, 0, 0), + [1615] = {.entry = {.count = 1, .reusable = true}}, SHIFT(639), + [1617] = {.entry = {.count = 1, .reusable = false}}, SHIFT(162), + [1619] = {.entry = {.count = 1, .reusable = true}}, SHIFT(635), + [1621] = {.entry = {.count = 1, .reusable = true}}, SHIFT(646), + [1623] = {.entry = {.count = 1, .reusable = true}}, SHIFT(669), + [1625] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1516), + [1627] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1517), + [1629] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1518), + [1631] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1418), + [1633] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1419), + [1635] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1420), + [1637] = {.entry = {.count = 1, .reusable = true}}, SHIFT(856), + [1639] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1574), + [1641] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1519), + [1643] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1552), + [1645] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1567), + [1647] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1256), + [1649] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_if_statement, 3, 0, 44), + [1651] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_if_statement, 3, 0, 44), + [1653] = {.entry = {.count = 1, .reusable = false}}, SHIFT(938), + [1655] = {.entry = {.count = 1, .reusable = true}}, SHIFT(624), + [1657] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_return_statement, 3, 0, 0), + [1659] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_return_statement, 3, 0, 0), + [1661] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 8, 0, 60), + [1663] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 8, 0, 60), + [1665] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 6, 0, 90), + [1667] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 6, 0, 90), + [1669] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 6, 0, 89), + [1671] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 6, 0, 89), + [1673] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 4, 0, 5), + [1675] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 4, 0, 5), + [1677] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_emit_statement, 4, 0, 45), + [1679] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_emit_statement, 4, 0, 45), + [1681] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_statement, 4, 0, 36), + [1683] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_statement, 4, 0, 36), + [1685] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_macro_invocation, 4, 0, 66), + [1687] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_macro_invocation, 4, 0, 66), + [1689] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_assignment, 4, 0, 67), + [1691] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_assignment, 4, 0, 67), + [1693] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_destructure_statement, 7, 0, 97), + [1695] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_destructure_statement, 7, 0, 97), + [1697] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 7, 0, 49), + [1699] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 7, 0, 49), + [1701] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_if_statement, 5, 0, 78), + [1703] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_if_statement, 5, 0, 78), + [1705] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_destructure_statement, 5, 0, 79), + [1707] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_destructure_statement, 5, 0, 79), + [1709] = {.entry = {.count = 2, .reusable = true}}, REDUCE(sym__expression, 1, 0, 0), SHIFT(1384), + [1712] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 5, 0, 80), + [1714] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 5, 0, 80), + [1716] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 5, 0, 42), + [1718] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 5, 0, 42), + [1720] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_statement, 5, 0, 36), + [1722] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_statement, 5, 0, 36), + [1724] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_statement, 3, 0, 2), + [1726] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_statement, 3, 0, 2), + [1728] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_return_statement, 2, 0, 0), + [1730] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_return_statement, 2, 0, 0), + [1732] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_continue_statement, 2, 0, 0), + [1734] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_continue_statement, 2, 0, 0), + [1736] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_break_statement, 2, 0, 0), + [1738] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_break_statement, 2, 0, 0), + [1740] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_loop_statement, 2, 0, 27), + [1742] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop_statement, 2, 0, 27), + [1744] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_call_statement, 2, 0, 0), + [1746] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_call_statement, 2, 0, 0), + [1748] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_emit_statement, 3, 0, 45), + [1750] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_emit_statement, 3, 0, 45), + [1752] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_while_statement, 3, 0, 46), + [1754] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_while_statement, 3, 0, 46), + [1756] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_statement, 5, 0, 77), + [1758] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_statement, 5, 0, 77), + [1760] = {.entry = {.count = 1, .reusable = true}}, SHIFT(509), + [1762] = {.entry = {.count = 1, .reusable = false}}, SHIFT(40), + [1764] = {.entry = {.count = 1, .reusable = false}}, SHIFT(185), + [1766] = {.entry = {.count = 1, .reusable = true}}, SHIFT(120), + [1768] = {.entry = {.count = 1, .reusable = false}}, SHIFT(71), + [1770] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value_or_condition, 1, 0, 0), + [1772] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1505), + [1774] = {.entry = {.count = 1, .reusable = false}}, SHIFT(177), + [1776] = {.entry = {.count = 1, .reusable = true}}, SHIFT(115), + [1778] = {.entry = {.count = 1, .reusable = true}}, SHIFT(71), + [1780] = {.entry = {.count = 1, .reusable = true}}, SHIFT(177), + [1782] = {.entry = {.count = 1, .reusable = false}}, SHIFT(161), + [1784] = {.entry = {.count = 1, .reusable = true}}, SHIFT(161), + [1786] = {.entry = {.count = 1, .reusable = true}}, SHIFT(162), + [1788] = {.entry = {.count = 2, .reusable = true}}, REDUCE(sym__condition, 1, 0, 0), SHIFT(1207), + [1791] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 4, 0, 99), + [1793] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 4, 0, 99), + [1795] = {.entry = {.count = 1, .reusable = true}}, SHIFT(540), + [1797] = {.entry = {.count = 1, .reusable = true}}, SHIFT(643), + [1799] = {.entry = {.count = 1, .reusable = true}}, SHIFT(637), + [1801] = {.entry = {.count = 1, .reusable = true}}, SHIFT(642), + [1803] = {.entry = {.count = 1, .reusable = false}}, SHIFT(118), + [1805] = {.entry = {.count = 1, .reusable = true}}, SHIFT(118), + [1807] = {.entry = {.count = 1, .reusable = true}}, SHIFT(645), + [1809] = {.entry = {.count = 1, .reusable = true}}, SHIFT(657), + [1811] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_hook, 5, 0, 93), + [1813] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_hook, 5, 0, 93), + [1815] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 5, 0, 104), + [1817] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 5, 0, 104), + [1819] = {.entry = {.count = 1, .reusable = true}}, SHIFT(542), + [1821] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_hook, 7, 0, 105), + [1823] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_hook, 7, 0, 105), + [1825] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 3, 0, 91), + [1827] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 3, 0, 91), + [1829] = {.entry = {.count = 1, .reusable = true}}, SHIFT(544), + [1831] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_transition, 8, 0, 107), + [1833] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_transition, 8, 0, 107), + [1835] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_hook, 3, 0, 69), + [1837] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_hook, 3, 0, 69), + [1839] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 4, 0, 98), + [1841] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 4, 0, 98), + [1843] = {.entry = {.count = 1, .reusable = true}}, SHIFT(543), + [1845] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_transition, 4, 0, 81), + [1847] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_transition, 4, 0, 81), + [1849] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_hook, 5, 0, 92), + [1851] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_hook, 5, 0, 92), + [1853] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_transition, 6, 0, 100), + [1855] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_transition, 6, 0, 100), + [1857] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_transition, 6, 0, 101), + [1859] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_transition, 6, 0, 101), + [1861] = {.entry = {.count = 1, .reusable = true}}, SHIFT(804), + [1863] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 5, 0, 99), + [1865] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 5, 0, 99), + [1867] = {.entry = {.count = 1, .reusable = true}}, SHIFT(628), + [1869] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 6, 0, 104), + [1871] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 6, 0, 104), + [1873] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 5, 0, 98), + [1875] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 5, 0, 98), + [1877] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_match_arm, 4, 0, 91), + [1879] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_arm, 4, 0, 91), + [1881] = {.entry = {.count = 1, .reusable = true}}, SHIFT(778), + [1883] = {.entry = {.count = 1, .reusable = true}}, SHIFT(204), + [1885] = {.entry = {.count = 1, .reusable = true}}, SHIFT(205), + [1887] = {.entry = {.count = 1, .reusable = false}}, SHIFT(205), + [1889] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), SHIFT_REPEAT(903), + [1892] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_range, 3, 0, 0), + [1894] = {.entry = {.count = 1, .reusable = true}}, SHIFT(903), + [1896] = {.entry = {.count = 2, .reusable = true}}, REDUCE(sym__expression, 1, 0, 0), SHIFT(1207), + [1899] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_comparison, 3, 0, 0), + [1901] = {.entry = {.count = 1, .reusable = true}}, SHIFT(770), + [1903] = {.entry = {.count = 1, .reusable = false}}, SHIFT(895), + [1905] = {.entry = {.count = 1, .reusable = true}}, SHIFT(556), + [1907] = {.entry = {.count = 1, .reusable = true}}, SHIFT(894), + [1909] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1348), + [1911] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1192), + [1913] = {.entry = {.count = 1, .reusable = true}}, SHIFT(834), + [1915] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1201), + [1917] = {.entry = {.count = 1, .reusable = true}}, SHIFT(850), + [1919] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_path_repeat1, 2, 0, 0), SHIFT_REPEAT(1262), + [1922] = {.entry = {.count = 1, .reusable = true}}, SHIFT(109), + [1924] = {.entry = {.count = 1, .reusable = false}}, SHIFT(188), + [1926] = {.entry = {.count = 1, .reusable = true}}, SHIFT(113), + [1928] = {.entry = {.count = 1, .reusable = true}}, SHIFT(188), + [1930] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1253), + [1932] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1245), + [1934] = {.entry = {.count = 1, .reusable = true}}, SHIFT(603), + [1936] = {.entry = {.count = 1, .reusable = true}}, SHIFT(481), + [1938] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1329), + [1940] = {.entry = {.count = 1, .reusable = true}}, SHIFT(460), + [1942] = {.entry = {.count = 1, .reusable = true}}, SHIFT(523), + [1944] = {.entry = {.count = 1, .reusable = true}}, SHIFT(561), + [1946] = {.entry = {.count = 1, .reusable = true}}, SHIFT(37), + [1948] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1293), + [1950] = {.entry = {.count = 1, .reusable = true}}, SHIFT(459), + [1952] = {.entry = {.count = 1, .reusable = true}}, SHIFT(564), + [1954] = {.entry = {.count = 1, .reusable = true}}, SHIFT(471), + [1956] = {.entry = {.count = 1, .reusable = true}}, SHIFT(234), + [1958] = {.entry = {.count = 1, .reusable = true}}, SHIFT(522), + [1960] = {.entry = {.count = 1, .reusable = true}}, SHIFT(526), + [1962] = {.entry = {.count = 1, .reusable = true}}, SHIFT(631), + [1964] = {.entry = {.count = 1, .reusable = true}}, SHIFT(483), + [1966] = {.entry = {.count = 1, .reusable = true}}, SHIFT(466), + [1968] = {.entry = {.count = 1, .reusable = true}}, SHIFT(463), + [1970] = {.entry = {.count = 1, .reusable = true}}, SHIFT(228), + [1972] = {.entry = {.count = 1, .reusable = true}}, SHIFT(641), + [1974] = {.entry = {.count = 1, .reusable = true}}, SHIFT(644), + [1976] = {.entry = {.count = 1, .reusable = true}}, SHIFT(223), + [1978] = {.entry = {.count = 1, .reusable = true}}, SHIFT(166), + [1980] = {.entry = {.count = 1, .reusable = false}}, SHIFT(184), + [1982] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1284), + [1984] = {.entry = {.count = 2, .reusable = true}}, REDUCE(sym__expression, 1, 0, 0), SHIFT(1510), + [1987] = {.entry = {.count = 1, .reusable = true}}, SHIFT(164), + [1989] = {.entry = {.count = 1, .reusable = true}}, SHIFT(482), + [1991] = {.entry = {.count = 1, .reusable = true}}, SHIFT(216), + [1993] = {.entry = {.count = 1, .reusable = true}}, SHIFT(678), + [1995] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1430), + [1997] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1522), + [1999] = {.entry = {.count = 1, .reusable = false}}, SHIFT(920), + [2001] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1251), + [2003] = {.entry = {.count = 1, .reusable = true}}, SHIFT(160), + [2005] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1342), + [2007] = {.entry = {.count = 1, .reusable = true}}, SHIFT(615), + [2009] = {.entry = {.count = 1, .reusable = true}}, SHIFT(86), + [2011] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56), + [2013] = {.entry = {.count = 1, .reusable = true}}, SHIFT(194), + [2015] = {.entry = {.count = 1, .reusable = true}}, SHIFT(168), + [2017] = {.entry = {.count = 1, .reusable = true}}, SHIFT(169), + [2019] = {.entry = {.count = 1, .reusable = false}}, SHIFT(169), + [2021] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1496), + [2023] = {.entry = {.count = 1, .reusable = true}}, SHIFT(616), + [2025] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1193), + [2027] = {.entry = {.count = 1, .reusable = true}}, SHIFT(50), + [2029] = {.entry = {.count = 1, .reusable = true}}, SHIFT(619), + [2031] = {.entry = {.count = 1, .reusable = true}}, SHIFT(620), + [2033] = {.entry = {.count = 1, .reusable = true}}, SHIFT(621), + [2035] = {.entry = {.count = 1, .reusable = true}}, SHIFT(181), + [2037] = {.entry = {.count = 1, .reusable = false}}, SHIFT(181), + [2039] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [2041] = {.entry = {.count = 1, .reusable = true}}, SHIFT(187), + [2043] = {.entry = {.count = 1, .reusable = true}}, SHIFT(857), + [2045] = {.entry = {.count = 1, .reusable = true}}, SHIFT(180), + [2047] = {.entry = {.count = 1, .reusable = false}}, SHIFT(179), + [2049] = {.entry = {.count = 1, .reusable = true}}, SHIFT(179), + [2051] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value, 1, 0, 0), + [2053] = {.entry = {.count = 1, .reusable = true}}, SHIFT(184), + [2055] = {.entry = {.count = 1, .reusable = true}}, SHIFT(185), + [2057] = {.entry = {.count = 1, .reusable = true}}, SHIFT(210), + [2059] = {.entry = {.count = 1, .reusable = true}}, SHIFT(198), + [2061] = {.entry = {.count = 1, .reusable = false}}, SHIFT(198), + [2063] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_match_value_arm_repeat1, 2, 0, 0), + [2065] = {.entry = {.count = 1, .reusable = true}}, SHIFT(878), + [2067] = {.entry = {.count = 1, .reusable = true}}, SHIFT(535), + [2069] = {.entry = {.count = 1, .reusable = true}}, SHIFT(92), + [2071] = {.entry = {.count = 1, .reusable = true}}, SHIFT(173), + [2073] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_declaration, 6, 0, 75), + [2075] = {.entry = {.count = 1, .reusable = false}}, SHIFT(48), + [2077] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), + [2079] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_variant, 3, 0, 32), + [2081] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__data_value, 1, 0, 0), + [2083] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_declaration, 5, 0, 62), + [2085] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_in_range, 3, 0, 0), + [2087] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_logical_condition, 3, 0, 0), + [2089] = {.entry = {.count = 1, .reusable = false}}, SHIFT(122), + [2091] = {.entry = {.count = 1, .reusable = true}}, SHIFT(122), + [2093] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_not_condition, 2, 0, 0), + [2095] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_declaration, 7, 0, 88), + [2097] = {.entry = {.count = 1, .reusable = true}}, SHIFT(75), + [2099] = {.entry = {.count = 1, .reusable = true}}, SHIFT(279), + [2101] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1495), + [2103] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1344), + [2105] = {.entry = {.count = 1, .reusable = true}}, SHIFT(263), + [2107] = {.entry = {.count = 1, .reusable = true}}, SHIFT(532), + [2109] = {.entry = {.count = 1, .reusable = true}}, SHIFT(407), + [2111] = {.entry = {.count = 1, .reusable = true}}, SHIFT(110), + [2113] = {.entry = {.count = 1, .reusable = true}}, SHIFT(108), + [2115] = {.entry = {.count = 1, .reusable = true}}, SHIFT(141), + [2117] = {.entry = {.count = 1, .reusable = true}}, SHIFT(428), + [2119] = {.entry = {.count = 1, .reusable = true}}, SHIFT(199), + [2121] = {.entry = {.count = 1, .reusable = true}}, SHIFT(393), + [2123] = {.entry = {.count = 1, .reusable = true}}, SHIFT(538), + [2125] = {.entry = {.count = 1, .reusable = true}}, SHIFT(307), + [2127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1487), + [2129] = {.entry = {.count = 1, .reusable = true}}, SHIFT(709), + [2131] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1387), + [2133] = {.entry = {.count = 1, .reusable = true}}, SHIFT(315), + [2135] = {.entry = {.count = 1, .reusable = true}}, SHIFT(352), + [2137] = {.entry = {.count = 1, .reusable = true}}, SHIFT(450), + [2139] = {.entry = {.count = 1, .reusable = true}}, SHIFT(348), + [2141] = {.entry = {.count = 1, .reusable = true}}, SHIFT(413), + [2143] = {.entry = {.count = 1, .reusable = true}}, SHIFT(414), + [2145] = {.entry = {.count = 1, .reusable = true}}, SHIFT(349), + [2147] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_impl_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1555), + [2150] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_impl_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1387), + [2153] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_impl_item_repeat1, 2, 0, 0), + [2155] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_impl_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1502), + [2158] = {.entry = {.count = 1, .reusable = false}}, SHIFT(562), + [2160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(667), + [2162] = {.entry = {.count = 1, .reusable = true}}, SHIFT(259), + [2164] = {.entry = {.count = 1, .reusable = true}}, SHIFT(260), + [2166] = {.entry = {.count = 1, .reusable = true}}, SHIFT(286), + [2168] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1540), + [2170] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1189), + [2172] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1210), + [2174] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1222), + [2176] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1231), + [2178] = {.entry = {.count = 1, .reusable = true}}, SHIFT(975), + [2180] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1573), + [2182] = {.entry = {.count = 1, .reusable = true}}, SHIFT(95), + [2184] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1331), + [2186] = {.entry = {.count = 1, .reusable = true}}, SHIFT(261), + [2188] = {.entry = {.count = 1, .reusable = true}}, SHIFT(424), + [2190] = {.entry = {.count = 1, .reusable = true}}, SHIFT(333), + [2192] = {.entry = {.count = 1, .reusable = true}}, SHIFT(370), + [2194] = {.entry = {.count = 1, .reusable = true}}, SHIFT(371), + [2196] = {.entry = {.count = 1, .reusable = false}}, SHIFT(899), + [2198] = {.entry = {.count = 1, .reusable = true}}, SHIFT(990), + [2200] = {.entry = {.count = 1, .reusable = false}}, SHIFT(930), + [2202] = {.entry = {.count = 1, .reusable = true}}, SHIFT(811), + [2204] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1449), + [2206] = {.entry = {.count = 1, .reusable = true}}, SHIFT(451), + [2208] = {.entry = {.count = 1, .reusable = false}}, SHIFT(218), + [2210] = {.entry = {.count = 1, .reusable = true}}, SHIFT(632), + [2212] = {.entry = {.count = 1, .reusable = true}}, SHIFT(373), + [2214] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1038), + [2216] = {.entry = {.count = 1, .reusable = true}}, SHIFT(240), + [2218] = {.entry = {.count = 1, .reusable = true}}, SHIFT(303), + [2220] = {.entry = {.count = 1, .reusable = true}}, SHIFT(390), + [2222] = {.entry = {.count = 1, .reusable = true}}, SHIFT(391), + [2224] = {.entry = {.count = 1, .reusable = true}}, SHIFT(314), + [2226] = {.entry = {.count = 1, .reusable = true}}, SHIFT(392), + [2228] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1335), + [2230] = {.entry = {.count = 1, .reusable = true}}, SHIFT(287), + [2232] = {.entry = {.count = 1, .reusable = false}}, SHIFT(200), + [2234] = {.entry = {.count = 1, .reusable = true}}, SHIFT(650), + [2236] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1037), + [2238] = {.entry = {.count = 1, .reusable = true}}, SHIFT(977), + [2240] = {.entry = {.count = 1, .reusable = true}}, SHIFT(725), + [2242] = {.entry = {.count = 1, .reusable = false}}, SHIFT(865), + [2244] = {.entry = {.count = 1, .reusable = true}}, SHIFT(865), + [2246] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1213), + [2248] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1557), + [2250] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1543), + [2252] = {.entry = {.count = 1, .reusable = true}}, SHIFT(383), + [2254] = {.entry = {.count = 1, .reusable = true}}, SHIFT(388), + [2256] = {.entry = {.count = 1, .reusable = true}}, SHIFT(274), + [2258] = {.entry = {.count = 1, .reusable = true}}, SHIFT(268), + [2260] = {.entry = {.count = 1, .reusable = true}}, SHIFT(395), + [2262] = {.entry = {.count = 1, .reusable = true}}, SHIFT(398), + [2264] = {.entry = {.count = 1, .reusable = true}}, SHIFT(404), + [2266] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_pattern, 5, 0, 58), + [2268] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_pattern, 5, 0, 58), + [2270] = {.entry = {.count = 1, .reusable = true}}, SHIFT(438), + [2272] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_pattern, 3, 0, 0), + [2274] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_pattern, 3, 0, 0), + [2276] = {.entry = {.count = 1, .reusable = true}}, SHIFT(405), + [2278] = {.entry = {.count = 1, .reusable = true}}, SHIFT(409), + [2280] = {.entry = {.count = 1, .reusable = true}}, SHIFT(256), + [2282] = {.entry = {.count = 1, .reusable = true}}, SHIFT(412), + [2284] = {.entry = {.count = 1, .reusable = true}}, SHIFT(241), + [2286] = {.entry = {.count = 1, .reusable = true}}, SHIFT(416), + [2288] = {.entry = {.count = 1, .reusable = true}}, SHIFT(417), + [2290] = {.entry = {.count = 1, .reusable = true}}, SHIFT(335), + [2292] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_pattern, 4, 0, 0), + [2294] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_pattern, 4, 0, 0), + [2296] = {.entry = {.count = 1, .reusable = true}}, SHIFT(422), + [2298] = {.entry = {.count = 1, .reusable = true}}, SHIFT(423), + [2300] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_pattern, 3, 0, 58), + [2302] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_pattern, 3, 0, 58), + [2304] = {.entry = {.count = 1, .reusable = true}}, SHIFT(426), + [2306] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_pattern, 7, 0, 58), + [2308] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_pattern, 7, 0, 58), + [2310] = {.entry = {.count = 1, .reusable = true}}, SHIFT(430), + [2312] = {.entry = {.count = 1, .reusable = true}}, SHIFT(288), + [2314] = {.entry = {.count = 1, .reusable = true}}, SHIFT(317), + [2316] = {.entry = {.count = 1, .reusable = true}}, SHIFT(433), + [2318] = {.entry = {.count = 1, .reusable = true}}, SHIFT(434), + [2320] = {.entry = {.count = 1, .reusable = true}}, SHIFT(281), + [2322] = {.entry = {.count = 1, .reusable = true}}, SHIFT(265), + [2324] = {.entry = {.count = 1, .reusable = true}}, SHIFT(276), + [2326] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_pattern, 5, 0, 0), + [2328] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_pattern, 5, 0, 0), + [2330] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_string_repeat1, 2, 0, 0), + [2332] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2, 0, 0), SHIFT_REPEAT(851), + [2335] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_repeat1, 2, 0, 0), SHIFT_REPEAT(851), + [2338] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_string_repeat1, 2, 0, 0), SHIFT_REPEAT(1213), + [2341] = {.entry = {.count = 1, .reusable = true}}, SHIFT(114), + [2343] = {.entry = {.count = 1, .reusable = false}}, SHIFT(860), + [2345] = {.entry = {.count = 1, .reusable = true}}, SHIFT(860), + [2347] = {.entry = {.count = 1, .reusable = true}}, SHIFT(316), + [2349] = {.entry = {.count = 1, .reusable = true}}, SHIFT(116), + [2351] = {.entry = {.count = 1, .reusable = false}}, SHIFT(851), + [2353] = {.entry = {.count = 1, .reusable = true}}, SHIFT(851), + [2355] = {.entry = {.count = 1, .reusable = true}}, SHIFT(439), + [2357] = {.entry = {.count = 1, .reusable = true}}, SHIFT(330), + [2359] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_pattern, 6, 0, 58), + [2361] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_pattern, 6, 0, 58), + [2363] = {.entry = {.count = 1, .reusable = true}}, SHIFT(691), + [2365] = {.entry = {.count = 1, .reusable = true}}, SHIFT(339), + [2367] = {.entry = {.count = 1, .reusable = true}}, SHIFT(300), + [2369] = {.entry = {.count = 1, .reusable = true}}, SHIFT(345), + [2371] = {.entry = {.count = 1, .reusable = true}}, SHIFT(305), + [2373] = {.entry = {.count = 1, .reusable = true}}, SHIFT(285), + [2375] = {.entry = {.count = 1, .reusable = true}}, SHIFT(309), + [2377] = {.entry = {.count = 1, .reusable = true}}, SHIFT(354), + [2379] = {.entry = {.count = 1, .reusable = true}}, SHIFT(360), + [2381] = {.entry = {.count = 1, .reusable = true}}, SHIFT(366), + [2383] = {.entry = {.count = 1, .reusable = true}}, SHIFT(367), + [2385] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_pattern, 4, 0, 58), + [2387] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_pattern, 4, 0, 58), + [2389] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_pattern, 8, 0, 58), + [2391] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_record_pattern, 8, 0, 58), + [2393] = {.entry = {.count = 1, .reusable = true}}, SHIFT(301), + [2395] = {.entry = {.count = 1, .reusable = true}}, SHIFT(446), + [2397] = {.entry = {.count = 1, .reusable = true}}, SHIFT(277), + [2399] = {.entry = {.count = 1, .reusable = true}}, SHIFT(377), + [2401] = {.entry = {.count = 1, .reusable = true}}, SHIFT(298), + [2403] = {.entry = {.count = 1, .reusable = true}}, SHIFT(251), + [2405] = {.entry = {.count = 1, .reusable = true}}, SHIFT(447), + [2407] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_pattern, 2, 0, 0), + [2409] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_array_pattern, 2, 0, 0), + [2411] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_binding_pattern, 1, 0, 7), + [2413] = {.entry = {.count = 1, .reusable = true}}, SHIFT(290), + [2415] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_tree, 1, 0, 0), + [2417] = {.entry = {.count = 1, .reusable = true}}, SHIFT(799), + [2419] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1373), + [2421] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_use_tree_repeat1, 2, 0, 0), + [2423] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_use_tree_repeat1, 2, 0, 0), SHIFT_REPEAT(897), + [2426] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_tree, 2, 0, 0), + [2428] = {.entry = {.count = 1, .reusable = true}}, SHIFT(787), + [2430] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1488), + [2432] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1533), + [2434] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1277), + [2436] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1531), + [2438] = {.entry = {.count = 1, .reusable = true}}, SHIFT(224), + [2440] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), + [2442] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1537), + [2444] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1114), + [2446] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_generic_parameters, 5, 0, 0), + [2448] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_generic_parameters, 5, 0, 0), + [2450] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1163), + [2452] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_interpolation, 3, 0, 0), + [2454] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_interpolation, 3, 0, 0), + [2456] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1123), + [2458] = {.entry = {.count = 1, .reusable = true}}, SHIFT(262), + [2460] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_generic_parameters, 4, 0, 0), + [2462] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_generic_parameters, 4, 0, 0), + [2464] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1147), + [2466] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1049), + [2468] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1149), + [2470] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69), + [2472] = {.entry = {.count = 1, .reusable = true}}, SHIFT(504), + [2474] = {.entry = {.count = 1, .reusable = false}}, SHIFT(654), + [2476] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_binding_pattern, 2, 0, 2), + [2478] = {.entry = {.count = 1, .reusable = true}}, SHIFT(236), + [2480] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_interpolation, 2, 0, 0), + [2482] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_interpolation, 2, 0, 0), + [2484] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_generic_parameters, 3, 0, 0), + [2486] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_generic_parameters, 3, 0, 0), + [2488] = {.entry = {.count = 1, .reusable = true}}, SHIFT(66), + [2490] = {.entry = {.count = 1, .reusable = true}}, SHIFT(221), + [2492] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1172), + [2494] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1575), + [2496] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1336), + [2498] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1179), + [2500] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1181), + [2502] = {.entry = {.count = 1, .reusable = true}}, SHIFT(249), + [2504] = {.entry = {.count = 1, .reusable = true}}, SHIFT(361), + [2506] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1330), + [2508] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1028), + [2510] = {.entry = {.count = 1, .reusable = true}}, SHIFT(838), + [2512] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1413), + [2514] = {.entry = {.count = 1, .reusable = true}}, SHIFT(331), + [2516] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_function_type_parameter_repeat1, 2, 0, 65), + [2518] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_function_type_parameter_repeat1, 2, 0, 65), SHIFT_REPEAT(876), + [2521] = {.entry = {.count = 1, .reusable = true}}, SHIFT(444), + [2523] = {.entry = {.count = 1, .reusable = true}}, SHIFT(89), + [2525] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type_parameter, 4, 0, 43), + [2527] = {.entry = {.count = 1, .reusable = true}}, SHIFT(876), + [2529] = {.entry = {.count = 1, .reusable = true}}, SHIFT(775), + [2531] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1306), + [2533] = {.entry = {.count = 1, .reusable = true}}, SHIFT(782), + [2535] = {.entry = {.count = 1, .reusable = true}}, SHIFT(884), + [2537] = {.entry = {.count = 1, .reusable = true}}, SHIFT(864), + [2539] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1269), + [2541] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_value_arm_repeat1, 2, 0, 0), SHIFT_REPEAT(194), + [2544] = {.entry = {.count = 1, .reusable = true}}, SHIFT(284), + [2546] = {.entry = {.count = 1, .reusable = true}}, SHIFT(242), + [2548] = {.entry = {.count = 1, .reusable = true}}, SHIFT(763), + [2550] = {.entry = {.count = 1, .reusable = true}}, SHIFT(886), + [2552] = {.entry = {.count = 1, .reusable = true}}, SHIFT(269), + [2554] = {.entry = {.count = 1, .reusable = true}}, SHIFT(96), + [2556] = {.entry = {.count = 1, .reusable = true}}, SHIFT(94), + [2558] = {.entry = {.count = 1, .reusable = true}}, SHIFT(537), + [2560] = {.entry = {.count = 1, .reusable = true}}, SHIFT(193), + [2562] = {.entry = {.count = 1, .reusable = true}}, SHIFT(93), + [2564] = {.entry = {.count = 1, .reusable = true}}, SHIFT(340), + [2566] = {.entry = {.count = 1, .reusable = true}}, SHIFT(801), + [2568] = {.entry = {.count = 1, .reusable = true}}, SHIFT(837), + [2570] = {.entry = {.count = 1, .reusable = true}}, SHIFT(793), + [2572] = {.entry = {.count = 1, .reusable = true}}, SHIFT(847), + [2574] = {.entry = {.count = 1, .reusable = true}}, SHIFT(346), + [2576] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_trait_item_repeat1, 2, 0, 0), + [2578] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_trait_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1330), + [2581] = {.entry = {.count = 1, .reusable = true}}, SHIFT(378), + [2583] = {.entry = {.count = 1, .reusable = true}}, SHIFT(399), + [2585] = {.entry = {.count = 1, .reusable = true}}, SHIFT(440), + [2587] = {.entry = {.count = 1, .reusable = true}}, SHIFT(822), + [2589] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1247), + [2591] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_function_type_repeat1, 2, 0, 0), SHIFT_REPEAT(612), + [2594] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_function_type_repeat1, 2, 0, 0), + [2596] = {.entry = {.count = 1, .reusable = true}}, SHIFT(299), + [2598] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type_parameter, 3, 0, 26), + [2600] = {.entry = {.count = 1, .reusable = true}}, SHIFT(578), + [2602] = {.entry = {.count = 1, .reusable = true}}, SHIFT(893), + [2604] = {.entry = {.count = 1, .reusable = true}}, SHIFT(596), + [2606] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__attribute_body, 1, 0, 1), + [2608] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87), + [2610] = {.entry = {.count = 1, .reusable = true}}, SHIFT(60), + [2612] = {.entry = {.count = 1, .reusable = true}}, SHIFT(491), + [2614] = {.entry = {.count = 1, .reusable = true}}, SHIFT(675), + [2616] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parameters, 2, 0, 0), + [2618] = {.entry = {.count = 1, .reusable = true}}, SHIFT(915), + [2620] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_group, 2, 0, 0), + [2622] = {.entry = {.count = 1, .reusable = true}}, SHIFT(786), + [2624] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1103), + [2626] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_tree, 4, 0, 0), + [2628] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_tree, 4, 0, 16), + [2630] = {.entry = {.count = 1, .reusable = true}}, SHIFT(792), + [2632] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1152), + [2634] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type_parameter, 1, 0, 7), + [2636] = {.entry = {.count = 1, .reusable = true}}, SHIFT(824), + [2638] = {.entry = {.count = 1, .reusable = true}}, SHIFT(584), + [2640] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1025), + [2642] = {.entry = {.count = 1, .reusable = true}}, SHIFT(237), + [2644] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1156), + [2646] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1386), + [2648] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1110), + [2650] = {.entry = {.count = 1, .reusable = true}}, SHIFT(585), + [2652] = {.entry = {.count = 1, .reusable = true}}, SHIFT(848), + [2654] = {.entry = {.count = 1, .reusable = true}}, SHIFT(238), + [2656] = {.entry = {.count = 1, .reusable = true}}, SHIFT(849), + [2658] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_group, 4, 0, 0), + [2660] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_use_group_repeat1, 2, 0, 0), SHIFT_REPEAT(853), + [2663] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_use_group_repeat1, 2, 0, 0), + [2665] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), + [2667] = {.entry = {.count = 1, .reusable = true}}, SHIFT(668), + [2669] = {.entry = {.count = 1, .reusable = true}}, SHIFT(648), + [2671] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1304), + [2673] = {.entry = {.count = 1, .reusable = true}}, SHIFT(916), + [2675] = {.entry = {.count = 1, .reusable = true}}, SHIFT(425), + [2677] = {.entry = {.count = 1, .reusable = true}}, SHIFT(869), + [2679] = {.entry = {.count = 1, .reusable = true}}, SHIFT(932), + [2681] = {.entry = {.count = 1, .reusable = true}}, SHIFT(613), + [2683] = {.entry = {.count = 1, .reusable = true}}, SHIFT(246), + [2685] = {.entry = {.count = 1, .reusable = true}}, SHIFT(292), + [2687] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1044), + [2689] = {.entry = {.count = 1, .reusable = true}}, SHIFT(873), + [2691] = {.entry = {.count = 1, .reusable = true}}, SHIFT(293), + [2693] = {.entry = {.count = 1, .reusable = true}}, SHIFT(789), + [2695] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_expression_repeat1, 2, 0, 0), + [2697] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_expression_repeat1, 2, 0, 0), SHIFT_REPEAT(51), + [2700] = {.entry = {.count = 1, .reusable = true}}, SHIFT(125), + [2702] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), + [2704] = {.entry = {.count = 1, .reusable = true}}, SHIFT(590), + [2706] = {.entry = {.count = 1, .reusable = true}}, SHIFT(222), + [2708] = {.entry = {.count = 1, .reusable = true}}, SHIFT(102), + [2710] = {.entry = {.count = 1, .reusable = true}}, SHIFT(131), + [2712] = {.entry = {.count = 1, .reusable = true}}, SHIFT(606), + [2714] = {.entry = {.count = 1, .reusable = true}}, SHIFT(914), + [2716] = {.entry = {.count = 1, .reusable = true}}, SHIFT(597), + [2718] = {.entry = {.count = 1, .reusable = true}}, SHIFT(922), + [2720] = {.entry = {.count = 1, .reusable = true}}, SHIFT(319), + [2722] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), + [2724] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1175), + [2726] = {.entry = {.count = 1, .reusable = true}}, SHIFT(137), + [2728] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1062), + [2730] = {.entry = {.count = 1, .reusable = true}}, SHIFT(99), + [2732] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1196), + [2734] = {.entry = {.count = 1, .reusable = true}}, SHIFT(924), + [2736] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_tree, 3, 0, 0), + [2738] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_tree, 3, 0, 10), + [2740] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_declaration, 5, 0, 63), + [2742] = {.entry = {.count = 1, .reusable = true}}, SHIFT(209), + [2744] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_function_type_parameter_repeat1, 2, 0, 64), + [2746] = {.entry = {.count = 1, .reusable = true}}, SHIFT(889), + [2748] = {.entry = {.count = 1, .reusable = true}}, SHIFT(560), + [2750] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_variant, 1, 0, 7), + [2752] = {.entry = {.count = 1, .reusable = true}}, SHIFT(192), + [2754] = {.entry = {.count = 1, .reusable = true}}, SHIFT(984), + [2756] = {.entry = {.count = 1, .reusable = true}}, SHIFT(334), + [2758] = {.entry = {.count = 1, .reusable = true}}, SHIFT(253), + [2760] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pattern_field, 1, 0, 7), + [2762] = {.entry = {.count = 1, .reusable = true}}, SHIFT(569), + [2764] = {.entry = {.count = 1, .reusable = true}}, SHIFT(966), + [2766] = {.entry = {.count = 1, .reusable = true}}, SHIFT(881), + [2768] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1182), + [2770] = {.entry = {.count = 1, .reusable = true}}, SHIFT(846), + [2772] = {.entry = {.count = 1, .reusable = true}}, SHIFT(254), + [2774] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_declaration, 3, 0, 24), + [2776] = {.entry = {.count = 1, .reusable = true}}, SHIFT(190), + [2778] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_struct_item_repeat2, 2, 0, 0), SHIFT_REPEAT(898), + [2781] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_struct_item_repeat2, 2, 0, 0), + [2783] = {.entry = {.count = 1, .reusable = true}}, SHIFT(870), + [2785] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parameter, 3, 0, 25), + [2787] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_group, 5, 0, 0), + [2789] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parameters, 4, 0, 0), + [2791] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_parameters_repeat1, 2, 0, 0), SHIFT_REPEAT(875), + [2794] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_parameters_repeat1, 2, 0, 0), + [2796] = {.entry = {.count = 1, .reusable = true}}, SHIFT(830), + [2798] = {.entry = {.count = 1, .reusable = true}}, SHIFT(859), + [2800] = {.entry = {.count = 1, .reusable = true}}, SHIFT(982), + [2802] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1545), + [2804] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_function_type_parameters_repeat1, 2, 0, 0), SHIFT_REPEAT(1310), + [2807] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_function_type_parameters_repeat1, 2, 0, 0), + [2809] = {.entry = {.count = 1, .reusable = true}}, SHIFT(308), + [2811] = {.entry = {.count = 1, .reusable = true}}, SHIFT(350), + [2813] = {.entry = {.count = 1, .reusable = true}}, SHIFT(843), + [2815] = {.entry = {.count = 1, .reusable = true}}, SHIFT(622), + [2817] = {.entry = {.count = 1, .reusable = true}}, SHIFT(106), + [2819] = {.entry = {.count = 1, .reusable = true}}, SHIFT(670), + [2821] = {.entry = {.count = 1, .reusable = true}}, SHIFT(510), + [2823] = {.entry = {.count = 1, .reusable = true}}, SHIFT(322), + [2825] = {.entry = {.count = 1, .reusable = true}}, SHIFT(911), + [2827] = {.entry = {.count = 1, .reusable = true}}, SHIFT(651), + [2829] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_closure_expression_repeat1, 2, 0, 0), SHIFT_REPEAT(943), + [2832] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_closure_expression_repeat1, 2, 0, 0), + [2834] = {.entry = {.count = 1, .reusable = true}}, SHIFT(326), + [2836] = {.entry = {.count = 1, .reusable = true}}, SHIFT(652), + [2838] = {.entry = {.count = 1, .reusable = true}}, SHIFT(653), + [2840] = {.entry = {.count = 1, .reusable = true}}, SHIFT(338), + [2842] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_arguments_repeat1, 2, 0, 0), SHIFT_REPEAT(39), + [2845] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_arguments_repeat1, 2, 0, 0), + [2847] = {.entry = {.count = 1, .reusable = true}}, SHIFT(655), + [2849] = {.entry = {.count = 1, .reusable = true}}, SHIFT(344), + [2851] = {.entry = {.count = 1, .reusable = true}}, SHIFT(880), + [2853] = {.entry = {.count = 1, .reusable = true}}, SHIFT(130), + [2855] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_record_expression_repeat1, 2, 0, 0), SHIFT_REPEAT(1238), + [2858] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_record_expression_repeat1, 2, 0, 0), + [2860] = {.entry = {.count = 1, .reusable = true}}, SHIFT(656), + [2862] = {.entry = {.count = 1, .reusable = true}}, SHIFT(594), + [2864] = {.entry = {.count = 1, .reusable = true}}, SHIFT(211), + [2866] = {.entry = {.count = 1, .reusable = true}}, SHIFT(926), + [2868] = {.entry = {.count = 1, .reusable = true}}, SHIFT(214), + [2870] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1081), + [2872] = {.entry = {.count = 1, .reusable = true}}, SHIFT(353), + [2874] = {.entry = {.count = 1, .reusable = true}}, SHIFT(355), + [2876] = {.entry = {.count = 1, .reusable = true}}, SHIFT(658), + [2878] = {.entry = {.count = 1, .reusable = true}}, SHIFT(823), + [2880] = {.entry = {.count = 1, .reusable = true}}, SHIFT(814), + [2882] = {.entry = {.count = 1, .reusable = true}}, SHIFT(660), + [2884] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_pattern_repeat1, 2, 0, 0), + [2886] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_pattern_repeat1, 2, 0, 0), SHIFT_REPEAT(571), + [2889] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1095), + [2891] = {.entry = {.count = 1, .reusable = true}}, SHIFT(365), + [2893] = {.entry = {.count = 1, .reusable = true}}, SHIFT(815), + [2895] = {.entry = {.count = 1, .reusable = true}}, SHIFT(85), + [2897] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1382), + [2899] = {.entry = {.count = 1, .reusable = true}}, SHIFT(591), + [2901] = {.entry = {.count = 1, .reusable = true}}, SHIFT(257), + [2903] = {.entry = {.count = 1, .reusable = true}}, SHIFT(907), + [2905] = {.entry = {.count = 1, .reusable = true}}, SHIFT(374), + [2907] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1104), + [2909] = {.entry = {.count = 1, .reusable = true}}, SHIFT(818), + [2911] = {.entry = {.count = 1, .reusable = true}}, SHIFT(375), + [2913] = {.entry = {.count = 1, .reusable = true}}, SHIFT(942), + [2915] = {.entry = {.count = 1, .reusable = true}}, SHIFT(572), + [2917] = {.entry = {.count = 1, .reusable = true}}, SHIFT(475), + [2919] = {.entry = {.count = 1, .reusable = true}}, SHIFT(661), + [2921] = {.entry = {.count = 1, .reusable = true}}, SHIFT(382), + [2923] = {.entry = {.count = 1, .reusable = true}}, SHIFT(706), + [2925] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), + [2927] = {.entry = {.count = 1, .reusable = true}}, SHIFT(892), + [2929] = {.entry = {.count = 1, .reusable = true}}, SHIFT(577), + [2931] = {.entry = {.count = 1, .reusable = true}}, SHIFT(464), + [2933] = {.entry = {.count = 1, .reusable = true}}, SHIFT(826), + [2935] = {.entry = {.count = 1, .reusable = true}}, SHIFT(385), + [2937] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1121), + [2939] = {.entry = {.count = 1, .reusable = true}}, SHIFT(827), + [2941] = {.entry = {.count = 1, .reusable = true}}, SHIFT(386), + [2943] = {.entry = {.count = 1, .reusable = true}}, SHIFT(829), + [2945] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_data_object_repeat1, 2, 0, 0), SHIFT_REPEAT(945), + [2948] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_data_object_repeat1, 2, 0, 0), + [2950] = {.entry = {.count = 1, .reusable = true}}, SHIFT(579), + [2952] = {.entry = {.count = 1, .reusable = true}}, SHIFT(470), + [2954] = {.entry = {.count = 1, .reusable = true}}, SHIFT(580), + [2956] = {.entry = {.count = 1, .reusable = true}}, SHIFT(232), + [2958] = {.entry = {.count = 1, .reusable = true}}, SHIFT(629), + [2960] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_use_group, 3, 0, 0), + [2962] = {.entry = {.count = 1, .reusable = true}}, SHIFT(394), + [2964] = {.entry = {.count = 1, .reusable = true}}, SHIFT(809), + [2966] = {.entry = {.count = 1, .reusable = true}}, SHIFT(831), + [2968] = {.entry = {.count = 1, .reusable = true}}, SHIFT(832), + [2970] = {.entry = {.count = 1, .reusable = true}}, SHIFT(662), + [2972] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1129), + [2974] = {.entry = {.count = 1, .reusable = true}}, SHIFT(403), + [2976] = {.entry = {.count = 1, .reusable = true}}, SHIFT(264), + [2978] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_guard, 2, 0, 85), + [2980] = {.entry = {.count = 1, .reusable = true}}, SHIFT(100), + [2982] = {.entry = {.count = 1, .reusable = true}}, SHIFT(101), + [2984] = {.entry = {.count = 1, .reusable = true}}, SHIFT(47), + [2986] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_enum_item_repeat1, 2, 0, 0), SHIFT_REPEAT(1307), + [2989] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_enum_item_repeat1, 2, 0, 0), + [2991] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [2993] = {.entry = {.count = 1, .reusable = true}}, SHIFT(663), + [2995] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_match_expression_repeat1, 2, 0, 0), SHIFT_REPEAT(112), + [2998] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_match_expression_repeat1, 2, 0, 0), + [3000] = {.entry = {.count = 1, .reusable = true}}, SHIFT(842), + [3002] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), + [3004] = {.entry = {.count = 1, .reusable = true}}, SHIFT(712), + [3006] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1137), + [3008] = {.entry = {.count = 1, .reusable = true}}, SHIFT(713), + [3010] = {.entry = {.count = 1, .reusable = true}}, SHIFT(835), + [3012] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1027), + [3014] = {.entry = {.count = 1, .reusable = true}}, SHIFT(445), + [3016] = {.entry = {.count = 1, .reusable = true}}, SHIFT(408), + [3018] = {.entry = {.count = 1, .reusable = true}}, SHIFT(836), + [3020] = {.entry = {.count = 1, .reusable = true}}, SHIFT(618), + [3022] = {.entry = {.count = 1, .reusable = true}}, SHIFT(896), + [3024] = {.entry = {.count = 1, .reusable = true}}, SHIFT(586), + [3026] = {.entry = {.count = 1, .reusable = true}}, SHIFT(587), + [3028] = {.entry = {.count = 1, .reusable = true}}, SHIFT(839), + [3030] = {.entry = {.count = 1, .reusable = true}}, SHIFT(419), + [3032] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1143), + [3034] = {.entry = {.count = 1, .reusable = true}}, SHIFT(841), + [3036] = {.entry = {.count = 1, .reusable = true}}, SHIFT(420), + [3038] = {.entry = {.count = 1, .reusable = true}}, SHIFT(828), + [3040] = {.entry = {.count = 1, .reusable = true}}, SHIFT(105), + [3042] = {.entry = {.count = 1, .reusable = true}}, SHIFT(702), + [3044] = {.entry = {.count = 1, .reusable = true}}, SHIFT(664), + [3046] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), + [3048] = {.entry = {.count = 1, .reusable = true}}, SHIFT(707), + [3050] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1148), + [3052] = {.entry = {.count = 1, .reusable = true}}, SHIFT(611), + [3054] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_record_pattern_repeat1, 2, 0, 0), SHIFT_REPEAT(1271), + [3057] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_record_pattern_repeat1, 2, 0, 0), + [3059] = {.entry = {.count = 1, .reusable = true}}, SHIFT(844), + [3061] = {.entry = {.count = 1, .reusable = true}}, SHIFT(429), + [3063] = {.entry = {.count = 1, .reusable = true}}, SHIFT(845), + [3065] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1000), + [3067] = {.entry = {.count = 1, .reusable = true}}, SHIFT(273), + [3069] = {.entry = {.count = 1, .reusable = true}}, SHIFT(104), + [3071] = {.entry = {.count = 1, .reusable = true}}, SHIFT(665), + [3073] = {.entry = {.count = 1, .reusable = true}}, SHIFT(721), + [3075] = {.entry = {.count = 1, .reusable = true}}, SHIFT(666), + [3077] = {.entry = {.count = 1, .reusable = true}}, SHIFT(575), + [3079] = {.entry = {.count = 1, .reusable = true}}, SHIFT(557), + [3081] = {.entry = {.count = 1, .reusable = true}}, SHIFT(296), + [3083] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parameters, 3, 0, 0), + [3085] = {.entry = {.count = 1, .reusable = true}}, SHIFT(774), + [3087] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), + [3089] = {.entry = {.count = 1, .reusable = true}}, SHIFT(581), + [3091] = {.entry = {.count = 1, .reusable = true}}, SHIFT(524), + [3093] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1326), + [3095] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1042), + [3097] = {.entry = {.count = 1, .reusable = true}}, SHIFT(582), + [3099] = {.entry = {.count = 1, .reusable = true}}, SHIFT(630), + [3101] = {.entry = {.count = 1, .reusable = true}}, SHIFT(863), + [3103] = {.entry = {.count = 1, .reusable = true}}, SHIFT(866), + [3105] = {.entry = {.count = 1, .reusable = true}}, SHIFT(627), + [3107] = {.entry = {.count = 1, .reusable = true}}, SHIFT(918), + [3109] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1009), + [3111] = {.entry = {.count = 1, .reusable = true}}, SHIFT(785), + [3113] = {.entry = {.count = 1, .reusable = true}}, SHIFT(890), + [3115] = {.entry = {.count = 1, .reusable = true}}, SHIFT(796), + [3117] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_attribute_arguments_repeat1, 2, 0, 0), SHIFT_REPEAT(103), + [3120] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_attribute_arguments_repeat1, 2, 0, 0), + [3122] = {.entry = {.count = 1, .reusable = true}}, SHIFT(659), + [3124] = {.entry = {.count = 1, .reusable = true}}, SHIFT(588), + [3126] = {.entry = {.count = 1, .reusable = true}}, SHIFT(638), + [3128] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), + [3130] = {.entry = {.count = 1, .reusable = true}}, SHIFT(155), + [3132] = {.entry = {.count = 1, .reusable = true}}, SHIFT(671), + [3134] = {.entry = {.count = 1, .reusable = true}}, SHIFT(917), + [3136] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1135), + [3138] = {.entry = {.count = 1, .reusable = true}}, SHIFT(589), + [3140] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_field, 1, 0, 7), + [3142] = {.entry = {.count = 1, .reusable = true}}, SHIFT(59), + [3144] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1014), + [3146] = {.entry = {.count = 1, .reusable = true}}, SHIFT(129), + [3148] = {.entry = {.count = 1, .reusable = true}}, SHIFT(672), + [3150] = {.entry = {.count = 1, .reusable = true}}, SHIFT(919), + [3152] = {.entry = {.count = 1, .reusable = true}}, SHIFT(673), + [3154] = {.entry = {.count = 1, .reusable = true}}, SHIFT(867), + [3156] = {.entry = {.count = 1, .reusable = true}}, SHIFT(674), + [3158] = {.entry = {.count = 1, .reusable = true}}, SHIFT(280), + [3160] = {.entry = {.count = 1, .reusable = true}}, SHIFT(887), + [3162] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_generic_parameters_repeat1, 2, 0, 0), SHIFT_REPEAT(1438), + [3165] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_generic_parameters_repeat1, 2, 0, 0), + [3167] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_field_declaration, 4, 0, 41), + [3169] = {.entry = {.count = 1, .reusable = true}}, SHIFT(183), + [3171] = {.entry = {.count = 1, .reusable = true}}, SHIFT(297), + [3173] = {.entry = {.count = 1, .reusable = true}}, SHIFT(771), + [3175] = {.entry = {.count = 1, .reusable = true}}, SHIFT(929), + [3177] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1177), + [3179] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parameters, 5, 0, 0), + [3181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(931), + [3183] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_parameter, 4, 0, 42), + [3185] = {.entry = {.count = 1, .reusable = true}}, SHIFT(825), + [3187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(559), + [3189] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_method, 6, 0, 76), + [3191] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1302), + [3193] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), + [3195] = {.entry = {.count = 1, .reusable = true}}, SHIFT(357), + [3197] = {.entry = {.count = 1, .reusable = true}}, SHIFT(67), + [3199] = {.entry = {.count = 1, .reusable = true}}, SHIFT(489), + [3201] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute_argument, 1, 0, 0), + [3203] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1365), + [3205] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1258), + [3207] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1576), + [3209] = {.entry = {.count = 1, .reusable = true}}, SHIFT(923), + [3211] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_field, 3, 0, 30), + [3213] = {.entry = {.count = 1, .reusable = true}}, SHIFT(64), + [3215] = {.entry = {.count = 1, .reusable = true}}, SHIFT(502), + [3217] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_data_field, 3, 0, 31), + [3219] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), + [3221] = {.entry = {.count = 1, .reusable = true}}, SHIFT(436), + [3223] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_mutable_specifier, 1, 0, 0), + [3225] = {.entry = {.count = 1, .reusable = false}}, SHIFT(1258), + [3227] = {.entry = {.count = 1, .reusable = true}}, SHIFT(973), + [3229] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_value_arm, 3, 0, 86), + [3231] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1292), + [3233] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1489), + [3235] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_receiver, 1, 0, 0), + [3237] = {.entry = {.count = 1, .reusable = true}}, SHIFT(602), + [3239] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1308), + [3241] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_receiver, 3, 0, 0), + [3243] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_count_range, 3, 0, 0), + [3245] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1268), + [3247] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pattern_field, 3, 0, 7), + [3249] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1404), + [3251] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83), + [3253] = {.entry = {.count = 1, .reusable = true}}, SHIFT(609), + [3255] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), + [3257] = {.entry = {.count = 1, .reusable = true}}, SHIFT(368), + [3259] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_binding, 2, 0, 72), + [3261] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_receiver, 2, 0, 0), + [3263] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_value_arm, 4, 0, 94), + [3265] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_value_arm, 4, 0, 95), + [3267] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1453), + [3269] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1454), + [3271] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1457), + [3273] = {.entry = {.count = 1, .reusable = true}}, SHIFT(840), + [3275] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), + [3277] = {.entry = {.count = 1, .reusable = true}}, SHIFT(324), + [3279] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute_argument, 3, 0, 37), + [3281] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), + [3283] = {.entry = {.count = 1, .reusable = true}}, SHIFT(312), + [3285] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), + [3287] = {.entry = {.count = 1, .reusable = true}}, SHIFT(328), + [3289] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_match_value_arm, 5, 0, 102), + [3291] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argument, 3, 0, 74), + [3293] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_argument, 1, 0, 0), + [3295] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_count_range, 7, 0, 0), + [3297] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1486), + [3299] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_record_field, 3, 0, 7), + [3301] = {.entry = {.count = 1, .reusable = true}}, SHIFT(910), + [3303] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_trait_method, 4, 0, 2), + [3305] = {.entry = {.count = 1, .reusable = true}}, SHIFT(954), + [3307] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), + [3309] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1477), + [3311] = {.entry = {.count = 1, .reusable = true}}, SHIFT(494), + [3313] = {.entry = {.count = 1, .reusable = true}}, SHIFT(380), + [3315] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1470), + [3317] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1377), + [3319] = {.entry = {.count = 1, .reusable = true}}, SHIFT(833), + [3321] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1186), + [3323] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), + [3325] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1239), + [3327] = {.entry = {.count = 1, .reusable = true}}, SHIFT(948), + [3329] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type_parameters, 4, 0, 0), + [3331] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_count_range, 1, 0, 0), + [3333] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1378), + [3335] = {.entry = {.count = 1, .reusable = true}}, SHIFT(595), + [3337] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1249), + [3339] = {.entry = {.count = 1, .reusable = true}}, SHIFT(496), + [3341] = {.entry = {.count = 1, .reusable = true}}, SHIFT(497), + [3343] = {.entry = {.count = 1, .reusable = true}}, SHIFT(995), + [3345] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1490), + [3347] = {.entry = {.count = 1, .reusable = true}}, SHIFT(111), + [3349] = {.entry = {.count = 1, .reusable = true}}, SHIFT(708), + [3351] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1493), + [3353] = {.entry = {.count = 1, .reusable = true}}, SHIFT(710), + [3355] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1532), + [3357] = {.entry = {.count = 1, .reusable = true}}, SHIFT(576), + [3359] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1353), + [3361] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1017), + [3363] = {.entry = {.count = 1, .reusable = true}}, SHIFT(191), + [3365] = {.entry = {.count = 1, .reusable = true}}, SHIFT(761), + [3367] = {.entry = {.count = 1, .reusable = true}}, SHIFT(780), + [3369] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_mutable_specifier, 1, 0, 0), + [3371] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1278), + [3373] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1390), + [3375] = {.entry = {.count = 1, .reusable = true}}, SHIFT(311), + [3377] = {.entry = {.count = 1, .reusable = true}}, SHIFT(202), + [3379] = {.entry = {.count = 1, .reusable = true}}, SHIFT(937), + [3381] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1391), + [3383] = {.entry = {.count = 1, .reusable = true}}, SHIFT(432), + [3385] = {.entry = {.count = 1, .reusable = true}}, SHIFT(807), + [3387] = {.entry = {.count = 1, .reusable = true}}, SHIFT(762), + [3389] = {.entry = {.count = 1, .reusable = true}}, SHIFT(989), + [3391] = {.entry = {.count = 1, .reusable = true}}, SHIFT(974), + [3393] = {.entry = {.count = 1, .reusable = true}}, SHIFT(499), + [3395] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53), + [3397] = {.entry = {.count = 1, .reusable = true}}, SHIFT(934), + [3399] = {.entry = {.count = 1, .reusable = true}}, SHIFT(63), + [3401] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1276), + [3403] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1234), + [3405] = {.entry = {.count = 1, .reusable = true}}, SHIFT(58), + [3407] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1514), + [3409] = {.entry = {.count = 1, .reusable = true}}, SHIFT(501), + [3411] = {.entry = {.count = 1, .reusable = true}}, SHIFT(65), + [3413] = {.entry = {.count = 1, .reusable = true}}, SHIFT(244), + [3415] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1070), + [3417] = {.entry = {.count = 1, .reusable = true}}, SHIFT(647), + [3419] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1019), + [3421] = {.entry = {.count = 1, .reusable = true}}, SHIFT(372), + [3423] = {.entry = {.count = 1, .reusable = true}}, SHIFT(487), + [3425] = {.entry = {.count = 1, .reusable = true}}, SHIFT(139), + [3427] = {.entry = {.count = 1, .reusable = true}}, SHIFT(649), + [3429] = {.entry = {.count = 1, .reusable = true}}, SHIFT(999), + [3431] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1319), + [3433] = {.entry = {.count = 1, .reusable = true}}, SHIFT(640), + [3435] = {.entry = {.count = 1, .reusable = true}}, SHIFT(528), + [3437] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute_arguments, 3, 0, 0), + [3439] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__attribute_body, 2, 0, 1), + [3441] = {.entry = {.count = 1, .reusable = true}}, SHIFT(158), + [3443] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1040), + [3445] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type_parameters, 3, 0, 0), + [3447] = {.entry = {.count = 1, .reusable = true}}, SHIFT(998), + [3449] = {.entry = {.count = 1, .reusable = true}}, SHIFT(455), + [3451] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1421), + [3453] = {.entry = {.count = 1, .reusable = true}}, SHIFT(808), + [3455] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1151), + [3457] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1337), + [3459] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1051), + [3461] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1052), + [3463] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1272), + [3465] = {.entry = {.count = 1, .reusable = true}}, SHIFT(144), + [3467] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1054), + [3469] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1055), + [3471] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1279), + [3473] = {.entry = {.count = 1, .reusable = true}}, SHIFT(488), + [3475] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1541), + [3477] = {.entry = {.count = 1, .reusable = true}}, SHIFT(935), + [3479] = {.entry = {.count = 1, .reusable = true}}, SHIFT(275), + [3481] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1057), + [3483] = {.entry = {.count = 1, .reusable = true}}, SHIFT(960), + [3485] = {.entry = {.count = 1, .reusable = true}}, SHIFT(921), + [3487] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1441), + [3489] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1060), + [3491] = {.entry = {.count = 1, .reusable = true}}, SHIFT(868), + [3493] = {.entry = {.count = 1, .reusable = true}}, SHIFT(62), + [3495] = {.entry = {.count = 1, .reusable = true}}, SHIFT(495), + [3497] = {.entry = {.count = 1, .reusable = true}}, SHIFT(768), + [3499] = {.entry = {.count = 1, .reusable = true}}, SHIFT(325), + [3501] = {.entry = {.count = 1, .reusable = true}}, SHIFT(874), + [3503] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1068), + [3505] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1069), + [3507] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1197), + [3509] = {.entry = {.count = 1, .reusable = true}}, SHIFT(816), + [3511] = {.entry = {.count = 1, .reusable = true}}, SHIFT(877), + [3513] = {.entry = {.count = 1, .reusable = true}}, SHIFT(490), + [3515] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute_arguments, 4, 0, 0), + [3517] = {.entry = {.count = 1, .reusable = true}}, SHIFT(879), + [3519] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1372), + [3521] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1325), + [3523] = {.entry = {.count = 1, .reusable = true}}, SHIFT(784), + [3525] = {.entry = {.count = 1, .reusable = true}}, SHIFT(159), + [3527] = {.entry = {.count = 1, .reusable = true}}, SHIFT(573), + [3529] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), + [3531] = {.entry = {.count = 1, .reusable = true}}, SHIFT(891), + [3533] = {.entry = {.count = 1, .reusable = true}}, SHIFT(961), + [3535] = {.entry = {.count = 1, .reusable = true}}, SHIFT(397), + [3537] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1087), + [3539] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1384), + [3541] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1286), + [3543] = {.entry = {.count = 1, .reusable = true}}, SHIFT(76), + [3545] = {.entry = {.count = 1, .reusable = true}}, SHIFT(530), + [3547] = {.entry = {.count = 1, .reusable = true}}, SHIFT(947), + [3549] = {.entry = {.count = 1, .reusable = true}}, SHIFT(803), + [3551] = {.entry = {.count = 1, .reusable = true}}, SHIFT(953), + [3553] = {.entry = {.count = 1, .reusable = true}}, SHIFT(861), + [3555] = {.entry = {.count = 1, .reusable = true}}, SHIFT(506), + [3557] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1434), + [3559] = {.entry = {.count = 1, .reusable = true}}, SHIFT(819), + [3561] = {.entry = {.count = 1, .reusable = true}}, SHIFT(437), + [3563] = {.entry = {.count = 1, .reusable = true}}, SHIFT(467), + [3565] = {.entry = {.count = 1, .reusable = true}}, SHIFT(820), + [3567] = {.entry = {.count = 1, .reusable = true}}, SHIFT(507), + [3569] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1472), + [3571] = {.entry = {.count = 1, .reusable = true}}, SHIFT(195), + [3573] = {.entry = {.count = 1, .reusable = true}}, SHIFT(318), + [3575] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1160), + [3577] = {.entry = {.count = 1, .reusable = true}}, SHIFT(885), + [3579] = {.entry = {.count = 1, .reusable = true}}, SHIFT(817), + [3581] = {.entry = {.count = 1, .reusable = true}}, SHIFT(329), + [3583] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1515), + [3585] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1526), + [3587] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1478), + [3589] = {.entry = {.count = 1, .reusable = true}}, SHIFT(765), + [3591] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1221), + [3593] = {.entry = {.count = 1, .reusable = true}}, SHIFT(912), + [3595] = {.entry = {.count = 1, .reusable = true}}, SHIFT(289), + [3597] = {.entry = {.count = 1, .reusable = true}}, SHIFT(79), + [3599] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1367), + [3601] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1045), + [3603] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1571), + [3605] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1468), + [3607] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1294), + [3609] = {.entry = {.count = 1, .reusable = true}}, SHIFT(336), + [3611] = {.entry = {.count = 1, .reusable = true}}, SHIFT(492), + [3613] = {.entry = {.count = 1, .reusable = true}}, SHIFT(694), + [3615] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1355), + [3617] = {.entry = {.count = 1, .reusable = true}}, SHIFT(599), + [3619] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1079), + [3621] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute_arguments, 5, 0, 0), + [3623] = {.entry = {.count = 1, .reusable = true}}, SHIFT(944), + [3625] = {.entry = {.count = 1, .reusable = true}}, SHIFT(189), + [3627] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1380), + [3629] = {.entry = {.count = 1, .reusable = true}}, SHIFT(248), + [3631] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1047), + [3633] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1322), + [3635] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1491), + [3637] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_count_range, 8, 0, 0), + [3639] = {.entry = {.count = 1, .reusable = true}}, SHIFT(980), + [3641] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1226), + [3643] = {.entry = {.count = 1, .reusable = true}}, SHIFT(601), + [3645] = {.entry = {.count = 1, .reusable = true}}, SHIFT(196), + [3647] = {.entry = {.count = 1, .reusable = true}}, SHIFT(68), + [3649] = {.entry = {.count = 1, .reusable = true}}, SHIFT(625), + [3651] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1195), + [3653] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_count_range, 12, 0, 0), + [3655] = {.entry = {.count = 1, .reusable = true}}, SHIFT(574), + [3657] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1321), + [3659] = {.entry = {.count = 1, .reusable = true}}, SHIFT(794), + [3661] = {.entry = {.count = 1, .reusable = true}}, SHIFT(342), + [3663] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1161), + [3665] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1403), + [3667] = {.entry = {.count = 1, .reusable = true}}, SHIFT(962), + [3669] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1497), + [3671] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1406), + [3673] = {.entry = {.count = 1, .reusable = true}}, SHIFT(107), + [3675] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1162), + [3677] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1314), + [3679] = {.entry = {.count = 1, .reusable = true}}, SHIFT(940), + [3681] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1410), + [3683] = {.entry = {.count = 1, .reusable = true}}, SHIFT(701), + [3685] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1417), + [3687] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1252), + [3689] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1425), + [3691] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1351), + [3693] = {.entry = {.count = 1, .reusable = true}}, SHIFT(283), + [3695] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1166), + [3697] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1433), + [3699] = {.entry = {.count = 1, .reusable = true}}, SHIFT(965), + [3701] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1435), + [3703] = {.entry = {.count = 1, .reusable = true}}, SHIFT(70), + [3705] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1379), + [3707] = {.entry = {.count = 1, .reusable = true}}, SHIFT(583), + [3709] = {.entry = {.count = 1, .reusable = true}}, SHIFT(201), + [3711] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1446), + [3713] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1450), + [3715] = {.entry = {.count = 1, .reusable = true}}, SHIFT(411), + [3717] = {.entry = {.count = 1, .reusable = true}}, SHIFT(909), + [3719] = {.entry = {.count = 1, .reusable = true}}, SHIFT(206), + [3721] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1461), + [3723] = {.entry = {.count = 1, .reusable = true}}, SHIFT(776), + [3725] = {.entry = {.count = 1, .reusable = true}}, SHIFT(121), + [3727] = {.entry = {.count = 1, .reusable = true}}, SHIFT(888), + [3729] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1498), + [3731] = {.entry = {.count = 1, .reusable = true}}, SHIFT(208), + [3733] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1476), + [3735] = {.entry = {.count = 1, .reusable = true}}, SHIFT(617), + [3737] = {.entry = {.count = 1, .reusable = true}}, SHIFT(358), + [3739] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1341), + [3741] = {.entry = {.count = 1, .reusable = true}}, SHIFT(608), + [3743] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1550), + [3745] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute_arguments, 2, 0, 0), + [3747] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1575), + [3749] = {.entry = {.count = 1, .reusable = true}}, SHIFT(812), + [3751] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_type_parameters, 5, 0, 0), + [3753] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1511), + [3755] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1513), + [3757] = {.entry = {.count = 1, .reusable = true}}, SHIFT(797), + [3759] = {.entry = {.count = 1, .reusable = true}}, SHIFT(798), + [3761] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1460), + [3763] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1524), + [3765] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1525), + [3767] = {.entry = {.count = 1, .reusable = true}}, SHIFT(788), + [3769] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1529), + [3771] = {.entry = {.count = 1, .reusable = true}}, SHIFT(758), + [3773] = {.entry = {.count = 1, .reusable = true}}, SHIFT(605), + [3775] = {.entry = {.count = 1, .reusable = true}}, SHIFT(927), + [3777] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1347), + [3779] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1536), + [3781] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1548), + [3783] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1549), + [3785] = {.entry = {.count = 1, .reusable = true}}, SHIFT(676), + [3787] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1551), + [3789] = {.entry = {.count = 1, .reusable = true}}, SHIFT(677), + [3791] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1554), + [3793] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1556), + [3795] = {.entry = {.count = 1, .reusable = true}}, SHIFT(679), + [3797] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1560), + [3799] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1563), + [3801] = {.entry = {.count = 1, .reusable = true}}, SHIFT(267), + [3803] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1565), + [3805] = {.entry = {.count = 1, .reusable = true}}, SHIFT(231), + [3807] = {.entry = {.count = 1, .reusable = true}}, SHIFT(1568), + [3809] = {.entry = {.count = 1, .reusable = true}}, SHIFT(634), + [3811] = {.entry = {.count = 1, .reusable = true}}, SHIFT(913), +}; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef TREE_SITTER_HIDE_SYMBOLS +#define TS_PUBLIC +#elif defined(_WIN32) +#define TS_PUBLIC __declspec(dllexport) +#else +#define TS_PUBLIC __attribute__((visibility("default"))) +#endif + +TS_PUBLIC const TSLanguage *tree_sitter_sand(void) { + static const TSLanguage language = { + .abi_version = LANGUAGE_VERSION, + .symbol_count = SYMBOL_COUNT, + .alias_count = ALIAS_COUNT, + .token_count = TOKEN_COUNT, + .external_token_count = EXTERNAL_TOKEN_COUNT, + .state_count = STATE_COUNT, + .large_state_count = LARGE_STATE_COUNT, + .production_id_count = PRODUCTION_ID_COUNT, + .supertype_count = SUPERTYPE_COUNT, + .field_count = FIELD_COUNT, + .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, + .parse_table = &ts_parse_table[0][0], + .small_parse_table = ts_small_parse_table, + .small_parse_table_map = ts_small_parse_table_map, + .parse_actions = ts_parse_actions, + .symbol_names = ts_symbol_names, + .field_names = ts_field_names, + .field_map_slices = ts_field_map_slices, + .field_map_entries = ts_field_map_entries, + .symbol_metadata = ts_symbol_metadata, + .public_symbol_map = ts_symbol_map, + .alias_map = ts_non_terminal_alias_map, + .alias_sequences = &ts_alias_sequences[0][0], + .lex_modes = (const void*)ts_lex_modes, + .lex_fn = ts_lex, + .keyword_lex_fn = ts_lex_keywords, + .keyword_capture_token = sym_identifier, + .primary_state_ids = ts_primary_state_ids, + .name = "sand", + .max_reserved_word_set_size = 0, + .metadata = { + .major_version = 0, + .minor_version = 1, + .patch_version = 0, + }, + }; + return &language; +} +#ifdef __cplusplus +} +#endif diff --git a/editors/tree-sitter-sand/src/tree_sitter/alloc.h b/editors/tree-sitter-sand/src/tree_sitter/alloc.h new file mode 100644 index 00000000..1abdd120 --- /dev/null +++ b/editors/tree-sitter-sand/src/tree_sitter/alloc.h @@ -0,0 +1,54 @@ +#ifndef TREE_SITTER_ALLOC_H_ +#define TREE_SITTER_ALLOC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +// Allow clients to override allocation functions +#ifdef TREE_SITTER_REUSE_ALLOCATOR + +extern void *(*ts_current_malloc)(size_t size); +extern void *(*ts_current_calloc)(size_t count, size_t size); +extern void *(*ts_current_realloc)(void *ptr, size_t size); +extern void (*ts_current_free)(void *ptr); + +#ifndef ts_malloc +#define ts_malloc ts_current_malloc +#endif +#ifndef ts_calloc +#define ts_calloc ts_current_calloc +#endif +#ifndef ts_realloc +#define ts_realloc ts_current_realloc +#endif +#ifndef ts_free +#define ts_free ts_current_free +#endif + +#else + +#ifndef ts_malloc +#define ts_malloc malloc +#endif +#ifndef ts_calloc +#define ts_calloc calloc +#endif +#ifndef ts_realloc +#define ts_realloc realloc +#endif +#ifndef ts_free +#define ts_free free +#endif + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_ALLOC_H_ diff --git a/editors/tree-sitter-sand/src/tree_sitter/array.h b/editors/tree-sitter-sand/src/tree_sitter/array.h new file mode 100644 index 00000000..a17a574f --- /dev/null +++ b/editors/tree-sitter-sand/src/tree_sitter/array.h @@ -0,0 +1,291 @@ +#ifndef TREE_SITTER_ARRAY_H_ +#define TREE_SITTER_ARRAY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "./alloc.h" + +#include +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4101) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif + +#define Array(T) \ + struct { \ + T *contents; \ + uint32_t size; \ + uint32_t capacity; \ + } + +/// Initialize an array. +#define array_init(self) \ + ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL) + +/// Create an empty array. +#define array_new() \ + { NULL, 0, 0 } + +/// Get a pointer to the element at a given `index` in the array. +#define array_get(self, _index) \ + (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index]) + +/// Get a pointer to the first element in the array. +#define array_front(self) array_get(self, 0) + +/// Get a pointer to the last element in the array. +#define array_back(self) array_get(self, (self)->size - 1) + +/// Clear the array, setting its size to zero. Note that this does not free any +/// memory allocated for the array's contents. +#define array_clear(self) ((self)->size = 0) + +/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is +/// less than the array's current capacity, this function has no effect. +#define array_reserve(self, new_capacity) \ + _array__reserve((Array *)(self), array_elem_size(self), new_capacity) + +/// Free any memory allocated for this array. Note that this does not free any +/// memory allocated for the array's contents. +#define array_delete(self) _array__delete((Array *)(self)) + +/// Push a new `element` onto the end of the array. +#define array_push(self, element) \ + (_array__grow((Array *)(self), 1, array_elem_size(self)), \ + (self)->contents[(self)->size++] = (element)) + +/// Increase the array's size by `count` elements. +/// New elements are zero-initialized. +#define array_grow_by(self, count) \ + do { \ + if ((count) == 0) break; \ + _array__grow((Array *)(self), count, array_elem_size(self)); \ + memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \ + (self)->size += (count); \ + } while (0) + +/// Append all elements from one array to the end of another. +#define array_push_all(self, other) \ + array_extend((self), (other)->size, (other)->contents) + +/// Append `count` elements to the end of the array, reading their values from the +/// `contents` pointer. +#define array_extend(self, count, contents) \ + _array__splice( \ + (Array *)(self), array_elem_size(self), (self)->size, \ + 0, count, contents \ + ) + +/// Remove `old_count` elements from the array starting at the given `index`. At +/// the same index, insert `new_count` new elements, reading their values from the +/// `new_contents` pointer. +#define array_splice(self, _index, old_count, new_count, new_contents) \ + _array__splice( \ + (Array *)(self), array_elem_size(self), _index, \ + old_count, new_count, new_contents \ + ) + +/// Insert one `element` into the array at the given `index`. +#define array_insert(self, _index, element) \ + _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element)) + +/// Remove one element from the array at the given `index`. +#define array_erase(self, _index) \ + _array__erase((Array *)(self), array_elem_size(self), _index) + +/// Pop the last element off the array, returning the element by value. +#define array_pop(self) ((self)->contents[--(self)->size]) + +/// Assign the contents of one array to another, reallocating if necessary. +#define array_assign(self, other) \ + _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self)) + +/// Swap one array with another +#define array_swap(self, other) \ + _array__swap((Array *)(self), (Array *)(other)) + +/// Get the size of the array contents +#define array_elem_size(self) (sizeof *(self)->contents) + +/// Search a sorted array for a given `needle` value, using the given `compare` +/// callback to determine the order. +/// +/// If an existing element is found to be equal to `needle`, then the `index` +/// out-parameter is set to the existing value's index, and the `exists` +/// out-parameter is set to true. Otherwise, `index` is set to an index where +/// `needle` should be inserted in order to preserve the sorting, and `exists` +/// is set to false. +#define array_search_sorted_with(self, compare, needle, _index, _exists) \ + _array__search_sorted(self, 0, compare, , needle, _index, _exists) + +/// Search a sorted array for a given `needle` value, using integer comparisons +/// of a given struct field (specified with a leading dot) to determine the order. +/// +/// See also `array_search_sorted_with`. +#define array_search_sorted_by(self, field, needle, _index, _exists) \ + _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists) + +/// Insert a given `value` into a sorted array, using the given `compare` +/// callback to determine the order. +#define array_insert_sorted_with(self, compare, value) \ + do { \ + unsigned _index, _exists; \ + array_search_sorted_with(self, compare, &(value), &_index, &_exists); \ + if (!_exists) array_insert(self, _index, value); \ + } while (0) + +/// Insert a given `value` into a sorted array, using integer comparisons of +/// a given struct field (specified with a leading dot) to determine the order. +/// +/// See also `array_search_sorted_by`. +#define array_insert_sorted_by(self, field, value) \ + do { \ + unsigned _index, _exists; \ + array_search_sorted_by(self, field, (value) field, &_index, &_exists); \ + if (!_exists) array_insert(self, _index, value); \ + } while (0) + +// Private + +typedef Array(void) Array; + +/// This is not what you're looking for, see `array_delete`. +static inline void _array__delete(Array *self) { + if (self->contents) { + ts_free(self->contents); + self->contents = NULL; + self->size = 0; + self->capacity = 0; + } +} + +/// This is not what you're looking for, see `array_erase`. +static inline void _array__erase(Array *self, size_t element_size, + uint32_t index) { + assert(index < self->size); + char *contents = (char *)self->contents; + memmove(contents + index * element_size, contents + (index + 1) * element_size, + (self->size - index - 1) * element_size); + self->size--; +} + +/// This is not what you're looking for, see `array_reserve`. +static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) { + if (new_capacity > self->capacity) { + if (self->contents) { + self->contents = ts_realloc(self->contents, new_capacity * element_size); + } else { + self->contents = ts_malloc(new_capacity * element_size); + } + self->capacity = new_capacity; + } +} + +/// This is not what you're looking for, see `array_assign`. +static inline void _array__assign(Array *self, const Array *other, size_t element_size) { + _array__reserve(self, element_size, other->size); + self->size = other->size; + memcpy(self->contents, other->contents, self->size * element_size); +} + +/// This is not what you're looking for, see `array_swap`. +static inline void _array__swap(Array *self, Array *other) { + Array swap = *other; + *other = *self; + *self = swap; +} + +/// This is not what you're looking for, see `array_push` or `array_grow_by`. +static inline void _array__grow(Array *self, uint32_t count, size_t element_size) { + uint32_t new_size = self->size + count; + if (new_size > self->capacity) { + uint32_t new_capacity = self->capacity * 2; + if (new_capacity < 8) new_capacity = 8; + if (new_capacity < new_size) new_capacity = new_size; + _array__reserve(self, element_size, new_capacity); + } +} + +/// This is not what you're looking for, see `array_splice`. +static inline void _array__splice(Array *self, size_t element_size, + uint32_t index, uint32_t old_count, + uint32_t new_count, const void *elements) { + uint32_t new_size = self->size + new_count - old_count; + uint32_t old_end = index + old_count; + uint32_t new_end = index + new_count; + assert(old_end <= self->size); + + _array__reserve(self, element_size, new_size); + + char *contents = (char *)self->contents; + if (self->size > old_end) { + memmove( + contents + new_end * element_size, + contents + old_end * element_size, + (self->size - old_end) * element_size + ); + } + if (new_count > 0) { + if (elements) { + memcpy( + (contents + index * element_size), + elements, + new_count * element_size + ); + } else { + memset( + (contents + index * element_size), + 0, + new_count * element_size + ); + } + } + self->size += new_count - old_count; +} + +/// A binary search routine, based on Rust's `std::slice::binary_search_by`. +/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`. +#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \ + do { \ + *(_index) = start; \ + *(_exists) = false; \ + uint32_t size = (self)->size - *(_index); \ + if (size == 0) break; \ + int comparison; \ + while (size > 1) { \ + uint32_t half_size = size / 2; \ + uint32_t mid_index = *(_index) + half_size; \ + comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \ + if (comparison <= 0) *(_index) = mid_index; \ + size -= half_size; \ + } \ + comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \ + if (comparison == 0) *(_exists) = true; \ + else if (comparison < 0) *(_index) += 1; \ + } while (0) + +/// Helper macro for the `_sorted_by` routines below. This takes the left (existing) +/// parameter by reference in order to work with the generic sorting function above. +#define _compare_int(a, b) ((int)*(a) - (int)(b)) + +#ifdef _MSC_VER +#pragma warning(pop) +#elif defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_ARRAY_H_ diff --git a/editors/tree-sitter-sand/src/tree_sitter/parser.h b/editors/tree-sitter-sand/src/tree_sitter/parser.h new file mode 100644 index 00000000..cdbe64cc --- /dev/null +++ b/editors/tree-sitter-sand/src/tree_sitter/parser.h @@ -0,0 +1,287 @@ +#ifndef TREE_SITTER_PARSER_H_ +#define TREE_SITTER_PARSER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define ts_builtin_sym_error ((TSSymbol)-1) +#define ts_builtin_sym_end 0 +#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 + +#ifndef TREE_SITTER_API_H_ +typedef uint16_t TSStateId; +typedef uint16_t TSSymbol; +typedef uint16_t TSFieldId; +typedef struct TSLanguage TSLanguage; +typedef struct TSLanguageMetadata TSLanguageMetadata; +typedef struct TSLanguageMetadata { + uint8_t major_version; + uint8_t minor_version; + uint8_t patch_version; +} TSLanguageMetadata; +#endif + +typedef struct { + TSFieldId field_id; + uint8_t child_index; + bool inherited; +} TSFieldMapEntry; + +// Used to index the field and supertype maps. +typedef struct { + uint16_t index; + uint16_t length; +} TSMapSlice; + +typedef struct { + bool visible; + bool named; + bool supertype; +} TSSymbolMetadata; + +typedef struct TSLexer TSLexer; + +struct TSLexer { + int32_t lookahead; + TSSymbol result_symbol; + void (*advance)(TSLexer *, bool); + void (*mark_end)(TSLexer *); + uint32_t (*get_column)(TSLexer *); + bool (*is_at_included_range_start)(const TSLexer *); + bool (*eof)(const TSLexer *); + void (*log)(const TSLexer *, const char *, ...); +}; + +typedef enum { + TSParseActionTypeShift, + TSParseActionTypeReduce, + TSParseActionTypeAccept, + TSParseActionTypeRecover, +} TSParseActionType; + +typedef union { + struct { + uint8_t type; + TSStateId state; + bool extra; + bool repetition; + } shift; + struct { + uint8_t type; + uint8_t child_count; + TSSymbol symbol; + int16_t dynamic_precedence; + uint16_t production_id; + } reduce; + uint8_t type; +} TSParseAction; + +typedef struct { + uint16_t lex_state; + uint16_t external_lex_state; +} TSLexMode; + +typedef struct { + uint16_t lex_state; + uint16_t external_lex_state; + uint16_t reserved_word_set_id; +} TSLexerMode; + +typedef union { + TSParseAction action; + struct { + uint8_t count; + bool reusable; + } entry; +} TSParseActionEntry; + +typedef struct { + int32_t start; + int32_t end; +} TSCharacterRange; + +struct TSLanguage { + uint32_t abi_version; + uint32_t symbol_count; + uint32_t alias_count; + uint32_t token_count; + uint32_t external_token_count; + uint32_t state_count; + uint32_t large_state_count; + uint32_t production_id_count; + uint32_t field_count; + uint16_t max_alias_sequence_length; + const uint16_t *parse_table; + const uint16_t *small_parse_table; + const uint32_t *small_parse_table_map; + const TSParseActionEntry *parse_actions; + const char * const *symbol_names; + const char * const *field_names; + const TSMapSlice *field_map_slices; + const TSFieldMapEntry *field_map_entries; + const TSSymbolMetadata *symbol_metadata; + const TSSymbol *public_symbol_map; + const uint16_t *alias_map; + const TSSymbol *alias_sequences; + const TSLexerMode *lex_modes; + bool (*lex_fn)(TSLexer *, TSStateId); + bool (*keyword_lex_fn)(TSLexer *, TSStateId); + TSSymbol keyword_capture_token; + struct { + const bool *states; + const TSSymbol *symbol_map; + void *(*create)(void); + void (*destroy)(void *); + bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); + unsigned (*serialize)(void *, char *); + void (*deserialize)(void *, const char *, unsigned); + } external_scanner; + const TSStateId *primary_state_ids; + const char *name; + const TSSymbol *reserved_words; + uint16_t max_reserved_word_set_size; + uint32_t supertype_count; + const TSSymbol *supertype_symbols; + const TSMapSlice *supertype_map_slices; + const TSSymbol *supertype_map_entries; + TSLanguageMetadata metadata; +}; + +static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { + uint32_t index = 0; + uint32_t size = len - index; + while (size > 1) { + uint32_t half_size = size / 2; + uint32_t mid_index = index + half_size; + const TSCharacterRange *range = &ranges[mid_index]; + if (lookahead >= range->start && lookahead <= range->end) { + return true; + } else if (lookahead > range->end) { + index = mid_index; + } + size -= half_size; + } + const TSCharacterRange *range = &ranges[index]; + return (lookahead >= range->start && lookahead <= range->end); +} + +/* + * Lexer Macros + */ + +#ifdef _MSC_VER +#define UNUSED __pragma(warning(suppress : 4101)) +#else +#define UNUSED __attribute__((unused)) +#endif + +#define START_LEXER() \ + bool result = false; \ + bool skip = false; \ + UNUSED \ + bool eof = false; \ + int32_t lookahead; \ + goto start; \ + next_state: \ + lexer->advance(lexer, skip); \ + start: \ + skip = false; \ + lookahead = lexer->lookahead; + +#define ADVANCE(state_value) \ + { \ + state = state_value; \ + goto next_state; \ + } + +#define ADVANCE_MAP(...) \ + { \ + static const uint16_t map[] = { __VA_ARGS__ }; \ + for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \ + if (map[i] == lookahead) { \ + state = map[i + 1]; \ + goto next_state; \ + } \ + } \ + } + +#define SKIP(state_value) \ + { \ + skip = true; \ + state = state_value; \ + goto next_state; \ + } + +#define ACCEPT_TOKEN(symbol_value) \ + result = true; \ + lexer->result_symbol = symbol_value; \ + lexer->mark_end(lexer); + +#define END_STATE() return result; + +/* + * Parse Table Macros + */ + +#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT) + +#define STATE(id) id + +#define ACTIONS(id) id + +#define SHIFT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = (state_value) \ + } \ + }} + +#define SHIFT_REPEAT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = (state_value), \ + .repetition = true \ + } \ + }} + +#define SHIFT_EXTRA() \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .extra = true \ + } \ + }} + +#define REDUCE(symbol_name, children, precedence, prod_id) \ + {{ \ + .reduce = { \ + .type = TSParseActionTypeReduce, \ + .symbol = symbol_name, \ + .child_count = children, \ + .dynamic_precedence = precedence, \ + .production_id = prod_id \ + }, \ + }} + +#define RECOVER() \ + {{ \ + .type = TSParseActionTypeRecover \ + }} + +#define ACCEPT_INPUT() \ + {{ \ + .type = TSParseActionTypeAccept \ + }} + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_PARSER_H_ diff --git a/editors/tree-sitter-sand/tree-sitter.json b/editors/tree-sitter-sand/tree-sitter.json new file mode 100644 index 00000000..5d9e4949 --- /dev/null +++ b/editors/tree-sitter-sand/tree-sitter.json @@ -0,0 +1,18 @@ +{ + "grammars": [ + { + "name": "sand", + "camelcase": "Sand", + "scope": "source.sand", + "path": ".", + "file-types": ["sand"], + "highlights": "queries/highlights.scm" + } + ], + "metadata": { + "version": "0.1.0", + "license": "MIT", + "description": "Tree-sitter grammar for the Sand datapack language", + "links": { "repository": "https://github.com/ThatOneToast/sand" } + } +} diff --git a/editors/zed/Cargo.lock b/editors/zed/Cargo.lock new file mode 100644 index 00000000..180a14b5 --- /dev/null +++ b/editors/zed/Cargo.lock @@ -0,0 +1,845 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "auditable-serde" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7bf8143dfc3c0258df908843e169b5cc5fcf76c7718bd66135ef4a9cd558c5" +dependencies = [ + "semver", + "serde", + "serde_json", + "topological-sort", +] + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "crc32fast" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[package]] +name = "spdx" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e17e880bafaeb362a7b751ec46bdc5b61445a188f80e0606e68167cd540fa3" +dependencies = [ + "smallvec", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "wasm-encoder" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bb72f02e7fbf07183443b27b0f3d4144abf8c114189f2e088ed95b696a7822" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce1ef0faabbbba6674e97a56bee857ccddf942785a336c8b47b42373c922a91d" +dependencies = [ + "anyhow", + "auditable-serde", + "flate2", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "spdx", + "url", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f51cad774fb3c9461ab9bccc9c62dfb7388397b5deda31bf40e8108ccd678b2" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10fb6648689b3929d56bbc7eb1acf70c9a42a29eb5358c67c10f54dbd5d695de" +dependencies = [ + "wit-bindgen-rt", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92fa781d4f2ff6d3f27f3cc9b74a73327b31ca0dc4a3ef25a0ce2983e0e5af9b" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db52a11d4dfb0a59f194c064055794ee6564eb1ced88c25da2cf76e50c5621" +dependencies = [ + "bitflags", + "futures", + "once_cell", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0809dc5ba19e2e98661bf32fc0addc5a3ca5bf3a6a7083aa6ba484085ff3ce" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.119", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad19eec017904e04c60719592a803ee5da76cb51c81e3f6fbf9457f59db49799" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.119", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "635c3adc595422cbf2341a17fb73a319669cc8d33deed3a48368a841df86b676" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zed-sand" +version = "0.1.0" +dependencies = [ + "zed_extension_api", +] + +[[package]] +name = "zed_extension_api" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0729d50b4ca0a7e28e590bbe32e3ca0194d97ef654961451a424c661a366fca0" +dependencies = [ + "serde", + "serde_json", + "wit-bindgen", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/editors/zed/Cargo.toml b/editors/zed/Cargo.toml new file mode 100644 index 00000000..4a326c50 --- /dev/null +++ b/editors/zed/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "zed-sand" +version = "0.1.0" +edition = "2021" +publish = false +license = "MIT" +description = "Zed extension for the Sand datapack language" + +# Built by Zed as a WebAssembly component; not part of the Sand workspace. +[workspace] + +[lib] +crate-type = ["cdylib"] +path = "src/lib.rs" + +[dependencies] +zed_extension_api = "0.7.0" diff --git a/editors/zed/languages/sand/brackets.scm b/editors/zed/languages/sand/brackets.scm new file mode 100644 index 00000000..2fbfd443 --- /dev/null +++ b/editors/zed/languages/sand/brackets.scm @@ -0,0 +1,4 @@ +("(" @open ")" @close) +("[" @open "]" @close) +("{" @open "}" @close) +("\"" @open "\"" @close) diff --git a/editors/zed/languages/sand/config.toml b/editors/zed/languages/sand/config.toml new file mode 100644 index 00000000..c6fd4610 --- /dev/null +++ b/editors/zed/languages/sand/config.toml @@ -0,0 +1,14 @@ +name = "Sand" +grammar = "sand" +path_suffixes = ["sand"] +line_comments = ["// ", "/// ", "//! "] +block_comment = ["/* ", " */"] +tab_size = 4 +autoclose_before = ";:.,=}])" +brackets = [ + { start = "{", end = "}", close = true, newline = true }, + { start = "[", end = "]", close = true, newline = true }, + { start = "(", end = ")", close = true, newline = true }, + { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, +] +word_characters = ["_"] diff --git a/editors/zed/languages/sand/highlights.scm b/editors/zed/languages/sand/highlights.scm new file mode 100644 index 00000000..f1fd0254 --- /dev/null +++ b/editors/zed/languages/sand/highlights.scm @@ -0,0 +1,129 @@ +; Comments +(doc_comment) @comment.doc +(line_comment) @comment +(block_comment) @comment + +; Literals +(string) @string +(escape_sequence) @string.escape +(brace_escape) @string.escape +(interpolation + "{" @punctuation.special + "}" @punctuation.special) @embedded +(interpolation_content) @variable.special +(integer) @number +(float) @number +(boolean) @boolean + +; Attributes: #[tick], #[on(death)], #![pack(...)] +(attribute "#" @attribute "[" @attribute "]" @attribute) +(inner_attribute "#" @attribute "!" @attribute "[" @attribute "]" @attribute) +(attribute_name) @attribute +(argument_name) @property + +; Struct values and inherent methods +(trait_item name: (identifier) @type) +(trait_method name: (identifier) @function.method) +(function_type_parameter name: (identifier) @type bound: (path) @type) +(impl_item trait: (path) @type) +(struct_item name: (identifier) @type) +(impl_item type: (path) @type) +(record_expression type: (path) @type) +(record_field name: (identifier) @property) +(record_pattern type: (path) @type) +(pattern_field name: (identifier) @property) +(binding_pattern name: (identifier) @variable) +(method_expression method: (identifier) @function.method) +(field_expression field: (identifier) @property) +(receiver) @variable.builtin +(generic_parameters (identifier) @type) + +; Declarations +(function_item name: (identifier) @function) +(extern_function name: (identifier) @function) +(event_item name: (identifier) @type) +(state_item name: (identifier) @type) +(enum_item name: (identifier) @type) +(flow_item name: (identifier) @type) +(mod_item name: (identifier) @namespace) +(const_item name: (identifier) @constant) +(variant name: (identifier) @variant) +(field_declaration name: (field_identifier) @property) +(data_item name: (identifier) @type) +(data_kind) @keyword +(data_field key: (field_identifier) @property) +(parameter name: (identifier) @variable.parameter) +(let_statement name: (identifier) @variable) +(mutable_specifier) @keyword.modifier +(type) @type +(scope) @keyword.modifier +(hook_phase) @keyword + +; Uses +(place field: (field_identifier) @property) +(macro_invocation macro: (macro_name) @function.macro "!" @function.macro) +(call_expression function: (path (identifier) @function .)) +(transition from: (path (identifier) @variant)) +(transition to: (path (identifier) @variant)) +(hook state: (path (identifier) @variant)) +(hook function: (path (identifier) @function .)) + +; Paths: `Type::Variant`, `module::item`, upper-case names as types +((identifier) @type + (#match? @type "^[A-Z][A-Za-z0-9_]*$")) +((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$")) +(crate) @keyword +(self) @keyword +(super) @keyword + +; Keywords +[ + "fn" + "struct" + "move" + "trait" + "impl" + "mod" + "use" + "const" + "enum" + "state" + "flow" + "event" + "extern" + "as" + "on" + "let" +] @keyword + +[ + "if" + "else" + "for" + "in" + "every" + "priority" + "match" + "while" + "loop" + "return" + "continue" + "break" + "emit" +] @keyword.control + +(visibility) @keyword + +; Operators and punctuation +[ + "=" "+=" "-=" "*=" "/=" "%=" + "==" "!=" "<" "<=" ">" ">=" + "&&" "||" "!" "|" + "+" "-" "*" "/" "%" + ".." "..=" + "->" "=>" +] @operator + +["(" ")" "{" "}" "[" "]"] @punctuation.bracket +["," ";" ":" "::" "."] @punctuation.delimiter diff --git a/editors/zed/languages/sand/indents.scm b/editors/zed/languages/sand/indents.scm new file mode 100644 index 00000000..e4c79845 --- /dev/null +++ b/editors/zed/languages/sand/indents.scm @@ -0,0 +1,13 @@ +[ + (block) + (state_item) + (enum_item) + (flow_item) + (mod_item) + (use_group) + (arguments) + (attribute_arguments) +] @indent + +(_ "{" "}" @end) @indent +(_ "(" ")" @end) @indent diff --git a/editors/zed/languages/sand/outline.scm b/editors/zed/languages/sand/outline.scm new file mode 100644 index 00000000..01b8313b --- /dev/null +++ b/editors/zed/languages/sand/outline.scm @@ -0,0 +1,51 @@ +(function_item + (visibility)? @context + "fn" @context + name: (identifier) @name) @item + +(event_item + "event" @context + name: (identifier) @name) @item + +(extern_function + "extern" @context + name: (identifier) @name) @item + +(state_item + scope: (scope) @context + "state" @context + name: (identifier) @name) @item + +(field_declaration + name: (field_identifier) @name) @item + +(enum_item + "enum" @context + name: (identifier) @name) @item + +(variant + name: (identifier) @name) @item + +(flow_item + "flow" @context + name: (identifier) @name) @item + +(const_item + "const" @context + name: (identifier) @name) @item + +(mod_item + "mod" @context + name: (identifier) @name) @item + +(data_item + kind: (data_kind) @context + name: (identifier) @name) @item + +(struct_item + "struct" @context + name: (identifier) @name) @item + +(impl_item + "impl" @context + type: (path) @name) @item diff --git a/editors/zed/src/lib.rs b/editors/zed/src/lib.rs new file mode 100644 index 00000000..a52ca825 --- /dev/null +++ b/editors/zed/src/lib.rs @@ -0,0 +1,47 @@ +//! Zed extension for the Sand datapack language. +//! +//! Highlighting comes from the tree-sitter grammar; everything semantic +//! (diagnostics, hover, completion, navigation, rename) comes from the Sand +//! language server, started as `sand lsp`. + +use zed_extension_api::{self as zed, settings::LspSettings, LanguageServerId, Result}; + +struct SandExtension; + +impl zed::Extension for SandExtension { + fn new() -> Self { + SandExtension + } + + fn language_server_command( + &mut self, + language_server_id: &LanguageServerId, + worktree: &zed::Worktree, + ) -> Result { + // `lsp.sand.binary` in Zed settings overrides discovery. + let binary = LspSettings::for_worktree(language_server_id.as_ref(), worktree) + .ok() + .and_then(|settings| settings.binary); + let command = binary + .as_ref() + .and_then(|binary| binary.path.clone()) + .or_else(|| worktree.which("sand")) + .ok_or_else(|| { + "Sand: the `sand` command was not found on PATH. Install it with \ + `cargo install --path sand-cli` from the Sand repository, or set \ + `lsp.sand.binary.path` in your Zed settings." + .to_string() + })?; + let args = binary + .as_ref() + .and_then(|binary| binary.arguments.clone()) + .unwrap_or_else(|| vec!["lsp".into()]); + Ok(zed::Command { + command, + args, + env: worktree.shell_env(), + }) + } +} + +zed::register_extension!(SandExtension); diff --git a/examples/README.md b/examples/README.md index 003e556a..e525a512 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,7 +1,7 @@ # Sand Examples The `.rs` files in this directory are copyable reference snippets. The project -subdirectories below are standalone crates that build against this checkout. +subdirectories below contain standalone Rust crates or Sand language packages. ## Complete projects @@ -18,6 +18,13 @@ subdirectories below are standalone crates that build against this checkout. | [rpg_entity](rpg_entity/) | Typed entity archetypes and deterministic export coverage. | | [participant_audit](participant_audit/) | Live event participants, equipment snapshots, and multiplayer regressions. | | [portable_counter](portable_counter/) | Rust frontend for the portable-program acceptance counter. | +| [lang_encounters](lang_encounters/) | The same kind of gameplay written in the Sand language (`.sand`), built with `sand lang build`. | +| [lang_methods](lang_methods/) | Struct values and methods, player State methods, teleportation and runtime cooldowns in Sand source. | +| [lang_reference_combat](lang_reference_combat/) | Borrowed methods, persistent attackers, delayed marks, entity State, recipes and vanilla kill credit in Sand source. | +| [lang_collections](lang_collections/) | Saved quest arrays, indexed mutable methods, array iteration and reward history in Sand source. | +| [lang_runtime_text](lang_runtime_text/) | Saved personal journal with runtime strings, scalar formatting and styled interpolation. | +| [lang_vectors](lang_vectors/) | Per-player exploration log with growable vectors of records and saved coordinates. | +| [lang_checkpoints](lang_checkpoints/) | Save a player-owned position and return to it using a typed cooldown. | | [arcane_pack](arcane_pack/) | Advanced integration fixture with primitive scoreboard/storage controls and golden tests. | Start with `book_project` for the guided tutorial and `cooperative_arena` for a @@ -55,10 +62,11 @@ For a new project, follow [installing and creating a datapack](../book/src/01-in ## Testing -`scripts/check-examples.sh` discovers every standalone project under `examples/`, +`scripts/check-examples.sh` discovers every standalone Rust project under `examples/`, runs its tests, and builds a server-ready datapack through the Sand CLI. Both `scripts/check.sh` and the Rust CI workflow invoke it, so a new example project -receives the same coverage automatically. +receives the same coverage automatically. Sand language example packages are +compiled by `sand-lang` integration tests; native language probes also run in CI. The unified-State real-server audit runs in the 26.2 lane of the vanilla workflow. Run it locally with Minecraft 26.2 and Java 25: diff --git a/examples/animated_boss/Cargo.lock b/examples/animated_boss/Cargo.lock index 8082d163..f02325a6 100644 --- a/examples/animated_boss/Cargo.lock +++ b/examples/animated_boss/Cargo.lock @@ -1149,6 +1149,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.21", "unicode-general-category", @@ -1165,6 +1167,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.21", @@ -1174,6 +1177,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64 0.22.1", "inventory", "sand-api-contract", "sand-build", @@ -1204,6 +1208,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/cooperative_arena/Cargo.lock b/examples/cooperative_arena/Cargo.lock index b0e9f267..ee5966ec 100644 --- a/examples/cooperative_arena/Cargo.lock +++ b/examples/cooperative_arena/Cargo.lock @@ -1150,6 +1150,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.21", "unicode-general-category", @@ -1166,6 +1168,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.21", @@ -1175,6 +1178,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64 0.22.1", "inventory", "sand-api-contract", "sand-build", @@ -1205,6 +1209,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/interaction_hub/Cargo.lock b/examples/interaction_hub/Cargo.lock index c2d2c54f..d849d053 100644 --- a/examples/interaction_hub/Cargo.lock +++ b/examples/interaction_hub/Cargo.lock @@ -1149,6 +1149,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.21", "unicode-general-category", @@ -1165,6 +1167,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.21", @@ -1174,6 +1177,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64 0.22.1", "inventory", "sand-api-contract", "sand-build", @@ -1204,6 +1208,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/lang_callbacks/README.md b/examples/lang_callbacks/README.md new file mode 100644 index 00000000..40138f0d --- /dev/null +++ b/examples/lang_callbacks/README.md @@ -0,0 +1,10 @@ +# Reward Notes + +Mine stone to see a personal points message. The player State stores a formatter +function with its own captured prefix. Mining invokes a copy of that callback +with the player's current points. + +```sh +sand lang build examples/lang_callbacks +sand lang run examples/lang_callbacks --offline +``` diff --git a/examples/lang_callbacks/pack.sand b/examples/lang_callbacks/pack.sand new file mode 100644 index 00000000..476a2c1a --- /dev/null +++ b/examples/lang_callbacks/pack.sand @@ -0,0 +1,26 @@ +//! A player's selected message formatter keeps a snapshot of their preference. +#![pack(namespace = "reward_notes", minecraft = "26.2")] + +player state Notes { + format: fn(number) -> string, + points: number +} + +fn style(prefix: string) -> fn(number) -> string { + return move |points: number| -> string { + return prefix + points.to_string(); + }; +} + +#[on(join)] +fn setup() { + let name = "Mining points: "; + Notes.format = style(name); +} + +#[on(mine_block = Block::Stone)] +fn mine() { + Notes.points += 1; + let render = Notes.format; + chat!(render(Notes.points)); +} diff --git a/examples/lang_checkpoints/README.md b/examples/lang_checkpoints/README.md new file mode 100644 index 00000000..276d1a4a --- /dev/null +++ b/examples/lang_checkpoints/README.md @@ -0,0 +1,14 @@ +# Scout checkpoints + +Sneak while using a carrot on a stick to save your Overworld position. Use it +normally to return to that position with a five-second cooldown. The checkpoint +and cooldown belong to each player. A private boss bar shows the remaining +cooldown after returning to camp. + +```sh +sand lang add spatial +sand lang add time +sand lang build +``` + +The installer vendors the libraries as ordinary source modules. diff --git a/examples/lang_checkpoints/pack.sand b/examples/lang_checkpoints/pack.sand new file mode 100644 index 00000000..cc889ba0 --- /dev/null +++ b/examples/lang_checkpoints/pack.sand @@ -0,0 +1,49 @@ +#![pack(namespace = "scout_checkpoints", minecraft = "26.2", description = "Save and revisit a camp checkpoint")] + +use spatial::Position; +use time::Duration; + +player state Camp { + saved: bool, + checkpoint: Position, + cooldown: timer, +} + +hud Recovery { + ticks: 100, + every: 4, + bossbar: { title: "{aqua}Checkpoint recovery", value: Camp.cooldown, max: 100 }, +} + +#[on(first_join)] +fn equip_scout() { + give_item(Item::CarrotOnAStick); + chat!("Use the checkpoint tool while sneaking to save your spot."); +} + +#[on(use_item = Item::CarrotOnAStick)] +fn use_checkpoint() { + if is_sneaking() { + if !dimension_is(Dimension::Overworld) { + actionbar!("Save your checkpoint in the Overworld."); + return; + } + Camp.checkpoint = Position::player(); + Camp.saved = true; + actionbar!("Checkpoint saved."); + return; + } + + if !Camp.saved || !dimension_is(Dimension::Overworld) { + actionbar!("Save an Overworld checkpoint before returning to it."); + return; + } + if timer_running(Camp.cooldown) { + actionbar!("Checkpoint travel is cooling down."); + return; + } + let recovery = Duration::from_seconds(5); + start_timer(Camp.cooldown, ticks = recovery.as_ticks()); + Camp.checkpoint.teleport(); + start_hud(Recovery); +} diff --git a/examples/lang_collections/README.md b/examples/lang_collections/README.md new file mode 100644 index 00000000..7c56c90e --- /dev/null +++ b/examples/lang_collections/README.md @@ -0,0 +1,20 @@ +# Quest board + +A Sand-language pack with three saved personal quests: mine stone, mine oak logs, +and defeat zombies. Players receive a board item on first join; using it shows +progress. Each completed quest pays emeralds once. + +The pack demonstrates arrays of structs in player State, mutable methods on +indexed elements, `[value; N]` defaults, snapshot `for` iteration, `len()`, +`contains()`, `get_or()`, and an indexed circular reward history. Each player's +quests and history remain separate. Struct receivers use the same call and +copying model as ordinary function values. + +```sh +cargo run -p sand-cli -- lang check examples/lang_collections/pack.sand +cargo run -p sand-cli -- lang build examples/lang_collections/pack.sand --output dist/quest_board +cargo run -p sand-cli -- lang run examples/lang_collections/pack.sand +``` + +Run from the repository root. Targets Minecraft Java 26.2. See the +[language guide](../../book/src/language.md) for collection bounds and copy rules. diff --git a/examples/lang_collections/pack.sand b/examples/lang_collections/pack.sand new file mode 100644 index 00000000..97e7b24a --- /dev/null +++ b/examples/lang_collections/pack.sand @@ -0,0 +1,82 @@ +//! Three saved quests, using arrays, indexed methods and snapshot iteration. +#![pack(namespace = "quest_board", minecraft = "26.2")] +struct Quest { + remaining: number, + reward: number +} +impl Quest { + fn advance(&mut self) -> bool { + if self.remaining == 0 { + return false; + } + self.remaining -= 1; + return self.remaining == 0; + } +} +player state QuestBook { + quests: [Quest; 3] = [Quest { + remaining: 12, + reward: 2 + }, Quest { + remaining: 8, + reward: 3 + }, Quest { + remaining: 4, + reward: 4 + },], + recent_rewards: [number; 5] = [0; 5], + cursor: number, + completed: number, +} +impl QuestBook { + fn advance(&mut self, index: number) { + if self.quests[index].advance() { + let reward = self.quests[index].reward; + give_item(Item::Emerald, reward); + self.recent_rewards[self.cursor] = reward; + self.cursor = (self.cursor + 1) % self.recent_rewards.len(); + self.completed += 1; + chat!("{gold}Quest complete! Earned {reward} emeralds."); + } + } + fn show(&self) { + let mut remaining = 0; + for quest in self.quests { + remaining += quest.remaining; + } + let latest = self.recent_rewards.get_or((self.cursor + self.recent_rewards.len() - 1) % self.recent_rewards.len(), 0); + chat!("{aqua}Quest board: {remaining} actions left; {self.completed} quests complete."); + chat!("{gray}Last recorded reward: {latest} emeralds."); + if self.recent_rewards.contains(4) { + chat!("{green}Zombie contract recorded!"); + } + } +} +item Board { + base: Item::CarrotOnAStick, + name: "{aqua}Quest Board", + unbreakable: true +} +#[on(first_join)] +fn welcome() { + give_item(Board); + chat!("{aqua}Quests: mine 12 stone, mine 8 oak logs, and defeat 4 zombies."); +} +#[on(use_item = Item::CarrotOnAStick)] +fn inspect() { + if holding(Board) { + QuestBook.show(); + } +} +#[on(mine_block = Block::Stone)] +fn stone() { + QuestBook.advance(0); +} +#[on(mine_block = Block::OakLog)] +fn logs() { + QuestBook.advance(1); +} +#[on(kill = Entity::Zombie)] +fn zombies() { + QuestBook.advance(2); +} diff --git a/examples/lang_encounters/README.md b/examples/lang_encounters/README.md new file mode 100644 index 00000000..0d5850cf --- /dev/null +++ b/examples/lang_encounters/README.md @@ -0,0 +1,15 @@ +# Encounters (Sand language) + +A two-module pack written in the [Sand language](../../book/src/language.md) +instead of Rust: per-player encounter phases driven by a flow, a shared world +clock, and rewards granted from another module. The raid module also shows +how to select and equip nearby guards. The rewards module defines an amethyst +Sentry trim for armor at the smithing table and a native advancement for +acquiring amethyst or defeating a zombie. + +```sh +sand lang check +sand lang build # writes dist/demo +``` + +No `Cargo.toml` or `sand.toml` is needed; `pack.sand` is the package root. diff --git a/examples/lang_encounters/pack.sand b/examples/lang_encounters/pack.sand new file mode 100644 index 00000000..c9c00e30 --- /dev/null +++ b/examples/lang_encounters/pack.sand @@ -0,0 +1,83 @@ +//! Player encounters and a shared world phase, written in the Sand language. +#![pack(namespace = "demo", minecraft = "26.2", description = "Encounters")] + +pub mod raid; +mod rewards; + +use rewards::grant; + +/// Energy every player starts with and can never exceed. +const MAX_ENERGY: number = 100; + +/// Where a player is in their encounter. +enum Phase { + /// Waiting for enough energy. + Idle, + /// Fighting. + Active, + /// Recovering after a fight. + Resting = 5, +} + +/// Per-player encounter progress. +player state Hero { + phase: Phase = Phase::Idle, + /// Spent by encounters, clamped to the valid range. + #[clamp(0..=MAX_ENERGY)] + energy: number = MAX_ENERGY, + events: number, +} + +/// One shared clock for the whole server. +global state World { + ticks: number, +} + +flow Encounter on Hero.phase { + Idle -> Active if Hero.energy >= 30 priority 100; + Idle -> Resting; + Active -> Resting if Hero.energy <= 10; + + enter Active => start; + tick Active { + Hero.events += 1; + } + tick Active every 2 { + Hero.energy -= 5; + } +} + +fn start() { + Hero.energy -= 30; + Hero.events += 10; +} + +/// Greet newcomers and explain the encounter loop. +#[on(first_join)] +fn welcome() { + title!("{gold}{bold}Encounters"); + chat!("Welcome, {player}! Spend {aqua}energy{reset} to start encounters."); +} + +/// Dying costs energy and resets the encounter. +#[on(death)] +fn died() { + Hero.energy -= 20; + Hero.phase = Phase::Idle; + actionbar!("{red}You lost 20 energy ({Hero.energy} left)."); +} + +/// Advance the world clock and reward everyone every ten seconds. +#[tick] +fn world_tick() { + World.ticks += 1; + if World.ticks >= 200 && World.ticks != 999 { + World.ticks = 0; + broadcast!("{green}Energy restored for everyone!"); + for player in players() { + grant(); + } + } else if World.ticks == 100 { + broadcast!("{gray}Halfway to the next restore."); + } +} diff --git a/examples/lang_encounters/raid.sand b/examples/lang_encounters/raid.sand new file mode 100644 index 00000000..84d39a11 --- /dev/null +++ b/examples/lang_encounters/raid.sand @@ -0,0 +1,86 @@ +//! A raid: custom events, timers, a boss bar, loot, and world edits. + +/// Shared raid health. +global state Fight { + #[clamp(0..=200)] + boss_hp: number = 200, +} + +/// How long until a player can strike again. +player state Striker { + cooldown: timer, +} + +/// Shown to everyone while the raid runs. +bossbar Raid { + title: "{red}{bold}Raid Boss", + color: BossBarColor::Purple, + style: BossBarStyle::Notched10, + max: 200, +} + +/// What a landed strike can drop. +loot Spoils { + pools: [ + { rolls: 2, items: [Item::GoldIngot, { item: Item::Diamond, weight: 1, count: 2 }] }, + { chance: 0.25, weather: Weather::Thunder, items: [Item::Emerald] }, + ], +} + +/// Raised whenever a player lands a strike. +pub event Struck(damage: number); + +#[on(Struck)] +fn wound_boss(damage: number) { + Fight.boss_hp -= damage; + set_bossbar(Raid, Fight.boss_hp); +} + +#[on(Struck)] +fn reward_striker(_damage: number) { + add_experience(points = 5); + give_loot(Spoils); +} + +/// Open the arena and show the bar. +pub fn begin() { + Fight.boss_hp = 200; + set_bossbar(Raid, Fight.boss_hp); + set_time(18000); + set_weather(Weather::Thunder, seconds = 120); + show_bossbar_all(Raid); +} + +/// Strike while sneaking with a diamond sword, on a shared cooldown. +#[on(use_item = Item::DiamondSword)] +fn strike() { + if !is_sneaking() || !holding(Item::DiamondSword) { + return; + } + if timer_running(Striker.cooldown) { + actionbar!("{red}Ready in {Striker.cooldown} ticks"); + return; + } + start_timer(Striker.cooldown, seconds = 2); + if block_is(Block::Air, offset(0, -1, 0)) { + set_block(Block::Glass, offset(0, -1, 0)); + } + if any_entities(type = Entity::Zombie, distance = ..=16) { + emit Struck(10); + } +} + +item GuardBlade { + base: Item::IronSword, + name: "Raid guard's blade", + enchantments: [{ enchantment: Enchantment::Sharpness, level: 2 }], +} + +/// Arm nearby raid guards without changing guards already carrying a raid blade. +pub fn arm_guards() { + for guard in entities(type = Entity::Zombie, tag = "raid_guard", distance = ..=16) { + if !holding(GuardBlade, slot = EquipmentSlot::Mainhand) { + equip(GuardBlade, EquipmentSlot::Mainhand); + } + } +} diff --git a/examples/lang_encounters/rewards.sand b/examples/lang_encounters/rewards.sand new file mode 100644 index 00000000..167a8e82 --- /dev/null +++ b/examples/lang_encounters/rewards.sand @@ -0,0 +1,47 @@ +//! Rewards granted by the world clock. + +use crate::Hero; + +/// Restore some energy to the current player. +pub fn grant() { + Hero.energy += 25; + play_sound(Sound::EntityExperienceOrbPickup); + let sparks = Hero.energy / 10; + spawn_particle(Particle::HappyVillager, count = sparks, spread = 0.25); + if advancement_done(RaidSupply) { + actionbar!("{green}Raid supplies ready"); + } + if Hero.phase == crate::Phase::Resting { + Hero.phase = crate::Phase::Idle; + } +} + +/// An amethyst Sentry trim for any trimmable armor. +recipe GuardTrim { + smithing_trim: Item::SentryArmorTrimSmithingTemplate, + base: "#minecraft:trimmable_armor", + addition: Item::AmethystShard, + trim_pattern: "minecraft:sentry", +} + +/// Recognize a supply find or a successful hunt. +advancement RaidSupply { + display: { + icon: Item::AmethystShard, + title: "{light_purple}Ready for the raid", + description: "Find amethyst or defeat a zombie.", + background: "minecraft:gui/advancements/backgrounds/adventure", + }, + criteria: { + collect_shard: { inventory_item: Item::AmethystShard }, + defeat_zombie: { kill_entity: Entity::Zombie }, + }, + require_any: true, + experience: 5, +} + +#[on(advancement = RaidSupply)] +fn celebrate_supplies() { + let supplies = inventory_count(Item::AmethystShard); + chat!("{light_purple}Raid supply milestone unlocked. Amethyst shards: {supplies}"); +} diff --git a/examples/lang_generics/README.md b/examples/lang_generics/README.md new file mode 100644 index 00000000..5cf6e8f6 --- /dev/null +++ b/examples/lang_generics/README.md @@ -0,0 +1,15 @@ +# Generic Mining History + +One `History` library stores both strings and numbers in separate saved +per-player histories. Its impl uses borrowed receivers, associated constructors, +`Self`, and a method with its own `U` parameter. A generic function returns a fixed +array, which the caller destructures into independent locals. + +```sh +sand lang build examples/lang_generics +sand lang run examples/lang_generics --offline +``` + +Mine ten stone blocks to receive iron and read the latest entries. The generic +library lives in `history.sand`; it has the same module and privacy rules as the +rest of the project. diff --git a/examples/lang_generics/history.sand b/examples/lang_generics/history.sand new file mode 100644 index 00000000..ddff2712 --- /dev/null +++ b/examples/lang_generics/history.sand @@ -0,0 +1,24 @@ +//! Reusable owned history with one implementation for every element type. +pub struct History { + values: Vec +} +impl History { + pub fn new() -> Self { + return Self { values: [] }; + } + pub fn record(&mut self, value: T) { + if self.values.len() == 10 { + self.values.remove_or(0, value); + } + self.values.push(value); + } + pub fn recent(&self, fallback: T) -> T { + return self.values.get_or(self.values.len() - 1, fallback); + } + pub fn snapshot(&self) -> Vec { + return self.values; + } + pub fn choose(&self, empty: U, populated: U) -> U { + return match self.values.is_empty() { true => empty, false => populated }; + } +} diff --git a/examples/lang_generics/pack.sand b/examples/lang_generics/pack.sand new file mode 100644 index 00000000..aba52068 --- /dev/null +++ b/examples/lang_generics/pack.sand @@ -0,0 +1,36 @@ +//! Two independently saved histories using the same generic library. +#![pack(namespace = "mining_history", minecraft = "26.2")] +mod history; +use history::History; +player state Journal { + entries: History, + rewards: History, + mined: number +} +fn duplicate(value: T) -> [T; 2] { + return [value, value]; +} +#[on(first_join)] +fn welcome() { + Journal.entries = History::::new(); + Journal.rewards = History::::new(); + chat!("{green}Mine stone to build your personal mining history."); +} +#[on(mine_block = Block::Stone)] +fn mine() { + Journal.mined += 1; + let points = match Journal.mined % 10 { 0 => 5, _ => 1 }; + Journal.entries.record("Mined stone"); + Journal.rewards.record(points); + if Journal.mined % 10 == 0 { + let [iron, bonus] = duplicate(points); + give_item(Item::IronIngot, count = iron + bonus); + let heading = Journal.entries.choose("No history", "Recent mining history"); + chat!("{gold}{heading}"); + for entry in Journal.entries.snapshot() { + chat!(entry); + } + let recent = Journal.rewards.recent(0); + chat!("{gray}Latest reward: {recent} points."); + } +} diff --git a/examples/lang_inventory_transfer/README.md b/examples/lang_inventory_transfer/README.md new file mode 100644 index 00000000..23f4c40b --- /dev/null +++ b/examples/lang_inventory_transfer/README.md @@ -0,0 +1,13 @@ +# Camp supply transfer + +Build with `sand lang build examples/lang_inventory_transfer` for Minecraft 26.2. +Place at least two items in your first hotbar slot and leave the first slot in +the top row of your main inventory empty. Run `/function camp_supplies:stow` +as the player to move two items. Run it again with the same stack to merge +another two into the destination. + +Try with fewer than two items in the source or with a different item in the +destination to see the rejection callback. + +Run `/function camp_supplies:supplies` to open the native menu. Select +**Stow two supplies** and confirm the move, or use **Next** to find the slot guide. diff --git a/examples/lang_inventory_transfer/pack.sand b/examples/lang_inventory_transfer/pack.sand new file mode 100644 index 00000000..1a3a457f --- /dev/null +++ b/examples/lang_inventory_transfer/pack.sand @@ -0,0 +1,47 @@ +#![pack(namespace = "camp_supplies", minecraft = "26.2", description = "Sort camp supplies")] + +inventory_transfer PackSupplies { + from: 0, + to: 9, + amount: 2, + success: packed, + rejected: no_room, +} + +menu CampSupplies { + title: "{gold}Camp supplies", + ticks: 200, + page_size: 1, + choices: [ + { label: "Stow two supplies", next: "confirm" }, + { label: "View slot guide", action: show_slots }, + ], + views: [{ + name: "confirm", + title: "{gold}Pack two items?", + choices: [ + { label: "Pack supplies", action: stow }, + { label: "Back to supplies", next: "main" }, + ], + }], +} + +pub fn supplies() { + open_menu(CampSupplies); +} + +fn show_slots() { + chat!("The first hotbar slot is the source. The first main inventory slot is the destination."); +} + +pub fn stow() { + transfer_inventory(PackSupplies); +} + +fn packed() { + actionbar!("{green}Packed two items"); +} + +fn no_room() { + actionbar!("{red}Check the source stack and destination slot"); +} diff --git a/examples/lang_maps/README.md b/examples/lang_maps/README.md new file mode 100644 index 00000000..b6bfd6c2 --- /dev/null +++ b/examples/lang_maps/README.md @@ -0,0 +1,13 @@ +# Ore Journal + +Mine iron or gold ore to record a discovery and increment your personal count. +Use a carrot on a stick to read your journal in discovery order. + +```sh +sand lang build examples/lang_maps +sand lang run examples/lang_maps --offline +``` + +The example bundles an editable copy of the module installed by +`sand lang add collections`. The map holds counts, and the set tracks first +discoveries. Both persist in player State. diff --git a/examples/lang_maps/collections.sand b/examples/lang_maps/collections.sand new file mode 100644 index 00000000..25aef179 --- /dev/null +++ b/examples/lang_maps/collections.sand @@ -0,0 +1,132 @@ +//! Owned, insertion-ordered collections built from Sand's typed vectors. +/// One independent key/value pair returned by Map.entries(). +pub struct Entry { + pub key: K, + pub value: V +} +/// A bounded map with exact typed key equality and independent owned values. +pub struct Map { + items: Vec> +} +implMap { + pub fn new() -> Self { + return Self { + items: [] + }; + } + pub fn len(&self) -> number { + return self.items.len(); + } + pub fn is_empty(&self) -> bool { + return self.items.is_empty(); + } + pub fn contains_key(&self, key: K) -> bool { + for entry in self.items { + if entry.key == key { + return true; + } + } + return false; + } + pub fn get_or(&self, key: K, fallback: V) -> V { + for entry in self.items { + if entry.key == key { + return entry.value; + } + } + return fallback; + } + /// Insert or replace a value. False means a new key would exceed capacity. + pub fn insert(&mut self, key: K, value: V) -> bool { + for i in 0..self.items.len() { + if self.items[i].key == key { + self.items[i].value = value; + return true; + } + } + return self.items.push(Entry { + key, + value + }); + } + pub fn remove(&mut self, key: K) -> bool { + for i in 0..self.items.len() { + if self.items[i].key == key { + self.items.remove_or(i, self.items[i]); + return true; + } + } + return false; + } + pub fn remove_or(&mut self, key: K, fallback: V) -> V { + for i in 0..self.items.len() { + if self.items[i].key == key { + let entry = self.items.remove_or(i, self.items[i]); + return entry.value; + } + } + return fallback; + } + pub fn clear(&mut self) { + self.items.clear(); + } + pub fn keys(&self) -> Vec { + let mut keys: Vec; + for entry in self.items { + keys.push(entry.key); + } + return keys; + } + pub fn values(&self) -> Vec { + let mut values: Vec; + for entry in self.items { + values.push(entry.value); + } + return values; + } + pub fn entries(&self) -> Vec> { + return self.items; + } +} +/// A bounded set that preserves insertion order and compares whole owned values. +pub struct Set { + items: Vec +} +implSet { + pub fn new() -> Self { + return Self { + items: [] + }; + } + pub fn len(&self) -> number { + return self.items.len(); + } + pub fn is_empty(&self) -> bool { + return self.items.is_empty(); + } + pub fn contains(&self, value: T) -> bool { + return self.items.contains(value); + } + /// True only when a new value was added; duplicates and full sets return false. + pub fn insert(&mut self, value: T) -> bool { + if self.items.contains(value) { + return false; + } + return self.items.push(value); + } + pub fn remove(&mut self, value: T) -> bool { + for i in 0..self.items.len() { + if self.items[i] == value { + self.items.remove_or(i, self.items[i]); + return true; + } + } + return false; + } + pub fn clear(&mut self) { + self.items.clear(); + } + pub fn values(&self) -> Vec { + return self.items; + } +} diff --git a/examples/lang_maps/pack.sand b/examples/lang_maps/pack.sand new file mode 100644 index 00000000..8cb3738b --- /dev/null +++ b/examples/lang_maps/pack.sand @@ -0,0 +1,33 @@ +//! A per-player journal of mined ores and discoveries. +#![pack(namespace = "ore_journal", minecraft = "26.2")] +mod collections; +use collections:: { + Map, + Set +}; +player state Journal { + counts: Map, + discoveries: Set +} +fn record(ore: string) { + let total = Journal.counts.get_or(ore, 0) + 1; + if Journal.counts.insert(ore, total) && Journal.discoveries.insert(ore) { + chat!("{gold}Discovered {ore}!"); + } +} +#[on(mine_block = Block::IronOre)] +fn iron() { + record("iron"); +} +#[on(mine_block = Block::GoldOre)] +fn gold() { + record("gold"); +} +#[on(use_item = Item::CarrotOnAStick)] +fn show() { + let found = Journal.discoveries.len(); + chat!("{gold}Ore journal: {found} discoveries"); + for entry in Journal.counts.entries() { + chat!("{entry.key}: {entry.value}"); + } +} diff --git a/examples/lang_methods/README.md b/examples/lang_methods/README.md new file mode 100644 index 00000000..88b14a29 --- /dev/null +++ b/examples/lang_methods/README.md @@ -0,0 +1,22 @@ +# Blinkstep + +A Sand language pack demonstrating nested struct values and State methods. +Players receive a Blinkstep wand on their first join. Using it moves the player +six blocks east, spends 15 energy, and starts a three-second cooldown. Death +restores energy. + +`position.sand` encapsulates coordinates behind public methods. `east(mut self)` +returns a changed copy; `apply(self)` teleports the executor. `hero.sand` keeps a +Position in player State and uses `&self` / `&mut self` methods to read and change +persistent fields. Cooldown seconds are an ordinary runtime function argument. + +From the repository root: + +```sh +cargo run -p sand-cli -- lang check examples/lang_methods/pack.sand +cargo run -p sand-cli -- lang build examples/lang_methods/pack.sand --output dist/blinkstep +cargo run -p sand-cli -- lang run examples/lang_methods/pack.sand +``` + +Targets Minecraft Java 26.2. See the [language guide](../../book/src/language.md) +for value-copy, visibility, receiver, and executor rules. diff --git a/examples/lang_methods/hero.sand b/examples/lang_methods/hero.sand new file mode 100644 index 00000000..6e1532f4 --- /dev/null +++ b/examples/lang_methods/hero.sand @@ -0,0 +1,25 @@ +use crate::position::Position; +pub player state Hero { + #[clamp(0..=100)] + energy: number = 100, + cooldown: timer, + previous: Position, +} +impl Hero { + pub fn ready(&self) -> bool { + return self.energy >= 15 && !timer_running(Self.cooldown); + } + pub fn blink(&mut self, distance: float, seconds: number) { + if !Self.ready() { + actionbar!("{gray}Not ready."); + return; + } + self.previous = Position::capture(); + self.previous.east(distance).apply(); + self.energy -= 15; + start_timer(Self.cooldown, seconds = seconds); + } + pub fn restore(&mut self) { + self.energy = 100; + } +} diff --git a/examples/lang_methods/pack.sand b/examples/lang_methods/pack.sand new file mode 100644 index 00000000..14d81b2a --- /dev/null +++ b/examples/lang_methods/pack.sand @@ -0,0 +1,25 @@ +//! Blinkstep: typed value objects and persistent State methods. +#![pack(namespace = "blinkstep", minecraft = "26.2")] +mod position; +mod hero; +use hero::Hero; +item BlinkWand { + base: Item::CarrotOnAStick, + name: "{aqua}Blinkstep", + unbreakable: true +} +#[on(first_join)] +fn welcome() { + give_item(BlinkWand); + chat!("{aqua}Use Blinkstep to move six blocks east. Costs 15 energy."); +} +#[on(use_item = Item::CarrotOnAStick)] +fn blink() { + if holding(BlinkWand) { + Hero.blink(6.0, 3); + } +} +#[on(death)] +fn restore_energy() { + Hero.restore(); +} diff --git a/examples/lang_methods/position.sand b/examples/lang_methods/position.sand new file mode 100644 index 00000000..4d22c46f --- /dev/null +++ b/examples/lang_methods/position.sand @@ -0,0 +1,22 @@ +/// A copyable position value, with private fields and public value methods. +pub struct Position { + x: float, + y: float, + z: float +} +impl Position { + pub fn capture() -> Self { + return Self { + x: Player.x, + y: Player.y, + z: Player.z + }; + } + pub fn east(mut self, distance: float) -> Self { + self.x += distance; + return self; + } + pub fn apply(self) { + teleport(self.x, self.y, self.z); + } +} diff --git a/examples/lang_patterns/README.md b/examples/lang_patterns/README.md new file mode 100644 index 00000000..ed00035d --- /dev/null +++ b/examples/lang_patterns/README.md @@ -0,0 +1,13 @@ +# Mining Streak + +Mine stone to earn a personal reward every ten blocks. An exhaustive value match +selects a typed reward record, then a nested pattern unpacks its title and fixed +array of item amounts. Each player's streak persists separately. + +```sh +sand lang build examples/lang_patterns +sand lang run examples/lang_patterns --offline +``` + +The example combines enum alternatives, block expressions, guarded destructuring +arms, nested array patterns, runtime item counts, and formatted strings. diff --git a/examples/lang_patterns/pack.sand b/examples/lang_patterns/pack.sand new file mode 100644 index 00000000..0f317a1d --- /dev/null +++ b/examples/lang_patterns/pack.sand @@ -0,0 +1,37 @@ +//! A per-player mining streak with typed reward matches and owned destructuring. +#![pack(namespace = "mining_streak", minecraft = "26.2")] +enum Rank { Beginner, Explorer, Veteran } +struct Reward { title: string, amounts: [number; 2] } +player state Progress { mined: number } +fn reward(rank: Rank) -> Reward { + return match rank { + Rank::Beginner => Reward { title: "First steps", amounts: [1, 0] }, + Rank::Explorer => { + let iron = 2; + Reward { title: "Explorer", amounts: [iron, 1] } + }, + Rank::Veteran => Reward { title: "Veteran", amounts: [4, 2] }, + }; +} +#[on(mine_block = Block::Stone)] +fn mine() { + Progress.mined += 1; + if Progress.mined % 10 == 0 { + let rank = match Progress.mined { + 10 | 20 => Rank::Beginner, + _ if Progress.mined <= 40 => Rank::Explorer, + _ => Rank::Veteran, + }; + match reward(rank) { + let Reward { title, amounts: [iron, gold] } if gold > 0 => { + give_item(Item::IronIngot, count = iron); + give_item(Item::GoldIngot, count = gold); + chat!("{gold}{title}{reset}: mined {Progress.mined} stone!"); + } + let Reward { title, amounts: [iron, _] } => { + give_item(Item::IronIngot, count = iron); + chat!("{gold}{title}{reset}: mined {Progress.mined} stone!"); + } + } + } +} diff --git a/examples/lang_reference_combat/README.md b/examples/lang_reference_combat/README.md new file mode 100644 index 00000000..586cf853 --- /dev/null +++ b/examples/lang_reference_combat/README.md @@ -0,0 +1,25 @@ +# Marked combat + +A Sand language pack demonstrating borrowed struct methods, retained attackers, +entity-State attachment, runtime timer arguments, recipes and vanilla kill credit. + +Use the marking wand near zombies. Each mark stores its caster's `EntityRef` on +the zombie, then deals six half-hearts after twenty ticks. A later cast replaces +an existing mark's owner and timer. The caster receives vanilla kill credit when +the damage is lethal, and the kill event updates their personal score. If the +caster is offline, the attack is skipped and the mark is cleared. Entity timers +advance while their entities are loaded. + +`Spell.empower(&mut self)` updates its mutable local receiver. `Mark.owner` +retains the caster after the casting function returns and across pack reloads. +This uses the same pack-owned identity allocator as Sand's Rust gameplay runtime. + +From the repository root: + +```sh +cargo run -p sand-cli -- lang check examples/lang_reference_combat/pack.sand +cargo run -p sand-cli -- lang build examples/lang_reference_combat/pack.sand --output dist/marked_combat +cargo run -p sand-cli -- lang run examples/lang_reference_combat/pack.sand +``` + +Targets Minecraft Java 26.2. See the [language guide](../../book/src/language.md). diff --git a/examples/lang_reference_combat/pack.sand b/examples/lang_reference_combat/pack.sand new file mode 100644 index 00000000..919d7c0f --- /dev/null +++ b/examples/lang_reference_combat/pack.sand @@ -0,0 +1,71 @@ +//! A delayed mark remembers its caster and awards vanilla kill credit. +#![pack(namespace = "marked_combat", minecraft = "26.2")] +struct Spell { + damage: float, + delay: number +} +impl Spell { + fn empower(&mut self) { + self.damage += 1.0; + } +} +entity state Mark { + owner: EntityRef, + damage: float, + delay: timer +} +player state Mage { + kills: number +} +item MarkingWand { + base: Item::CarrotOnAStick, + name: "{light_purple}Marking Wand", + unbreakable: true +} +damage_type ArcaneMark { + message_id: "arcane_mark", + scaling: DamageScaling::Never, + effects: DamageEffects::Thorns, +} +recipe WandRecipe { + shapeless: [Item::Stick, Item::AmethystShard], + result: MarkingWand +} +#[on(first_join)] +fn welcome() { + give_item(MarkingWand); + chat!("{light_purple}Use your wand near zombies to mark them."); +} +#[on(use_item = Item::CarrotOnAStick)] +fn cast() { + if !holding(MarkingWand) { + return; + } + let owner = entity_ref(); + let mut spell = Spell { + damage: 5.0, + delay: 20 + }; + spell.empower(); + for target in entities(type = Entity::Zombie, distance =..=8) { + attach_state(Mark); + Mark.owner = owner; + Mark.damage = spell.damage; + start_timer(Mark.delay, ticks = spell.delay); + } + actionbar!("{light_purple}Marked nearby zombies."); +} +#[tick] +fn resolve_marks() { + for target in entities(with = Mark) { + if timer_done(Mark.delay) { + damage(Mark.damage, by = Mark.owner, type = ArcaneMark); + detach_state(Mark); + } + } +} +#[on(kill = Entity::Zombie)] +fn reward() { + Mage.kills += 1; + chat!("{gold}Zombies defeated: {Mage.kills}"); +} diff --git a/examples/lang_runtime_text/README.md b/examples/lang_runtime_text/README.md new file mode 100644 index 00000000..d33fc4d8 --- /dev/null +++ b/examples/lang_runtime_text/README.md @@ -0,0 +1,19 @@ +# Field Journal + +A language-only datapack with a separate persistent journal for each player. +Mine stone or defeat zombies to add notes; right-click the supplied notebook to +read the last five entries. Values survive datapack reloads. + +```sh +sand lang build examples/lang_runtime_text +sand lang run examples/lang_runtime_text --offline +``` + +The example combines string constants, concatenation, scalar `to_string`, +string fields in State, arrays of strings, snapshot iteration, borrowed State +methods, Unicode text, and styled runtime interpolation. Strings copy by value; +indices and `len` count Unicode scalar characters. Collection size is fixed in +this example. The notebook name and the chat layout use Minecraft translation +keys. The welcome message includes a chat tooltip and a copy action, and the +written field guide includes a link to its second page. A native notice +explains how to record and read journal entries at first join. diff --git a/examples/lang_runtime_text/pack.sand b/examples/lang_runtime_text/pack.sand new file mode 100644 index 00000000..ffc6bb91 --- /dev/null +++ b/examples/lang_runtime_text/pack.sand @@ -0,0 +1,81 @@ +//! A saved personal journal: owned text, record fields and a small history. +#![pack(namespace = "field_journal", minecraft = "26.2")] +const HEADING: string = "Field " + "journal"; +player state Journal { + entries: [string; 5] = [""; 5], + cursor: number, + stone: number, + title: string = HEADING, +} +impl Journal { + fn record(&mut self, entry: string) { + self.entries[self.cursor] = entry; + self.cursor = (self.cursor + 1) % self.entries.len(); + chat!("{green}Recorded: {entry}"); + } + fn show(&self) { + chat!("{gold}{bold}{self.title}"); + for entry in self.entries { + if entry.is_empty() { + continue; + } + chat!("{gray}• {entry}"); + } + let count = self.stone.to_string(); + chat!("{aqua}Stone mined: {count}"); + } +} +item Notebook { + base: Item::CarrotOnAStick, + name: Text::translate("item.minecraft.writable_book"), + lore: ["{gray}Right-click to read your saved notes."], + unbreakable: true +} +item FieldGuide { + base: Item::WrittenBook, + book: { + title: "Field guide", + author: "The Surveyors", + pages: [ + Text::page("{aqua}Turn to the instructions", 2), + "{bold}Your journal\n{reset}Mine stone or defeat zombies to add entries.", + ], + }, +} +dialog JournalNotice { + title: "{gold}Field journal", + body: [ + "Mine stone or defeat zombies to record entries.", + "Right-click the notebook to read your notes.", + ], + button: "Start exploring", +} +#[on(first_join)] +fn welcome() { + give_item(Notebook); + give_item(FieldGuide); + show_dialog(JournalNotice); + chat!(Text::translate("chat.type.text", "Journal", "The journey begins 🌍")); + chat!(Text::hover( + Text::copy("{aqua}Copy the journal code", "field-journal"), + "Right-click the notebook to read your notes.", + )); + Journal.record("The journey begins 🌍"); +} +#[on(mine_block = Block::Stone)] +fn stone() { + Journal.stone += 1; + if Journal.stone % 10 == 0 { + Journal.record("Mined " + Journal.stone.to_string() + " stone."); + } +} +#[on(kill = Entity::Zombie)] +fn zombie() { + Journal.record("Defeated a zombie!"); +} +#[on(use_item = Item::CarrotOnAStick)] +fn read() { + if holding(Notebook) { + Journal.show(); + } +} diff --git a/examples/lang_vectors/README.md b/examples/lang_vectors/README.md new file mode 100644 index 00000000..8b15e10e --- /dev/null +++ b/examples/lang_vectors/README.md @@ -0,0 +1,15 @@ +# Exploration Log + +A language-only datapack with a separate saved vector of visits for each player. +Mine stone or defeat zombies to record coordinates. Right-click the supplied +notebook to read the last eight visits. + +```sh +sand lang build examples/lang_vectors +sand lang run examples/lang_vectors --offline +``` + +Each vector element is a record with a string and two fixed-point coordinates. +The example combines `Vec` State, mutation and removal, snapshot iteration, +associated functions, borrowed methods, typed player properties, and runtime +text. The example keeps eight entries; language vectors support up to 1,024. diff --git a/examples/lang_vectors/pack.sand b/examples/lang_vectors/pack.sand new file mode 100644 index 00000000..3c9146fb --- /dev/null +++ b/examples/lang_vectors/pack.sand @@ -0,0 +1,70 @@ +//! An eight-entry personal exploration log stored as a vector of records. +#![pack(namespace = "explorer_log", minecraft = "26.2")] +struct Visit { + label: string, + x: float, + z: float +} +impl Visit { + fn capture(label: string) -> Self { + return Self { + label, + x: Player.x, + z: Player.z + }; + } + fn describe(&self) -> string { + return self.label + " at " + self.x.to_string() + ", " + self.z.to_string(); + } +} +player state Journal { + visits: Vec +} +impl Journal { + fn record(&mut self, label: string) { + if self.visits.len() == 8 { + self.visits.remove_or(0, Visit { + label: "", + x: 0.0, + z: 0.0 + }); + } + self.visits.push(Visit::capture(label)); + chat!("{green}Added a visit to your exploration log."); + } + fn show(&self) { + let count = self.visits.len(); + chat!("{gold}{bold}Exploration log: {count} entries"); + for visit in self.visits { + chat!(visit.describe()); + } + if self.visits.is_empty() { + chat!("{gray}Mine stone or defeat a zombie to record a visit."); + } + } +} +item Notebook { + base: Item::CarrotOnAStick, + name: "{gold}Exploration Log", + lore: ["{gray}Right-click to read your recent visits."], + unbreakable: true +} +#[on(first_join)] +fn welcome() { + give_item(Notebook); + Journal.record("The journey begins"); +} +#[on(mine_block = Block::Stone)] +fn stone() { + Journal.record("Mined stone"); +} +#[on(kill = Entity::Zombie)] +fn zombie() { + Journal.record("Defeated a zombie"); +} +#[on(use_item = Item::CarrotOnAStick)] +fn read() { + if holding(Notebook) { + Journal.show(); + } +} diff --git a/examples/lang_vehicles/README.md b/examples/lang_vehicles/README.md new file mode 100644 index 00000000..c73e04b5 --- /dev/null +++ b/examples/lang_vehicles/README.md @@ -0,0 +1,11 @@ +# Minecart shuttle + +Build the pack with `sand lang build examples/lang_vehicles` and load it into a +Minecraft 26.2 world. Stand on a rail and run `/function cart_shuttle:place_cart` +to place a shuttle minecart. First-time players receive a carrot on a stick. If +you already joined the world, give yourself one with `/give @s carrot_on_a_stick`. + +Use the item within eight blocks of a shuttle cart to board. Use it again to +dismount. The pack retains the nearest cart's identity while the query executes +as the cart, then mounts the original player using that reference. Vanilla +decides whether a cart has an available seat. diff --git a/examples/lang_vehicles/pack.sand b/examples/lang_vehicles/pack.sand new file mode 100644 index 00000000..a492f96a --- /dev/null +++ b/examples/lang_vehicles/pack.sand @@ -0,0 +1,38 @@ +#![pack(namespace = "cart_shuttle", minecraft = "26.2", description = "A minecart shuttle")] + +#[on(first_join)] +fn issue_pass() { + give_item(Item::CarrotOnAStick); + chat!("Use your shuttle pass near a cart to board or get off."); +} + +/// Place a shuttle cart at the function's execution position. +pub fn place_cart() { + summon(Entity::Minecart, tag = "cart_shuttle_vehicle"); +} + +#[on(use_item = Item::CarrotOnAStick)] +fn toggle_seat() { + let empty: EntityRef; + let current = entity_ref(Relation::Vehicle); + if current != empty { + dismount(); + return; + } + + let mut vehicle: EntityRef; + for cart in entities(type = Entity::Minecart, tag = "cart_shuttle_vehicle", distance = ..=8, sort = Sort::Nearest, limit = 1) { + vehicle = entity_ref(); + } + if vehicle == empty { + chat!("No shuttle cart nearby."); + return; + } + mount(vehicle); +} +/// Nudge the nearest shuttle cart east. +pub fn boost_cart() { + for cart in entities(type = Entity::Minecart, tag = "cart_shuttle_vehicle", distance = ..=8, sort = Sort::Nearest, limit = 1) { + set_velocity(cart.velocity_x + 0.15, cart.velocity_y, cart.velocity_z); + } +} diff --git a/examples/lang_waits/README.md b/examples/lang_waits/README.md new file mode 100644 index 00000000..a43694f9 --- /dev/null +++ b/examples/lang_waits/README.md @@ -0,0 +1,13 @@ +# Bread baked to order + +Build with `sand lang build examples/lang_waits` for Minecraft 26.2. Use a carrot +on a stick to place an order. A batch of bread arrives two seconds later while +the original chunk is loaded. Each order keeps its own batch number, including +when several players order at once or one player places several orders. + +Run `/function bread_orders:cancel_order` as a player to cancel that player's +pending batches. The pack counts orders in player State and keeps pending +ingredients and batch numbers in each invocation's local variables. + +Every third batch spends an extra 12 loaded ticks in the oven. Both branches +serve the original batch after its own timer completes. diff --git a/examples/lang_waits/pack.sand b/examples/lang_waits/pack.sand new file mode 100644 index 00000000..665fd8c8 --- /dev/null +++ b/examples/lang_waits/pack.sand @@ -0,0 +1,35 @@ +#![pack(namespace = "bread_orders", minecraft = "26.2", description = "Bread baked to order")] + +player state Bakery { batches: number } + +#[on(first_join)] +fn issue_ticket() { + give_item(Item::CarrotOnAStick); + chat!("Use your bakery ticket to order fresh bread."); +} + +#[on(use_item = Item::CarrotOnAStick)] +fn order() { + Bakery.batches += 1; + bake(Bakery.batches); +} + +fn bake(batch: number) { + let quantity = 3; + actionbar!("Batch {batch} is in the oven."); + let baking_ticks = quantity * 12; + if batch % 3 == 0 { + actionbar!("Batch {batch} is getting an extra-crisp crust."); + wait(baking_ticks + 12); + } else { + wait(baking_ticks); + } + give_item(Item::Bread, count = quantity); + chat!("Batch {batch} is ready. Here are your {quantity} loaves."); +} + +#[player] +pub fn cancel_order() { + cancel_waits(); + actionbar!("Your pending bakery orders were cancelled."); +} diff --git a/examples/lang_world_ops/README.md b/examples/lang_world_ops/README.md new file mode 100644 index 00000000..8600fbbc --- /dev/null +++ b/examples/lang_world_ops/README.md @@ -0,0 +1,17 @@ +# Checkpoint room markers + +Build with `sand lang build examples/lang_world_ops` for Minecraft 26.2. +Stand in a clear test area and run `/function checkpoint_rooms:place` in the +Overworld, Nether, or Workshop. The pack places a lantern marker two blocks south and +clones it four blocks east. The marker comes from the included +`structures/checkpoint_marker.nbt` template. The masked clone preserves blocks at the destination +where the source region contains air. + +Run `/function checkpoint_rooms:inspect_nether` from any dimension to check the +Nether from a scoped function call. The call keeps the same executor and the +invoker stays in their original dimension. + +Install the pack before starting the world to register its flat Workshop +dimension and warm, dry custom biome. Run `/function checkpoint_rooms:inspect_workshop` to check it from +another dimension. An operator can enter it using +`/execute in checkpoint_rooms:workshop run tp @s 0 -61 0`. diff --git a/examples/lang_world_ops/pack.sand b/examples/lang_world_ops/pack.sand new file mode 100644 index 00000000..f0f4eb79 --- /dev/null +++ b/examples/lang_world_ops/pack.sand @@ -0,0 +1,66 @@ +#![pack(namespace = "checkpoint_rooms", minecraft = "26.2", description = "Repeatable checkpoint rooms")] +biome WorkshopClimate { + precipitation: false, + temperature: 1.1, + downfall: 0.0, + sky_color: "#e6b88a", + water_color: "#4b8fa3", + spawners: { + creature: [{ entity: Entity::Rabbit, weight: 12, min_count: 1, max_count: 3 }], + }, +} + +dimension Workshop { + biome: WorkshopClimate, + layers: [ + { block: Block::Bedrock, height: 1 }, + { block: Block::Sandstone, height: 2 }, + ], +} + +structure_template CheckpointMarker { + source: "structures/checkpoint_marker.nbt", +} + +/// Call near the test area in the Overworld, Nether, or Workshop. +pub fn place() { + if dimension_is(Dimension::Overworld) || dimension_is(Dimension::TheNether) || dimension_is(Workshop) { + // Place the saved marker and copy it four blocks away. + place_template(CheckpointMarker, offset(0, 0, 2)); + clone_blocks(offset(0, 0, 2), offset(0, 2, 2), offset(4, 0, 2), masked = true); + } +} +/// Inspect the portal dimension from the caller's current world. +pub fn inspect_nether() { + in_dimension(Dimension::TheNether, report_dimension); +} +fn report_dimension() { + if dimension_is(Dimension::TheNether) { + broadcast!("The Nether checkpoint dimension is available."); + } +} +/// Inspect the pack's flat workshop from the caller's current world. +pub fn inspect_workshop() { + in_dimension(Workshop, report_workshop); +} +fn report_workshop() { + if dimension_is(Workshop) { + broadcast!("The sandstone workshop is available."); + } +} + +/// Call while standing one block south of a barrel. +pub fn count_barrel_stacks() { + let stacks = block_data_number(offset(0, 0, -1), "Items"); + broadcast!("The barrel contains ${stacks} occupied slots."); +} + +/// Place two stocked barrels ahead of the caller. +pub fn stock_supply_barrels() { + set_block(Block::Barrel, offset(0, 0, 2)); + set_block(Block::Barrel, offset(1, 0, 2)); + set_block_data(offset(0, 0, 2), "Items", [ + Nbt { Slot: false, id: "minecraft:bread", count: 8 }, + ]); + copy_block_data(offset(0, 0, 2), "Items", offset(1, 0, 2), "Items"); +} diff --git a/examples/lang_world_ops/structures/checkpoint_marker.nbt b/examples/lang_world_ops/structures/checkpoint_marker.nbt new file mode 100644 index 00000000..c331c97a Binary files /dev/null and b/examples/lang_world_ops/structures/checkpoint_marker.nbt differ diff --git a/examples/owned_combat/Cargo.lock b/examples/owned_combat/Cargo.lock index 784e5e53..6c4f63e3 100644 --- a/examples/owned_combat/Cargo.lock +++ b/examples/owned_combat/Cargo.lock @@ -1149,6 +1149,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.21", "unicode-general-category", @@ -1165,6 +1167,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.21", @@ -1174,6 +1177,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64 0.22.1", "inventory", "sand-api-contract", "sand-build", @@ -1204,6 +1208,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/participant_audit/Cargo.lock b/examples/participant_audit/Cargo.lock index 7c06f2e3..a6cc3b9a 100644 --- a/examples/participant_audit/Cargo.lock +++ b/examples/participant_audit/Cargo.lock @@ -1126,6 +1126,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.19", "unicode-general-category", @@ -1142,6 +1144,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.19", @@ -1151,6 +1154,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64", "inventory", "sand-api-contract", "sand-build", @@ -1181,6 +1185,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/portable_counter/Cargo.lock b/examples/portable_counter/Cargo.lock index 491039aa..59893290 100644 --- a/examples/portable_counter/Cargo.lock +++ b/examples/portable_counter/Cargo.lock @@ -1149,6 +1149,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.21", "unicode-general-category", @@ -1165,6 +1167,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.21", @@ -1174,6 +1177,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64 0.22.1", "inventory", "sand-api-contract", "sand-build", @@ -1204,6 +1208,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/quest_rounds/Cargo.lock b/examples/quest_rounds/Cargo.lock index ff431b68..3773a735 100644 --- a/examples/quest_rounds/Cargo.lock +++ b/examples/quest_rounds/Cargo.lock @@ -1149,6 +1149,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.21", "unicode-general-category", @@ -1165,6 +1167,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.21", @@ -1174,6 +1177,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64 0.22.1", "inventory", "sand-api-contract", "sand-build", @@ -1204,6 +1208,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/recipes.rs b/examples/recipes.rs index e51d8942..ec011657 100644 --- a/examples/recipes.rs +++ b/examples/recipes.rs @@ -4,7 +4,7 @@ //! stonecutting, and smithing. use sand_core::{ - CookingRecipe, CookingType, Ingredient, ItemId, RecipeResult, ShapedRecipe, ShapelessRecipe, + CookingRecipe, CookingType, Ingredient, ItemId, RecipeResult, ResourceLocation, ShapedRecipe, ShapelessRecipe, SmithingTransformRecipe, SmithingTrimRecipe, StonecuttingRecipe, TagId, generated::Item, }; use sand_macros::datapack_component; @@ -91,7 +91,10 @@ pub fn custom_upgrade() -> SmithingTransformRecipe { #[datapack_component] pub fn custom_trim() -> SmithingTrimRecipe { - SmithingTrimRecipe::new("my_pack:custom_trim".parse().unwrap()) + SmithingTrimRecipe::new( + "my_pack:custom_trim".parse().unwrap(), + ResourceLocation::minecraft("coast").unwrap(), + ) .template(Ingredient::item_id( ItemId::minecraft("coast_armor_trim_smithing_template").unwrap(), )) diff --git a/examples/rpg_entity/Cargo.lock b/examples/rpg_entity/Cargo.lock index 2b2e3fa1..ba2092ee 100644 --- a/examples/rpg_entity/Cargo.lock +++ b/examples/rpg_entity/Cargo.lock @@ -1127,6 +1127,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.19", "unicode-general-category", @@ -1143,6 +1145,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.19", @@ -1152,6 +1155,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64", "inventory", "sand-api-contract", "sand-build", @@ -1182,6 +1186,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/examples/unified_state/Cargo.lock b/examples/unified_state/Cargo.lock index 15daa14a..3baa4b1b 100644 --- a/examples/unified_state/Cargo.lock +++ b/examples/unified_state/Cargo.lock @@ -1118,6 +1118,8 @@ dependencies = [ "sand-api-contract", "sand-macros", "sand-version", + "schemars", + "serde", "serde_json", "thiserror 2.0.20", "unicode-general-category", @@ -1134,6 +1136,7 @@ dependencies = [ "sand-commands", "sand-macros", "sand-version", + "schemars", "serde", "serde_json", "thiserror 2.0.20", @@ -1143,6 +1146,7 @@ dependencies = [ name = "sand-core" version = "0.1.0" dependencies = [ + "base64", "inventory", "sand-api-contract", "sand-build", @@ -1173,6 +1177,7 @@ version = "0.1.0" dependencies = [ "sand-api-contract", "sand-macros", + "serde_json", ] [[package]] diff --git a/sand-api-contract/src/syntax/registry_id.rs b/sand-api-contract/src/syntax/registry_id.rs index 55ba7154..555fbed4 100644 --- a/sand-api-contract/src/syntax/registry_id.rs +++ b/sand-api-contract/src/syntax/registry_id.rs @@ -152,6 +152,12 @@ pub fn expand(input: TokenStream) -> syn::Result { } } + impl<'de> serde::Deserialize<'de> for #name { + fn deserialize>(d: D) -> std::result::Result { + ResourceLocation::deserialize(d).map(Self) + } + } + impl std::str::FromStr for #name { type Err = crate::error::SandError; fn from_str(s: &str) -> Result { Ok(Self(s.parse()?)) } diff --git a/sand-api-enforce/tests/contract_source.rs b/sand-api-enforce/tests/contract_source.rs index ddb923f8..c40aefe4 100644 --- a/sand-api-enforce/tests/contract_source.rs +++ b/sand-api-enforce/tests/contract_source.rs @@ -508,7 +508,54 @@ fn repository_contract_sources_are_the_actual_authored_declarations() { } sources.sort(); let declarations = contract_declarations_from_files(&sources).unwrap(); - assert_eq!(declarations.len(), 4_991); + // CaptureEntity (+2), WithEntity (+4), and Damage::by (+1) extend + // the same enforced advanced vocabulary; no scope exemptions are added. + // Typed storage fields/projections/operands, canonical data operations, + // owned NBT text and the text constructor add 44 contracted source items. + // Related capture, source locations, mounting, waits, and world operations add 43 items. + assert_eq!(declarations.len(), 5_667); + for path in [ + "sand::advanced::compiler::DataField", + "sand::advanced::compiler::DataReference", + "sand::advanced::compiler::DataProjection", + "sand::advanced::compiler::DataOperand", + "sand::advanced::compiler::DataModifyOperation", + "sand::advanced::compiler::Action::DataModify", + "sand::advanced::compiler::Action::DataRead", + "sand::advanced::compiler::Action::DataEqual", + "sand::advanced::compiler::Action::DataRemove", + "sand::advanced::compiler::Action::CaptureEntity::relation", + "sand::advanced::compiler::Action::Ride", + "sand::advanced::compiler::Action::Suspend", + "sand::advanced::compiler::Action::CancelWaits", + "sand::advanced::compiler::Compiler::compile_with_command_sources", + "sand::advanced::compiler::TextPart::Stored", + "sand::text::TextComponent::nbt", + ] { + assert!( + declarations + .iter() + .any(|declaration| declaration.canonical_path == path), + "missing contract {path}" + ); + } + for member in [ + "CaptureEntity", + "CaptureEntity::score", + "WithEntity", + "WithEntity::reference", + "WithEntity::players", + "WithEntity::body", + "Damage::by", + ] { + let path = format!("sand::advanced::compiler::Action::{member}"); + assert!( + declarations + .iter() + .any(|declaration| declaration.canonical_path == path), + "missing contract {path}" + ); + } assert!( declarations .iter() diff --git a/sand-api-enforce/tests/repository_manifest.rs b/sand-api-enforce/tests/repository_manifest.rs index 05128c8a..e0881bfe 100644 --- a/sand-api-enforce/tests/repository_manifest.rs +++ b/sand-api-enforce/tests/repository_manifest.rs @@ -89,14 +89,14 @@ fn repository_surface_manifest_records_the_audited_pending_baseline() { [ ( "placeholder-codegen", - 5_269, + 5_945, 0, "api-surface-baseline-placeholder.txt".to_owned(), ), - ("26.2", 11_369, 0, "api-surface-baseline.txt".to_owned(),), + ("26.2", 12_259, 0, "api-surface-baseline.txt".to_owned(),), ( "26.3", - 11_628, + 12_521, 0, "api-surface-baseline-26.3.txt".to_owned(), ), diff --git a/sand-api-enforce/tests/repository_surface.rs b/sand-api-enforce/tests/repository_surface.rs index 570816b9..3a5fedaf 100644 --- a/sand-api-enforce/tests/repository_surface.rs +++ b/sand-api-enforce/tests/repository_surface.rs @@ -15,23 +15,23 @@ fn checked_repository_surface_baseline_is_complete_and_partitioned() { "configuration=all-supported-features,current-target" ); assert_eq!(lines[2], "minecraft_version=26.2"); - assert_eq!(lines[3], "total=11369"); + assert_eq!(lines[3], "total=12259"); let kinds = prefixed_counts(&lines, "kind "); - assert_eq!(kinds.values().sum::(), 11_369); - assert_eq!(kinds["field"], 739); - assert_eq!(kinds["variant"], 5_802); - assert_eq!(kinds["enum"], 168); + assert_eq!(kinds.values().sum::(), 12_259); + assert_eq!(kinds["field"], 1_102); + assert_eq!(kinds["variant"], 6_236); + assert_eq!(kinds["enum"], 201); assert_eq!(kinds["trait"], 41); assert_eq!(kinds["trait_method"], 89); assert_eq!(kinds["attribute_macro"], 9); assert_eq!(kinds["derive_macro"], 7); let origins = prefixed_counts(&lines, "origin "); - assert_eq!(origins.values().sum::(), 11_369); - assert_eq!(origins["source"], 4_991); + assert_eq!(origins.values().sum::(), 12_259); + assert_eq!(origins["source"], 5_667); assert_eq!(origins["generator:generated_commands"], 1_233); - assert_eq!(origins["generator:generated_registries"], 4_867); + assert_eq!(origins["generator:generated_registries"], 5_081); assert_eq!(origins["generator:generated_registry_ids"], 158); assert_eq!(origins["generator:generated_effect_registry_enums"], 95); assert_eq!(origins["generator:generated_event_markers"], 25); @@ -46,11 +46,11 @@ fn checked_repository_surface_baseline_is_complete_and_partitioned() { .iter() .map(|line| numeric_field(line, "items=")) .sum::(); - assert_eq!(scoped_items, 11_369); + assert_eq!(scoped_items, 12_259); assert_eq!( lines.last().copied(), Some( - "totals pending_scopes=0 pending_items=0 enforced_items=11369 pending_scope_ceiling=0 pending_item_ceiling=0" + "totals pending_scopes=0 pending_items=0 enforced_items=12259 pending_scope_ceiling=0 pending_item_ceiling=0" ) ); } @@ -64,9 +64,9 @@ fn checked_repository_profiles_bind_exact_versioned_baselines() { assert_eq!(profiles.profiles.len(), 3); let expected = [ - ("placeholder-codegen", 5_269, 0, 0, 0), - ("26.2", 11_369, 1_233, 4_867, 0), - ("26.3", 11_628, 1_255, 5_104, 0), + ("placeholder-codegen", 5_945, 0, 0, 0), + ("26.2", 12_259, 1_233, 5_081, 0), + ("26.3", 12_521, 1_255, 5_321, 0), ]; for (version, total, commands, registries, pending) in expected { let profile = profiles @@ -82,7 +82,7 @@ fn checked_repository_profiles_bind_exact_versioned_baselines() { assert_eq!(lines[3], format!("total={total}")); let origins = prefixed_counts(&lines, "origin "); assert_eq!(origins.values().sum::(), total); - assert_eq!(origins["source"], 4_991); + assert_eq!(origins["source"], 5_667); assert_eq!( origins .get("generator:generated_commands") diff --git a/sand-build/examples/refresh_vanilla_catalog.rs b/sand-build/examples/refresh_vanilla_catalog.rs new file mode 100644 index 00000000..99cab8f5 --- /dev/null +++ b/sand-build/examples/refresh_vanilla_catalog.rs @@ -0,0 +1,10 @@ +//! Explicitly refresh the committed offline vanilla registry catalog. +fn main() { + let mut args = std::env::args().skip(1); + let output = args + .next() + .expect("usage: refresh_vanilla_catalog OUTPUT VERSION..."); + let versions: Vec = args.collect(); + assert!(!versions.is_empty(), "supply explicit Minecraft versions"); + sand_build::refresh_vanilla_catalog(&versions, std::path::Path::new(&output)).unwrap(); +} diff --git a/sand-build/src/api_provider.rs b/sand-build/src/api_provider.rs index 24dd5581..c825d932 100644 --- a/sand-build/src/api_provider.rs +++ b/sand-build/src/api_provider.rs @@ -362,7 +362,9 @@ pub fn write_placeholder_codegen(out_dir: &Path, minecraft_version: &str) -> Res pub(crate) enum EntityType {}\n\ impl EntityType { pub(crate) fn resource_location(&self) -> &'static str { match *self {} } }\n\ pub(crate) enum SoundEvent {}\n\ - impl SoundEvent { pub(crate) fn resource_location(&self) -> &'static str { match *self {} } }\n", + impl SoundEvent { pub(crate) fn resource_location(&self) -> &'static str { match *self {} } }\n\ + pub(crate) enum ParticleType {}\n\ + impl ParticleType { pub(crate) fn resource_location(&self) -> &'static str { match *self {} } }\n", )?; std::fs::write(out_dir.join("block_states.rs"), "// Generation failed\n")?; std::fs::write( diff --git a/sand-build/src/bin/refresh-vanilla-catalog.rs b/sand-build/src/bin/refresh-vanilla-catalog.rs new file mode 100644 index 00000000..403bcd85 --- /dev/null +++ b/sand-build/src/bin/refresh-vanilla-catalog.rs @@ -0,0 +1,18 @@ +use std::{path::Path, process::ExitCode}; + +fn main() -> ExitCode { + let mut args = std::env::args().skip(1); + let output = args.next(); + let versions: Vec<_> = args.collect(); + let Some(output) = output.filter(|_| !versions.is_empty()) else { + eprintln!("usage: refresh-vanilla-catalog ..."); + return ExitCode::FAILURE; + }; + match sand_build::refresh_vanilla_catalog(&versions, Path::new(&output)) { + Ok(()) => ExitCode::SUCCESS, + Err(error) => { + eprintln!("failed to refresh the vanilla catalog: {error}"); + ExitCode::FAILURE + } + } +} diff --git a/sand-build/src/codegen/biomes.rs b/sand-build/src/codegen/biomes.rs index b5cb08ce..718dfe93 100644 --- a/sand-build/src/codegen/biomes.rs +++ b/sand-build/src/codegen/biomes.rs @@ -69,18 +69,7 @@ struct BiomeParameterEntry { /// `sand::vanilla::Biome` enum is deliberately not part of this issue's /// scope). pub fn generate(reports_dir: &Path, out_dir: &Path, minecraft_version: &str) -> Result<()> { - let mut biomes: BTreeSet = FIXED_BIOMES.iter().map(|s| s.to_string()).collect(); - - for report in BIOME_PARAMETER_REPORTS { - let path = reports_dir.join(report); - // Missing input must fail closed. Silently emitting a partial list - // turns valid target-version biomes into false validation failures. - let content = std::fs::read_to_string(&path)?; - let parsed: BiomeParameters = serde_json::from_str(&content)?; - for entry in parsed.biomes { - biomes.insert(entry.biome); - } - } + let biomes = read_biomes(reports_dir)?; let mut code = String::from("// Generated by sand-build. Do not edit manually.\n\n"); code.push_str("/// The exact Minecraft version this file's data was generated for.\n"); @@ -104,6 +93,23 @@ pub fn generate(reports_dir: &Path, out_dir: &Path, minecraft_version: &str) -> Ok(()) } +/// Read the verified set of vanilla biomes used by all frontends. +pub(crate) fn read_biomes(reports_dir: &Path) -> Result> { + let mut biomes: BTreeSet = FIXED_BIOMES.iter().map(|s| s.to_string()).collect(); + + for report in BIOME_PARAMETER_REPORTS { + let path = reports_dir.join(report); + // Missing input must fail closed. Silently emitting a partial list + // turns valid target-version biomes into false validation failures. + let content = std::fs::read_to_string(&path)?; + let parsed: BiomeParameters = serde_json::from_str(&content)?; + for entry in parsed.biomes { + biomes.insert(entry.biome); + } + } + Ok(biomes) +} + #[cfg(test)] mod tests { use super::*; diff --git a/sand-build/src/codegen/cache.rs b/sand-build/src/codegen/cache.rs index d2ef7c57..721bbde3 100644 --- a/sand-build/src/codegen/cache.rs +++ b/sand-build/src/codegen/cache.rs @@ -145,6 +145,16 @@ pub fn fingerprint(reports_dir: &Path, minecraft_version: &str) -> Result }; // Sort entries by protocol_id for a stable, game-order enum. - let mut entries: Vec<(&String, &EntryData)> = registry.entries.iter().collect(); - entries.sort_by_key(|(_, v)| v.protocol_id); + let mut entries: Vec<_> = registry.entries.iter().collect(); + entries.sort_by_key(|(_, value)| value.protocol_id); + let ids: Vec<_> = entries.into_iter().map(|(key, _)| key.as_str()).collect(); - let contracts = enum_api_entries(enum_name, registry_key, &entries, minecraft_version); - write_enum(&mut code, enum_name, doc, &entries, &contracts); + let contracts = enum_api_entries(enum_name, registry_key, &ids, minecraft_version); + write_enum(&mut code, enum_name, doc, &ids, &contracts); + api_entries.extend(contracts); + } + + // Enchantments are loaded from built-in datapack data by the catalog + // maintenance generator. Runtime language checking and Rust generation + // use that same version-specific catalog. + if let Some(entries) = + sand_version::registry::variants(minecraft_version, "minecraft:enchantment") + { + let ids: Vec<_> = entries.values().map(String::as_str).collect(); + let contracts = enum_api_entries( + "Enchantment", + "minecraft:enchantment", + &ids, + minecraft_version, + ); + write_enum( + &mut code, + "Enchantment", + "Minecraft enchantment registry.", + &ids, + &contracts, + ); + code.push_str( + r#" +impl From for sand_components::EnchantmentId { + fn from(enchantment: Enchantment) -> Self { + enchantment.resource_location().parse().expect("generated enchantment IDs are valid") + } +} +"#, + ); api_entries.extend(contracts); } @@ -89,7 +114,7 @@ pub fn generate(reports_dir: &Path, out_dir: &Path, minecraft_version: &str) -> fn enum_api_entries( enum_name: &str, registry_key: &str, - entries: &[(&String, &EntryData)], + entries: &[&str], minecraft_version: &str, ) -> Vec { let enum_path = format!("sand::vanilla::{enum_name}"); @@ -98,7 +123,7 @@ fn enum_api_entries( .strip_prefix("minecraft:") .unwrap_or(registry_key); let availability = vec![format!("minecraft = {minecraft_version}")]; - let example_variant = entries.first().map(|(key, _)| resource_key_to_variant(key)); + let example_variant = entries.first().map(|key| resource_key_to_variant(key)); let enum_example = example_variant.as_ref().map_or_else( || format!("let value: Option = None;"), |variant| format!("let value = sand::vanilla::{enum_name}::{variant};"), @@ -167,7 +192,7 @@ fn enum_api_entries( }, }); - result.extend(entries.iter().map(|(key, _)| { + result.extend(entries.iter().map(|key| { let variant = resource_key_to_variant(key); GeneratedProviderEntry { definition_identity: format!("sand_core::generated::{enum_name}::{variant}"), @@ -202,7 +227,7 @@ fn write_enum( code: &mut String, enum_name: &str, _doc: &str, - entries: &[(&String, &EntryData)], + entries: &[&str], contracts: &[GeneratedProviderEntry], ) { let enum_contract = contracts @@ -213,7 +238,7 @@ fn write_enum( writeln!(code, "#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]").unwrap(); writeln!(code, "pub enum {enum_name} {{").unwrap(); - for (key, _) in entries { + for key in entries { let variant = resource_key_to_variant(key); let path = format!("sand::vanilla::{enum_name}::{variant}"); let variant_contract = contracts @@ -240,7 +265,7 @@ fn write_enum( ) .unwrap(); writeln!(code, " match self {{").unwrap(); - for (key, _) in entries { + for key in entries { let variant = resource_key_to_variant(key); writeln!(code, " Self::{variant} => {key:?},").unwrap(); } @@ -370,4 +395,22 @@ mod tests { "generated Rust must be byte-for-byte deterministic" ); } + + #[test] + fn enchantments_generate_from_the_language_catalog_without_network_report_entries() { + let directory = tempfile::tempdir().unwrap(); + std::fs::write(directory.path().join("registries.json"), "{}").unwrap(); + generate(directory.path(), directory.path(), "26.2").unwrap(); + + let expected = sand_version::registry::variants("26.2", "minecraft:enchantment").unwrap(); + let api: ApiProviderCatalog = serde_json::from_slice( + &std::fs::read(directory.path().join("registries.api.json")).unwrap(), + ) + .unwrap(); + assert_eq!(api.entries.len(), expected.len() + 2); + for variant in expected.keys() { + assert!(api.entries.iter().any(|entry| entry.contract.canonical_path + == format!("sand::vanilla::Enchantment::{variant}"))); + } + } } diff --git a/sand-build/src/lib.rs b/sand-build/src/lib.rs index c03038cf..8f4fbbdd 100644 --- a/sand-build/src/lib.rs +++ b/sand-build/src/lib.rs @@ -41,6 +41,8 @@ mod manifest; mod registry_fixture; mod registry_id_contracts; mod report; +mod vanilla_catalog; +pub use vanilla_catalog::refresh_vanilla_catalog; pub mod source_tree_fingerprint; pub use api_provider::{ diff --git a/sand-build/src/report.rs b/sand-build/src/report.rs index f4c65df7..2b5edf5b 100644 --- a/sand-build/src/report.rs +++ b/sand-build/src/report.rs @@ -98,6 +98,10 @@ fn valid_reports(dir: &Path, sha1: &str) -> Result { } fn run_generator(working_dir: &Path, jar_path: &Path) -> Result<()> { + run_data_generator(working_dir, jar_path, "--reports") +} + +pub(crate) fn run_data_generator(working_dir: &Path, jar_path: &Path, mode: &str) -> Result<()> { // Probe for java on PATH first so we can give a clear error. let java = which_java()?; @@ -105,7 +109,7 @@ fn run_generator(working_dir: &Path, jar_path: &Path) -> Result<()> { .arg("-DbundlerMainClass=net.minecraft.data.Main") .arg("-jar") .arg(jar_path) - .arg("--reports") + .arg(mode) .current_dir(working_dir) .output() .map_err(|e| { diff --git a/sand-build/src/vanilla_catalog.rs b/sand-build/src/vanilla_catalog.rs new file mode 100644 index 00000000..1754e2bd --- /dev/null +++ b/sand-build/src/vanilla_catalog.rs @@ -0,0 +1,118 @@ +//! Maintenance generator for the offline, target-specific vanilla catalogs. +use std::collections::BTreeMap; +use std::path::Path; + +use crate::{Result, cache, download, fingerprint::hash_bytes, report, resolve_version}; +use serde_json::{Value, json}; + +/// Regenerate offline registry catalogs from verified Mojang server reports. +/// +/// This is an explicit maintenance operation: it may download pinned server +/// JARs and run their data generators. Normal compilation only reads the +/// committed result and performs no network or cache I/O. Each entry includes +/// the exact report fingerprint; names use the same conversion as Rust codegen. +pub fn refresh_vanilla_catalog(versions: &[String], output: &Path) -> Result<()> { + let mut targets = BTreeMap::new(); + for version in versions { + let root = cache::cache_dir()?; + let entry = resolve_version(&root, version, &download::Http)?; + let cache = cache::VersionCache::acquire(&root, &entry.id)?; + let jar = download::ensure_server_jar(&cache, &entry, &download::Http)?; + let reports = report::ensure_reports(&cache, &jar)?; + let bytes = std::fs::read(reports.join("registries.json"))?; + let report: Value = serde_json::from_slice(&bytes)?; + let mut registries = BTreeMap::new(); + for kind in [ + "item", + "block", + "entity_type", + "sound_event", + "particle_type", + "attribute", + "mob_effect", + "potion", + ] { + let name = format!("minecraft:{kind}"); + let entries = report[&name]["entries"] + .as_object() + .ok_or_else(|| cache::invalid(format!("{version}: missing registry {name}")))?; + registries.insert( + name.clone(), + named_variants(version, &name, entries.keys().cloned())?, + ); + } + let name = "minecraft:worldgen/biome"; + let biomes = crate::codegen::biomes::read_biomes(&reports)?; + registries.insert(name.into(), named_variants(version, name, biomes)?); + let staged = tempfile::tempdir()?; + report::run_data_generator(staged.path(), &jar, "--server")?; + for kind in ["enchantment", "damage_type"] { + let name = format!("minecraft:{kind}"); + let ids = server_resource_ids(staged.path(), kind)?; + if ids.is_empty() { + return Err(cache::invalid(format!( + "{version}: missing registry {name}" + ))); + } + registries.insert(name.clone(), named_variants(version, &name, ids)?); + } + targets.insert( + entry.id.clone(), + json!({"registries": registries, "report_sha1": hash_bytes(&bytes)}), + ); + } + let result = json!({"format": "sand.vanilla_catalog", "format_version": 1, + "provenance": "Verified Mojang server data generator registry and biome reports and built-in data", "targets": targets}); + std::fs::write( + output, + format!("{}\n", serde_json::to_string_pretty(&result)?), + )?; + Ok(()) +} + +fn server_resource_ids(root: &Path, kind: &str) -> Result> { + let directory = root.join("generated/data/minecraft").join(kind); + let mut pending = vec![directory.clone()]; + let mut ids = Vec::new(); + while let Some(subdirectory) = pending.pop() { + for entry in std::fs::read_dir(subdirectory)? { + let entry = entry?; + let kind = entry.file_type()?; + let path = entry.path(); + if kind.is_dir() { + pending.push(path); + } else if kind.is_file() + && path + .extension() + .is_some_and(|extension| extension == "json") + { + let key = path + .strip_prefix(&directory) + .expect("generated resource directory"); + let key = key + .with_extension("") + .to_string_lossy() + .replace(std::path::MAIN_SEPARATOR, "/"); + ids.push(format!("minecraft:{key}")); + } + } + } + Ok(ids) +} + +fn named_variants( + version: &str, + registry: &str, + ids: impl IntoIterator, +) -> Result> { + let mut variants = BTreeMap::new(); + for id in ids { + let variant = crate::codegen::registries::resource_key_to_variant(&id); + if variants.insert(variant.clone(), id).is_some() { + return Err(cache::invalid(format!( + "{version}: colliding variant {variant} in {registry}" + ))); + } + } + Ok(variants) +} diff --git a/sand-cli/Cargo.toml b/sand-cli/Cargo.toml index 56ce3406..8ea9f8fa 100644 --- a/sand-cli/Cargo.toml +++ b/sand-cli/Cargo.toml @@ -17,6 +17,8 @@ sand-api-contract = { path = "../sand-api-contract" } sand-build = { path = "../sand-build" } sand-components = { path = "../sand-components" } sand-core = { path = "../sand-core" } +sand-lang = { path = "../sand-lang" } +sand-lsp = { path = "../sand-lsp" } clap = { version = "4", features = ["derive"] } # default-features off: handlebars 6.4.3+ enables `preserve_json_order` by # default, which flips serde_json to insertion-ordered maps workspace-wide and diff --git a/sand-cli/src/api_cmd.rs b/sand-cli/src/api_cmd.rs index a3e45ad6..1d555a94 100644 --- a/sand-cli/src/api_cmd.rs +++ b/sand-cli/src/api_cmd.rs @@ -4562,7 +4562,31 @@ mod tests { || entry.canonical_path.starts_with("sand::advanced::") }) .collect::>(); - assert_eq!(entries.len(), 346); + assert_eq!(entries.len(), 992); + for member in [ + "CaptureEntity", + "CaptureEntity::relation", + "WithEntity", + "Damage::by", + "Ride", + "Suspend", + "CancelWaits", + ] { + assert!( + show( + catalog, + &format!("sand::advanced::compiler::Action::{member}") + ) + .is_ok() + ); + } + assert!( + show( + catalog, + "sand::advanced::compiler::Compiler::compile_with_command_sources" + ) + .is_ok() + ); assert!( show(catalog, "sand::advanced::compiler::ScoreField::bounds") .unwrap() diff --git a/sand-cli/src/lang_cmd.rs b/sand-cli/src/lang_cmd.rs new file mode 100644 index 00000000..381c55c4 --- /dev/null +++ b/sand-cli/src/lang_cmd.rs @@ -0,0 +1,585 @@ +//! `sand lang` and `sand lsp`: the Sand language frontend. +//! +//! Sand source compiles through the same portable compiler as JSON programs, +//! so `sand lang build` needs neither Cargo nor `sand.toml`. + +use anyhow::{Context, Result, bail}; +use clap::{Args, Subcommand}; +use colored::Colorize; +use sand_lang::library::Library; +use sand_lang::{Analysis, Diagnostic, DiskFiles, Severity}; +use std::io::Write; +use std::path::{Path, PathBuf}; + +#[derive(Args)] +pub struct LangArgs { + #[command(subcommand)] + command: Command, +} + +#[derive(Subcommand)] +enum Command { + /// Run Sand-authored tests in a disposable Minecraft world + Test { + #[command(flatten)] + input: Input, + /// Discover tests without launching Minecraft + #[arg(long)] + list: bool, + /// Use a specific server JAR instead of the verified version cache + #[arg(long)] + jar: Option, + /// Accept the Minecraft EULA for this test server + #[arg(long)] + accept_eula: bool, + /// Maximum seconds for startup, each test, and shutdown + #[arg(long, default_value_t = 120, value_parser = clap::value_parser!(u64).range(1..=3600))] + timeout: u64, + }, + /// Vendor a bundled Sand library into an existing package + Add { + /// Library to install (collections, spatial, or time) + library: Library, + #[command(flatten)] + input: Input, + }, + /// Format every source file in a Sand package + Fmt { + #[command(flatten)] + input: Input, + /// Report unformatted files without modifying them + #[arg(long)] + check: bool, + }, + /// Type-check a Sand language package without writing files + Check(Input), + /// Compile a Sand language package into a datapack directory + Build { + #[command(flatten)] + input: Input, + /// Output directory; defaults to dist/ next to the root file + #[arg(long)] + output: Option, + }, + /// Compile the package and launch a local Minecraft server to test it + Run { + #[command(flatten)] + input: Input, + /// JVM heap size, e.g. "4G" or "2048M" + #[arg(long, default_value = "4G")] + ram: String, + /// Set online-mode=false in server.properties (easier local testing) + #[arg(long)] + offline: bool, + /// Skip compiling; launch whatever is already in dist/ + #[arg(long)] + no_build: bool, + /// How to present the Minecraft server's log + #[arg(long, value_enum, default_value = "classified")] + server_log: crate::console::OutputMode, + }, + /// Print the portable program JSON the package lowers to + Emit(Input), + /// Print source locations for emitted commands and portable operations as JSON + SourceMap(Input), + /// Create a new Sand language project in a new directory + New { + /// Project directory (its name becomes the namespace) + path: PathBuf, + /// Namespace for generated resources; defaults to the directory name + #[arg(long)] + namespace: Option, + }, + /// Install Sand language support for the Zed editor + Zed { + /// Where to write the extension; defaults to ~/.sand/zed + #[arg(long)] + dir: Option, + }, +} + +#[derive(Args)] +struct Input { + /// Package root file, any file in the package, or a directory containing pack.sand + #[arg(default_value = ".")] + path: PathBuf, +} + +/// Run a `sand lang` subcommand. +pub fn run(args: LangArgs) -> Result<()> { + match args.command { + Command::Test { + input, + list, + jar, + accept_eula, + timeout, + } => { + let root = package_root(&input.path)?; + let analysis = sand_lang::analyze_tests(sand_lang::load(&root, &DiskFiles)); + report(&analysis)?; + if list || analysis.tests.is_empty() { + for test in &analysis.tests { + println!("{}", test.name); + } + println!("{} test(s)", analysis.tests.len()); + return Ok(()); + } + crate::lang_test::run( + &analysis, + jar, + accept_eula, + std::time::Duration::from_secs(timeout), + ) + } + Command::Add { library, input } => { + let installed = install_library(&input.path, library)?; + println!("{} {}", "Added".green().bold(), installed.display()); + let import = match library { + Library::Collections => "use collections::{Map, Set};", + Library::Spatial => "use spatial::Position;", + Library::Time => "use time::Duration;", + }; + println!(" Import with {import}"); + Ok(()) + } + Command::Fmt { input, check } => format_package(&input.path, check), + Command::Check(input) => { + let analysis = analyze(&input.path)?; + let diagnostics = report(&analysis)?; + println!( + "{} {} ({diagnostics})", + "Checked".green().bold(), + analysis.package.root.display() + ); + Ok(()) + } + Command::Build { input, output } => { + let analysis = analyze(&input.path)?; + report(&analysis)?; + build(&analysis, output)?; + Ok(()) + } + Command::Run { + input, + ram, + offline, + no_build, + server_log, + } => run_project( + &input.path, + crate::run_cmd::RunArgs { + ram, + offline, + no_build, + server_log, + profile: "dev".into(), + }, + ), + Command::New { path, namespace } => { + let name = path + .file_name() + .map(|n| n.to_string_lossy().into_owned()) + .context("project path needs a final directory name")?; + let namespace = namespace.unwrap_or_else(|| { + name.to_ascii_lowercase() + .chars() + .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }) + .collect() + }); + let valid = namespace + .chars() + .next() + .is_some_and(|c| c.is_ascii_lowercase()) + && namespace + .bytes() + .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'_'); + if !valid { + bail!( + "`{namespace}` is not a valid namespace; pass --namespace with lowercase letters, digits, and `_`" + ); + } + let minecraft = sand::advanced::compiler::Compiler::capabilities()["targets"] + .as_array() + .and_then(|targets| targets.last()) + .and_then(|target| target.as_str()) + .unwrap_or("26.2") + .to_string(); + crate::lang_setup::new_project(&path, &namespace, &minecraft)?; + println!( + "{} {} (namespace `{namespace}`, Minecraft {minecraft})", + "Created".green().bold(), + path.display() + ); + println!(" cd {} && sand lang build", path.display()); + Ok(()) + } + Command::Zed { dir } => { + let dir = match dir { + Some(dir) => dir, + None => crate::lang_setup::default_zed_dir()?, + }; + let install = crate::lang_setup::install_zed(&dir)?; + let short = &install.revision[..install.revision.len().min(12)]; + println!( + "{} Zed extension → {}", + "Wrote".green().bold(), + install.extension.display() + ); + println!( + " grammar → {} (commit {short})", + install.grammar.display() + ); + println!(); + println!("Finish in Zed (one time):"); + println!(" 1. Open the command palette (cmd-shift-p / ctrl-shift-p)."); + println!(" 2. Run `zed: install dev extension`."); + println!(" 3. Choose {}", install.extension.display()); + println!(); + println!( + "Zed builds the extension with Rust (rustup) and starts `sand lsp` for .sand files." + ); + println!( + "After upgrading Sand, run `sand lang zed` again and choose `Rebuild` on the Sand extension." + ); + Ok(()) + } + Command::SourceMap(input) => { + let analysis = analyze(&input.path)?; + report(&analysis)?; + let map = analysis + .source_map() + .map_err(|errors| report_compilation_errors(&analysis, errors))?; + println!("{}", serde_json::to_string_pretty(&map)?); + Ok(()) + } + Command::Emit(input) => { + let analysis = analyze(&input.path)?; + report(&analysis)?; + let program = analysis + .program + .as_ref() + .context("the package did not lower to a program")?; + println!("{}", serde_json::to_string_pretty(program)?); + Ok(()) + } + } +} + +/// Format all declared source files, or check their formatting without writes. +/// +/// Every file is parsed and formatted before any file is changed. Semantic +/// errors do not prevent formatting, but syntax and module-loading errors do. +pub fn format_package(path: &Path, check: bool) -> Result<()> { + let analysis = analyze(path)?; + if !analysis.package.diagnostics.is_empty() { + for diagnostic in &analysis.package.diagnostics { + eprint!("{}", diagnostic.render(&analysis.package)); + } + bail!("cannot format a package with syntax or module-loading errors"); + } + let mut changed = Vec::new(); + for file in &analysis.package.files { + let formatted = sand_lang::format::format(&file.text) + .map_err(|_| anyhow::anyhow!("cannot format {}: syntax errors", file.path.display()))?; + if formatted != file.text { + changed.push((file.path.clone(), formatted)); + } + } + if check { + for (path, _) in &changed { + println!("Would format {}", path.display()); + } + if !changed.is_empty() { + bail!("{} source file(s) need formatting", changed.len()); + } + } else { + for (path, text) in &changed { + std::fs::write(path, text) + .with_context(|| format!("cannot write {}", path.display()))?; + println!("Formatted {}", path.display()); + } + } + Ok(()) +} + +/// Compile a package and publish it; returns its namespace. +fn build(analysis: &Analysis, output: Option) -> Result { + let pack = analysis + .compile() + .map_err(|errors| report_compilation_errors(analysis, errors))?; + let namespace = namespace_of(analysis); + let default_output = output.is_none(); + let root = project_root(analysis); + let output = output.unwrap_or_else(|| root.join("dist").join(&namespace)); + let published = crate::build::publication::publish_pack(&output, &pack.resources)?; + println!( + "{} {} for Minecraft {} → {} ({} written, {} unchanged, {} removed)", + "Built".green().bold(), + namespace, + pack.target, + output.display(), + published.summary.written, + published.summary.unchanged, + published.summary.removed, + ); + // Keep a local test world current, so an edit only needs `/reload`. + let installed = root.join("dist/server/world/datapacks").join(&namespace); + if default_output && installed.exists() { + crate::run_cmd::sync_dir(&output, &installed) + .with_context(|| format!("failed to update {}", installed.display()))?; + println!( + " {} the test world's copy; run {} in-game to load it", + "Updated".dimmed(), + "/reload".white() + ); + } + Ok(namespace) +} + +fn namespace_of(analysis: &Analysis) -> String { + analysis + .pack + .as_ref() + .map(|p| p.namespace.clone()) + .unwrap_or_else(|| "pack".into()) +} + +fn project_root(analysis: &Analysis) -> PathBuf { + analysis + .package + .root + .parent() + .unwrap_or(Path::new(".")) + .to_path_buf() +} + +/// Compile a package (unless `--no-build`) and launch the local test server. +/// Language projects need neither Cargo nor `sand.toml`. +pub(crate) fn run_project(path: &Path, args: crate::run_cmd::RunArgs) -> Result<()> { + let analysis = analyze(path)?; + report(&analysis)?; + let namespace = if args.no_build { + namespace_of(&analysis) + } else { + build(&analysis, None)? + }; + let minecraft = analysis + .program + .as_ref() + .map(|program| program.target.minecraft.to_string()) + .context("the package did not produce a program")?; + let root = project_root(&analysis); + std::env::set_current_dir(&root).with_context(|| format!("cannot enter {}", root.display()))?; + crate::run_cmd::launch_built(&namespace, &minecraft, args) +} + +pub fn run_lsp() -> Result<()> { + sand_lsp::run_stdio().map_err(|error| anyhow::anyhow!("language server failed: {error}")) +} + +fn package_root(path: &Path) -> Result { + let path = + std::fs::canonicalize(path).with_context(|| format!("cannot open {}", path.display()))?; + let root = if path.is_dir() { + let root = path.join(sand_lang::ROOT_FILE); + if !root.is_file() { + bail!( + "{} has no {}; pass the package root file explicitly", + path.display(), + sand_lang::ROOT_FILE + ); + } + root + } else { + sand_lang::find_root(&path, &DiskFiles) + }; + Ok(root) +} + +fn analyze(path: &Path) -> Result { + Ok(sand_lang::analyze_path(&package_root(path)?, &DiskFiles)) +} + +fn imported_name(tree: &sand_lang::ast::UseTree, name: &str) -> bool { + if let Some(group) = &tree.group { + return group.iter().any(|tree| imported_name(tree, name)); + } + tree.alias.as_ref().unwrap_or_else(|| tree.path.last()).name == name +} + +/// Install a normal, editable source module without replacing existing code. +fn install_library(path: &Path, library: Library) -> Result { + use sand_lang::ast::ItemKind; + let root = package_root(path)?; + let parent = root + .parent() + .context("package root has no parent directory")?; + let original = std::fs::read_to_string(&root)?; + let (source, errors) = sand_lang::parser::parse(&original); + anyhow::ensure!( + errors.is_empty(), + "fix package-root syntax errors before adding a library" + ); + let name = library.name(); + let target = parent.join(format!("{name}.sand")); + anyhow::ensure!( + !target.exists() && !parent.join(name).exists(), + "{} already exists; no files were changed", + target.display() + ); + let mut declared = false; + for item in &source.items { + if item.name().is_some_and(|item| item.name == name) { + match &item.kind { + ItemKind::Mod(module) if module.inline.is_none() => declared = true, + _ => bail!( + "`{name}` is already declared in {}; no files were changed", + root.display() + ), + } + } + if let ItemKind::Use(import) = &item.kind { + anyhow::ensure!( + !imported_name(&import.tree, name), + "`{name}` is already imported in {}; no files were changed", + root.display() + ); + } + } + let mut contents = original.clone(); + if !declared { + if !contents.ends_with('\n') { + contents.push('\n'); + } + contents.push_str(&format!("\nmod {name};\n")); + } + let mut module = tempfile::NamedTempFile::new_in(parent)?; + module.write_all(library.source().as_bytes())?; + module + .persist_noclobber(&target) + .with_context(|| format!("install {}", target.display()))?; + let result = (|| -> Result<()> { + anyhow::ensure!( + std::fs::read_to_string(&root)? == original, + "package root changed during library installation; retry with the latest source" + ); + if !declared { + let mut staged = tempfile::NamedTempFile::new_in(parent)?; + staged.write_all(contents.as_bytes())?; + staged + .as_file() + .set_permissions(std::fs::metadata(&root)?.permissions())?; + staged + .persist(&root) + .context("install library module declaration")?; + } + Ok(()) + })(); + if let Err(error) = result { + let _ = std::fs::remove_file(&target); + return Err(error); + } + Ok(target) +} + +fn report_compilation_errors(analysis: &Analysis, errors: Vec) -> anyhow::Error { + for error in &errors { + eprint!("{}", error.render(&analysis.package)); + } + anyhow::anyhow!("compilation failed with {} error(s)", errors.len()) +} + +/// Print diagnostics; fail when any is an error. Returns a summary. +fn report(analysis: &Analysis) -> Result { + let mut errors = 0; + let mut warnings = 0; + for diagnostic in &analysis.diagnostics { + match diagnostic.severity { + Severity::Error => errors += 1, + Severity::Warning => warnings += 1, + } + eprintln!("{}", diagnostic.render(&analysis.package)); + } + if errors > 0 { + bail!("{errors} error(s), {warnings} warning(s)"); + } + Ok(format!("{warnings} warning(s)")) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn building_updates_an_existing_test_world_only_when_there_is_one() { + let dir = tempfile::tempdir().unwrap(); + // Publishing refuses symlinked paths, such as macOS's `/var`. + let base = std::fs::canonicalize(dir.path()).unwrap(); + let project = base.join("arena"); + crate::lang_setup::new_project(&project, "arena", "26.2").unwrap(); + let analysis = analyze(&project).unwrap(); + assert_eq!(build(&analysis, None).unwrap(), "arena"); + let installed = project.join("dist/server/world/datapacks/arena"); + assert!(!installed.exists(), "no test world exists yet"); + + std::fs::create_dir_all(&installed).unwrap(); + build(&analysis, None).unwrap(); + assert!( + installed.join("pack.mcmeta").is_file(), + "reload picks up the rebuilt pack" + ); + + // An explicit output is a separate destination, not the project's pack. + std::fs::remove_dir_all(&installed).unwrap(); + std::fs::create_dir_all(&installed).unwrap(); + build(&analysis, Some(base.join("elsewhere"))).unwrap(); + assert!(!installed.join("pack.mcmeta").exists()); + } +} + +#[cfg(test)] +mod library_tests { + use super::*; + + #[test] + fn installing_collections_adds_a_normal_module_and_compiles_it() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path().join("pack.sand"); + std::fs::write(&root, "#![pack(namespace = \"maps\", minecraft = \"26.2\")]\nuse collections::{Map, Set};\nfn run() { let mut map = Map::::new(); map.insert(\"a\", 1); let set = Set::::new(); }\n").unwrap(); + let library = install_library(dir.path(), Library::Collections).unwrap(); + assert_eq!( + std::fs::read_to_string(&library).unwrap(), + Library::Collections.source() + ); + let source = std::fs::read_to_string(&root).unwrap(); + assert_eq!(source.matches("mod collections;").count(), 1); + let analysis = analyze(dir.path()).unwrap(); + assert!(!analysis.has_errors(), "{:?}", analysis.diagnostics); + analysis.compile().unwrap(); + assert!(install_library(dir.path(), Library::Collections).is_err()); + assert_eq!(std::fs::read_to_string(&root).unwrap(), source); + } + + #[test] + fn installation_preserves_existing_source_and_accepts_a_missing_declared_module() { + for source in [ + "#![pack(namespace = \"maps\")] struct collections { x: number }", + "#![pack(namespace = \"maps\")] use other as collections;", + "#![pack(namespace = \"maps\")] mod collections {}", + ] { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path().join("pack.sand"); + std::fs::write(&root, source).unwrap(); + assert!(install_library(dir.path(), Library::Collections).is_err()); + assert_eq!(std::fs::read_to_string(&root).unwrap(), source); + assert!(!dir.path().join("collections.sand").exists()); + } + let dir = tempfile::tempdir().unwrap(); + let root = dir.path().join("pack.sand"); + let source = "#![pack(namespace = \"maps\")] mod collections;\n"; + std::fs::write(&root, source).unwrap(); + install_library(&root, Library::Collections).unwrap(); + assert_eq!(std::fs::read_to_string(root).unwrap(), source); + } +} diff --git a/sand-cli/src/lang_setup.rs b/sand-cli/src/lang_setup.rs new file mode 100644 index 00000000..381adacf --- /dev/null +++ b/sand-cli/src/lang_setup.rs @@ -0,0 +1,346 @@ +//! `sand lang new` and `sand lang zed`: project scaffolding and editor setup. + +use anyhow::{Context, Result, bail}; +use std::path::{Path, PathBuf}; +use std::process::Command; + +/// Files of the Zed extension, embedded so setup works from any install. +const ZED_FILES: &[(&str, &str)] = &[ + ("Cargo.toml", include_str!("../../editors/zed/Cargo.toml")), + ("src/lib.rs", include_str!("../../editors/zed/src/lib.rs")), + ( + "languages/sand/config.toml", + include_str!("../../editors/zed/languages/sand/config.toml"), + ), + ( + "languages/sand/highlights.scm", + include_str!("../../editors/zed/languages/sand/highlights.scm"), + ), + ( + "languages/sand/brackets.scm", + include_str!("../../editors/zed/languages/sand/brackets.scm"), + ), + ( + "languages/sand/indents.scm", + include_str!("../../editors/zed/languages/sand/indents.scm"), + ), + ( + "languages/sand/outline.scm", + include_str!("../../editors/zed/languages/sand/outline.scm"), + ), +]; + +/// The generated tree-sitter grammar Zed compiles for highlighting. +const GRAMMAR_FILES: &[(&str, &str)] = &[ + ( + "grammar.js", + include_str!("../../editors/tree-sitter-sand/grammar.js"), + ), + ( + "tree-sitter.json", + include_str!("../../editors/tree-sitter-sand/tree-sitter.json"), + ), + ( + "src/parser.c", + include_str!("../../editors/tree-sitter-sand/src/parser.c"), + ), + ( + "src/grammar.json", + include_str!("../../editors/tree-sitter-sand/src/grammar.json"), + ), + ( + "src/node-types.json", + include_str!("../../editors/tree-sitter-sand/src/node-types.json"), + ), + ( + "src/tree_sitter/parser.h", + include_str!("../../editors/tree-sitter-sand/src/tree_sitter/parser.h"), + ), + ( + "src/tree_sitter/alloc.h", + include_str!("../../editors/tree-sitter-sand/src/tree_sitter/alloc.h"), + ), + ( + "src/tree_sitter/array.h", + include_str!("../../editors/tree-sitter-sand/src/tree_sitter/array.h"), + ), + ( + "queries/highlights.scm", + include_str!("../../editors/tree-sitter-sand/queries/highlights.scm"), + ), +]; + +/// Where `sand lang zed` installs by default: `~/.sand/zed`. +pub fn default_zed_dir() -> Result { + let home = std::env::var_os("HOME") + .or_else(|| std::env::var_os("USERPROFILE")) + .context("cannot find your home directory; pass --dir")?; + Ok(PathBuf::from(home).join(".sand").join("zed")) +} + +fn write_files(root: &Path, files: &[(&str, &str)]) -> Result<()> { + for (relative, contents) in files { + let path = root.join(relative); + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent) + .with_context(|| format!("create {}", parent.display()))?; + } + std::fs::write(&path, contents).with_context(|| format!("write {}", path.display()))?; + } + Ok(()) +} + +fn git(dir: &Path, args: &[&str]) -> Result { + let output = Command::new("git") + .arg("-C") + .arg(dir) + // A fixed local identity keeps setup independent of user git config. + .args(["-c", "user.name=Sand", "-c", "user.email=sand@localhost"]) + .args(["-c", "commit.gpgsign=false"]) + .args(args) + .output() + .context("run git (Zed fetches grammars with git, so git must be installed)")?; + if !output.status.success() { + bail!( + "git {} failed: {}", + args.join(" "), + String::from_utf8_lossy(&output.stderr).trim() + ); + } + Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()) +} + +/// What `install_zed` produced. +pub struct ZedInstall { + /// The extension directory to select in Zed. + pub extension: PathBuf, + /// The local grammar repository. + pub grammar: PathBuf, + /// The pinned grammar commit. + pub revision: String, +} + +/// Write the Zed extension and a local, committed grammar repository. +/// +/// Zed fetches grammars with git at an exact revision, so the grammar is +/// committed into its own repository and that commit is pinned in +/// `extension.toml`. Re-running updates both in place. +pub fn install_zed(dir: &Path) -> Result { + let grammar = dir.join("tree-sitter-sand"); + let extension = dir.join("zed-sand"); + write_files(&grammar, GRAMMAR_FILES)?; + if !grammar.join(".git").exists() { + git(&grammar, &["init", "--quiet"])?; + } + git(&grammar, &["add", "--all"])?; + let changed = !git(&grammar, &["status", "--porcelain"])?.is_empty(); + let has_head = git(&grammar, &["rev-parse", "--verify", "--quiet", "HEAD"]).is_ok(); + if changed || !has_head { + git( + &grammar, + &["commit", "--quiet", "--message", "Sand tree-sitter grammar"], + )?; + } + let revision = git(&grammar, &["rev-parse", "HEAD"])?; + + write_files(&extension, ZED_FILES)?; + let grammar_url = format!("file://{}", std::fs::canonicalize(&grammar)?.display()); + let manifest = format!( + r#"id = "sand" +name = "Sand" +version = "0.1.0" +schema_version = 1 +authors = ["Sand contributors"] +description = "Sand datapack language: highlighting and the Sand language server." +repository = "https://github.com/ThatOneToast/sand" + +[grammars.sand] +repository = "{grammar_url}" +rev = "{revision}" + +[language_servers.sand] +name = "Sand Language Server" +languages = ["Sand"] +"# + ); + std::fs::write(extension.join("extension.toml"), manifest)?; + Ok(ZedInstall { + extension, + grammar, + revision, + }) +} + +/// Create a new Sand language project. +pub fn new_project(dir: &Path, namespace: &str, minecraft: &str) -> Result<()> { + if dir.exists() && dir.read_dir()?.next().is_some() { + bail!( + "directory '{}' already exists and is not empty", + dir.display() + ); + } + let title = dir + .file_name() + .map(|name| name.to_string_lossy().into_owned()) + .unwrap_or_else(|| namespace.to_string()); + let pack = PACK_TEMPLATE + .replace("@TITLE@", &title) + .replace("@NAMESPACE@", namespace) + .replace("@MINECRAFT@", minecraft); + let readme = README_TEMPLATE + .replace("@TITLE@", &title) + .replace("@NAMESPACE@", namespace); + write_files( + dir, + &[ + ("pack.sand", &pack), + ("rewards.sand", REWARDS_TEMPLATE), + ("shop.sand", SHOP_TEMPLATE), + ("README.md", &readme), + (".gitignore", "/dist/\n"), + ], + ) +} + +const PACK_TEMPLATE: &str = r#"//! @TITLE@: a datapack written in the Sand language. +#![pack(namespace = "@NAMESPACE@", minecraft = "@MINECRAFT@")] + +mod rewards; +mod shop; + +/// Coins each player has collected. +pub player state Wallet { + #[clamp(0..=9999)] + coins: number, +} + +/// Greet players the first time they join. +#[on(first_join)] +fn welcome() { + chat!("{gold}Welcome, {player}!{reset} You start with {Wallet.coins} coins."); + give_item(Item::Bread, 4); +} + +/// Start the payday timer whenever the pack loads. +#[load] +fn start() { + schedule(payday, seconds = 60); +} + +/// Pay every online player, then wait for the next payday. +fn payday() { + for player in players() { + rewards::pay(); + } + schedule(payday, seconds = 60); +} +"#; + +const REWARDS_TEMPLATE: &str = r#"//! Coin rewards. + +use crate::Wallet; + +/// Give the executing player one coin and tell them about it. +pub fn pay() { + Wallet.coins += 1; + actionbar!("{yellow}+1 coin {gray}({Wallet.coins} total)"); + play_sound(Sound::EntityExperienceOrbPickup); +} +"#; + +const SHOP_TEMPLATE: &str = r#"//! Spend coins on extra hearts. + +use crate::Wallet; + +/// Max health is measured in half-hearts: 20.0 is ten hearts. +const MAX_HEALTH: float = 40.0; + +/// The price of the next heart, rising with each one bought. +fn heart_price(extra_hearts: number) -> number { + return 50 + extra_hearts * 25; +} + +/// Right-click a carrot on a stick to buy one heart of max health. +#[on(use_item = Item::CarrotOnAStick)] +fn buy_heart() { + let health = Player.max_health; + if health >= MAX_HEALTH { + actionbar!("{gold}You already have the most hearts possible."); + return; + } + let price = heart_price(((health - 20.0) / 2.0) as number); + if Wallet.coins < price { + chat!("{red}A heart costs {price} coins; you have {Wallet.coins}."); + return; + } + Wallet.coins -= price; + Player.max_health = health + 2.0; + play_sound(Sound::EntityPlayerLevelup); + chat!("{green}Bought a heart for {price} coins!"); +} +"#; + +const README_TEMPLATE: &str = r#"# @TITLE@ + +A Minecraft datapack written in the Sand language. + +```sh +sand lang check # report errors and warnings +sand lang build # write the datapack to dist/@NAMESPACE@ +sand lang run # compile and launch a local test server +``` + +Copy `dist/@NAMESPACE@` into a world's `datapacks` folder and run `/reload`. + +Editor support: run `sand lang zed` once, then install the printed folder +with Zed's `zed: install dev extension` command. +"#; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn zed_queries_match_the_grammar_queries() { + assert_eq!( + include_str!("../../editors/zed/languages/sand/highlights.scm"), + include_str!("../../editors/tree-sitter-sand/queries/highlights.scm"), + ); + } + + #[test] + fn zed_install_pins_a_committed_grammar_and_is_idempotent() { + let dir = tempfile::tempdir().unwrap(); + let first = install_zed(dir.path()).unwrap(); + let manifest = std::fs::read_to_string(first.extension.join("extension.toml")).unwrap(); + assert!(manifest.contains(&format!("rev = \"{}\"", first.revision))); + assert!(manifest.contains("[language_servers.sand]")); + assert!(first.extension.join("languages/sand/config.toml").is_file()); + assert!(first.grammar.join("src/parser.c").is_file()); + assert_eq!( + git(&first.grammar, &["status", "--porcelain"]).unwrap(), + "", + "grammar files are committed" + ); + let second = install_zed(dir.path()).unwrap(); + assert_eq!(first.revision, second.revision); + } + + #[test] + fn new_projects_analyse_and_compile_cleanly() { + let dir = tempfile::tempdir().unwrap(); + let project = dir.path().join("arena"); + new_project(&project, "arena", "26.2").unwrap(); + let analysis = sand_lang::analyze_path(&project.join("pack.sand"), &sand_lang::DiskFiles); + assert!( + analysis.diagnostics.is_empty(), + "{:#?}", + analysis.diagnostics + ); + analysis.compile().unwrap(); + assert!( + new_project(&project, "arena", "26.2").is_err(), + "refuses non-empty dirs" + ); + } +} diff --git a/sand-cli/src/lang_test.rs b/sand-cli/src/lang_test.rs new file mode 100644 index 00000000..640b766e --- /dev/null +++ b/sand-cli/src/lang_test.rs @@ -0,0 +1,259 @@ +//! Run Sand test entry points on a disposable vanilla server. +use anyhow::{Context, Result, bail, ensure}; +use sand_lang::Analysis; +use std::collections::VecDeque; +use std::io::{BufRead, BufReader, Write}; +use std::net::{Ipv4Addr, TcpListener}; +use std::path::{Path, PathBuf}; +use std::process::{Child, ChildStdin, Command, Stdio}; +use std::sync::mpsc::{self, Receiver}; +use std::time::{Duration, Instant}; + +pub(crate) fn run( + analysis: &Analysis, + jar: Option, + accept_eula: bool, + timeout: Duration, +) -> Result<()> { + ensure!( + accept_eula, + "pass --accept-eula to run the vanilla Minecraft server" + ); + let pack = analysis.compile().map_err(|errors| { + for error in &errors { + eprint!("{}", error.render(&analysis.package)); + } + anyhow::anyhow!("test pack compilation failed") + })?; + let namespace = &analysis + .pack + .as_ref() + .expect("compiled pack metadata") + .namespace; + let jar = match jar { + Some(jar) => jar.canonicalize().context("open test server JAR")?, + None => { + sand_build::ensure_server_jar(pack.target.strip_suffix(".0").unwrap_or(&pack.target))? + } + }; + let root = tempfile::tempdir()?; + let path = root.path().canonicalize()?; + let datapack = path.join("world/datapacks").join(namespace); + crate::build::publication::publish_pack(&datapack, &pack.resources)?; + let mut server = TestServer::start(&path, &jar)?; + let mut version = None; + server.wait_for(timeout, "server startup", |line| { + if let Some((_, release)) = line.split_once("Starting minecraft server version ") { + version = Some(release.trim().to_owned()); + } + line.contains("Done (") && line.contains("For help") + })?; + let found = version.context("could not identify the Minecraft server version")?; + let release = sand::version::MinecraftVersion::parse(&found)?; + let expected = sand::version::MinecraftVersion::parse(&pack.target)?; + ensure!( + release.components() == expected.components(), + "test server is Minecraft {found}, but the pack targets {}", + pack.target + ); + + // Keep a deterministic origin available for tests that summon entities or + // set blocks, even while there are no connected players. + server.load_origin(timeout)?; + + let mut failed = 0; + for (index, test) in analysis.tests.iter().enumerate() { + let pass = format!(" __SAND_TEST_{index}_PASS__"); + let fail = format!(" __SAND_TEST_{index}_FAIL__"); + let done = format!("__SAND_TEST_{index}_DONE__"); + let done_suffix = format!(" {done}"); + server.send(&format!( + "execute in minecraft:overworld positioned 0 80 0 run function {}", + test.runner + ))?; + server.send(&format!("say {done}"))?; + let mut passed = false; + let mut completed = false; + let mut failed_assertion = None; + server.wait_for(timeout, &test.name, |line| { + if line.ends_with(&pass) || line.ends_with(&fail) { + passed = line.ends_with(&pass); + completed = true; + } + if let Some(location) = line + .rsplit_once(" __SAND_ASSERT_") + .and_then(|(_, suffix)| suffix.strip_suffix("__")) + { + failed_assertion = location.split_once('_').and_then(|(file, offset)| { + Some((file.parse::().ok()?, offset.parse::().ok()?)) + }); + } + line.ends_with(&done_suffix) + })?; + if completed && passed { + println!("ok {}", test.name); + } else { + failed += 1; + let assertion = failed_assertion.and_then(|(file, offset)| { + let source = analysis.package.files.get(file)?; + source.text.get(..offset)?; + Some((source, offset)) + }); + let (source, offset) = + assertion.unwrap_or((&analysis.package.files[test.file.0], test.span.start)); + let line = source.lines.chars(offset).line + 1; + let reason = if assertion.is_some() { + "assertion failed" + } else if completed { + "returned false" + } else { + "did not finish" + }; + eprintln!( + "FAILED {} ({}:{line}, {reason})", + test.name, + source.path.display() + ); + } + } + server.stop(timeout)?; + println!("{} passed, {failed} failed", analysis.tests.len() - failed); + if failed > 0 { + bail!("{failed} Sand test(s) failed"); + } + Ok(()) +} + +struct TestServer { + child: Child, + input: ChildStdin, + output: Receiver, + recent: VecDeque, +} + +impl TestServer { + fn start(root: &Path, jar: &Path) -> Result { + let socket = TcpListener::bind((Ipv4Addr::LOCALHOST, 0))?; + let port = socket.local_addr()?.port(); + std::fs::write(root.join("eula.txt"), "eula=true\n")?; + std::fs::write( + root.join("server.properties"), + format!( + "server-ip=127.0.0.1\nserver-port={port}\nonline-mode=false\n level-type=minecraft:flat\ngenerate-structures=false\nview-distance=2\n simulation-distance=2\npause-when-empty-seconds=0\n" + ), + )?; + drop(socket); + let stderr = std::fs::File::create(root.join("stderr.log"))?; + let mut child = Command::new("java") + .args(["-Xmx1G", "-jar"]) + .arg(jar) + .arg("nogui") + .current_dir(root) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(stderr) + .spawn() + .context("start Java for Sand tests")?; + let input = child.stdin.take().expect("piped stdin"); + let stdout = child.stdout.take().expect("piped stdout"); + let (tx, output) = mpsc::channel(); + std::thread::spawn(move || { + for line in BufReader::new(stdout).lines().map_while(Result::ok) { + if tx.send(line).is_err() { + break; + } + } + }); + Ok(Self { + child, + input, + output, + recent: VecDeque::new(), + }) + } + + fn send(&mut self, line: &str) -> Result<()> { + writeln!(self.input, "{line}").context("send command to Minecraft test server")?; + self.input.flush()?; + Ok(()) + } + + fn wait_for( + &mut self, + timeout: Duration, + phase: &str, + mut matches: impl FnMut(&str) -> bool, + ) -> Result<()> { + let deadline = Instant::now() + timeout; + while let Ok(line) = self + .output + .recv_timeout(deadline.saturating_duration_since(Instant::now())) + { + if matches(&line) { + return Ok(()); + } + if self.recent.len() == 20 { + self.recent.pop_front(); + } + self.recent.push_back(line); + if Instant::now() >= deadline { + break; + } + } + for line in &self.recent { + eprintln!("{line}"); + } + bail!("Minecraft test server did not complete {phase} within {timeout:?}"); + } + + fn load_origin(&mut self, timeout: Duration) -> Result<()> { + self.send("execute in minecraft:overworld run forceload add 0 0")?; + let deadline = Instant::now() + timeout; + loop { + let time_left = deadline.saturating_duration_since(Instant::now()); + ensure!( + !time_left.is_zero(), + "Minecraft did not load the test chunk" + ); + self.send( + "execute in minecraft:overworld if loaded 0 80 0 run say __SAND_TEST_READY__", + )?; + self.send("say __SAND_TEST_SETUP_DONE__")?; + let mut ready = false; + self.wait_for(time_left, "test world setup", |line| { + ready |= line.ends_with(" __SAND_TEST_READY__"); + line.ends_with(" __SAND_TEST_SETUP_DONE__") + })?; + if ready { + return Ok(()); + } + std::thread::sleep(Duration::from_millis(50)); + } + } + + fn stop(&mut self, timeout: Duration) -> Result<()> { + self.send("stop")?; + let deadline = Instant::now() + timeout; + while Instant::now() < deadline { + if let Some(status) = self.child.try_wait()? { + ensure!( + status.success(), + "Minecraft test server stopped with {status}" + ); + return Ok(()); + } + std::thread::sleep(Duration::from_millis(25)); + } + bail!("Minecraft test server did not stop within {timeout:?}"); + } +} + +impl Drop for TestServer { + fn drop(&mut self) { + if matches!(self.child.try_wait(), Ok(Some(_))) { + return; + } + let _ = self.child.kill(); + let _ = self.child.wait(); + } +} diff --git a/sand-cli/src/lib.rs b/sand-cli/src/lib.rs index 71858c67..b08dd704 100644 --- a/sand-cli/src/lib.rs +++ b/sand-cli/src/lib.rs @@ -21,6 +21,10 @@ mod dev; #[doc(hidden)] pub mod join_cmd; #[doc(hidden)] +pub mod lang_cmd; +mod lang_setup; +mod lang_test; +#[doc(hidden)] pub mod output; #[doc(hidden)] pub mod pack_format; diff --git a/sand-cli/src/main.rs b/sand-cli/src/main.rs index 0bd7093c..5a2fb683 100644 --- a/sand-cli/src/main.rs +++ b/sand-cli/src/main.rs @@ -24,8 +24,21 @@ struct Cli { #[derive(Subcommand)] enum Commands { + /// Format a Sand language package + Fmt { + /// Package directory or source file + #[arg(default_value = ".")] + path: PathBuf, + /// Report unformatted files without modifying them + #[arg(long)] + check: bool, + }, /// Compile or inspect portable gameplay programs Program(sand_cli::program::ProgramArgs), + /// Check, build, or inspect packs written in the Sand language (.sand) + Lang(sand_cli::lang_cmd::LangArgs), + /// Run the Sand language server over stdio (for editors) + Lsp, /// Inspect Sand's supported public API contracts Api(api_cmd::ApiArgs), /// Report the current project and installed API identity for tools and agents @@ -230,7 +243,10 @@ fn main() { fn run() -> Result<()> { let cli = Cli::parse(); match cli.command { + Commands::Fmt { path, check } => sand_cli::lang_cmd::format_package(&path, check), Commands::Program(args) => sand_cli::program::run(args), + Commands::Lang(args) => sand_cli::lang_cmd::run(args), + Commands::Lsp => sand_cli::lang_cmd::run_lsp(), Commands::Api(args) => api_cmd::run(args), Commands::Context { profile, format } => { let catalog = api_cmd::installed_catalog()?; diff --git a/sand-cli/src/run_cmd.rs b/sand-cli/src/run_cmd.rs index 40684c65..a2085e57 100644 --- a/sand-cli/src/run_cmd.rs +++ b/sand-cli/src/run_cmd.rs @@ -166,6 +166,10 @@ impl ResolvedServerProperties { } pub fn run(args: RunArgs) -> Result<()> { + // A Sand language project has `pack.sand` and no `sand.toml`. + if !Path::new("sand.toml").exists() && Path::new(sand_lang::ROOT_FILE).exists() { + return crate::lang_cmd::run_project(Path::new("."), args); + } run_internal( args, false, @@ -175,6 +179,20 @@ pub fn run(args: RunArgs) -> Result<()> { .map(|_| ()) } +/// Launch the managed local server with a pack already built in `dist/`, +/// without reading `sand.toml`. The current directory is the project root. +pub(crate) fn launch_built(namespace: &str, mc_version: &str, args: RunArgs) -> Result<()> { + launch( + args, + None, + &mut None, + &mut crate::dev::ManagedPack::default(), + namespace, + &resolve_mc_version(mc_version), + ) + .map(|_| ()) +} + /// Build and watch a project using the managed local server. Reload retains /// vanilla load-handler semantics; registry/configuration changes require a /// graceful restart with `R`. See `docs/dev-workflow.md` for the supported boundary. @@ -198,6 +216,12 @@ fn run_internal( // ── 1. Read sand.toml ──────────────────────────────────────────────────── let config_path = std::env::current_dir()?.join("sand.toml"); if !config_path.exists() { + if Path::new(sand_lang::ROOT_FILE).exists() { + bail!( + "this is a Sand language project, which has no sand.toml — \ + use `sand lang run`, and `sand lang build` plus `/reload` after edits" + ); + } bail!("sand.toml not found — run `sand run` from your project root"); } let config: SandConfig = toml::from_str(&std::fs::read_to_string(&config_path)?) @@ -221,7 +245,27 @@ fn run_internal( if preparation_cancelled(console) { return Ok(false); } + let namespace = config.pack.namespace.as_str().to_owned(); + launch( + args, + dev_inputs.map(|inputs| (&config, inputs)), + console, + managed_pack, + &namespace, + &mc_version, + ) +} +/// Prepare `dist/server/`, install the built pack, and run the server. Only +/// `sand dev` passes `watch`; everything else here is project-format agnostic. +fn launch( + args: RunArgs, + watch: Option<(&SandConfig, crate::dev::BuildInputs)>, + console: &mut Option, + managed_pack: &mut crate::dev::ManagedPack, + namespace: &str, + mc_version: &str, +) -> Result { // ── 2b. Read any ServerConfig a sand.build.rs produced (issue #317) ───── // 🖥️ Server (host) only — never part of the datapack. Only present when // the project has a sand.build.rs whose SandBuild configured a @@ -244,7 +288,7 @@ fn run_internal( "Checking".cyan().bold(), mc_version.yellow() ); - let jar_path = sand_build::ensure_server_jar(&mc_version) + let jar_path = sand_build::ensure_server_jar(mc_version) .with_context(|| format!("failed to get server jar for Minecraft {mc_version}"))?; println!( " {} {}", @@ -330,19 +374,18 @@ fn run_internal( ); } - let mut dev = if watch { - Some(crate::dev::Session::new( - &config, + let watching = watch.is_some(); + let mut dev = match watch { + Some((config, inputs)) => Some(crate::dev::Session::new( + config, &args.profile, &props_path, - dev_inputs.expect("dev inputs captured before building"), - )?) - } else { - None + inputs, + )?), + None => None, }; // ── 7. Sync datapack into world/datapacks/ ─────────────────────────────── - let namespace = config.pack.namespace.as_str(); let src = PathBuf::from("dist").join(namespace); let dest = server_dir.join("world").join("datapacks").join(namespace); @@ -356,7 +399,7 @@ fn run_internal( // A failed prior namespace handoff must not be overwritten by this sync, // even in a fresh process or when switching from dev to ordinary run. crate::dev::ensure_handoffs_complete(dest.parent().expect("datapacks parent"))?; - let (sync, committed) = if watch { + let (sync, committed) = if watching { managed_pack .install(&src, &dest) .map(|installed| (installed.stats, Some(installed.identity))) @@ -413,7 +456,7 @@ fn run_internal( let outcome = crate::console::process::run_server_with_dev( command, args.server_log, - &mc_version, + mc_version, dev.as_mut(), console, )?; diff --git a/sand-cli/tests/lang_format.rs b/sand-cli/tests/lang_format.rs new file mode 100644 index 00000000..32ed7e28 --- /dev/null +++ b/sand-cli/tests/lang_format.rs @@ -0,0 +1,35 @@ +//! Exercise both formatter entry points and package-wide failure behavior. +use std::fs; +use std::process::Command; + +#[test] +fn formatter_checks_all_modules_before_writing() { + let dir = tempfile::tempdir().unwrap(); + let root = dir.path().join("pack.sand"); + let module = dir.path().join("logic.sand"); + fs::write(&root, "#![pack(namespace=\"demo\")]\nmod logic;\n").unwrap(); + fs::write(&module, "pub fn run(){let n=2;}\n").unwrap(); + let run = |prefix: &[&str], check: bool| { + let mut cmd = Command::new(env!("CARGO_BIN_EXE_sand")); + cmd.args(prefix).arg(dir.path()); + if check { + cmd.arg("--check"); + } + cmd.output().unwrap() + }; + let original = fs::read(&root).unwrap(); + assert!(!run(&["fmt"], true).status.success()); + assert_eq!(fs::read(&root).unwrap(), original); + assert!(run(&["lang", "fmt"], false).status.success()); + assert!( + fs::read_to_string(&module) + .unwrap() + .contains(" let n = 2;") + ); + assert!(run(&["fmt"], true).status.success()); + let original = fs::read(&root).unwrap(); + fs::write(&module, "fn broken( {").unwrap(); + assert!(!run(&["fmt"], false).status.success()); + assert_eq!(fs::read(&root).unwrap(), original); + assert_eq!(fs::read_to_string(module).unwrap(), "fn broken( {"); +} diff --git a/sand-commands/Cargo.toml b/sand-commands/Cargo.toml index 2d6a94b5..0e746581 100644 --- a/sand-commands/Cargo.toml +++ b/sand-commands/Cargo.toml @@ -12,6 +12,8 @@ keywords = ["minecraft", "datapack", "commands", "gamedev"] categories = ["game-development"] [dependencies] +serde = { version = "1", features = ["derive"] } +schemars = "1" serde_json = "1" iri-string = "0.7" thiserror = "2" diff --git a/sand-commands/src/blocks.rs b/sand-commands/src/blocks.rs index 1c3df94e..a5812a1e 100644 --- a/sand-commands/src/blocks.rs +++ b/sand-commands/src/blocks.rs @@ -632,7 +632,10 @@ pub enum CloneMaskMode { variants(Force = "Force-clone even if blocks overlap.", Move = "Move blocks (clone then clear source).", Normal = "Normal cloning (default)."), )] /// Clone mode for the `clone` command. -#[derive(Debug, Clone, Copy, Default)] +#[derive( + Debug, Clone, Copy, Default, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(rename_all = "snake_case")] pub enum CloneMode { /// Normal cloning (default). #[default] diff --git a/sand-commands/src/nbt.rs b/sand-commands/src/nbt.rs index 4ebedcfb..b38269c1 100644 --- a/sand-commands/src/nbt.rs +++ b/sand-commands/src/nbt.rs @@ -34,7 +34,13 @@ use crate::selector::{Selector, TargetArgument}; variant_fields(Bool = ["Selects the bool NBT or data-command operation."], Byte = ["Selects the byte NBT or data-command operation."], Compound = ["Selects the compound NBT or data-command operation."], Double = ["Selects the double NBT or data-command operation."], Float = ["Selects the float NBT or data-command operation."], Int = ["Selects the int NBT or data-command operation."], List = ["Selects the list NBT or data-command operation."], Long = ["Selects the long NBT or data-command operation."], Raw = ["Explicit opaque SNBT. Sand renders this unchanged and does not parse it."], Short = ["Selects the short NBT or data-command operation."], String = ["Selects the string NBT or data-command operation."]), )] /// A typed SNBT value used by `data modify` and `data merge`. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)] +#[serde( + tag = "type", + content = "value", + rename_all = "snake_case", + deny_unknown_fields +)] pub enum NbtValue { #[doc = "Selects the bool NBT or data-command operation."] Bool(#[doc = "Selects the bool NBT or data-command operation."] bool), @@ -57,6 +63,7 @@ pub enum NbtValue { #[doc = "Selects the compound NBT or data-command operation."] Compound(#[doc = "Selects the compound NBT or data-command operation."] NbtCompound), /// Explicit opaque SNBT. Sand renders this unchanged and does not parse it. + #[serde(skip)] Raw(#[doc = "Explicit opaque SNBT. Sand renders this unchanged and does not parse it."] String), } @@ -132,11 +139,18 @@ impl fmt::Display for NbtValue { Self::Long(value) => write!(f, "{value}L"), Self::Float(value) => write!(f, "{value}f"), Self::Double(value) => write!(f, "{value}d"), - Self::String(value) => write!( - f, - "\"{}\"", - value.replace('\\', "\\\\").replace('"', "\\\"") - ), + Self::String(value) => { + f.write_str("\"")?; + for character in value.chars() { + match character { + '\\' => f.write_str("\\\\")?, + '"' => f.write_str("\\\"")?, + control if control.is_control() => write!(f, "\\u{:04x}", control as u32)?, + other => write!(f, "{other}")?, + } + } + f.write_str("\"") + } Self::List(values) => { let values = values .iter() @@ -201,7 +215,10 @@ impl From for NbtValue { example = "use sand::data::NbtCompound;", )] /// A typed SNBT compound preserving declaration order. -#[derive(Debug, Clone, Default, PartialEq)] +#[derive( + Debug, Clone, Default, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(deny_unknown_fields)] pub struct NbtCompound { entries: Vec<(String, NbtValue)>, } @@ -286,6 +303,12 @@ impl NbtCompound { } } +impl Validate for NbtCompound { + fn validate(&self, _profile: &CommandProfile) -> CommandResult<()> { + validate_compound(self) + } +} + impl fmt::Display for NbtCompound { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let entries = self @@ -909,6 +932,10 @@ impl From> for ReadOnlyNbtRef { } impl ReadOnlyNbtRef { + pub(crate) fn into_parts(self) -> (DataTarget, NbtPath) { + (self.reference.location, self.reference.path) + } + /// Returns the typed path carried by this read-only reference. #[sand_macros::api(registry = sand_api_contract, path = "sand::data::ReadOnlyNbtRef::path_value", aliases = ["sand::cmd::ReadOnlyNbtRef::path_value", "sand::command::ReadOnlyNbtRef::path_value", "sand::prelude::ReadOnlyNbtRef::path_value", "sand::prelude::cmd::ReadOnlyNbtRef::path_value"], module = "sand::data", kind = "method", summary = "Returns the typed path carried by this read-only reference.", context = "The target remains read-only while its path can be inspected or extended.", minecraft = "Emits no command.", use_when = ["Inspecting the addressed NBT path"], avoid_when = ["Mutating NBT"], returns = "The typed NBT path.", example = "use sand::prelude::*; let path = ItemLocation::PlayerMainHand.nbt().path_value().clone();")] pub fn path_value(&self) -> &NbtPath { @@ -1562,7 +1589,26 @@ impl NbtRef { // ── Typed data command IR ──────────────────────────────────────────────────── #[doc = "Defines data modify operation for typed Minecraft NBT and data commands."] -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive( + Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde( + tag = "kind", + content = "index", + rename_all = "snake_case", + deny_unknown_fields +)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::DataModifyOperation", module = "sand::advanced::compiler", + summary = "A canonical typed data-modify operation.", + context = "The same operation model drives typed NBT commands and portable storage-value writes.", + minecraft = "Lowers to set, append, prepend, insert or merge against a validated NBT selection.", + use_when = ["Choosing how a portable storage-value write combines its source and target"], + avoid_when = ["Reading or comparing a stored value"], + example = "let operation = sand::advanced::compiler::DataModifyOperation::Append;", + variants(Set = "Replace the selection.", Append = "Append to a list.", Prepend = "Prepend to a list.", Insert = "Insert at a fixed list offset.", Merge = "Merge compound members."), + variant_fields(Insert = ["Fixed insertion offset, using Minecraft's native negative-offset semantics."]), +)] pub enum DataModifyOperation { #[doc = "Selects the set NBT or data-command operation."] Set, @@ -1755,10 +1801,6 @@ fn validate_value(value: &NbtValue) -> CommandResult<()> { NbtValue::Double(value) if !value.is_finite() => { Err(data_error("value", "SNBT doubles must be finite")) } - NbtValue::String(value) if value.chars().any(char::is_control) => Err(data_error( - "value", - "typed SNBT strings cannot contain control characters", - )), NbtValue::List(values) => { for value in values { validate_value(value)?; diff --git a/sand-commands/src/selector.rs b/sand-commands/src/selector.rs index 4d5d48ba..cd54c64c 100644 --- a/sand-commands/src/selector.rs +++ b/sand-commands/src/selector.rs @@ -365,6 +365,29 @@ impl Target { self } + /// Require a player's completion status for an advancement or one criterion. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::command::Target::advancement", + module = "sand::command", kind = "method", + summary = "Filters players by advancement or criterion progress.", + context = "A whole-advancement requirement replaces criterion requirements for that advancement. Adding another criterion combines it with earlier criterion requirements.", + minecraft = "Renders the native Player selector advancements argument.", + use_when = ["Selecting players by their own advancement progress"], + avoid_when = ["Reading an unrelated scoreboard field"], + params(id = "Namespaced advancement identity.", criterion = "Optional criterion name belonging to the advancement.", complete = "Required completion status."), + returns = "The selector with the advancement filter.", + example = "use sand::command::Target; let selected = Target::all_players().advancement(\"demo:milestone\", None, true);", + )] + pub fn advancement( + mut self, + id: impl Into, + criterion: Option<&str>, + complete: bool, + ) -> Self { + self.raw = self.raw.advancement(id, criterion, complete); + self + } + /// Restricts candidates through a predicate component or canonical resource ID. /// /// Owned and borrowed components reference the resource without registering @@ -1349,6 +1372,40 @@ impl fmt::Display for Selector { } impl Selector { + fn advancement( + mut self, + id: impl Into, + criterion: Option<&str>, + complete: bool, + ) -> Self { + use std::collections::BTreeMap; + let index = self + .args + .iter() + .position(|arg| matches!(arg, SelectorArg::Advancements(_))) + .unwrap_or_else(|| { + self.args.push(SelectorArg::Advancements(BTreeMap::new())); + self.args.len() - 1 + }); + let SelectorArg::Advancements(filters) = &mut self.args[index] else { + unreachable!("index is an advancement argument"); + }; + let id = id.into(); + let progress = match criterion { + Some(criterion) => { + let mut criteria = match filters.remove(&id) { + Some(AdvancementMatch::Criteria(criteria)) => criteria, + _ => BTreeMap::new(), + }; + criteria.insert(criterion.to_owned(), complete); + AdvancementMatch::Criteria(criteria) + } + None => AdvancementMatch::Complete(complete), + }; + filters.insert(id, progress); + self + } + pub(crate) fn is_statically_single(&self) -> bool { if let Some(limit) = self.args.iter().find_map(|arg| match arg { SelectorArg::Limit(limit) => Some(*limit), @@ -2111,6 +2168,22 @@ impl fmt::Display for GameMode { mod tests { use super::*; + #[test] + fn advancement_builder_composes_named_criteria_and_whole_requirements() { + let selected = Target::self_() + .advancement("demo:quest", Some("find ore"), true) + .advancement("demo:quest", Some("win"), false) + .advancement("demo:badge", None, true); + assert_eq!( + selected.to_string(), + r#"@s[advancements={demo:badge=true,demo:quest={"find ore"=true,win=false}}]"# + ); + assert_eq!( + selected.advancement("demo:quest", None, true).to_string(), + "@s[advancements={demo:badge=true,demo:quest=true}]" + ); + } + #[test] fn current_dimension_scope_composes_with_distance_and_cardinality() { let profile = CommandProfile::unprofiled(); diff --git a/sand-commands/src/text.rs b/sand-commands/src/text.rs index 538b4452..b2b8e299 100644 --- a/sand-commands/src/text.rs +++ b/sand-commands/src/text.rs @@ -125,7 +125,13 @@ impl fmt::Display for ChatColor { variant_fields(ChangePage = ["Emit `change_page` with a numeric page value (written books only)."], CopyToClipboard = ["Copy text to the clipboard."], OpenUrl = ["Open a URL in the player's browser."], RunCommand = ["Execute a command when clicked."], SuggestCommand = ["Fill the chat bar with a command suggestion."]), )] /// A click event attached to a [`TextComponent`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)] +#[serde( + tag = "kind", + content = "value", + rename_all = "snake_case", + deny_unknown_fields +)] pub enum ClickEvent { /// Execute a command when clicked. RunCommand(#[doc = "Execute a command when clicked."] String), @@ -142,6 +148,24 @@ pub enum ClickEvent { ChangePage(#[doc = "Emit `change_page` with a numeric page value (written books only)."] u32), } +impl ClickEvent { + /// Check the payload using the same vanilla rules as a text component. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::text::ClickEvent::validate", + module = "sand::text", kind = "method", + summary = "Checks the payload of a Minecraft text click event.", + context = "Use before attaching a portable or authored click action to a text component. It uses the same payload checks as component serialization.", + minecraft = "Validates command text characters, HTTP(S) URLs, and one-indexed book pages.", + use_when = ["Validating an independently authored click event"], + avoid_when = ["Checking whether a UI surface supports clicking"], + returns = "Unit for a valid payload, or a command error with the click payload path.", + example = "sand::text::ClickEvent::SuggestCommand(\"/trigger next\".into()).validate()?;", + )] + pub fn validate(&self) -> CommandResult<()> { + validate_click(self, "text") + } +} + #[sand_macros::api( registry = sand_api_contract, path = "sand::text::HoverEvent", @@ -283,6 +307,11 @@ enum TextContent { with: Vec, }, Keybind(String), + Nbt { + target: crate::DataTarget, + path: crate::NbtPath, + separator: Box, + }, } #[derive(Debug, Clone)] @@ -593,6 +622,33 @@ impl TextComponent { Self::new(TextContent::Keybind(key.into())) } + /// Render readable NBT as plain text, joining multiple selected values with + /// `separator`. Stored text is never interpreted as JSON or command source. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::text::TextComponent::nbt", + aliases = ["sand::cmd::TextComponent::nbt", "sand::command::TextComponent::nbt", "sand::prelude::TextComponent::nbt", "sand::prelude::cmd::TextComponent::nbt"], + module = "sand::text", kind = "method", + summary = "Render readable NBT as plain text with an explicit separator.", + context = "The typed NBT reference selects storage, entity or block data; read-only views are accepted.", + minecraft = "Builds a validated NBT text component with interpret=false, preserving arbitrary stored text as text.", + use_when = ["Displaying runtime strings or values from command storage"], + avoid_when = ["Displaying a known literal or a scoreboard value"], + params(reference = "Readable typed NBT selection.", separator = "Component displayed between selected values."), + returns = "A plain-text NBT component that supports ordinary styling.", + example = "use sand::prelude::*; let text = TextComponent::nbt(sand::data::Nbt::storage(ResourceLocation::new(\"demo\", \"state\").unwrap()).path(\"name\"), TextComponent::literal(\"\"));", + )] + pub fn nbt( + reference: impl Into>, + separator: TextComponent, + ) -> Self { + let (target, path) = reference.into().into_parts(); + Self::new(TextContent::Nbt { + target, + path, + separator: Box::new(separator), + }) + } + fn new(content: TextContent) -> Self { Self { content, @@ -1096,6 +1152,24 @@ impl TextComponent { // ── Click events ────────────────────────────────────────────────────────── + /// Attach a typed click event to this component. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::text::TextComponent::with_click_event", + module = "sand::text", kind = "method", + summary = "Attaches a typed click event to a text component.", + context = "Use when an existing authoring model supplies a ClickEvent. The new event replaces any click event on the same component.", + minecraft = "Serializes a native click event and validates its payload with the text component.", + use_when = ["Attaching a click event constructed before the text component"], + avoid_when = ["Adding hover text"], + params(event = "The click event associated with the component."), + returns = "The component with the supplied native click event.", + example = "let action = sand::text::ClickEvent::CopyToClipboard(\"checkpoint\".into()); let text = sand::text::TextComponent::literal(\"Copy\").with_click_event(action);", + )] + pub fn with_click_event(mut self, event: ClickEvent) -> Self { + self.click_event = Some(event); + self + } + /// Run a command when this text is clicked. #[sand_macros::api( registry = sand_api_contract, @@ -1112,9 +1186,8 @@ impl TextComponent { returns = "The `TextComponent` value with the documented change applied to run a command when this text is clicked.", example = "use sand::prelude::*;\n\nfn demonstrate(text_component_value: sand::text::TextComponent, cmd: impl Into < String >) {\n let updated_text_component = text_component_value.click_run_command(cmd);\n}", )] - pub fn click_run_command(mut self, cmd: impl Into) -> Self { - self.click_event = Some(ClickEvent::RunCommand(cmd.into())); - self + pub fn click_run_command(self, cmd: impl Into) -> Self { + self.with_click_event(ClickEvent::RunCommand(cmd.into())) } /// Fill the chat bar with a suggestion when clicked. @@ -1133,9 +1206,8 @@ impl TextComponent { returns = "The `TextComponent` value with the documented change applied to fill the chat bar with a suggestion when clicked.", example = "use sand::prelude::*;\n\nfn demonstrate(text_component_value: sand::text::TextComponent, cmd: impl Into < String >) {\n let updated_text_component = text_component_value.click_suggest_command(cmd);\n}", )] - pub fn click_suggest_command(mut self, cmd: impl Into) -> Self { - self.click_event = Some(ClickEvent::SuggestCommand(cmd.into())); - self + pub fn click_suggest_command(self, cmd: impl Into) -> Self { + self.with_click_event(ClickEvent::SuggestCommand(cmd.into())) } /// Open a URL when clicked. @@ -1154,9 +1226,8 @@ impl TextComponent { returns = "The `TextComponent` value with the documented change applied to open a URL when clicked.", example = "use sand::prelude::*;\n\nfn demonstrate(text_component_value: sand::text::TextComponent, url: impl Into < String >) {\n let updated_text_component = text_component_value.click_open_url(url);\n}", )] - pub fn click_open_url(mut self, url: impl Into) -> Self { - self.click_event = Some(ClickEvent::OpenUrl(url.into())); - self + pub fn click_open_url(self, url: impl Into) -> Self { + self.with_click_event(ClickEvent::OpenUrl(url.into())) } /// Copy text to the clipboard when clicked. @@ -1178,9 +1249,8 @@ impl TextComponent { returns = "The `TextComponent` value with the documented change applied to copy text to the clipboard when clicked. `text` is the literal clipboard payload; it is not rendered as the player-visible label of this component.", example = "use sand::prelude::*;\n\nfn demonstrate(text_component_value: sand::text::TextComponent, text: impl Into < String >) {\n let updated_text_component = text_component_value.click_copy(text);\n}", )] - pub fn click_copy(mut self, text: impl Into) -> Self { - self.click_event = Some(ClickEvent::CopyToClipboard(text.into())); - self + pub fn click_copy(self, text: impl Into) -> Self { + self.with_click_event(ClickEvent::CopyToClipboard(text.into())) } /// Emit a `change_page` click event for a page inside a written book. @@ -1427,6 +1497,22 @@ impl TextComponent { } } TextContent::Keybind(key) => serde_json::json!({ "keybind": key }), + TextContent::Nbt { + target, + path, + separator, + } => { + let mut value = serde_json::json!({ "nbt": path.as_str(), "interpret": false, "separator": separator.to_json_value() }); + let (kind, source) = match target { + crate::DataTarget::Storage(id) | crate::DataTarget::StorageRaw(id) => { + ("storage", id.clone()) + } + crate::DataTarget::Entity(selector) => ("entity", selector.to_string()), + crate::DataTarget::Block(position) => ("block", position.to_string()), + }; + value[kind] = serde_json::Value::String(source); + value + } }; if let Some(c) = &self.color { obj["color"] = serde_json::json!(c); @@ -1584,6 +1670,14 @@ impl TextComponent { match &self.content { TextContent::Literal(_) => {} + TextContent::Nbt { + target, + path: selection, + separator, + } => { + crate::nbt::validate_ref_parts(target, selection, false, profile)?; + separator.validate_inner(profile, &format!("{path}.separator"), depth + 1)?; + } TextContent::Score { name, objective } => { validate_score_holder(name).map_err(|error| { text_error( diff --git a/sand-commands/tests/stored_text.rs b/sand-commands/tests/stored_text.rs new file mode 100644 index 00000000..253412fe --- /dev/null +++ b/sand-commands/tests/stored_text.rs @@ -0,0 +1,40 @@ +use sand_commands::{CommandProfile, DataTarget, NbtValue, TextComponent}; + +#[test] +fn typed_strings_escape_every_control_character_without_command_injection() { + let value = "\0\n\r\t\u{001b}\u{007f}\u{0085}\"\\$(uuid) 🌍"; + let literal = NbtValue::String(value.into()); + let expected = r#""\u0000\u000a\u000d\u0009\u001b\u007f\u0085\"\\$(uuid) 🌍""#; + assert_eq!(literal.to_string(), expected); + for version in ["26.2", "26.3"] { + let rendered = DataTarget::storage("demo:state") + .path("text") + .set(literal.clone()) + .try_render(&CommandProfile::new(version, false)) + .unwrap(); + assert!(!rendered.chars().any(char::is_control)); + assert!(rendered.ends_with(expected)); + } + let encoded = serde_json::to_string(&literal).unwrap(); + assert_eq!(serde_json::from_str::(&encoded).unwrap(), literal); + assert!(serde_json::to_string(&NbtValue::List(vec![NbtValue::raw("[]")])).is_err()); + assert!(serde_json::from_str::(r#"{"type":"raw","value":"[]"}"#).is_err()); +} + +#[test] +fn typed_nbt_text_stays_plain_and_validates_its_readable_reference() { + let text = TextComponent::nbt( + DataTarget::storage("demo:state").path("characters[]"), + TextComponent::literal(""), + ); + let json = text.try_to_json_value().unwrap(); + assert_eq!(json["storage"], "demo:state"); + assert_eq!(json["nbt"], "characters[]"); + assert_eq!(json["interpret"], false); + assert_eq!(json["separator"]["text"], ""); + let invalid = TextComponent::nbt( + DataTarget::storage("bad storage").path("characters[]"), + TextComponent::literal(""), + ); + assert!(invalid.try_to_json_value().is_err()); +} diff --git a/sand-components/Cargo.toml b/sand-components/Cargo.toml index fc758434..20cad835 100644 --- a/sand-components/Cargo.toml +++ b/sand-components/Cargo.toml @@ -15,6 +15,7 @@ categories = ["game-development", "data-structures"] [dependencies] serde = { version = "1", features = ["derive"] } serde_json = "1" +schemars = "1" thiserror = "2" sand-commands = { path = "../sand-commands" } sand-api-contract = { path = "../sand-api-contract" } diff --git a/sand-components/src/advancement/mod.rs b/sand-components/src/advancement/mod.rs index 2e25b030..1057a32f 100644 --- a/sand-components/src/advancement/mod.rs +++ b/sand-components/src/advancement/mod.rs @@ -3344,7 +3344,7 @@ impl AdvancementRewards { summary = "Sets a function to execute as a reward.", context = "Sets a function to execute as a reward. This semantic component model describes a datapack resource or gameplay value; JSON serialization and exporter bookkeeping remain implementation details.", minecraft = "The value serializes to the matching version-aware Minecraft datapack JSON schema when the project is exported.", - use_when = ["Defining a typed advancement, recipe, loot table, worldgen resource, item property, or related datapack component"], + use_when = ["React to an advancement by running a function as the completing player"], avoid_when = ["Injecting unchecked JSON when the typed schema can represent the resource"], params(func = "`func` provides the typed Minecraft resource identifier used to set a function to execute as a reward."), returns = "The `AdvancementRewards` value with the documented change applied to set a function to execute as a reward.", diff --git a/sand-components/src/damage_type/mod.rs b/sand-components/src/damage_type/mod.rs index 222d7ebc..91f3ff6a 100644 --- a/sand-components/src/damage_type/mod.rs +++ b/sand-components/src/damage_type/mod.rs @@ -24,7 +24,20 @@ use crate::resource_location::ResourceLocation; use crate::validation; /// Controls how damage scales with difficulty. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageScaling", module = "sand::component", + summary = "Selects how native damage scales with difficulty.", + context = "A typed option for a native damage type resource.", + minecraft = "Serializes to the corresponding built-in value in damage_type JSON.", + use_when = ["Defining a native damage type"], + avoid_when = ["Changing the raw amount dealt by a command"], + example = "let option = sand::component::DamageScaling::Never;", + variants(Never = "Do not scale.", WhenCausedByLivingNonPlayer = "Scale damage from living non-player attackers.", Always = "Always scale with difficulty."), +)] pub enum DamageScaling { /// Damage does not scale with difficulty. Never, @@ -35,6 +48,14 @@ pub enum DamageScaling { } impl DamageScaling { + /// Returns the exact identifier used in native damage type JSON. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageScaling::as_str", module = "sand::component", kind = "method", + summary = "Returns the native damage option identifier.", context = "The typed resource builder uses this same serialization.", + minecraft = "Returns the value accepted by the damage type codec.", use_when = ["Inspecting a native option"], + avoid_when = ["Supplying this enum directly to a typed builder"], returns = "Static native option identifier.", + example = "let name = sand::component::DamageScaling::Never.as_str();", + )] pub fn as_str(self) -> &'static str { match self { DamageScaling::Never => "never", @@ -45,7 +66,20 @@ impl DamageScaling { } /// The visual/sound effect played when this damage type is dealt. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageEffects", module = "sand::component", + summary = "Selects the native effect when an entity takes damage.", + context = "A typed option for a native damage type resource.", + minecraft = "Serializes to the corresponding built-in value in damage_type JSON.", + use_when = ["Defining a native damage type"], + avoid_when = ["Changing the raw amount dealt by a command"], + example = "let option = sand::component::DamageEffects::Hurt;", + variants(Hurt = "Normal hurt effect.", Thorns = "Thorns effect.", Drowning = "Drowning effect.", Burning = "Burning effect.", Poking = "Poking effect.", Freezing = "Freezing effect."), +)] pub enum DamageEffects { Hurt, Thorns, @@ -56,6 +90,14 @@ pub enum DamageEffects { } impl DamageEffects { + /// Returns the exact identifier used in native damage type JSON. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageEffects::as_str", module = "sand::component", kind = "method", + summary = "Returns the native damage option identifier.", context = "The typed resource builder uses this same serialization.", + minecraft = "Returns the value accepted by the damage type codec.", use_when = ["Inspecting a native option"], + avoid_when = ["Supplying this enum directly to a typed builder"], returns = "Static native option identifier.", + example = "let name = sand::component::DamageEffects::Hurt.as_str();", + )] pub fn as_str(self) -> &'static str { match self { DamageEffects::Hurt => "hurt", @@ -69,7 +111,20 @@ impl DamageEffects { } /// Controls the format of the death message for this damage type. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DeathMessageType", module = "sand::component", + summary = "Selects the native death message format.", + context = "A typed option for a native damage type resource.", + minecraft = "Serializes to the corresponding built-in value in damage_type JSON.", + use_when = ["Defining a native damage type"], + avoid_when = ["Changing the raw amount dealt by a command"], + example = "let option = sand::component::DeathMessageType::Default;", + variants(Default = "Default death message.", FallVariants = "Fall-specific variants.", IntentionalGameDesign = "Intentional-game-design suffix."), +)] pub enum DeathMessageType { Default, FallVariants, @@ -77,6 +132,14 @@ pub enum DeathMessageType { } impl DeathMessageType { + /// Returns the exact identifier used in native damage type JSON. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DeathMessageType::as_str", module = "sand::component", kind = "method", + summary = "Returns the native damage option identifier.", context = "The typed resource builder uses this same serialization.", + minecraft = "Returns the value accepted by the damage type codec.", use_when = ["Inspecting a native option"], + avoid_when = ["Supplying this enum directly to a typed builder"], returns = "Static native option identifier.", + example = "let name = sand::component::DeathMessageType::Default.as_str();", + )] pub fn as_str(self) -> &'static str { match self { DeathMessageType::Default => "default", @@ -86,23 +149,54 @@ impl DeathMessageType { } } -/// A Minecraft damage type definition (`data//damage_type/.json`). +fn default_scaling() -> DamageScaling { + DamageScaling::WhenCausedByLivingNonPlayer +} + +/// A Minecraft damage type definition. The portable representation includes +/// the resource identity. Resource export emits the native JSON body. +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType", module = "sand::component", + summary = "Defines a native damage type resource.", + context = "Use the resource's identity with the damage command to select its difficulty, hurt effects, and death message.", + minecraft = "Exports a validated damage_type JSON resource.", + use_when = ["Adding a native source of gameplay damage"], + avoid_when = ["Changing custom health or shield values"], + example = r#"let device = sand::component::DamageType::new("demo:spike".parse().unwrap()).message_id("spike");"#, +)] pub struct DamageType { + #[serde(rename = "id")] + #[schemars(with = "String")] location: ResourceLocation, /// Translation key suffix for death messages (e.g. `"laser"` → `"death.attack.laser"`). message_id: String, /// Hunger exhaustion applied when this damage is taken (0.0–0.4 typical). /// Must be finite and non-negative. No upper bound is enforced. + #[serde(default)] exhaustion: f32, /// Whether the damage scales with difficulty. + #[serde(default = "default_scaling")] scaling: DamageScaling, /// Optional visual/sound effect. + #[serde(default, skip_serializing_if = "Option::is_none")] effects: Option, /// Optional death message format. + #[serde(default, skip_serializing_if = "Option::is_none")] death_message_type: Option, } impl DamageType { + /// Begins a native damage type definition. Set a message ID before export. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType::new", module = "sand::component", kind = "method", + summary = "Begins a native damage type definition.", context = "Set a message ID before export.", + minecraft = "Defines the corresponding part of the native damage type resource.", + use_when = ["Authoring a native damage subtype"], avoid_when = ["Configuring an individual damage command"], + params(location = "The resource identity."), returns = "The damage type definition.", + example = r#"let definition = sand::component::DamageType::new("demo:spike".parse().unwrap());"#, + )] pub fn new(location: ResourceLocation) -> Self { Self { location, @@ -114,26 +208,71 @@ impl DamageType { } } + /// Sets the suffix of the death message key. The suffix must contain text and no control characters. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType::message_id", module = "sand::component", kind = "method", + summary = "Sets the suffix of the death message key.", context = "The suffix must contain text and no control characters.", + minecraft = "Defines the corresponding part of the native damage type resource.", + use_when = ["Authoring a native damage subtype"], avoid_when = ["Configuring an individual damage command"], + params(id = "Suffix of the death.attack translation key."), returns = "The damage type definition.", + example = r#"let definition = sand::component::DamageType::new("demo:spike".parse().unwrap()).message_id("spike");"#, + )] pub fn message_id(mut self, id: impl Into) -> Self { self.message_id = id.into(); self } + /// Sets how much hunger exhaustion this damage causes. The value is stored in the native exhaustion field. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType::exhaustion", module = "sand::component", kind = "method", + summary = "Sets how much hunger exhaustion this damage causes.", context = "The value is stored in the native exhaustion field.", + minecraft = "Defines the corresponding part of the native damage type resource.", + use_when = ["Authoring a native damage subtype"], avoid_when = ["Configuring an individual damage command"], + params(exhaustion = "Finite, non-negative hunger exhaustion."), returns = "The damage type definition.", + example = r#"let definition = sand::component::DamageType::new("demo:spike".parse().unwrap()).exhaustion(0.1);"#, + )] pub fn exhaustion(mut self, exhaustion: f32) -> Self { self.exhaustion = exhaustion; self } + /// Controls whether difficulty changes this damage. The native damage type codec reads the chosen scaling mode. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType::scaling", module = "sand::component", kind = "method", + summary = "Controls whether difficulty changes this damage.", context = "The native damage type codec reads the chosen scaling mode.", + minecraft = "Defines the corresponding part of the native damage type resource.", + use_when = ["Authoring a native damage subtype"], avoid_when = ["Configuring an individual damage command"], + params(scaling = "Difficulty scaling policy."), returns = "The damage type definition.", + example = r#"let definition = sand::component::DamageType::new("demo:spike".parse().unwrap()).scaling(sand::component::DamageScaling::Never);"#, + )] pub fn scaling(mut self, scaling: DamageScaling) -> Self { self.scaling = scaling; self } + /// Sets the effect played after a hit. The native damage type codec reads this effect. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType::effects", module = "sand::component", kind = "method", + summary = "Sets the effect played after a hit.", context = "The native damage type codec reads this effect.", + minecraft = "Defines the corresponding part of the native damage type resource.", + use_when = ["Authoring a native damage subtype"], avoid_when = ["Configuring an individual damage command"], + params(effects = "Native damage effect."), returns = "The damage type definition.", + example = r#"let definition = sand::component::DamageType::new("demo:spike".parse().unwrap()).effects(sand::component::DamageEffects::Thorns);"#, + )] pub fn effects(mut self, effects: DamageEffects) -> Self { self.effects = Some(effects); self } + /// Sets which native format handles the death message. The selected format controls the message suffix and parameters. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::DamageType::death_message_type", module = "sand::component", kind = "method", + summary = "Sets which native format handles the death message.", context = "The selected format controls the message suffix and parameters.", + minecraft = "Defines the corresponding part of the native damage type resource.", + use_when = ["Authoring a native damage subtype"], avoid_when = ["Configuring an individual damage command"], + params(t = "Native death message format."), returns = "The damage type definition.", + example = r#"let definition = sand::component::DamageType::new("demo:spike".parse().unwrap()).death_message_type(sand::component::DeathMessageType::Default);"#, + )] pub fn death_message_type(mut self, t: DeathMessageType) -> Self { self.death_message_type = Some(t); self diff --git a/sand-components/src/item/mod.rs b/sand-components/src/item/mod.rs index 2479bf6c..703c5f0a 100644 --- a/sand-components/src/item/mod.rs +++ b/sand-components/src/item/mod.rs @@ -1639,7 +1639,10 @@ impl ConsumableProperties { /// Equipment slot for the `equippable` item component. /// /// Specifies which equipment slot an item can be equipped into. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(rename_all = "snake_case")] pub enum EquipmentSlot { /// Head armor slot. Head, diff --git a/sand-components/src/recipe/mod.rs b/sand-components/src/recipe/mod.rs index b6bc4b7c..bd48eeeb 100644 --- a/sand-components/src/recipe/mod.rs +++ b/sand-components/src/recipe/mod.rs @@ -103,7 +103,7 @@ mod tests { json!({"id": "audit:result", "count": 2}) ); - let trim = SmithingTrimRecipe::new(id("trim")) + let trim = SmithingTrimRecipe::new(id("trim"), "minecraft:sentry".parse().unwrap()) .template(Ingredient::item( "minecraft:sentry_armor_trim_smithing_template", )) @@ -388,7 +388,7 @@ mod tests { .to_string() .contains("template") ); - let trim = SmithingTrimRecipe::new(id("trim_missing")) + let trim = SmithingTrimRecipe::new(id("trim_missing"), "minecraft:sentry".parse().unwrap()) .template(Ingredient::item("minecraft:template")); assert!(trim.try_content().unwrap_err().to_string().contains("base")); } diff --git a/sand-components/src/recipe/smithing.rs b/sand-components/src/recipe/smithing.rs index 67498797..3b25f017 100644 --- a/sand-components/src/recipe/smithing.rs +++ b/sand-components/src/recipe/smithing.rs @@ -177,7 +177,7 @@ impl SmithingTransformRecipe { ("base", &self.base), ("addition", &self.addition), ], - Some(&self.result), + ("result", serde_json::to_value(&self.result)?), ) } } @@ -242,28 +242,30 @@ pub struct SmithingTrimRecipe { template: Ingredient, base: Ingredient, addition: Ingredient, + pattern: ResourceLocation, } impl SmithingTrimRecipe { - /// Creates a new smithing trim recipe with the given resource location. + /// Creates a smithing trim recipe for the given armor trim pattern. #[sand_macros::api( registry = sand_api_contract, path = "sand::component::SmithingTrimRecipe::new", aliases = ["sand::prelude::SmithingTrimRecipe::new"], module = "sand::component", kind = "method", - summary = "Creates a new smithing trim recipe with the given resource location.", - context = "Creates a new smithing trim recipe with the given resource location. This semantic component model describes a datapack resource or gameplay value; JSON serialization and exporter bookkeeping remain implementation details.", + summary = "Creates a smithing trim recipe for the given armor trim pattern.", + context = "Creates a smithing trim recipe for the given armor trim pattern. This semantic component model describes a datapack resource or gameplay value; JSON serialization and exporter bookkeeping remain implementation details.", minecraft = "The value serializes to the matching version-aware Minecraft datapack JSON schema when the project is exported.", use_when = ["Defining a typed advancement, recipe, loot table, worldgen resource, item property, or related datapack component"], avoid_when = ["Injecting unchecked JSON when the typed schema can represent the resource"], - params(location = "`location` provides the typed resource identifier or location used to create a new smithing trim recipe with the given resource location."), + params(location = "The recipe identifier.", pattern = "The trim pattern applied to the input armor."), returns = "A `SmithingTrimRecipe` representing a new smithing trim recipe with the given resource location.", - example = "use sand::prelude::*;\n\nfn demonstrate(location: sand::ResourceLocation) {\n let smithing_trim_recipe = sand::component::SmithingTrimRecipe::new(location);\n}", + example = "use sand::prelude::*;\n\nfn demonstrate(location: sand::ResourceLocation, pattern: sand::ResourceLocation) {\n let smithing_trim_recipe = sand::component::SmithingTrimRecipe::new(location, pattern);\n}", )] - pub fn new(location: ResourceLocation) -> Self { + pub fn new(location: ResourceLocation, pattern: ResourceLocation) -> Self { Self { location, + pattern, group: None, template: Ingredient::empty(), base: Ingredient::empty(), @@ -364,7 +366,7 @@ impl SmithingTrimRecipe { ("base", &self.base), ("addition", &self.addition), ], - None, + ("pattern", serde_json::to_value(&self.pattern)?), ) } } @@ -401,7 +403,7 @@ fn build_smithing_json<'a>( kind: &str, group: Option<&String>, ingredients: impl IntoIterator, - result: Option<&RecipeResult>, + output: (&str, Value), ) -> SandResult { let mut map = serde_json::Map::new(); map.insert("type".into(), Value::String(kind.into())); @@ -414,11 +416,6 @@ fn build_smithing_json<'a>( serde_json::to_value(ingredient).map_err(SandError::from)?, ); } - if let Some(result) = result { - map.insert( - "result".into(), - serde_json::to_value(result).map_err(SandError::from)?, - ); - } + map.insert(output.0.into(), output.1); Ok(Value::Object(map)) } diff --git a/sand-components/src/structure_template.rs b/sand-components/src/structure_template.rs index a15b59c5..da9422b4 100644 --- a/sand-components/src/structure_template.rs +++ b/sand-components/src/structure_template.rs @@ -1,3 +1,5 @@ +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use serde_json::Value; use crate::component::DatapackComponent; @@ -20,9 +22,13 @@ use crate::resource_location::ResourceLocation; /// Structure templates are binary NBT assets. Sand treats them as copy-backed /// datapack components and writes them under /// `data//structure/.nbt`. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] pub struct StructureTemplate { + #[serde(rename = "id")] + #[schemars(with = "String")] location: ResourceLocation, + #[serde(rename = "source")] source_path: String, } @@ -82,6 +88,27 @@ impl DatapackComponent for StructureTemplate { Value::Null } + fn validate(&self) -> crate::error::Result<()> { + if !self.source_path.ends_with(".nbt") + || self.source_path.contains(['\0', '\\', ':']) + || self + .source_path + .split('/') + .any(|component| component.is_empty() || component == "..") + { + return Err(crate::validation::error( + &self.location, + "structure", + "source", + &format!( + "unsafe structure template source path '{}'; expected a project-root-relative .nbt file", + self.source_path + ), + )); + } + Ok(()) + } + fn component_dir(&self) -> &'static str { "structure" } diff --git a/sand-components/src/worldgen/biome.rs b/sand-components/src/worldgen/biome.rs index 88b5734b..869067a6 100644 --- a/sand-components/src/worldgen/biome.rs +++ b/sand-components/src/worldgen/biome.rs @@ -9,6 +9,8 @@ use std::collections::BTreeMap; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use serde_json::Value; use crate::SoundEventDefinition; @@ -45,7 +47,8 @@ const GENERATION_STEP_COUNT: usize = 11; avoid_when = ["Choosing spawn weights or group sizes; use SpawnEntry"], example = "use sand::component::SpawnCost; let cost = SpawnCost::new(1.0, 0.2);", )] -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] pub struct SpawnCost { energy_budget: f64, charge: f64, @@ -416,6 +419,10 @@ pub struct BiomeEffects { music: Option, } +fn rgb_json(color: u32) -> Value { + Value::String(format!("#{color:06x}")) +} + impl BiomeEffects { /// Creates effects with the minimum required colors. #[sand_macros::api( @@ -527,29 +534,25 @@ impl BiomeEffects { self } + fn visual_attributes(&self) -> serde_json::Map { + [ + ("minecraft:visual/fog_color", self.fog_color), + ("minecraft:visual/water_fog_color", self.water_fog_color), + ("minecraft:visual/sky_color", self.sky_color), + ] + .into_iter() + .map(|(name, color)| (name.to_owned(), rgb_json(color))) + .collect() + } + fn to_json(&self) -> Value { let mut map = serde_json::Map::new(); - map.insert( - "fog_color".to_string(), - Value::Number(self.fog_color.into()), - ); - map.insert( - "water_color".to_string(), - Value::Number(self.water_color.into()), - ); - map.insert( - "water_fog_color".to_string(), - Value::Number(self.water_fog_color.into()), - ); - map.insert( - "sky_color".to_string(), - Value::Number(self.sky_color.into()), - ); - if let Some(gc) = self.grass_color { - map.insert("grass_color".to_string(), Value::Number(gc.into())); + map.insert("water_color".to_owned(), rgb_json(self.water_color)); + if let Some(color) = self.grass_color { + map.insert("grass_color".to_owned(), rgb_json(color)); } - if let Some(fc) = self.foliage_color { - map.insert("foliage_color".to_string(), Value::Number(fc.into())); + if let Some(color) = self.foliage_color { + map.insert("foliage_color".to_owned(), rgb_json(color)); } if let Some(ref p) = self.particle { map.insert("particle".to_string(), p.clone()); @@ -684,7 +687,7 @@ impl CarvingStep { )] pub struct Biome { location: ResourceLocation, - /// Whether it rains (false = snows if cold enough). + /// Whether the biome has rain or snow. Temperature selects the form. has_precipitation: bool, /// Temperature used for mob spawning and weather (typical range -0.5–2.0). temperature: f32, @@ -1079,12 +1082,11 @@ impl DatapackComponent for Biome { fn to_json(&self) -> Value { let mut map = serde_json::Map::new(); + let mut attributes = self.effects.visual_attributes(); if let Some(sounds) = &self.ambient_sounds { - map.insert( - "attributes".into(), - serde_json::json!({AMBIENT_SOUNDS_ATTRIBUTE: sounds.to_json()}), - ); + attributes.insert(AMBIENT_SOUNDS_ATTRIBUTE.into(), sounds.to_json()); } + map.insert("attributes".into(), Value::Object(attributes)); map.insert( "has_precipitation".to_string(), @@ -1282,6 +1284,33 @@ mod tests { ); } + #[test] + fn visual_environment_attributes_share_the_attributes_map_with_ambient_audio() { + let sound = SoundEventDefinition::reference( + crate::SoundEventId::minecraft("ambient.cave").unwrap(), + ); + let biome = Biome::new(location(), effects().grass_color(0x001010)) + .ambient_sounds(BiomeAmbientSounds::new().loop_sound(sound)); + let json = biome.to_json(); + assert_eq!(json["attributes"]["minecraft:visual/fog_color"], "#c0d8ff"); + assert_eq!( + json["attributes"]["minecraft:visual/water_fog_color"], + "#050533" + ); + assert_eq!(json["attributes"]["minecraft:visual/sky_color"], "#78a7ff"); + assert_eq!( + json["attributes"][AMBIENT_SOUNDS_ATTRIBUTE], + serde_json::json!({"loop": "minecraft:ambient.cave", "additions": []}) + ); + assert_eq!( + json["effects"], + serde_json::json!({ + "water_color": "#3f76e4", + "grass_color": "#001010", + }) + ); + } + #[test] fn valid_biome_exports_unchanged() { let biome = Biome::new(location(), effects()) diff --git a/sand-components/src/worldgen/generator.rs b/sand-components/src/worldgen/generator.rs index 87ff86cd..f222a76f 100644 --- a/sand-components/src/worldgen/generator.rs +++ b/sand-components/src/worldgen/generator.rs @@ -10,6 +10,8 @@ use crate::registry::{BiomeId, BlockId, NoiseSettingsId}; use crate::resource_location::ResourceLocation; use crate::{error::Result as SandResult, validation}; use sand_macros::api; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; // FlatLevelGeneratorSettings validates the sum against DimensionType.Y_SIZE. @@ -20,7 +22,8 @@ const MAX_FLAT_HEIGHT: u64 = 4064; /// bottom of the column upward. /// /// 🌍 World (datapack). -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] #[api( registry = sand_api_contract, path = "sand::build::FlatLayer", @@ -36,6 +39,7 @@ const MAX_FLAT_HEIGHT: u64 = 4064; )] pub struct FlatLayer { /// Block resource location, e.g. `"minecraft:stone"`. + #[schemars(with = "String")] pub block: BlockId, /// Number of blocks this layer occupies (must be `> 0`). pub height: u32, @@ -70,7 +74,8 @@ impl FlatLayer { /// blocks. The referenced dimension type determines the usable world height. /// /// 🌍 World (datapack) — lowers to a `minecraft:flat` chunk generator. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] #[api( registry = sand_api_contract, path = "sand::build::FlatGenerator", @@ -88,6 +93,7 @@ pub struct FlatGenerator { /// Bottom-to-top layer stack, validated on dimension export. pub layers: Vec, /// The biome used for every column. + #[schemars(with = "String")] pub biome_id: BiomeId, /// Whether to allow Minecraft's default structure sets. pub structures: bool, diff --git a/sand-components/src/worldgen/structure.rs b/sand-components/src/worldgen/structure.rs index 99b64ced..db7b5bfb 100644 --- a/sand-components/src/worldgen/structure.rs +++ b/sand-components/src/worldgen/structure.rs @@ -7,6 +7,8 @@ use std::collections::BTreeMap; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use crate::component::DatapackComponent; @@ -197,7 +199,10 @@ impl TerrainAdaptation { variants(Ambient = "Targets Minecraft's ambient mob category.", Axolotls = "Targets Minecraft's axolotls mob category.", Creature = "Targets Minecraft's creature mob category.", Misc = "Targets Minecraft's misc mob category.", Monster = "Targets Minecraft's monster mob category.", UndergroundWaterCreature = "Targets Minecraft's underground water creature mob category.", WaterAmbient = "Targets Minecraft's water ambient mob category.", WaterCreature = "Targets Minecraft's water creature mob category."), )] /// A vanilla mob category used as a spawn-override key. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema, +)] +#[serde(rename_all = "snake_case")] pub enum MobCategory { #[doc = "Targets Minecraft's monster mob category."] Monster, @@ -306,8 +311,10 @@ impl SpawnBoundingBox { example = "use sand::component::SpawnEntry;", )] /// One weighted mob-spawn entry for a biome or [`SpawnOverride`]. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] pub struct SpawnEntry { + #[schemars(with = "String")] entity_type: EntityTypeId, weight: u32, min_count: u32, @@ -342,6 +349,22 @@ impl SpawnEntry { } } + /// The entity admitted by this weighted entry. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::component::SpawnEntry::entity_type", + aliases = ["sand::prelude::SpawnEntry::entity_type"], module = "sand::component", + summary = "Read the entity type in one weighted spawn entry.", + context = "Inspect the entry before validating it against the target’s entity registry.", + minecraft = "Returns the typed registry identity emitted as the spawn entry’s type.", + use_when = ["Checking or comparing the entity in a biome or structure spawn table"], + avoid_when = ["Changing the entity; create a new SpawnEntry"], + returns = "The entity type in this entry.", + example = "use sand::component::SpawnEntry;", + )] + pub fn entity_type(&self) -> &EntityTypeId { + &self.entity_type + } + pub(crate) fn to_json(&self) -> Value { serde_json::json!({ "type": self.entity_type.to_string(), diff --git a/sand-components/tests/biome_ambient_sounds.rs b/sand-components/tests/biome_ambient_sounds.rs index eb87d0b6..feca2203 100644 --- a/sand-components/tests/biome_ambient_sounds.rs +++ b/sand-components/tests/biome_ambient_sounds.rs @@ -41,7 +41,11 @@ fn typed_audio_moves_to_native_attribute_with_shared_holders() { for key in ["ambient_sound", "mood_sound", "additions_sound"] { assert!(value.to_json()["effects"].get(key).is_none()); } - assert!(biome().to_json().get("attributes").is_none()); + assert!( + biome().to_json()["attributes"] + .get("minecraft:audio/ambient_sounds") + .is_none() + ); assert_eq!( audio(&biome().ambient_sounds(BiomeAmbientSounds::new())), json!({"additions":[]}) diff --git a/sand-components/tests/canonical_26_2_components.rs b/sand-components/tests/canonical_26_2_components.rs index 4cd36e74..6e8c205f 100644 --- a/sand-components/tests/canonical_26_2_components.rs +++ b/sand-components/tests/canonical_26_2_components.rs @@ -478,15 +478,19 @@ fn canonical_26_2_recipe_smithing_transform() { /// Smithing trim recipe (no `result` field — trims are applied in-place). #[test] fn canonical_26_2_recipe_smithing_trim() { - let trim = SmithingTrimRecipe::new(id("smithing/sentry_trim")) - .template(Ingredient::item( - "minecraft:sentry_armor_trim_smithing_template", - )) - .base(Ingredient::item("minecraft:diamond_chestplate")) - .addition(Ingredient::item("minecraft:amethyst_shard")); + let trim = SmithingTrimRecipe::new( + id("smithing/sentry_trim"), + "minecraft:sentry".parse().unwrap(), + ) + .template(Ingredient::item( + "minecraft:sentry_armor_trim_smithing_template", + )) + .base(Ingredient::item("minecraft:diamond_chestplate")) + .addition(Ingredient::item("minecraft:amethyst_shard")); let expected = serde_json::json!({ "type": "minecraft:smithing_trim", + "pattern": "minecraft:sentry", "template": "minecraft:sentry_armor_trim_smithing_template", "base": "minecraft:diamond_chestplate", "addition": "minecraft:amethyst_shard" @@ -944,17 +948,22 @@ fn canonical_26_2_worldgen_biome() { expected_features[GenerationStep::UndergroundOres as usize] = vec!["minecraft:ore_iron"]; let expected = serde_json::json!({ "has_precipitation": false, - "attributes": {"minecraft:audio/ambient_sounds":{"loop":"minecraft:ambient.nether_wastes.loop","additions":[]}}, + "attributes": { + "minecraft:audio/ambient_sounds": { + "loop": "minecraft:ambient.nether_wastes.loop", + "additions": [], + }, + "minecraft:visual/fog_color": "#c0d8ff", + "minecraft:visual/sky_color": "#78a7ff", + "minecraft:visual/water_fog_color": "#050533", + }, "temperature": 2.0, "temperature_modifier": "none", "downfall": 0.0, "effects": { - "fog_color": 0xC0D8FF, - "water_color": 0x3F76E4, - "water_fog_color": 0x050533, - "sky_color": 0x78A7FF, - "grass_color": 0x8A_B689, - "foliage_color": 0x71_A74D, + "water_color": "#3f76e4", + "grass_color": "#8ab689", + "foliage_color": "#71a74d", }, "features": expected_features, "carvers": [], diff --git a/sand-core/Cargo.toml b/sand-core/Cargo.toml index a8c15d98..f1ddf531 100644 --- a/sand-core/Cargo.toml +++ b/sand-core/Cargo.toml @@ -13,6 +13,7 @@ keywords = ["minecraft", "datapack", "commands", "gamedev"] categories = ["game-development", "data-structures"] [dependencies] +base64 = "0.22" serde = { version = "1", features = ["derive"] } serde_json = "1" schemars = "1" diff --git a/sand-core/src/cmd/mod.rs b/sand-core/src/cmd/mod.rs index 811689bf..cb70fea9 100644 --- a/sand-core/src/cmd/mod.rs +++ b/sand-core/src/cmd/mod.rs @@ -664,8 +664,8 @@ mod tests { .count(); assert_eq!(command_entries.len(), command_rust_items); let (command_count, registry_count) = match commands["minecraft_version"].as_str() { - Some("26.2") => (1_233, 4_867), - Some("26.3") => (1_255, 5_104), + Some("26.2") => (1_233, 5_081), + Some("26.3") => (1_255, 5_321), version => panic!("add verified provider counts for {version:?}"), }; assert_eq!(command_entries.len(), command_count); diff --git a/sand-core/src/compiler/export/functions.rs b/sand-core/src/compiler/export/functions.rs index f4ae4832..36558585 100644 --- a/sand-core/src/compiler/export/functions.rs +++ b/sand-core/src/compiler/export/functions.rs @@ -177,6 +177,39 @@ pub(crate) fn resolve_local_refs(content: &str, namespace: &str) -> String { .replace(&format!("{sentinel}:"), &format!("{namespace}:")) } +/// Finish compiler-managed numeric objectives through the same owned load +/// function in every frontend. The reserved initializer identity is part of +/// collision validation; ordinary authored functions cannot declare these scores. +pub(crate) fn drain_score_setup( + records: &mut Vec, + namespace: &str, + runtime: &mut crate::compiler::runtime::RuntimePlan, + tag_map: &mut std::collections::BTreeMap>, +) { + let setup = crate::state::score::drain_internal_score_setup(); + if setup.is_empty() { + return; + } + let path = "__sand_score_init"; + runtime.generated_lifecycle( + format!("{namespace}:{path}"), + "load", + resolve_origins(crate::function::take_score_origins(), namespace), + ); + records.push(ComponentRecord { + namespace: namespace.into(), + dir: "function".into(), + path: path.into(), + ext: "mcfunction".into(), + content_type: "text".into(), + content: setup.join("\n"), + }); + tag_map + .entry("minecraft:load".into()) + .or_default() + .insert(0, format!("{namespace}:{path}")); +} + #[cfg(test)] mod tests { use super::*; diff --git a/sand-core/src/compiler/export/mod.rs b/sand-core/src/compiler/export/mod.rs index 2098de92..47207fa9 100644 --- a/sand-core/src/compiler/export/mod.rs +++ b/sand-core/src/compiler/export/mod.rs @@ -44,6 +44,20 @@ pub(crate) struct ExportCtx<'a> { pub(crate) is_fallback: bool, } +/// Rewrites finished records into the resource schema of the target version. +/// +/// Both Rust export and the portable compiler end here, so a resource has the +/// same shape on a given target whichever frontend produced it. +pub(crate) fn lower_for_target( + records: &mut [ComponentRecord], + ctx: &ExportCtx<'_>, +) -> ExportResult<()> { + if ctx.caps.is_at_least(26, 3, 0) { + schema_26_3::lower(records)?; + } + Ok(()) +} + /// Collect all inventory-registered components into records, routing every /// `ComponentFactory` through the fallible `component_to_record` helper /// which validates all components (JSON, text, and copy-backed) before diff --git a/sand-core/src/compiler/export/pipeline.rs b/sand-core/src/compiler/export/pipeline.rs index ff51789d..66ef6654 100644 --- a/sand-core/src/compiler/export/pipeline.rs +++ b/sand-core/src/compiler/export/pipeline.rs @@ -2633,29 +2633,7 @@ pub(crate) fn try_export_components_impl( // ── Compiler-managed score constants / expression temporaries ─────────── // Structured helper lowering can allocate numeric working objectives. // Finish every factory and dynamic helper before draining initialization. - let score_setup = crate::state::score::drain_internal_score_setup(); - if !score_setup.is_empty() { - let path = "__sand_score_init"; - runtime.generated_lifecycle( - format!("{namespace}:{path}"), - "load", - super::functions::resolve_origins(crate::function::take_score_origins(), namespace), - ); - records.push(ComponentRecord { - namespace: namespace.to_string(), - dir: "function".to_string(), - path: path.to_string(), - ext: "mcfunction".to_string(), - content_type: "text".to_string(), - content: score_setup.join("\n"), - }); - tag_map - .entry("minecraft:load".to_string()) - .or_default() - // Lowering happens late, but these objectives must exist before - // any generated lifecycle function can execute numeric actions. - .insert(0, format!("{namespace}:{path}")); - } + super::functions::drain_score_setup(&mut records, namespace, &mut runtime, &mut tag_map); // ── FunctionTagDescriptors ──────────────────────────────────────────────── // Append user-declared function tag entries after Sand-owned setup/dispatcher @@ -2698,8 +2676,8 @@ pub(crate) fn try_export_components_impl( "BUG: unresolved __sand_local sentinel found in exported records" ); - if ctx.is_some_and(|ctx| ctx.caps.is_at_least(26, 3, 0)) { - super::schema_26_3::lower(&mut records)?; + if let Some(ctx) = ctx { + super::lower_for_target(&mut records, ctx)?; } validate_unique_output_identities(&records)?; validate_gameplay_references(&records)?; diff --git a/sand-core/src/compiler/program/decode.rs b/sand-core/src/compiler/program/decode.rs index bbcc0f47..30a5cb30 100644 --- a/sand-core/src/compiler/program/decode.rs +++ b/sand-core/src/compiler/program/decode.rs @@ -231,6 +231,7 @@ pub(super) fn resolve( pack: input.pack, requires: input.requires, modules: resolved, + structure_assets: input.structure_assets, }) } diff --git a/sand-core/src/compiler/program/lower.rs b/sand-core/src/compiler/program/lower.rs index c043878b..ebed6930 100644 --- a/sand-core/src/compiler/program/lower.rs +++ b/sand-core/src/compiler/program/lower.rs @@ -1,5 +1,8 @@ //! Typed gameplay lowering with local, deterministic helper allocation. -use super::{diagnostic::Diagnostic, limits, model::*}; +mod continuations; +mod data; + +use super::{CommandSource, diagnostic::Diagnostic, limits, model::*}; use crate::compiler::export::{ functions, identities, lifecycle, records::{self, ComponentRecord}, @@ -8,6 +11,8 @@ use crate::compiler::export::{ use crate::ir::{Cmd, NumericWrite}; use std::collections::BTreeMap; +type LifecycleCommand = (String, usize, String); + /// Portable resource bytes and the same runtime provenance used by Rust export. pub(super) struct LoweredProgram { pub(super) resources: BTreeMap>, @@ -17,6 +22,7 @@ pub(super) struct LoweredProgram { pub(super) fn lower( program: &Program, target: &crate::version::VersionProfile, + sources: Option<&mut BTreeMap>>, ) -> Result> { let _registry = crate::function::ExportFunctionRegistryScope::enter_namespace(&program.pack.namespace); @@ -90,6 +96,13 @@ pub(super) fn lower( )] }, )?; + let mut dimensions: Vec<_> = program + .modules + .iter() + .flat_map(|module| &module.dimensions) + .map(|dimension| sand_components::DimensionId::custom(dimension.id.clone())) + .collect(); + dimensions.sort_by_cached_key(ToString::to_string); let mut lower = Lower { namespace: program.pack.namespace.clone(), holders: states @@ -109,13 +122,69 @@ pub(super) fn lower( helper_keys, runtime: crate::compiler::runtime::RuntimePlan::default(), records: Vec::new(), + sources, + continuations: Vec::new(), + dimensions, + continuation_count: 0, + cancel_waits: false, init, bytes: 0, profile: sand_commands::CommandProfile::new(target.resolved_name(), false), + constants: std::collections::BTreeSet::new(), + custom_items: BTreeMap::new(), + huds: BTreeMap::new(), + menus: BTreeMap::new(), + advancement_dispatchers: BTreeMap::new(), + flags: std::collections::BTreeSet::new(), + data_states: states + .iter() + .map(|state| (state.id.to_string(), (*state).clone())) + .collect(), + entity_states: states + .iter() + .filter(|state| state.scope == "entity") + .map(|state| { + ( + state.id.to_string(), + state + .fields + .iter() + .map(|field| (field.name.clone(), field.default)) + .collect(), + ) + }) + .collect(), }; + for module in &program.modules { + for menu in &module.menus { + lower + .menus + .insert(menu.id.to_string(), lower.menu_component(menu)); + } + for hud in &module.huds { + lower + .huds + .insert(hud.id.to_string(), lower.hud_component(hud)); + } + for (index, item) in module.items.iter().enumerate() { + let custom = custom_item(item, &lower.holders); + if item.book.is_some() { + custom.validate().map_err(|error| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &module.id.to_string(), + &format!("/items/{index}/book"), + error.to_string(), + )] + })?; + } + lower.custom_items.insert(item.id.to_string(), custom); + } + } let mut entries = BTreeMap::new(); let mut load = Vec::new(); let mut tick = Vec::new(); + let mut lifecycle_sources = BTreeMap::new(); let mut memberships = Vec::new(); let mut modules: Vec<_> = program.modules.iter().collect(); modules.sort_by_key(|module| module.id.to_string()); @@ -151,8 +220,12 @@ pub(super) fn lower( &owner, &format!("/{phase}"), )?; + if !body.sources.is_empty() { + lifecycle_sources.insert((phase, owner.clone()), body.sources); + } output.extend( - body.into_iter() + body.lines + .into_iter() .enumerate() .map(|(index, line)| (owner.clone(), index, line)), ); @@ -166,6 +239,48 @@ pub(super) fn lower( memberships.push((tag_id, function)); } } + let mut event_owner = format!("{}:__sand_program/events", program.pack.namespace); + while program + .modules + .iter() + .any(|module| module.id.to_string() == event_owner) + { + event_owner.push('_'); + } + let mut event_load = Vec::new(); + for (index, line) in lower.events(program)?.into_iter().enumerate() { + match line { + EventLine::Load(command) => event_load.push((event_owner.clone(), index, command)), + EventLine::Tick(command) => tick.push((event_owner.clone(), index, command)), + } + } + if !lower.constants.is_empty() { + let objective = constants_objective(&program.pack.namespace); + event_load.push(( + event_owner.clone(), + event_load.len(), + format!("scoreboard objectives add {objective} dummy"), + )); + for value in lower.constants.clone() { + event_load.push(( + event_owner.clone(), + event_load.len(), + format!( + "scoreboard players set {} {objective} {value}", + constant_holder(value) + ), + )); + } + } + for module in &program.modules { + for bar in &module.boss_bars { + for line in lower.boss_bar_setup(bar) { + event_load.push((event_owner.clone(), event_load.len(), line)); + } + } + } + // Objectives must exist before any module load body reads them. + load.splice(0..0, event_load); let field_defaults: BTreeMap<_, _> = states .iter() .flat_map(|state| { @@ -196,6 +311,56 @@ pub(super) fn lower( .unwrap_or(("", "")); vec![Diagnostic::error("SAND_PROGRAM_FLOW", module, ptr, message)] })?; + let caps = target.caps(); + let ctx = crate::compiler::export::ExportCtx { + caps: &caps, + requested_version: target.resolved_name(), + is_fallback: target.is_fallback(), + }; + lower.register_continuations(&ctx, &mut load, &mut tick)?; + for module in &program.modules { + use crate::registration::IntoDatapack; + let module_id = module.id.to_string(); + for (index, menu) in module.menus.iter().enumerate() { + lower.register_owned_runtime( + lower.menus[&menu.id.to_string()].clone().into_datapack(), + ( + &format!("menu {}", menu.id), + &module_id, + &format!("/menus/{index}"), + ), + &ctx, + &mut load, + &mut tick, + )?; + } + for (index, hud) in module.huds.iter().enumerate() { + lower.register_owned_runtime( + lower.huds[&hud.id.to_string()].clone().into_datapack(), + ( + &format!("hud {}", hud.id), + &module_id, + &format!("/huds/{index}"), + ), + &ctx, + &mut load, + &mut tick, + )?; + } + for (index, transfer) in module.inventory_transfers.iter().enumerate() { + lower.register_owned_runtime( + inventory_transfer(transfer).into_datapack(), + ( + &format!("inventory transfer {}", transfer.id), + &module_id, + &format!("/inventory_transfers/{index}"), + ), + &ctx, + &mut load, + &mut tick, + )?; + } + } lifecycle::validate_private_objectives(&automatic, &load, &flow_plan.private_objectives) .map_err(error)?; for generated in flow_plan.functions { @@ -229,6 +394,46 @@ pub(super) fn lower( flow_plan.global_tick_commands, ) .map_err(|e| error(e.to_string()))?; + if let Some(sources) = lower.sources.as_deref_mut() { + for (phase, origins) in [ + ("load", &lifecycle.load_owners), + ("tick", &lifecycle.tick_owners), + ] { + // Lifecycle assembly emits each module's single-line commands in + // order, following the framework's variable-length setup prefix. + for (module, commands) in origins + .chunk_by(|a, b| a.owner == b.owner) + .map(|commands| (&commands[0].owner, commands)) + { + if let Some(ranges) = lifecycle_sources.remove(&(phase, module.clone())) { + let offset = commands[0].first_line - 1; + sources + .entry(function_resource(&format!( + "{}:__sand_lifecycle_{phase}", + program.pack.namespace + ))) + .or_default() + .extend(ranges.into_iter().map(|(lines, pointer)| CommandSource { + lines: (lines.start() + offset)..=(lines.end() + offset), + module: module.clone(), + pointer, + })); + } + } + } + if lifecycle.player_initializer.is_some() { + for (id, _) in entries + .iter() + .filter(|(_, context)| **context == ExecutionContext::Player) + { + if let Some(locations) = sources.get_mut(&function_resource(id)) { + for source in locations { + source.lines = (source.lines.start() + 1)..=(source.lines.end() + 1); + } + } + } + } + } lifecycle.attribute(&program.pack.namespace, &mut lower.runtime); if !lifecycle.load_owners.is_empty() { lower.runtime.lifecycle_owners.insert( @@ -247,12 +452,6 @@ pub(super) fn lower( &entries, lifecycle.player_initializer.as_deref(), ); - tags::assemble_tags( - &program.pack.namespace, - &mut lower.records, - tag_map, - memberships, - ); functions::drain_generated_resources_into( &mut lower.records, &program.pack.namespace, @@ -260,9 +459,169 @@ pub(super) fn lower( &mut lower.runtime, ) .map_err(|e| error(e.to_string()))?; + functions::drain_score_setup( + &mut lower.records, + &program.pack.namespace, + &mut lower.runtime, + &mut tag_map, + ); + tags::assemble_tags( + &program.pack.namespace, + &mut lower.records, + tag_map, + memberships, + ); for record in &mut lower.records { record.content = functions::resolve_local_refs(&record.content, &program.pack.namespace); } + for module in &program.modules { + let owner = module.id.to_string(); + for (index, recipe) in module.recipes.iter().enumerate() { + let fail = |message: String| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/recipes/{index}"), + message, + )] + }; + let component = recipe_component(recipe, &lower.custom_items).map_err(fail)?; + let record = records::component_to_record(component.as_ref(), Some(&ctx)) + .map_err(|e| fail(e.to_string()))?; + lower.records.push(record); + } + for (index, template) in module.structure_templates.iter().enumerate() { + let record = records::component_to_record(template, Some(&ctx)).map_err(|error| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/structure_templates/{index}"), + error.to_string(), + )] + })?; + lower.records.push(record); + } + for (index, biome) in module.biomes.iter().enumerate() { + let component = custom_biome_component(biome); + let record = records::component_to_record(&component, Some(&ctx)).map_err(|error| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/biomes/{index}"), + error.to_string(), + )] + })?; + lower.records.push(record); + } + for (index, dimension) in module.dimensions.iter().enumerate() { + let component = sand_components::Dimension::flat_generator( + dimension.id.clone(), + dimension.dimension_type.clone(), + dimension.flat.clone(), + ); + let record = records::component_to_record(&component, Some(&ctx)).map_err(|error| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/dimensions/{index}"), + error.to_string(), + )] + })?; + lower.records.push(record); + } + for (index, dialog) in module.dialogs.iter().enumerate() { + let component = notice_dialog_component(dialog, &lower.holders); + let record = records::component_to_record(&component, Some(&ctx)).map_err(|error| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/dialogs/{index}"), + error.to_string(), + )] + })?; + lower.records.push(record); + } + for (index, advancement) in module.advancements.iter().enumerate() { + let fail = |message| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/advancements/{index}"), + message, + )] + }; + let reward_function = lower + .advancement_dispatchers + .get(&advancement.id.to_string()); + let component = advancement_component(advancement, &lower.holders, reward_function) + .map_err(fail)?; + let record = records::component_to_record(&component, Some(&ctx)) + .map_err(|error| fail(error.to_string()))?; + lower.records.push(record); + } + for (index, predicate) in module.predicates.iter().enumerate() { + let fail = |message| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/predicates/{index}"), + message, + )] + }; + let component = world_predicate_component(predicate).map_err(fail)?; + let record = records::component_to_record(&component, Some(&ctx)) + .map_err(|error| fail(error.to_string()))?; + lower.records.push(record); + } + for (index, damage_type) in module.damage_types.iter().enumerate() { + let record = + records::component_to_record(damage_type, Some(&ctx)).map_err(|error| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/damage_types/{index}"), + error.to_string(), + )] + })?; + lower.records.push(record); + } + for (index, table) in module.loot_tables.iter().enumerate() { + let fail = |message: String| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/loot_tables/{index}"), + message, + )] + }; + let component = loot_table_component(table); + let record = records::component_to_record(&component, Some(&ctx)) + .map_err(|e| fail(e.to_string()))?; + lower.records.push(record); + } + for (index, tag) in module.resource_tags.iter().enumerate() { + let fail = |message: String| { + vec![Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("/resource_tags/{index}"), + message, + )] + }; + let component = tag_component(tag).map_err(fail)?; + let record = records::component_to_record(component.as_ref(), Some(&ctx)) + .map_err(|e| fail(e.to_string()))?; + lower.records.push(record); + } + } + for flag in lower.flags.clone() { + let component = flag_predicate(&program.pack.namespace, flag).map_err(error)?; + let record = records::component_to_record(&component, Some(&ctx)) + .map_err(|e| error(e.to_string()))?; + lower.records.push(record); + } + crate::compiler::export::lower_for_target(&mut lower.records, &ctx) + .map_err(|e| error(e.to_string()))?; records::validate_unique_output_identities(&lower.records).map_err(|e| error(e.to_string()))?; records::validate_objective_definitions(&lower.records).map_err(|e| error(e.to_string()))?; let mut output = BTreeMap::new(); @@ -276,13 +635,22 @@ pub(super) fn lower( let runtime_report = crate::compiler::runtime::RuntimeReport::collect(&lower.records, &lower.runtime); for record in lower.records { + let content = if record.content_type == "copy" { + program + .structure_assets + .get(&record.content) + .cloned() + .ok_or_else(|| error(format!("missing structure asset `{}`", record.content)))? + } else { + record.content.into_bytes() + }; insert_output( &mut output, format!( "data/{}/{}/{}.{}", record.namespace, record.dir, record.path, record.ext ), - record.content.into_bytes(), + content, )?; } Ok(LoweredProgram { @@ -438,144 +806,1759 @@ fn helper(namespace: &str, key: &str, path: &str, role: &str) -> String { // hash collisions independently of declaration order. format!("{namespace}:__sand_program/{key}/{path}/{role}") } -struct Lower { - runtime: crate::compiler::runtime::RuntimePlan, - namespace: String, - holders: BTreeMap, - bounds: BTreeMap, - helper_keys: BTreeMap, - records: Vec, - init: Option, - bytes: usize, - profile: sand_commands::CommandProfile, +/// The canonical Rust custom item for a portable declaration. +fn custom_item( + item: &CustomItem, + holders: &BTreeMap, +) -> sand_components::CustomItem { + let mut custom = sand_components::CustomItem::new(&item.base).custom_data(item.id.to_string()); + if !item.name.is_empty() { + custom = custom.custom_name(static_text_component(&item.name, holders)); + } + if !item.lore.is_empty() { + custom = custom.lore( + item.lore + .iter() + .map(|line| static_text_component(line, holders)) + .collect(), + ); + } + if let Some(rarity) = item.rarity { + custom = custom.rarity(match rarity { + Rarity::Common => sand_components::ItemRarity::Common, + Rarity::Uncommon => sand_components::ItemRarity::Uncommon, + Rarity::Rare => sand_components::ItemRarity::Rare, + Rarity::Epic => sand_components::ItemRarity::Epic, + }); + } + if let Some(glint) = item.glint { + custom = custom.enchantment_glint_override(glint); + } + if let Some(size) = item.max_stack { + custom = custom.max_stack_size(size); + } + if item.unbreakable { + custom = custom.unbreakable(true); + } + for (enchantment, level) in &item.enchantments { + custom = custom.enchantment(enchantment.clone(), *level); + } + if let Some(data) = item.custom_model_data { + custom = custom.custom_model_data(data); + } + if let Some(book) = &item.book { + let mut built = sand_components::WrittenBook::new(&book.title, &book.author); + for parts in &book.pages { + built = built.page(static_text_component(parts, holders)); + } + custom = custom.component(sand_components::ItemComponent::WrittenBook(built)); + } + custom } -impl Lower { - fn function( - &mut self, - id: &str, - body: Vec, - module: &str, - ptr: &str, - ) -> Result<(), Vec> { - let content = body.join("\n"); - if self.records.len() >= limits::RESOURCES - || content.len() > limits::DOCUMENT_BYTES - || self.bytes.saturating_add(content.len()) > limits::OUTPUT_BYTES - { - return Err(vec![Diagnostic::error( - "SAND_PROGRAM_LIMIT", - module, - ptr, - "generated output limit exceeded", - )]); + +fn ingredient(id: &str) -> sand_components::recipe::Ingredient { + match id.strip_prefix('#') { + Some(tag) => sand_components::recipe::Ingredient::tag(tag), + None => sand_components::recipe::Ingredient::item(id), + } +} + +fn recipe_output( + output: &RecipeOutput, + custom_items: &BTreeMap, +) -> Result { + match custom_items.get(&output.item) { + Some(custom) => { + sand_components::recipe::RecipeResult::from_custom_item(custom, output.count) + .map_err(|e| e.to_string()) } - self.bytes += content.len(); - self.runtime.own_function(id.to_owned(), module.to_owned()); - let (namespace, path) = id.split_once(':').expect("validated/generated identity"); - self.records.push(ComponentRecord { - namespace: namespace.into(), - dir: "function".into(), - path: path.into(), - ext: "mcfunction".into(), - content_type: "text".into(), - content, - }); - Ok(()) + None => Ok(sand_components::recipe::RecipeResult::new( + &output.item, + output.count, + )), } - fn body( - &mut self, - body: &[Operation], - owner: &str, - path: &str, - module: &str, - ptr: &str, - ) -> Result, Vec> { - let mut commands = Vec::new(); - for (index, operation) in body.iter().enumerate() { - let path = if path.is_empty() { - index.to_string() - } else { - format!("{path}/{index}") - }; - let ptr = format!("{ptr}/{index}"); - let fail = |error: String| { - let mut error = Diagnostic::error("SAND_PROGRAM_COMMAND", module, &ptr, error); - error.origin = operation.origin.clone(); - vec![error] +} + +/// Build the typed recipe component that Rust authors would write. +fn recipe_component( + recipe: &Recipe, + custom_items: &BTreeMap, +) -> Result, String> { + use sand_components::recipe::*; + Ok(match recipe { + Recipe::Shaped { + id, + pattern, + key, + result, + } => { + let mut built = ShapedRecipe::new(id.clone()).pattern(pattern.iter().cloned()); + for (symbol, item) in key { + let symbol = symbol.chars().next().expect("validated single character"); + built = built.key(symbol, ingredient(item)); + } + Box::new(built.result(recipe_output(result, custom_items)?)) + } + Recipe::Shapeless { + id, + ingredients, + result, + } => { + let mut built = ShapelessRecipe::new(id.clone()); + for item in ingredients { + built = built.ingredient(ingredient(item)); + } + Box::new(built.result(recipe_output(result, custom_items)?)) + } + Recipe::Smithing { + id, + template, + base, + addition, + result, + } => Box::new( + SmithingTransformRecipe::new(id.clone()) + .template(ingredient(template)) + .base(ingredient(base)) + .addition(ingredient(addition)) + .result(recipe_output(result, custom_items)?), + ), + Recipe::SmithingTrim { + id, + template, + base, + addition, + pattern, + } => Box::new( + SmithingTrimRecipe::new(id.clone(), pattern.clone()) + .template(ingredient(template)) + .base(ingredient(base)) + .addition(ingredient(addition)), + ), + Recipe::Cooking { + id, + method, + ingredient: input, + result, + experience, + time, + } => { + let kind = match method { + CookingMethod::Smelting => CookingType::Smelting, + CookingMethod::Blasting => CookingType::Blasting, + CookingMethod::Smoking => CookingType::Smoking, + CookingMethod::Campfire => CookingType::CampfireCooking, }; - let cmds = match &operation.action { - Action::ScoreSet { score, value } | Action::ScoreAdd { score, value } => { - let bounds = self - .bounds - .get(&format!("{}.{}", score.state, score.field)) - .copied(); - let objective = objective(score); - let holder = &self.holders[&score.state.to_string()]; - if matches!(operation.action, Action::ScoreSet { .. }) { - // Portable v1 assigns only integer literals to @s or a - // global holder. Canonical constant lowering is local: - // it allocates no helpers or ambient registry state. - NumericWrite { - value: crate::entity::StatCurve::from(*value), - holder: holder.clone(), - objective: sand_commands::ObjectiveName::logical(objective), - scale: 1, - fixed: crate::entity::FixedPoint::default(), - bounds, - dirty: Vec::new(), - } - .lower(&module.parse().expect("validated module identity")) - .map_err(|error| fail(error.to_string()))? - } else { - let mut commands = - crate::ir::score_delta(holder, &objective, *value, false); - if let Some(bounds) = bounds { - commands.extend(crate::ir::score_bounds(holder, &objective, bounds)); - } - commands - } + let mut built = CookingRecipe::new(id.clone(), kind) + .ingredient(ingredient(input)) + .result(recipe_output(result, custom_items)?) + .experience(*experience); + if let Some(time) = time { + built = built.cooking_time(*time); + } + Box::new(built) + } + Recipe::Stonecutting { + id, + ingredient: input, + result, + } => Box::new( + StonecuttingRecipe::new(id.clone()) + .ingredient(ingredient(input)) + .result(recipe_output(result, custom_items)?) + .count(result.count), + ), + }) +} + +/// Build the typed registry tag that Rust authors would write. +fn tag_component(tag: &ResourceTag) -> Result, String> { + use sand_components::{BlockId, EntityTypeId, ItemId, TagId, TypedTag}; + fn build(tag: &ResourceTag) -> Result, String> + where + T: sand_components::TagRegistry + std::str::FromStr, + ::Err: std::fmt::Display, + { + let location: TagId = tag.id.to_string().parse().map_err(|e| format!("{e}"))?; + let mut built = TypedTag::new(location).replace(tag.replace); + for value in &tag.values { + built = match value.strip_prefix('#') { + Some(reference) => { + let reference: TagId = reference.parse().map_err(|e| format!("{e}"))?; + built.tag_ref(reference) } - Action::Call { function } => vec![Cmd::Function(reference_id(function))], - Action::Raw { command } => vec![Cmd::Raw(command.clone())], - Action::Players { body } => { - let target = if let [ - Operation { - action: - Action::Call { - function: function @ FunctionReference::Internal { .. }, - }, - .. - }, - ] = body.as_slice() - { - reference_id(function) - } else { - let id = - helper(&self.namespace, &self.helper_keys[owner], &path, "players"); - let mut lines = self.body( - body, - owner, - &format!("{path}/players"), - module, - &format!("{ptr}/action/body"), - )?; - if let Some(init) = &self.init { - lines.insert(0, Cmd::Function(init.clone()).render()); - } - self.function(&id, lines, module, &ptr)?; - id - }; - vec![Cmd::Execute { - operations: vec![sand_commands::ExecuteOp::As( - sand_commands::Selector::all_players(), - )], - run: Box::new(Cmd::Function(target)), + None => built.entry(value.parse::().map_err(|e| e.to_string())?), + }; + } + Ok(built) + } + Ok(match tag.kind { + TagKind::Item => Box::new(build::(tag)?), + TagKind::Block => Box::new(build::(tag)?), + TagKind::EntityType => Box::new(build::(tag)?), + }) +} + +/// Build the typed loot table that Rust authors would write. +fn loot_table_component(table: &LootTable) -> sand_components::LootTable { + use sand_components::{LootCondition, LootEntry, LootFunction, LootPool}; + let mut result = sand_components::LootTable::new(table.id.clone()); + for source in &table.pools { + let mut pool = LootPool::new().rolls(source.rolls as i32); + if let Some(chance) = source.chance { + pool = pool.condition(LootCondition::RandomChance { chance }); + } + if let Some(weather) = source.weather { + pool = pool.condition(LootCondition::WeatherCheck { + raining: Some(weather != Weather::Clear), + thundering: Some(weather == Weather::Thunder), + }); + } + if let Some(predicate) = &source.predicate { + pool = pool.condition(LootCondition::Reference { + name: predicate.to_string(), + }); + } + for item in &source.items { + let LootEntry::Item { + name, + quality, + conditions, + .. + } = LootEntry::item_raw(&item.item) + else { + unreachable!("item_raw builds an item entry"); + }; + pool = pool.entry(LootEntry::Item { + name, + weight: Some(item.weight as i32), + quality, + functions: if item.count > 1 { + vec![LootFunction::SetCount { + count: (item.count as i32).into(), + add: false, }] - } - Action::Branch { - condition, - then, - otherwise, + } else { + Vec::new() + }, + conditions, + }); + } + result = result.pool(pool); + } + result +} + +fn inventory_transfer(source: &InventoryTransferDefinition) -> crate::gameplay::InventoryTransfer { + let mut definition = + crate::gameplay::InventoryTransfer::new(source.id.clone(), source.from, source.to); + if let Some(amount) = source.amount { + definition = definition.amount(amount); + } + if let Some(callback) = &source.success { + let function = reference_id(callback); + definition = definition.on_success(move || Cmd::Function(function.clone())); + } + if let Some(callback) = &source.rejected { + let function = reference_id(callback); + definition = definition.on_rejected(move || Cmd::Function(function.clone())); + } + definition +} + +fn custom_biome_component(source: &CustomBiome) -> sand_components::Biome { + use sand_components::{Biome, BiomeEffects}; + let mut effects = BiomeEffects::new( + source.fog_color.unwrap_or(0xc0d8ff), + source.water_color.unwrap_or(0x3f76e4), + source.water_fog_color.unwrap_or(0x050533), + source.sky_color.unwrap_or(0x78a7ff), + ); + if let Some(color) = source.grass_color { + effects = effects.grass_color(color); + } + if let Some(color) = source.foliage_color { + effects = effects.foliage_color(color); + } + let mut biome = Biome::new(source.id.clone(), effects); + if let Some(precipitation) = source.precipitation { + biome = biome.has_precipitation(precipitation); + } + if let Some(temperature) = source.temperature { + biome = biome.temperature(temperature); + } + if let Some(downfall) = source.downfall { + biome = biome.downfall(downfall); + } + if !source.spawners.is_empty() { + biome = biome.spawners(source.spawners.clone()); + } + if !source.spawn_costs.is_empty() { + biome = biome.spawn_costs(source.spawn_costs.iter().map(|(entity, cost)| { + let id: sand_components::ResourceLocation = entity.parse().expect("validated entity"); + (id.into(), *cost) + })); + } + biome +} + +fn notice_dialog_component( + source: &NoticeDialog, + holders: &BTreeMap, +) -> sand_components::Dialog { + use sand_components::{Dialog, DialogBody, DialogButton, DialogId}; + let mut dialog = Dialog::notice(DialogId::custom(source.id.clone())) + .title(static_text_component(&source.title, holders)); + for text in &source.body { + dialog = dialog.body(DialogBody::text(static_text_component(text, holders))); + } + let button = if source.button.is_empty() { + sand_commands::TextComponent::translate("gui.done") + } else { + static_text_component(&source.button, holders) + }; + dialog.button(DialogButton::new(button)) +} + +fn advancement_component( + advancement: &Advancement, + holders: &BTreeMap, + reward_function: Option<&sand_components::FunctionId>, +) -> Result { + use sand_components::{ + AdvancementDisplay, AdvancementIcon, AdvancementRewards, AdvancementTrigger, Criterion, + EntityPredicate, + }; + let mut built = sand_components::Advancement::new(advancement.id.clone()); + if let Some(display) = &advancement.display { + let icon = display + .icon + .parse::() + .map_err(|err| err.to_string())?; + let mut visible = AdvancementDisplay::new( + AdvancementIcon::new(icon), + static_text_component(&display.title, holders), + static_text_component(&display.description, holders), + ); + if let Some(background) = &display.background { + visible = visible.background(background.clone()); + } + built = built.display(visible); + } + for (name, criterion) in &advancement.criteria { + let trigger = match criterion { + AdvancementCriterion::InventoryItem { item } => { + let item = item + .parse::() + .map_err(|err| err.to_string())?; + AdvancementTrigger::inventory_changed(vec![item]) + } + AdvancementCriterion::PlaceBlock { block } => { + let block = block + .parse::() + .map_err(|err| err.to_string())?; + AdvancementTrigger::placed_block(Some(block), None, None, None) + } + AdvancementCriterion::KillEntity { entity } => { + let entity = entity + .parse::() + .map_err(|err| err.to_string())?; + AdvancementTrigger::PlayerKilledEntity { + entity: Some(EntityPredicate::type_(entity)), + killing_blow: None, + } + } + }; + built = built.criterion(name, Criterion::new(trigger)); + } + let requirements = if advancement.require_any { + vec![advancement.criteria.keys().cloned().collect()] + } else { + advancement + .criteria + .keys() + .map(|name| vec![name.clone()]) + .collect() + }; + built = built.requirements(requirements); + if advancement.experience > 0 || reward_function.is_some() { + let mut rewards = AdvancementRewards::new().experience(advancement.experience); + if let Some(function) = reward_function { + rewards = rewards.function(function.clone()); + } + built = built.rewards(rewards); + } + Ok(built) +} + +fn world_predicate_component( + source: &WorldPredicate, +) -> Result { + use sand_components::{ + BlockPredicate, LocationPredicate, Predicate, PredicateId, PredicateRoot, WeatherPredicate, + }; + let mut terms = Vec::new(); + if source.biome.is_some() || source.dimension.is_some() || source.block.is_some() { + let mut location = LocationPredicate::new(); + if let Some(biome) = &source.biome { + location = location.biome( + biome + .parse::() + .map_err(|error| error.to_string())?, + ); + } + if let Some(dimension) = &source.dimension { + location = location.dimension(sand_components::DimensionId::custom(dimension.clone())); + } + if let Some(block) = &source.block { + let block = block + .parse::() + .map_err(|error| error.to_string())?; + location = location.block(BlockPredicate::new().blocks(vec![block])); + } + terms.push(PredicateRoot::location(location)); + } + if let Some(weather) = source.weather { + terms.push(PredicateRoot::weather( + WeatherPredicate::new() + .raining(weather != Weather::Clear) + .thundering(weather == Weather::Thunder), + )); + } + if let Some(chance) = source.chance { + terms.push(PredicateRoot::random_chance(chance)); + } + let root = if terms.len() == 1 { + terms.pop().expect("one predicate term") + } else { + PredicateRoot::all_of(terms) + }; + Ok(Predicate::new(PredicateId::custom(source.id.clone()), root)) +} + +/// The generated predicate that tests one entity flag. +fn flag_predicate(namespace: &str, flag: EntityFlag) -> Result { + use sand_components::{ + EntityFlags, EntityPredicate, EntityPredicateTarget, Predicate, PredicateRoot, + }; + let flags = EntityFlags::new(); + let flags = match flag { + EntityFlag::Sneaking => flags.sneaking(true), + EntityFlag::Sprinting => flags.sprinting(true), + EntityFlag::Swimming => flags.swimming(true), + EntityFlag::OnFire => flags.on_fire(true), + }; + let location = flag_predicate_id(namespace, flag) + .parse() + .map_err(|e| format!("{e}"))?; + Ok(Predicate::new( + location, + PredicateRoot::entity_properties( + EntityPredicateTarget::This, + EntityPredicate::new().flags(flags), + ), + )) +} + +fn flag_predicate_id(namespace: &str, flag: EntityFlag) -> String { + let name = match flag { + EntityFlag::Sneaking => "sneaking", + EntityFlag::Sprinting => "sprinting", + EntityFlag::Swimming => "swimming", + EntityFlag::OnFire => "on_fire", + }; + format!("{namespace}:__sand_program/flag/{name}") +} + +fn block_position(position: BlockPosition) -> sand_commands::BlockPos { + use sand_commands::{BlockPos, Coord}; + match position { + BlockPosition::Absolute { x, y, z } => BlockPos::new( + Coord::Absolute(f64::from(x)), + Coord::Absolute(f64::from(y)), + Coord::Absolute(f64::from(z)), + ), + BlockPosition::Relative { x, y, z } => BlockPos::new( + Coord::Relative(f64::from(x)), + Coord::Relative(f64::from(y)), + Coord::Relative(f64::from(z)), + ), + } +} + +/// The tag marking players who see a boss bar. +fn boss_bar_tag(bar: &sand_components::ResourceLocation) -> String { + format!( + "sand.{}", + sand_commands::scoreboard::hash_objective_name(&format!("{bar}#viewer")) + ) +} + +fn constants_objective(namespace: &str) -> String { + sand_commands::ObjectiveName::logical(format!("{namespace}.__sand_program.constants")) + .as_str() + .to_owned() +} + +fn constant_holder(value: i32) -> sand_commands::ScoreHolder { + sand_commands::ScoreHolder::fake(format!("#c{value}")) +} + +/// One generated lifecycle line for portable player events. +enum EventLine { + Load(String), + Tick(String), +} + +fn static_text_component( + parts: &[TextPart], + holders: &BTreeMap, +) -> sand_commands::TextComponent { + text_component(parts, holders, "p", &mut |_, _| { + unreachable!("static text was validated before lowering") + }) +} + +fn text_component( + parts: &[TextPart], + holders: &BTreeMap, + path: &str, + resolve_stored: &mut impl FnMut(&FieldReference, &str) -> sand_commands::TextComponent, +) -> sand_commands::TextComponent { + use sand_commands::{ChatColor, TextComponent}; + let styled = |mut component: TextComponent, style: &TextStyle| { + if let Some(color) = style.color { + component = component.color(match color { + TextColor::Black => ChatColor::Black, + TextColor::DarkBlue => ChatColor::DarkBlue, + TextColor::DarkGreen => ChatColor::DarkGreen, + TextColor::DarkAqua => ChatColor::DarkAqua, + TextColor::DarkRed => ChatColor::DarkRed, + TextColor::DarkPurple => ChatColor::DarkPurple, + TextColor::Gold => ChatColor::Gold, + TextColor::Gray => ChatColor::Gray, + TextColor::DarkGray => ChatColor::DarkGray, + TextColor::Blue => ChatColor::Blue, + TextColor::Green => ChatColor::Green, + TextColor::Aqua => ChatColor::Aqua, + TextColor::Red => ChatColor::Red, + TextColor::LightPurple => ChatColor::LightPurple, + TextColor::Yellow => ChatColor::Yellow, + TextColor::White => ChatColor::White, + }); + } + // Parts are children of an unstyled root, so unset properties stay + // unset instead of being restated as `false`. + if style.bold { + component = component.bold(true); + } + if style.italic { + component = component.italic(true); + } + if style.underlined { + component = component.underlined(true); + } + component + }; + let mut root = TextComponent::literal(""); + for (index, part) in parts.iter().enumerate() { + let component = match part { + TextPart::Stored { value, style } => { + styled(resolve_stored(value, &format!("{path}{index}")), style) + } + TextPart::Translation { + key, + arguments, + style, + } => { + let with = arguments + .iter() + .enumerate() + .map(|(argument, parts)| { + text_component( + parts, + holders, + &format!("{path}{index}_{argument}_"), + resolve_stored, + ) + }) + .collect(); + styled(TextComponent::translate_with(key, with), style) + } + TextPart::Interactive { + content, + tooltip, + click, + } => { + let mut component = text_component( + content, + holders, + &format!("{path}{index}_0_"), + resolve_stored, + ); + if !tooltip.is_empty() { + let hover = text_component( + tooltip, + holders, + &format!("{path}{index}_1_"), + resolve_stored, + ); + component = component.hover_text(hover); + } + if let Some(click) = click { + component = component.with_click_event(click.clone()); + } + component + } + TextPart::Text { text, style } => styled(TextComponent::literal(text.clone()), style), + TextPart::Score { score, style } => styled( + TextComponent::score( + holders[&score.state.to_string()].to_string(), + objective(score), + ), + style, + ), + TextPart::PlayerName { style } => styled(TextComponent::selector("@s"), style), + }; + root = root.then(component); + } + root +} + +/// Whether a body can end its enclosing function frame with `Return`. +/// +/// `Players` bodies are their own frame: a return there ends one player's +/// turn, so it does not propagate. +fn returns(body: &[Operation]) -> bool { + body.iter().any(|operation| match &operation.action { + Action::Return => true, + Action::Branch { + then, otherwise, .. + } => returns(then) || returns(otherwise), + Action::While { body, .. } | Action::InDimension { body, .. } => returns(body), + _ => false, + }) +} + +/// Call a helper; when it can return early, propagate that return. +/// +/// Helpers signal an early return by returning 1. `execute if function` +/// succeeds only for a nonzero result, so a helper that finishes normally +/// (with no result) lets the caller continue. +fn call_helper(id: String, propagate: bool) -> Cmd { + if propagate { + Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::If( + sand_commands::ConditionIr::Function(id), + )], + run: Box::new(Cmd::Return(1)), + } + } else { + Cmd::Function(id) + } +} + +/// A canonical State objective, matching Rust's `state::objective_name`. +fn state_objective(state: &str, suffix: &str) -> String { + sand_commands::ObjectiveName::logical(format!("{state}.{suffix}")) + .as_str() + .to_owned() +} + +fn query_selector(query: &EntityQuery) -> Result { + let mut selector = sand_commands::Selector::all_entities(); + if let Some(entity_type) = &query.entity_type { + selector = selector.entity_type_raw(entity_type.clone()); + } + if let Some(tag) = &query.tag { + selector = selector.tag(tag.clone()); + } + if let Some(state) = &query.with_state { + // Attached at revision 1, as `has_state` tests. + selector = selector + .score_typed( + sand_commands::ObjectiveName::logical(format!("{state}.presence")), + sand_commands::ScoreRange::exact(1), + ) + .map_err(|error| error.to_string())?; + } + if let Some(filter) = &query.score { + use sand_commands::ScoreRange; + let range = match (filter.min, filter.max) { + (Some(min), Some(max)) => ScoreRange::between(min, max), + (Some(min), None) => ScoreRange::at_least(min), + (None, Some(max)) => ScoreRange::at_most(max), + (None, None) => return Err("a query score filter requires a bound".into()), + }; + selector = selector + .score_typed( + sand_commands::ObjectiveName::logical(format!( + "{}.{}", + filter.score.state, filter.score.field + )), + range, + ) + .map_err(|error| error.to_string())?; + } + if let Some(nbt) = &query.nbt { + selector = selector.nbt_raw(nbt.to_string()); + } + selector = match (query.min_distance, query.max_distance) { + (Some(min), Some(max)) => selector.distance_range(min, max), + (Some(min), None) => selector.distance_min(min), + (None, Some(max)) => selector.distance_max(max), + (None, None) => selector, + }; + if let Some(sort) = query.sort { + selector = selector.sort(match sort { + EntitySort::Nearest => sand_commands::SortOrder::Nearest, + EntitySort::Furthest => sand_commands::SortOrder::Furthest, + EntitySort::Random => sand_commands::SortOrder::Random, + EntitySort::Arbitrary => sand_commands::SortOrder::Arbitrary, + }); + } + if let Some(limit) = query.limit { + selector = selector.limit(limit as i32); + } + Ok(selector) +} + +fn function_resource(id: &str) -> String { + let (namespace, path) = id.split_once(':').expect("validated/generated identity"); + format!("data/{namespace}/function/{path}.mcfunction") +} + +#[derive(Default)] +struct CommandBody { + lines: Vec, + sources: Vec<(std::ops::RangeInclusive, String)>, + /// Authored bodies carry precise ranges; generated bodies use their owner pointer. + authored: bool, +} + +impl From> for CommandBody { + fn from(lines: Vec) -> Self { + Self { + lines, + ..Self::default() + } + } +} + +impl CommandBody { + fn prepend_initializer(&mut self, id: &str) { + self.lines.insert(0, Cmd::Function(id.into()).render()); + for (lines, _) in &mut self.sources { + *lines = (lines.start() + 1)..=(lines.end() + 1); + } + } + + fn record(&mut self, first_line: usize, pointer: &str) { + if first_line <= self.lines.len() { + self.sources + .push((first_line..=self.lines.len(), pointer.into())); + } + } +} + +struct Lower<'sources> { + runtime: crate::compiler::runtime::RuntimePlan, + namespace: String, + holders: BTreeMap, + bounds: BTreeMap, + helper_keys: BTreeMap, + records: Vec, + sources: Option<&'sources mut BTreeMap>>, + continuations: Vec, + dimensions: Vec, + continuation_count: usize, + cancel_waits: bool, + init: Option, + bytes: usize, + profile: sand_commands::CommandProfile, + /// Constant operands materialised on the compiler-owned constant holder. + constants: std::collections::BTreeSet, + /// Declared custom items by id. + custom_items: BTreeMap, + huds: BTreeMap, + menus: BTreeMap, + advancement_dispatchers: BTreeMap, + /// Entity flags tested anywhere; each gets one generated predicate. + flags: std::collections::BTreeSet, + /// Owned backing storage for canonical data-field descriptors. + data_states: BTreeMap, + /// Entity States by id, with their field defaults. + entity_states: BTreeMap>, +} +fn whole_amount(operand: &ScoreOperand) -> Amount { + match operand { + ScoreOperand::Value(value) => Amount::Value(*value as f64), + ScoreOperand::Field(score) => Amount::Field(ScaledField { + score: score.clone(), + scale: 1.0, + }), + } +} + +struct NumericArgument<'a> { + name: &'a str, + value: &'a Amount, + integer: bool, + bounds: Option<(f64, f64)>, +} + +impl Lower<'_> { + fn function( + &mut self, + id: &str, + body: impl Into, + module: &str, + ptr: &str, + ) -> Result<(), Vec> { + let mut body = body.into(); + let content = body.lines.join("\n"); + if self.records.len() >= limits::RESOURCES + || content.len() > limits::DOCUMENT_BYTES + || self.bytes.saturating_add(content.len()) > limits::OUTPUT_BYTES + { + return Err(vec![Diagnostic::error( + "SAND_PROGRAM_LIMIT", + module, + ptr, + "generated output limit exceeded", + )]); + } + self.bytes += content.len(); + if let Some(sources) = self.sources.as_deref_mut() { + if !body.authored && !content.is_empty() { + body.sources.push((1..=content.lines().count(), ptr.into())); + } + if !body.sources.is_empty() { + sources.insert( + function_resource(id), + body.sources + .into_iter() + .map(|(lines, pointer)| CommandSource { + lines, + module: module.into(), + pointer, + }) + .collect(), + ); + } + } + self.runtime.own_function(id.to_owned(), module.to_owned()); + let (namespace, path) = id.split_once(':').expect("validated/generated identity"); + self.records.push(ComponentRecord { + namespace: namespace.into(), + dir: "function".into(), + path: path.into(), + ext: "mcfunction".into(), + content_type: "text".into(), + content, + }); + Ok(()) + } + /// Lower player observations and native advancement rewards to shared dispatchers. + /// A polled dispatcher consumes its observation before running its handlers. + fn events(&mut self, program: &Program) -> Result, Vec> { + let mut groups: BTreeMap)> = BTreeMap::new(); + let mut modules: Vec<_> = program.modules.iter().collect(); + modules.sort_by_key(|module| module.id.to_string()); + for module in modules { + for (index, hook) in module.events.iter().enumerate() { + groups + .entry(hook.event.key()) + .or_insert_with(|| (hook.event.clone(), Vec::new())) + .1 + .push(( + reference_id(&hook.function), + format!("{}#{index}", module.id), + )); + } + } + let mut lines = Vec::new(); + for (key, (event, handlers)) in groups { + let base = format!("{}.__sand_event.{key}", self.namespace); + let dispatch = format!("{}:__sand_program/event/{key}", self.namespace); + if let PlayerEvent::AdvancementCompleted { advancement } = &event { + self.advancement_dispatchers.insert( + advancement.to_string(), + dispatch + .parse() + .expect("validated advancement dispatcher identity"), + ); + } + let objective = sand_commands::ObjectiveName::logical(base.clone()) + .as_str() + .to_owned(); + let tag = format!( + "sand.{}", + sand_commands::scoreboard::hash_objective_name(&base) + ); + let mut body = Vec::new(); + if let Some(init) = &self.init { + body.push(Cmd::Function(init.clone()).render()); + } + let criteria = event.criterion(); + if let Some(criteria) = &criteria { + lines.push(EventLine::Load(format!( + "scoreboard objectives add {objective} {criteria}" + ))); + lines.push(EventLine::Tick(format!( + "execute as @a[scores={{{objective}=1..}}] at @s run function {dispatch}" + ))); + body.push(format!("scoreboard players reset @s {objective}")); + } + if matches!(event, PlayerEvent::Join | PlayerEvent::FirstJoin) { + // A persistent tag marks players already observed once; joins + // after that are seen through the leave_game statistic. + lines.push(EventLine::Tick(format!( + "execute as @a[tag=!{tag}] at @s run function {dispatch}" + ))); + body.push(format!("tag @s add {tag}")); + } + for (function, _) in &handlers { + body.push(Cmd::Function(function.clone()).render()); + } + let owner = handlers + .first() + .map(|(_, owner)| owner.clone()) + .unwrap_or_default(); + self.function(&dispatch, body, &owner, "/events")?; + } + Ok(lines) + } + + fn register_owned_runtime( + &mut self, + registration: crate::registration::DatapackRegistration, + origin: (&str, &str, &str), + context: &crate::compiler::export::ExportCtx<'_>, + load: &mut Vec, + tick: &mut Vec, + ) -> Result<(), Vec> { + use crate::registration::LifecyclePhase; + let (owner, module, pointer) = origin; + let (components, lifecycle, tags) = registration.into_parts(); + debug_assert!( + tags.is_empty(), + "owned runtime contributes lifecycle commands directly" + ); + for component in components { + let record = records::component_to_record(component.as_ref(), Some(context)).map_err( + |error| { + vec![Diagnostic::error( + "SAND_PROGRAM_COMMAND", + module, + pointer, + error.to_string(), + )] + }, + )?; + self.runtime.own_function( + format!("{}:{}", record.namespace, record.path), + module.to_owned(), + ); + self.records.push(record); + } + for (index, action) in lifecycle.into_iter().enumerate() { + let output = match action.phase() { + LifecyclePhase::Load => &mut *load, + LifecyclePhase::Tick => &mut *tick, + }; + output.push((owner.to_owned(), index, action.command().into())); + } + Ok(()) + } + + fn menu_component(&self, menu: &MenuDefinition) -> crate::gameplay::Menu { + use crate::{condition::Condition, gameplay::Menu}; + use sand_components::effect::Ticks; + + let mut definition = Menu::new( + menu.id.clone(), + static_text_component(&menu.title, &self.holders), + Ticks::new(menu.ticks), + ); + if let Some(size) = menu.page_size { + definition = definition.page_size(size as usize); + } + let flag = |score: &FieldReference| { + Condition::flag( + self.holders[&score.state.to_string()].to_string(), + objective(score), + true, + ) + }; + if let Some(score) = &menu.while_open { + definition = definition.while_open(flag(score)); + } + if let Some(start) = &menu.start { + definition = definition.encoded_start(menu.view_index(start).expect("validated view")); + } + for (index, (choices, _)) in menu.choice_lists().enumerate() { + if let Some(view) = index.checked_sub(1).and_then(|index| menu.views.get(index)) { + definition = definition.encoded_view( + index as i32, + static_text_component(&view.title, &self.holders), + ); + } + for choice in choices { + let function = choice.action.as_ref().map(reference_id); + let next = choice + .next + .as_deref() + .and_then(|name| menu.view_index(name)); + let allowed = choice + .when + .as_ref() + .map_or_else(|| Condition::all([]), flag); + definition = definition.encoded_choice( + static_text_component(&choice.label, &self.holders), + allowed, + next, + move || { + crate::ir::Actions(function.iter().cloned().map(Cmd::Function).collect()) + }, + ); + } + } + definition + } + + fn hud_component(&self, hud: &HudDefinition) -> crate::gameplay::Hud { + use crate::{ + entity::{PlayerKind, StatCurve}, + gameplay::{Hud, Lifetime}, + }; + use sand_components::effect::Ticks; + + let lifetime = Lifetime::::new(hud.id.clone(), Ticks::new(hud.ticks)) + .include_dimensions(self.dimensions.iter().cloned()) + .every(Ticks::new(hud.every.unwrap_or(1))); + let mut definition = Hud::new(lifetime); + if !hud.actionbar.is_empty() { + definition = definition.actionbar(static_text_component(&hud.actionbar, &self.holders)); + } + if let Some(bar) = &hud.bossbar { + let value = match &bar.value { + ScoreOperand::Value(value) => StatCurve::from(f64::from(*value)), + ScoreOperand::Field(field) => StatCurve::runtime_score( + self.holders[&field.state.to_string()].clone(), + sand_commands::ObjectiveName::logical(format!( + "{}.{}", + field.state, field.field + )), + 1, + ), + }; + definition = definition.bossbar( + static_text_component(&bar.title, &self.holders), + value, + bar.max, + ); + } + definition + } + + fn store_command_result(&self, score: &FieldReference, command: String) -> Cmd { + Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Score { + holder: self.holders[&score.state.to_string()].clone(), + objective: objective(score), + }, + )], + run: Box::new(Cmd::Raw(command)), + } + } + + /// Commands that create a boss bar and refresh its display at load. + fn boss_bar_setup(&self, bar: &BossBar) -> Vec { + let id = &bar.id; + let title = static_text_component(&bar.title, &self.holders); + let color = match bar.color { + BossBarColor::Blue => "blue", + BossBarColor::Green => "green", + BossBarColor::Pink => "pink", + BossBarColor::Purple => "purple", + BossBarColor::Red => "red", + BossBarColor::White => "white", + BossBarColor::Yellow => "yellow", + }; + let style = match bar.style { + BossBarStyle::Progress => "progress", + BossBarStyle::Notched6 => "notched_6", + BossBarStyle::Notched10 => "notched_10", + BossBarStyle::Notched12 => "notched_12", + BossBarStyle::Notched20 => "notched_20", + }; + let name = title.to_string(); + vec![ + format!("bossbar add {id} {name}"), + format!("bossbar set {id} name {name}"), + format!("bossbar set {id} color {color}"), + format!("bossbar set {id} style {style}"), + format!("bossbar set {id} max {}", bar.max), + ] + } + + // Snapshot validated numeric fields into storage before expanding one + // command. Macro identifiers follow normal helper ownership/collision rules. + fn numeric_command( + &mut self, + scope: (&str, &str, &str, &str), + label: &str, + mut command: String, + arguments: &[NumericArgument<'_>], + strings: &[(&str, String)], + ) -> Result, Vec> { + let (owner, path, module, ptr) = scope; + let storage = format!("{}:sand.args", self.namespace); + let mut setup = Vec::new(); + let mut guards = Vec::new(); + for arg in arguments { + match arg.value { + Amount::Value(value) => { + // Integer absolute x/z coordinates are block-centered by + // Minecraft. Preserve exact numeric positions with a decimal. + let rendered = + if label == "teleport" && !command.contains('~') && value.fract() == 0.0 { + format!("{value:.1}") + } else { + value.to_string() + }; + command = command.replace(&format!("$({})", arg.name), &rendered) + } + Amount::Field(field) => { + let holder = &self.holders[&field.score.state.to_string()]; + let objective = objective(&field.score); + if let Some((min, max)) = arg.bounds { + let lower = (min * field.scale).ceil(); + let upper = (max * field.scale).floor(); + if lower > i32::MAX as f64 || upper < i32::MIN as f64 || lower > upper { + return Ok(Vec::new()); + } + guards.push(format!( + "if score {holder} {objective} matches {}..{}", + lower.max(i32::MIN as f64) as i32, + upper.min(i32::MAX as f64) as i32 + )); + } + setup.push(Cmd::Raw(format!("execute store result storage {storage} {} {} {} run scoreboard players get {holder} {objective}", arg.name, if arg.integer { "int" } else { "double" }, 1.0 / field.scale))); + } + } + } + if setup.is_empty() && strings.is_empty() { + return Ok(vec![Cmd::Raw(command)]); + } + for (name, value) in strings { + // Substitute whole static item arguments, not text containing user + // components inside a macro template. Expansion is not recursive. + setup.push(Cmd::Raw(format!( + "data modify storage {storage} {name} set value {}", + serde_json::to_string(value).expect("string serialization") + ))); + } + let id = helper(&self.namespace, &self.helper_keys[owner], path, label); + self.function(&id, vec![format!("${command}")], module, ptr)?; + let call = format!("function {id} with storage {storage}"); + setup.push(Cmd::Raw(if guards.is_empty() { + call + } else { + format!("execute {} run {call}", guards.join(" ")) + })); + Ok(setup) + } + + /// A custom item as a command item argument with its identity components. + fn item_argument(&self, item: &str) -> Result { + let Some(custom) = self.custom_items.get(item) else { + return Ok(item.to_owned()); + }; + let predicate = custom.item_predicate().map_err(|e| e.to_string())?; + let lowered = sand_components::predicates::lower_item_predicate_for_command(&predicate)?; + let base = lowered + .items + .as_ref() + .and_then(|items| items.first()) + .map(|id| id.to_string()) + .unwrap_or_default(); + Ok(format!("{base}[{}]", lowered.constraints.join(","))) + } + + fn item_stack_argument(&self, item: &str) -> Result { + match self.custom_items.get(item) { + Some(custom) => sand_components::IntoItemStack::try_into_item_stack(custom.clone()) + .map(|stack| stack.to_string()) + .map_err(|error| error.to_string()), + None => Ok(item.to_owned()), + } + } + + fn frame_commands(&self, fields: &[FieldReference], push: bool) -> Vec { + if push { + let storage = frame_storage(&self.namespace); + let mut commands = vec![Cmd::Raw(format!( + "data modify storage {storage} stack append value {{}}" + ))]; + for (index, field) in fields.iter().enumerate() { + if self.is_data_field(field) { + commands.extend( + self.copy_data_field( + field, + &storage, + &format!("stack[-1].f{index}"), + false, + ) + .into_iter() + .map(Cmd::Raw), + ); + continue; + } + commands.push(Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Nbt { + target: sand_commands::DataTarget::Storage(storage.clone()), + path: format!("stack[-1].f{index}"), + kind: sand_commands::NbtStoreKind::Int, + scale: 1.0, + }, + )], + run: Box::new(Cmd::Raw(format!( + "scoreboard players get {} {}", + self.holders[&field.state.to_string()], + objective(field) + ))), + }); + } + commands + } else { + let storage = frame_storage(&self.namespace); + let mut commands = Vec::with_capacity(fields.len() + 1); + for (index, field) in fields.iter().enumerate() { + if self.is_data_field(field) { + commands.extend( + self.copy_data_field(field, &storage, &format!("stack[-1].f{index}"), true) + .into_iter() + .map(Cmd::Raw), + ); + continue; + } + commands.push(Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Score { + holder: self.holders[&field.state.to_string()].clone(), + objective: objective(field), + }, + )], + run: Box::new(Cmd::Raw(format!( + "data get storage {storage} stack[-1].f{index}" + ))), + }); + } + commands.push(Cmd::Raw(format!("data remove storage {storage} stack[-1]"))); + commands + } + } + + fn block_data_address(address: &BlockDataAddress) -> sand_commands::NbtRef { + sand_commands::DataTarget::block(block_position(address.at)).path(address.path.as_str()) + } + + fn condition_test( + &mut self, + condition: &Condition, + ) -> Result { + Ok(match condition { + Condition::Exists(test) => { + sand_commands::ConditionIr::Entity(query_selector(&test.exists)?) + } + Condition::Block(test) => sand_commands::ConditionIr::Block { + position: block_position(test.at), + block: test.block.clone(), + }, + Condition::Biome(test) => sand_commands::ConditionIr::Biome { + position: block_position(test.at), + biome: test.biome.clone(), + }, + Condition::Dimension(test) => { + sand_commands::ConditionIr::Dimension(test.dimension.to_string()) + } + Condition::Holding(test) => sand_commands::ConditionIr::ItemsEntity { + target: sand_commands::Selector::self_(), + slot: crate::item::location::equipment_item_slot(test.slot.unwrap_or( + if test.offhand { + sand_components::EquipmentSlot::Offhand + } else { + sand_components::EquipmentSlot::Mainhand + }, + )) + .map_err(|error| error.to_string())?, + item: self.item_argument(&test.holding)?, + }, + Condition::Advancement { + advancement, + criterion, + } => sand_commands::ConditionIr::Entity( + sand_commands::TargetArgument::into_target_selector( + sand_commands::Target::self_().advancement( + advancement.to_string(), + criterion.as_deref(), + true, + ), + ), + ), + Condition::Predicate { predicate } => { + sand_commands::ConditionIr::Predicate(predicate.to_string()) + } + Condition::Flag(test) => { + self.flags.insert(test.flag); + sand_commands::ConditionIr::Predicate(flag_predicate_id(&self.namespace, test.flag)) + } + Condition::Attached(test) => sand_commands::ConditionIr::ScoreMatches { + holder: sand_commands::ScoreHolder::self_(), + objective: state_objective(&test.attached.to_string(), "presence"), + range: "1..1".into(), + }, + Condition::Range(range) => sand_commands::ConditionIr::ScoreMatches { + holder: self.holders[&range.score.state.to_string()].clone(), + objective: objective(&range.score), + range: format!( + "{}..{}", + range.min.unwrap_or(i32::MIN), + range.max.unwrap_or(i32::MAX) + ), + }, + Condition::Relation(relation) => sand_commands::ConditionIr::ScoreCompare { + left: self.holders[&relation.left.state.to_string()].clone(), + left_objective: objective(&relation.left), + op: match relation.relation { + Relation::Lt => sand_commands::ScoreCmp::Lt, + Relation::Le => sand_commands::ScoreCmp::Le, + Relation::Eq => sand_commands::ScoreCmp::Eq, + Relation::Ge => sand_commands::ScoreCmp::Ge, + Relation::Gt => sand_commands::ScoreCmp::Gt, + }, + right: self.holders[&relation.right.state.to_string()].clone(), + right_objective: objective(&relation.right), + }, + }) + } + + fn body( + &mut self, + body: &[Operation], + owner: &str, + path: &str, + module: &str, + ptr: &str, + ) -> Result> { + let mut commands = CommandBody { + authored: true, + ..CommandBody::default() + }; + for (index, operation) in body.iter().enumerate() { + let path = if path.is_empty() { + index.to_string() + } else { + format!("{path}/{index}") + }; + let ptr = format!("{ptr}/{index}"); + let fail = |error: String| { + let mut error = Diagnostic::error("SAND_PROGRAM_COMMAND", module, &ptr, error); + error.origin = operation.origin.clone(); + vec![error] + }; + let cmds = match &operation.action { + Action::ScoreSet { score, value } | Action::ScoreAdd { score, value } => { + let bounds = self + .bounds + .get(&format!("{}.{}", score.state, score.field)) + .copied(); + let objective = objective(score); + let holder = &self.holders[&score.state.to_string()]; + if matches!(operation.action, Action::ScoreSet { .. }) { + // Portable v1 assigns only integer literals to @s or a + // global holder. Canonical constant lowering is local: + // it allocates no helpers or ambient registry state. + NumericWrite { + value: crate::entity::StatCurve::from(*value), + holder: holder.clone(), + objective: sand_commands::ObjectiveName::logical(objective), + scale: 1, + fixed: crate::entity::FixedPoint::default(), + bounds, + dirty: Vec::new(), + } + .lower(&module.parse().expect("validated module identity")) + .map_err(|error| fail(error.to_string()))? + } else { + let mut commands = + crate::ir::score_delta(holder, &objective, *value, false); + if let Some(bounds) = bounds { + commands.extend(crate::ir::score_bounds(holder, &objective, bounds)); + } + commands + } + } + Action::Call { function } => vec![Cmd::Function(reference_id(function))], + Action::Raw { command } => vec![Cmd::Raw(command.clone())], + Action::Players { body } => { + let target = if let [ + Operation { + action: + Action::Call { + function: function @ FunctionReference::Internal { .. }, + }, + .. + }, + ] = body.as_slice() + { + reference_id(function) + } else { + let id = + helper(&self.namespace, &self.helper_keys[owner], &path, "players"); + let mut lines = self.body( + body, + owner, + &format!("{path}/players"), + module, + &format!("{ptr}/action/body"), + )?; + if let Some(init) = &self.init { + lines.prepend_initializer(init); + } + self.function(&id, lines, module, &ptr)?; + id + }; + vec![Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::As( + sand_commands::Selector::all_players(), + )], + run: Box::new(Cmd::Function(target)), + }] + } + Action::ScoreOperation { + score, + operator, + operand, + } => { + let holder = self.holders[&score.state.to_string()].clone(); + let target_objective = objective(score); + let mut commands = Vec::new(); + let (source, source_objective) = match operand { + ScoreOperand::Field(field) => ( + self.holders[&field.state.to_string()].clone(), + objective(field), + ), + ScoreOperand::Value(value) => { + self.constants.insert(*value); + ( + constant_holder(*value), + constants_objective(&self.namespace), + ) + } + }; + commands.push(Cmd::ScorePlayers(crate::ir::ScorePlayersOp::Operation { + target: holder.to_string(), + target_obj: target_objective.clone(), + op: match operator { + ScoreOperator::Set => crate::ir::ScoreOpKind::Assign, + ScoreOperator::Add => crate::ir::ScoreOpKind::Add, + ScoreOperator::Sub => crate::ir::ScoreOpKind::Sub, + ScoreOperator::Mul => crate::ir::ScoreOpKind::Mul, + ScoreOperator::Div => crate::ir::ScoreOpKind::Div, + ScoreOperator::Mod => crate::ir::ScoreOpKind::Mod, + ScoreOperator::Min => crate::ir::ScoreOpKind::Min, + ScoreOperator::Max => crate::ir::ScoreOpKind::Max, + }, + source: source.to_string(), + source_obj: source_objective, + })); + if let Some(bounds) = self + .bounds + .get(&format!("{}.{}", score.state, score.field)) + .copied() + { + commands.extend(crate::ir::score_bounds( + &holder, + &target_objective, + bounds, + )); + } + commands + } + Action::ScoreRandom { score, min, max } => { + let holder = self.holders[&score.state.to_string()].clone(); + let target_objective = objective(score); + let mut commands = vec![Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Score { + holder: holder.clone(), + objective: target_objective.clone(), + }, + )], + run: Box::new(Cmd::Raw(format!("random value {min}..{max}"))), + }]; + if let Some(bounds) = self + .bounds + .get(&format!("{}.{}", score.state, score.field)) + .copied() + { + commands.extend(crate::ir::score_bounds( + &holder, + &target_objective, + bounds, + )); + } + commands + } + Action::Message { + audience, + channel, + text, + } => { + let target = match audience { + Audience::Player => sand_commands::Selector::self_(), + Audience::Everyone => sand_commands::Selector::all_players(), + }; + let storage = format!("{}:__program_text", self.namespace); + let mut staged = Vec::new(); + let mut cleanup = Vec::new(); + let component = text_component(text, &self.holders, "p", &mut |value, path| { + let remove = format!("data remove storage {storage} {path}"); + staged.push(remove.clone()); + cleanup.push(remove); + staged.extend(self.copy_data_field(value, &storage, path, false)); + sand_commands::TextComponent::nbt( + sand_commands::DataTarget::storage(&storage).path(format!("{path}[]")), + sand_commands::TextComponent::literal(""), + ) + }); + let lines = match channel { + MessageChannel::Chat => vec![crate::cmd::tellraw(target, component)], + MessageChannel::Actionbar => { + vec![sand_commands::Actionbar::show(target, component)] + } + MessageChannel::Title => sand_commands::Title::of(target) + .title(component) + .try_build() + .map_err(|e| fail(e.to_string()))?, + MessageChannel::Subtitle => sand_commands::Title::of(target) + .subtitle(component) + .try_build() + .map_err(|e| fail(e.to_string()))?, + }; + staged.extend(lines); + staged.extend(cleanup); + staged.into_iter().map(Cmd::Raw).collect() + } + Action::Dialog { dialog } => vec![Cmd::Raw(match dialog { + Some(dialog) => crate::cmd::show_dialog( + sand_commands::Target::self_(), + sand_components::DialogId::custom(dialog.clone()), + ), + None => "dialog clear @s".into(), + })], + Action::Sound { + sound, + volume, + pitch, + } => self.numeric_command( + (owner, &path, module, &ptr), + "sound", + format!("playsound {sound} master @s ~ ~ ~ $(volume) $(pitch)"), + &[ + NumericArgument { + name: "volume", + value: volume, + integer: false, + bounds: Some((0.0, f32::MAX as f64)), + }, + NumericArgument { + name: "pitch", + value: pitch, + integer: false, + bounds: Some((0.0, 2.0)), + }, + ], + &[], + )?, + Action::Particle { + particle, + count, + spread, + speed, + } => self.numeric_command( + (owner, &path, module, &ptr), + "particle", + format!( + "particle {particle} ~ ~1 ~ $(spread) $(spread) $(spread) $(speed) $(count)" + ), + &[ + NumericArgument { + name: "spread", + value: spread, + integer: false, + bounds: Some((0.0, 1000.0)), + }, + NumericArgument { + name: "speed", + value: speed, + integer: false, + bounds: Some((0.0, 1000.0)), + }, + NumericArgument { + name: "count", + value: &whole_amount(count), + integer: true, + bounds: Some((0.0, 100_000.0)), + }, + ], + &[], + )?, + Action::Effect { + effect, + seconds, + amplifier, + hide_particles, + } => vec![Cmd::Effect( + sand_commands::EffectCommand::give_raw( + sand_commands::Selector::self_(), + effect.clone(), + ) + .duration(match seconds { + Some(seconds) => sand_commands::EffectDuration::Seconds(*seconds), + None => sand_commands::EffectDuration::Infinite, + }) + .amplifier(*amplifier) + .particles(!hide_particles), + )], + Action::ClearEffect { effect } => vec![Cmd::Raw(match effect { + Some(effect) => format!("effect clear @s {effect}"), + None => "effect clear @s".to_owned(), + })], + Action::GiveItem { item, count } => { + let item = self.item_stack_argument(item).map_err(fail)?; + let count = whole_amount(count); + let dynamic = matches!(count, Amount::Field(_)); + let strings = if dynamic { + vec![("item", item.clone())] + } else { + Vec::new() + }; + self.numeric_command( + (owner, &path, module, &ptr), + "give", + format!( + "give @s {} $(count)", + if dynamic { "$(item)" } else { &item } + ), + &[NumericArgument { + name: "count", + value: &count, + integer: true, + bounds: Some((1.0, 6400.0)), + }], + &strings, + )? + } + Action::SetEquipment { slot, item, count } => { + use sand_commands::inventory::{ + ItemCommandLocation, ItemReplaceCommand, ItemReplaceSource, + }; + + let replace = ItemReplaceCommand { + destination: ItemCommandLocation::Entity { + target: sand_commands::Selector::self_(), + slot: crate::item::location::equipment_item_slot(*slot) + .map_err(|error| fail(error.to_string()))?, + }, + source: match item { + Some(item) => ItemReplaceSource::Stack { + item: self.item_stack_argument(item).map_err(fail)?, + count: *count, + }, + None => ItemReplaceSource::Clear, + }, + }; + vec![Cmd::Raw( + sand_commands::RenderCommand::render(&replace, &self.profile) + .map_err(|error| fail(error.to_string()))?, + )] + } + Action::ClearItem { item, count } => { + let inventory = sand_commands::Inventory::of(sand_commands::Selector::self_()); + // Custom items clear by their custom_data identity. + let item = match item { + Some(item) => Some(self.item_argument(item).map_err(fail)?), + None => None, + }; + match (item, count) { + (Some(item), Some(ScoreOperand::Value(count))) => { + vec![Cmd::Raw(inventory.clear_item_count(item, *count as u32))] + } + (Some(item), Some(count @ ScoreOperand::Field(_))) => { + inventory + .try_clear_item_count(&item, 0) + .map_err(|error| fail(error.to_string()))?; + self.numeric_command( + (owner, &path, module, &ptr), + "clear_item", + "clear @s $(item) $(count)".to_owned(), + &[NumericArgument { + name: "count", + value: &whole_amount(count), + integer: true, + bounds: Some((0.0, f64::from(i32::MAX))), + }], + &[("item", item)], + )? + } + (Some(item), None) => vec![Cmd::Raw(inventory.clear_item(item))], + (None, _) => vec![Cmd::Raw(inventory.clear_all())], + } + } + Action::Menu { menu, open } => { + let definition = &self.menus[&menu.to_string()]; + if *open { + definition.open().0 + } else { + definition.close().0 + } + } + Action::Hud { hud, show } => { + let definition = &self.huds[&hud.to_string()]; + if *show { + definition.start().0 + } else { + definition.cancel().0 + } + } + Action::TransferInventory { transfer } => { + crate::gameplay::InventoryTransfer::invoke(transfer).0 + } + Action::CountItems { item, score } => { + let inventory = + sand_commands::Inventory::of(sand_commands::Target::current_player()); + let predicate = self.item_argument(item).map_err(fail)?; + let command = inventory + .try_clear_item_count(predicate, 0) + .map_err(|error| fail(error.to_string()))?; + vec![self.store_command_result(score, command)] + } + Action::Schedule { function, ticks } => { + vec![Cmd::Raw(sand_commands::builtins::schedule_replace_raw( + reference_id(function), + format!("{ticks}t"), + ))] + } + Action::Branch { + condition, + then, + otherwise, } => { let yes = helper(&self.namespace, &self.helper_keys[owner], &path, "then"); let no = helper( @@ -602,38 +2585,753 @@ impl Lower { )?; self.function(&yes, yes_body, module, &ptr)?; self.function(&no, no_body, module, &ptr)?; - let range = format!( - "{}..{}", - condition.min.unwrap_or(i32::MIN), - condition.max.unwrap_or(i32::MAX) - ); + let test = self.condition_test(condition).map_err(fail)?; + let propagate = returns(then) || returns(otherwise); let guard = Cmd::Execute { - operations: vec![sand_commands::ExecuteOp::If( - sand_commands::ConditionIr::ScoreMatches { - holder: self.holders[&condition.score.state.to_string()].clone(), - objective: objective(&condition.score), - range, - }, - )], + operations: vec![sand_commands::ExecuteOp::If(test)], run: Box::new(Cmd::ReturnRun(Box::new(Cmd::Function(yes)))), }; + // Without early returns the decision keeps its original + // shape; with them, both outcomes forward the helper result. + let otherwise_call = if propagate { + Cmd::ReturnRun(Box::new(Cmd::Function(no))) + } else { + Cmd::Function(no) + }; self.function( &decision, - vec![guard.render(), Cmd::Function(no).render()], + vec![guard.render(), otherwise_call.render()], module, &ptr, )?; - vec![Cmd::Function(decision)] + vec![call_helper(decision, propagate)] + } + Action::Return => vec![Cmd::Return(1)], + Action::Entities { query, body } => { + let id = helper(&self.namespace, &self.helper_keys[owner], &path, "entities"); + let lines = self.body( + body, + owner, + &format!("{path}/entities"), + module, + &format!("{ptr}/action/body"), + )?; + self.function(&id, lines, module, &ptr)?; + vec![Cmd::Execute { + operations: vec![ + sand_commands::ExecuteOp::As(query_selector(query).map_err(fail)?), + sand_commands::ExecuteOp::At(sand_commands::Selector::self_()), + ], + run: Box::new(Cmd::Function(id)), + }] + } + Action::Kill => vec![Cmd::Raw("kill @s".into())], + Action::Ride { vehicle: None } => vec![Cmd::Raw("ride @s dismount".into())], + Action::Ride { + vehicle: Some(vehicle), + } => { + let identity = crate::gameplay::identity::objective( + &format!("{}:entities", self.namespace) + .parse() + .expect("valid scope"), + ) + .map_err(|error| fail(error.to_string()))?; + let selector = crate::gameplay::identity::non_player_selector( + &identity.to_string(), + "$(vehicle)", + ); + let value = Amount::Field(ScaledField { + score: vehicle.clone(), + scale: 1.0, + }); + self.numeric_command( + (owner, &path, module, &ptr), + "mount", + format!("execute if entity {selector} run ride @s mount {selector}"), + &[NumericArgument { + name: "vehicle", + value: &value, + integer: true, + bounds: Some((1.0, 2147483646.0)), + }], + &[], + )? + } + Action::SetVelocity { x, y, z } => { + let arguments = + [("x", x), ("y", y), ("z", z)].map(|(name, value)| NumericArgument { + name, + value, + integer: false, + bounds: Some((-10.0, 10.0)), + }); + self.numeric_command( + (owner, &path, module, &ptr), + "set_velocity", + "execute if entity @s[type=!minecraft:player] run data modify entity @s Motion set value [$(x)d,$(y)d,$(z)d]".into(), + &arguments, + &[], + )? + } + Action::Teleport { destination } => match destination { + TeleportDestination::Position { x, y, z } + | TeleportDestination::Offset { x, y, z } => { + let relative = matches!(destination, TeleportDestination::Offset { .. }); + let dynamic = [x, y, z].iter().any(|v| matches!(v, Amount::Field(_))); + // Macro doubles may render without a decimal suffix. + // Relative coordinates never receive block centering; + // anchor absolute runtime positions at the world's zero. + let anchor = if dynamic && !relative { + "execute positioned 0.0 0.0 0.0 run " + } else { + "" + }; + let prefix = if relative || dynamic { "~" } else { "" }; + self.numeric_command( + (owner, &path, module, &ptr), + "teleport", + format!("{anchor}tp @s {prefix}$(x) {prefix}$(y) {prefix}$(z)"), + &[ + NumericArgument { + name: "x", + value: x, + integer: false, + bounds: None, + }, + NumericArgument { + name: "y", + value: y, + integer: false, + bounds: None, + }, + NumericArgument { + name: "z", + value: z, + integer: false, + bounds: None, + }, + ], + &[], + )? + } + TeleportDestination::Entity { query } => { + let mut query = query.clone(); + query.limit = Some(1); + query.sort = query.sort.or(Some(EntitySort::Nearest)); + vec![Cmd::Raw(format!( + "tp @s {}", + query_selector(&query).map_err(fail)? + ))] + } + }, + // Mirrors Rust's `state_attach_commands` for entity State: + // keep existing values, default the rest, then mark present. + Action::AttachState { state } => { + let id = state.to_string(); + let mut commands: Vec = self.entity_states[&id] + .iter() + .map(|(field, default)| { + let objective = state_objective(&id, field); + Cmd::Raw(format!( + "execute unless score @s {objective} matches -2147483648.. run scoreboard players set @s {objective} {default}" + )) + }) + .collect(); + for field in &self.data_states[&id].data_fields { + commands.extend( + crate::state::owned::with_data_field( + &self.data_states[&id], + &field.name, + crate::entity::state::state_data_initialize_commands, + ) + .into_iter() + .map(Cmd::Raw), + ); + } + let presence = state_objective(&id, "presence"); + commands.push(Cmd::Raw(format!( + "execute unless score @s {presence} matches 1.. run scoreboard players set @s {presence} 1" + ))); + commands + } + // Mirrors Rust's `state_detach_commands` with dirty tracking. + Action::DetachState { state } => { + let id = state.to_string(); + let mut commands = Vec::new(); + for (field, _) in &self.entity_states[&id] { + commands.push(Cmd::Raw(format!( + "scoreboard players reset @s {}", + state_objective(&id, field) + ))); + commands.push(Cmd::Raw(format!( + "scoreboard players reset @s {}", + state_objective(&id, &format!("{field}.dirty")) + ))); + } + for field in &self.data_states[&id].data_fields { + commands.extend( + crate::state::owned::with_data_field( + &self.data_states[&id], + &field.name, + crate::entity::state::state_data_remove_commands, + ) + .into_iter() + .map(Cmd::Raw), + ); + } + commands.push(Cmd::Raw(format!( + "scoreboard players reset @s {}", + state_objective(&id, "reconcile_dirty") + ))); + commands.push(Cmd::Raw(format!( + "scoreboard players reset @s {}", + state_objective(&id, "presence") + ))); + commands + } + Action::SetBlock { block, at } => { + vec![Cmd::Raw(format!( + "setblock {} {block}", + block_position(*at) + ))] + } + Action::FillBlocks { block, from, to } => vec![Cmd::Raw(format!( + "fill {} {} {block}", + block_position(*from), + block_position(*to) + ))], + Action::CloneBlocks { + from, + to, + destination, + masked, + filter, + mode, + } => { + let clone = sand_commands::CloneBlocks::new( + block_position(*from), + block_position(*to), + block_position(*destination), + ) + .clone_mode(*mode); + let clone = match (masked, filter) { + (_, Some(filter)) => clone.filtered(filter), + (true, _) => clone.masked(), + _ => clone, + }; + let command = sand_commands::RenderCommand::render(&clone, &self.profile) + .map_err(|error| fail(error.to_string()))?; + vec![Cmd::Raw(command)] + } + Action::PlaceTemplate { template, at } => { + let position = block_position(*at); + #[cfg(not(sand_placeholder_codegen))] + let command = crate::cmd::place_template(template.clone()) + .pos(position) + .to_string(); + #[cfg(sand_placeholder_codegen)] + let command = format!("place template {template} {position}"); + vec![Cmd::Raw(command)] + } + + Action::InDimension { dimension, body } => { + let id = helper( + &self.namespace, + &self.helper_keys[owner], + &path, + "in_dimension", + ); + let lines = self.body( + body, + owner, + &format!("{path}/dimension"), + module, + &format!("{ptr}/action/body"), + )?; + self.function(&id, lines, module, &ptr)?; + vec![Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::In(dimension.to_string())], + run: Box::new(call_helper(id, returns(body))), + }] + } + Action::ReadEntityData { path, score } => { + let command = sand_commands::Nbt::entity(sand_commands::Selector::self_()) + .typed_path::(sand_commands::NbtPath::new(path)) + .get() + .try_render(&self.profile) + .map_err(|error| fail(error.to_string()))?; + vec![self.store_command_result(score, command)] + } + Action::ReadBlockData { target, score } => { + let command = Self::block_data_address(target) + .get() + .try_render(&self.profile) + .map_err(|error| fail(error.to_string()))?; + vec![self.store_command_result(score, command)] + } + Action::WriteBlockData { + value: Some(DataOperand::Reference { .. }), + .. + } => self.data_operation(&operation.action, owner, &path, module, &ptr)?, + Action::WriteBlockData { target, value } => { + let address = Self::block_data_address(target); + match value { + Some(DataOperand::Score { + value: ScoreOperand::Field(score), + }) => { + // Check the same path with the typed writable data model. + address + .set(sand_commands::NbtValue::Int(0)) + .try_render(&self.profile) + .map_err(|error| fail(error.to_string()))?; + let holder = self.holders[&score.state.to_string()].clone(); + let objective = objective(score); + vec![Cmd::Execute { + operations: vec![ + sand_commands::ExecuteOp::If( + sand_commands::ConditionIr::ScoreMatches { + holder: holder.clone(), + objective: objective.clone(), + range: "-2147483648..2147483647".into(), + }, + ), + sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Nbt { + target: sand_commands::DataTarget::block( + block_position(target.at), + ), + path: target.path.clone(), + kind: sand_commands::NbtStoreKind::Int, + scale: 1.0, + }, + ), + ], + run: Box::new(Cmd::Raw(format!( + "scoreboard players get {holder} {objective}" + ))), + }] + } + other => { + let command = match other { + Some(DataOperand::Value { value }) => address.set(value.clone()), + Some(DataOperand::Block { value }) => { + address.copy_from(&Self::block_data_address(value)) + } + Some(DataOperand::Score { + value: ScoreOperand::Value(number), + }) => address.set(sand_commands::NbtValue::Int(*number)), + None => address.remove(), + Some( + DataOperand::Score { + value: ScoreOperand::Field(_), + } + | DataOperand::Reference { .. }, + ) => unreachable!(), + }; + vec![Cmd::Raw( + command + .try_render(&self.profile) + .map_err(|error| fail(error.to_string()))?, + )] + } + } + } + Action::AddExperience { amount, levels } => { + let amount = match amount { + ScoreOperand::Value(value) => Amount::Value(*value as f64), + ScoreOperand::Field(score) => Amount::Field(ScaledField { + score: score.clone(), + scale: 1.0, + }), + }; + self.numeric_command( + (owner, &path, module, &ptr), + "experience", + format!( + "xp add @s $(amount) {}", + if *levels { "levels" } else { "points" } + ), + &[NumericArgument { + name: "amount", + value: &amount, + integer: true, + bounds: None, + }], + &[], + )? + } + Action::SetGameMode { mode } => vec![Cmd::Raw(format!( + "gamemode {} @s", + match mode { + PlayerGameMode::Survival => "survival", + PlayerGameMode::Creative => "creative", + PlayerGameMode::Adventure => "adventure", + PlayerGameMode::Spectator => "spectator", + } + ))], + Action::SetTime { ticks } => vec![Cmd::Raw(format!("time set {ticks}"))], + Action::SetWeather { weather, seconds } => { + let weather = match weather { + Weather::Clear => "clear", + Weather::Rain => "rain", + Weather::Thunder => "thunder", + }; + vec![Cmd::Raw(match seconds { + Some(seconds) => format!("weather {weather} {seconds}s"), + None => format!("weather {weather}"), + })] + } + Action::BossBarAudience { + bar, + audience, + visible, + } => { + // `bossbar set players` replaces the viewer list, so a tag + // remembers who sees the bar across individual changes. + let tag = boss_bar_tag(bar); + let targets = match audience { + Audience::Player => "@s", + Audience::Everyone => "@a", + }; + let verb = if *visible { "add" } else { "remove" }; + vec![ + Cmd::Raw(format!("tag {targets} {verb} {tag}")), + Cmd::Raw(format!("bossbar set {bar} players @a[tag={tag}]")), + ] + } + Action::SetBossBar { bar, value, max } => { + let property = if *max { "max" } else { "value" }; + vec![Cmd::Raw(match value { + ScoreOperand::Value(value) => { + format!("bossbar set {bar} {property} {value}") + } + ScoreOperand::Field(field) => format!( + "execute store result bossbar {bar} {property} run scoreboard players get {} {}", + self.holders[&field.state.to_string()], + objective(field) + ), + })] + } + Action::GiveLoot { table } => { + vec![Cmd::Raw(format!("loot give @s loot {table}"))] + } + Action::DropLoot { table } => { + vec![Cmd::Raw(format!("loot spawn ~ ~ ~ loot {table}"))] + } + Action::DataModify { .. } + | Action::DataRemove { .. } + | Action::DataRead { .. } + | Action::DataEqual { .. } => { + self.data_operation(&operation.action, owner, &path, module, &ptr)? + } + Action::PushFrame { fields } => self.frame_commands(fields, true), + Action::PopFrame { fields } => self.frame_commands(fields, false), + Action::Suspend { + ticks, + fields, + body, + } => self.suspend((owner, &path, module, &ptr), ticks, fields, body)?, + Action::CancelWaits => { + self.cancel_waits = true; + vec![Cmd::Function(self.cancellation_function())] + } + Action::DataGet { + score, + value, + scale, + } => vec![Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Score { + holder: self.holders[&score.state.to_string()].clone(), + objective: objective(score), + }, + )], + run: Box::new(Cmd::Raw(format!( + "data get entity @s {} {scale}", + value.path() + ))), + }], + Action::EntityTag { tag, add } => vec![Cmd::Raw(format!( + "tag @s {} {tag}", + if *add { "add" } else { "remove" } + ))], + Action::Summon { entity_type, tag } => vec![Cmd::Raw(match tag { + Some(tag) => format!("summon {entity_type} ~ ~ ~ {{Tags:[\"{tag}\"]}}"), + None => format!("summon {entity_type} ~ ~ ~"), + })], + Action::CaptureEntity { score, relation } => { + let identity = crate::gameplay::identity::objective( + &format!("{}:entities", self.namespace) + .parse() + .expect("valid scope"), + ) + .map_err(|error| fail(error.to_string()))?; + let id = helper( + &self.namespace, + &self.helper_keys[owner], + &path, + "capture_entity", + ); + self.function(&id, vec![ + format!("execute if score @s {identity} matches 1.. run return run scoreboard players get @s {identity}"), + format!("scoreboard players add #next {identity} 0"), + format!("execute unless score #next {identity} matches 0..2147483645 run return 0"), + format!("scoreboard players add #next {identity} 1"), + format!("scoreboard players operation @s {identity} = #next {identity}"), + format!("return run scoreboard players get @s {identity}"), + ], module, &ptr)?; + let holder = &self.holders[&score.state.to_string()]; + // Resolve the destination holder before traversal changes @s. + let on = relation.map_or_else(String::new, |relation| { + format!(" on {}", relation.keyword()) + }); + vec![ + Cmd::Raw(format!( + "scoreboard players set {holder} {} 0", + objective(score) + )), + Cmd::Raw(format!( + "execute store result score {holder} {}{on} run function {id}", + objective(score) + )), + ] + } + Action::WithEntity { + reference, + players, + body, + } => { + let identity = crate::gameplay::identity::objective( + &format!("{}:entities", self.namespace) + .parse() + .expect("valid scope"), + ) + .map_err(|error| fail(error.to_string()))?; + let id = helper( + &self.namespace, + &self.helper_keys[owner], + &path, + "with_entity_body", + ); + let mut lines = self.body( + body, + owner, + &format!("{path}/with_entity"), + module, + &format!("{ptr}/action/body"), + )?; + if *players && let Some(init) = &self.init { + lines.prepend_initializer(init); + } + self.function(&id, lines, module, &ptr)?; + let selectors = crate::gameplay::identity::selectors( + if *players { "player" } else { "entity" }, + &identity.to_string(), + "$(reference)", + ); + // Each selector is expanded before its callback runs. Use one + // dispatch macro so recursive callbacks cannot change a later + // selection through shared numeric argument storage. + let dispatch = helper( + &self.namespace, + &self.helper_keys[owner], + &path, + "with_entity_dispatch", + ); + let mut lines: Vec<_> = selectors + .into_iter() + .map(|selector| { + format!("$execute as {selector} at @s run return run function {id}") + }) + .collect(); + lines.push("return 0".into()); + self.function(&dispatch, lines, module, &ptr)?; + let value = Amount::Field(ScaledField { + score: reference.clone(), + scale: 1.0, + }); + self.numeric_command( + (owner, &path, module, &ptr), + "with_entity", + format!("function {dispatch} {{reference:$(reference)}}"), + &[NumericArgument { + name: "reference", + value: &value, + integer: true, + bounds: Some((1.0, 2147483646.0)), + }], + &[], + )? + } + Action::Damage { + amount, + by, + damage_type, + } => { + let id = damage_type.as_ref().map(ToString::to_string); + let reference; + let mut arguments = vec![NumericArgument { + name: "amount", + value: amount, + integer: false, + bounds: Some((0.01, 1_000_000.0)), + }]; + let command = if let Some(by) = by { + let identity = crate::gameplay::identity::objective( + &format!("{}:entities", self.namespace) + .parse() + .expect("valid scope"), + ) + .map_err(|error| fail(error.to_string()))?; + reference = Amount::Field(ScaledField { + score: by.clone(), + scale: 1.0, + }); + arguments.push(NumericArgument { + name: "attacker", + value: &reference, + integer: true, + bounds: Some((1.0, 2147483646.0)), + }); + let dispatch = helper( + &self.namespace, + &self.helper_keys[owner], + &path, + "damage_source", + ); + let damage_type = id.as_deref().unwrap_or("minecraft:generic"); + let mut lines: Vec<_> = crate::gameplay::identity::selectors("entity", &identity.to_string(), "$(attacker)").into_iter().map(|selector| format!("$execute if entity {selector} run return run damage @s $(amount) {damage_type} by {selector}")).collect(); + lines.push("return 0".into()); + self.function(&dispatch, lines, module, &ptr)?; + format!("function {dispatch} {{amount:$(amount),attacker:$(attacker)}}") + } else { + id.map_or_else( + || "damage @s $(amount)".into(), + |id| format!("damage @s $(amount) {id}"), + ) + }; + self.numeric_command( + (owner, &path, module, &ptr), + "damage", + command, + &arguments, + &[], + )? + } + Action::CountEntities { score, query } => vec![Cmd::Raw(format!( + "execute store result score {} {} if entity {}", + self.holders[&score.state.to_string()], + objective(score), + query_selector(query).map_err(fail)? + ))], + Action::While { condition, body } => { + let looped = helper(&self.namespace, &self.helper_keys[owner], &path, "loop"); + let mut lines = self.body( + body, + owner, + &format!("{path}/loop"), + module, + &format!("{ptr}/action/body"), + )?; + let test = self.condition_test(condition).map_err(fail)?; + // Tail call: re-check the condition after each pass and + // forward an early return from deeper passes. + lines.lines.push( + Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::If(test.clone())], + run: Box::new(Cmd::ReturnRun(Box::new(Cmd::Function(looped.clone())))), + } + .render(), + ); + if self.sources.is_some() { + lines.record(lines.lines.len(), &ptr); + } + self.function(&looped, lines, module, &ptr)?; + let mut operations = vec![sand_commands::ExecuteOp::If(test)]; + let run = if returns(body) { + operations.push(sand_commands::ExecuteOp::If( + sand_commands::ConditionIr::Function(looped), + )); + Cmd::Return(1) + } else { + Cmd::Function(looped) + }; + vec![Cmd::Execute { + operations, + run: Box::new(run), + }] } + Action::AttributeGet { + score, + attribute, + scale, + } => vec![Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::StoreResult( + sand_commands::ExecuteStoreTarget::Score { + holder: self.holders[&score.state.to_string()].clone(), + objective: objective(score), + }, + )], + run: Box::new(Cmd::Raw(format!( + "attribute @s {attribute} base get {scale}" + ))), + }], + Action::AttributeSet { attribute, value } => match value { + Amount::Value(value) => { + vec![Cmd::Raw(format!( + "attribute @s {attribute} base set {value}" + ))] + } + Amount::Field(field) => { + // Minecraft cannot read a score as a command argument; + // copy it into storage and apply it through a macro. + let storage = format!("{}:sand.args", self.namespace); + let id = helper( + &self.namespace, + &self.helper_keys[owner], + &path, + "attribute", + ); + self.function( + &id, + vec![format!("$attribute @s {attribute} base set $(value)")], + module, + &ptr, + )?; + vec![ + Cmd::Execute { + operations: vec![sand_commands::ExecuteOp::Raw(format!( + "store result storage {storage} value double {}", + 1.0 / field.scale + ))], + run: Box::new(Cmd::Raw(format!( + "scoreboard players get {} {}", + self.holders[&field.score.state.to_string()], + objective(&field.score) + ))), + }, + Cmd::Raw(format!("function {id} with storage {storage}")), + ] + } + }, }; + let first_line = commands.lines.len() + 1; for cmd in cmds { let rendered = cmd.try_render().map_err(|e| fail(e.to_string()))?; let rendered = sand_commands::render::validate_standalone_line(&rendered, &self.profile) .map_err(|e| fail(e.to_string()))?; - commands.push(rendered); + commands.lines.push(rendered); + } + if self.sources.is_some() { + commands.record(first_line, &ptr); } } Ok(commands) } } + +/// The command storage that holds saved call frames for recursive functions. +fn frame_storage(namespace: &str) -> String { + format!("{namespace}:__sand_frames") +} diff --git a/sand-core/src/compiler/program/lower/continuations.rs b/sand-core/src/compiler/program/lower/continuations.rs new file mode 100644 index 00000000..30cf1b70 --- /dev/null +++ b/sand-core/src/compiler/program/lower/continuations.rs @@ -0,0 +1,165 @@ +//! Connect portable function continuations to the canonical owned lifetime runtime. +use super::*; +use crate::compiler::export::ExportCtx; +use crate::entity::kind::AnyEntity; +use crate::gameplay::Lifetime; +use crate::registration::{DatapackRegistration, IntoDatapack}; +use sand_components::{ResourceLocation, effect::Ticks}; + +pub(super) struct Continuation { + id: ResourceLocation, + registration: DatapackRegistration, + module: String, + pointer: String, +} + +impl Lower<'_> { + pub(super) fn suspend( + &mut self, + location: (&str, &str, &str, &str), + ticks: &ScoreOperand, + fields: &[FieldReference], + body: &[Operation], + ) -> Result, Vec> { + let (owner, path, module, pointer) = location; + self.continuation_count += 1; + if self.continuation_count > 64 { + return Err(vec![Diagnostic::error( + "SAND_PROGRAM_LIMIT", + module, + pointer, + "a program supports at most 64 distinct wait sites", + )]); + } + + let continuation = helper( + &self.namespace, + &self.helper_keys[owner], + path, + "continuation", + ); + let resume = helper(&self.namespace, &self.helper_keys[owner], path, "resume"); + let id: ResourceLocation = helper(&self.namespace, &self.helper_keys[owner], path, "wait") + .parse() + .expect("valid wait identity"); + let lines = self.body( + body, + owner, + &format!("{path}/wait"), + module, + &format!("{pointer}/action/body"), + )?; + self.function(&continuation, lines, module, pointer)?; + + let storage = frame_storage(&self.namespace); + let append_payload = + format!("data modify storage {storage} stack append from entity @s data.sand_wait"); + let discard_payload = format!("data remove storage {storage} stack[-1]"); + let push = self.frame_commands(fields, true); + let pop = self.frame_commands(fields, false); + // The marker appends its payload. Preserve the live slots in a frame + // under a transient copy of the payload so a synchronous call from the + // continuation can use the same stack and slots safely. + let mut resume_body = push.iter().map(Cmd::render).collect::>(); + resume_body.push(format!( + "data modify storage {storage} stack append from storage {storage} stack[-2]" + )); + resume_body.extend(pop.iter().map(Cmd::render)); + resume_body.push(Cmd::Function(continuation.clone()).render()); + resume_body.extend(pop.iter().map(Cmd::render)); + self.function(&resume, resume_body, module, pointer)?; + + let store = + format!("data modify entity @s data.sand_wait set from storage {storage} stack[-1]"); + let discard_tick = discard_payload.clone(); + let (lifetime, invalid) = match ticks { + ScoreOperand::Value(ticks) => { + let duration = Ticks::new(*ticks as u32); + ( + Lifetime::::new(id.clone(), duration).every(duration), + None, + ) + } + ScoreOperand::Field(score) => { + let holder = self.holders[&score.state.to_string()].clone(); + let objective = sand_commands::ObjectiveName::logical(format!( + "{}.{}", + score.state, score.field + )); + let invalid = Cmd::Raw(format!( + "execute unless score {holder} {objective} matches 1.. run return run function {continuation}" + )); + ( + Lifetime::::new(id.clone(), Ticks::new(1)) + .with_duration_score(holder, objective), + Some(invalid), + ) + } + }; + let lifetime = lifetime + .include_dimensions(self.dimensions.iter().cloned()) + .at_invocation_position() + .on_start(move |_| Cmd::Raw(store.clone())) + .on_tick(move |ctx| { + let mut actions = crate::ir::Actions(vec![ + Cmd::Raw("execute unless data entity @s data.sand_wait run return 0".into()), + Cmd::Raw(append_payload.clone()), + ]); + actions.extend([ctx.owner_at_instance(Cmd::Function(resume.clone()))]); + actions.0.push(Cmd::Raw(discard_tick.clone())); + actions + }); + let mut commands = Vec::new(); + commands.extend(invalid); + commands.extend(push); + commands.extend(lifetime.start().0); + commands.push(Cmd::Raw(discard_payload)); + self.continuations.push(Continuation { + id, + registration: lifetime.into_datapack(), + module: module.into(), + pointer: pointer.into(), + }); + Ok(commands) + } + + pub(super) fn register_continuations( + &mut self, + context: &ExportCtx<'_>, + load: &mut Vec, + tick: &mut Vec, + ) -> Result<(), Vec> { + let mut cancellation = Vec::new(); + for continuation in std::mem::take(&mut self.continuations) { + use crate::gameplay::identity; + let Continuation { + id, + registration, + module, + pointer, + } = continuation; + self.register_owned_runtime( + registration, + (&format!("wait {id}"), &module, &pointer), + context, + load, + tick, + )?; + cancellation.extend( + identity::call(&id, "cancel") + .0 + .into_iter() + .map(|command| command.render()), + ); + } + if self.cancel_waits { + let id = self.cancellation_function(); + self.function(&id, cancellation, "", "")?; + } + Ok(()) + } + + pub(super) fn cancellation_function(&self) -> String { + format!("{}:__sand_program/cancel_waits", self.namespace) + } +} diff --git a/sand-core/src/compiler/program/lower/data.rs b/sand-core/src/compiler/program/lower/data.rs new file mode 100644 index 00000000..25b65186 --- /dev/null +++ b/sand-core/src/compiler/program/lower/data.rs @@ -0,0 +1,275 @@ +//! Owned storage lowering. Only integer indices enter macro arguments. +use super::*; + +impl Lower<'_> { + pub(super) fn is_data_field(&self, field: &FieldReference) -> bool { + self.data_states + .get(&field.state.to_string()) + .is_some_and(|state| { + state + .data_fields + .iter() + .any(|candidate| candidate.name == field.field) + }) + } + + pub(super) fn copy_data_field( + &self, + field: &FieldReference, + storage: &str, + path: &str, + write: bool, + ) -> Vec { + crate::state::owned::with_data_field( + &self.data_states[&field.state.to_string()], + &field.field, + |descriptor| { + crate::entity::state::state_data_copy_commands(descriptor, storage, path, write) + }, + ) + } + + fn data_selection( + &self, + reference: &DataReference, + storage: &str, + root: &str, + commands: &mut Vec, + indices: &mut usize, + ) -> String { + commands.push(format!("data remove storage {storage} {root}")); + commands.extend(self.copy_data_field(&reference.field, storage, root, false)); + let mut path = root.to_owned(); + for projection in &reference.path { + match projection { + DataProjection::Member { name } => { + path.push('.'); + path.push_str(name); + } + DataProjection::Each => path.push_str("[]"), + DataProjection::Index { + index: ScoreOperand::Value(index), + } => path.push_str(&format!("[{index}]")), + DataProjection::Index { + index: ScoreOperand::Field(index), + } => { + let argument = format!("i{}", *indices); + *indices += 1; + let holder = &self.holders[&index.state.to_string()]; + let objective = objective(index); + commands.push(format!("execute store result storage {storage} args.{argument} int 1 run scoreboard players get {holder} {objective}")); + commands.push(format!("execute unless score {holder} {objective} matches 0.. run data modify storage {storage} args.valid set value 0b")); + path.push_str(&format!("[$({argument})]")); + } + } + } + path + } + + pub(super) fn data_operation( + &mut self, + action: &Action, + owner: &str, + path: &str, + module: &str, + ptr: &str, + ) -> Result, Vec> { + let fail = |message| { + vec![Diagnostic::error( + "SAND_PROGRAM_COMMAND", + module, + ptr, + message, + )] + }; + let storage = format!("{}:__program_data", self.namespace); + let mut commands = vec![format!( + "data modify storage {storage} args set value {{valid:1b}}" + )]; + let mut indices = 0; + let mut body = Vec::new(); + let mut after = Vec::new(); + let mut result = Vec::new(); + let mut written_score = None; + match action { + Action::DataModify { + target, + operator, + source, + } => { + // Copy both sides before changing either, including a projected + // source of the same root as the target. + let source = match source { + DataOperand::Reference { value } => { + self.data_selection(value, &storage, "input", &mut commands, &mut indices) + } + DataOperand::Block { value } => { + let input = sand_commands::DataTarget::storage(&storage).path("input"); + commands.push(input.remove().try_render(&self.profile).map_err(fail)?); + commands.push( + input + .copy_from(&Self::block_data_address(value)) + .try_render(&self.profile) + .map_err(fail)?, + ); + "input".into() + } + DataOperand::Value { value } => { + commands.push(format!( + "data modify storage {storage} input set value {value}" + )); + "input".into() + } + DataOperand::Score { value } => { + match value { + ScoreOperand::Value(value) => commands.push(format!("data modify storage {storage} input set value {value}")), + ScoreOperand::Field(field) => commands.push(format!("execute store result storage {storage} input int 1 run scoreboard players get {} {}", self.holders[&field.state.to_string()], objective(field))), + } + "input".into() + } + }; + let target_path = + self.data_selection(target, &storage, "output", &mut commands, &mut indices); + let operator = match operator { + sand_commands::DataModifyOperation::Set => "set".into(), + sand_commands::DataModifyOperation::Append => "append".into(), + sand_commands::DataModifyOperation::Prepend => "prepend".into(), + sand_commands::DataModifyOperation::Insert(index) => format!("insert {index}"), + sand_commands::DataModifyOperation::Merge => "merge".into(), + }; + body.push(format!("data modify storage {storage} {target_path} {operator} from storage {storage} {source}")); + body.extend(self.copy_data_field(&target.field, &storage, "output", true)); + } + Action::WriteBlockData { + target, + value: Some(DataOperand::Reference { value }), + } => { + let source = + self.data_selection(value, &storage, "input", &mut commands, &mut indices); + let address = Self::block_data_address(target); + if indices == 0 { + let from = sand_commands::DataTarget::storage(&storage).path(source); + body.push( + address + .copy_from(&from) + .try_render(&self.profile) + .map_err(fail)?, + ); + } else { + // Resolve projections into a plain storage value first. + // The authored block path never enters the macro body. + let output = sand_commands::DataTarget::storage(&storage).path("output"); + commands.push(output.remove().try_render(&self.profile).map_err(fail)?); + body.push(format!( + "data modify storage {storage} output set from storage {storage} {source}" + )); + after.push( + address + .copy_from(&output) + .try_render(&self.profile) + .map_err(fail)?, + ); + } + } + Action::DataRemove { target } => { + if target.path.is_empty() { + return Ok(crate::state::owned::with_data_field( + &self.data_states[&target.field.state.to_string()], + &target.field.field, + crate::entity::state::state_data_remove_commands, + ) + .into_iter() + .map(Cmd::Raw) + .collect()); + } + let target_path = + self.data_selection(target, &storage, "output", &mut commands, &mut indices); + body.push(format!("data remove storage {storage} {target_path}")); + body.extend(self.copy_data_field(&target.field, &storage, "output", true)); + } + Action::DataRead { score, source } => { + written_score = Some(score); + let source = + self.data_selection(source, &storage, "input", &mut commands, &mut indices); + let holder = &self.holders[&score.state.to_string()]; + let objective = objective(score); + commands.push(format!("scoreboard players set {holder} {objective} 0")); + body.push(format!("execute store result score {holder} {objective} run data get storage {storage} {source}")); + } + Action::DataEqual { score, left, right } => { + written_score = Some(score); + let left = self.data_selection(left, &storage, "left", &mut commands, &mut indices); + let right = + self.data_selection(right, &storage, "right", &mut commands, &mut indices); + let holder = &self.holders[&score.state.to_string()]; + let objective = objective(score); + commands.push(format!("scoreboard players set {holder} {objective} 0")); + body.push(format!("data remove storage {storage} compare")); + body.push(format!( + "data modify storage {storage} compare set from storage {storage} {left}" + )); + body.push(format!("execute store success storage {storage} unequal byte 1 run data modify storage {storage} compare set from storage {storage} {right}")); + body.push(format!("execute if data storage {storage} {left} if data storage {storage} {right} if data storage {storage} {{unequal:0b}} run scoreboard players set {holder} {objective} 1")); + } + _ => unreachable!("only storage operations use storage lowering"), + } + if indices == 0 { + // Literal projections need neither a macro call nor argument storage. + commands.remove(0); + commands.extend(body); + } else { + let name = helper( + &self.namespace, + &self.helper_keys[owner], + path, + "data_value", + ); + let body: Vec<_> = body + .into_iter() + .map(|line| { + if line.contains("$(") { + format!("${line}") + } else { + line + } + }) + .collect(); + self.function(&name, body, module, ptr)?; + commands.push(format!("execute if data storage {storage} args{{valid:1b}} run function {name} with storage {storage} args")); + commands.push(format!("data remove storage {storage} args")); + } + commands.extend(after); + // Only release scratch actually used by this operation. Reads in a + // bounded collection search must not pay for unrelated write/equality + // buffers on every element. Snapshot ordering and alias safety stay the + // same; no callback or user code runs during these operations. + let scratch: &[&str] = match action { + Action::DataModify { .. } => &["input", "output"], + Action::DataRemove { .. } => &["output"], + Action::DataRead { .. } => &["input"], + Action::WriteBlockData { .. } if indices == 0 => &["input"], + Action::WriteBlockData { .. } => &["input", "output"], + Action::DataEqual { .. } => &["left", "right", "compare", "unequal"], + _ => unreachable!("storage operations only"), + }; + commands.extend( + scratch + .iter() + .map(|field| format!("data remove storage {storage} {field}")), + ); + result.extend(commands.into_iter().map(Cmd::Raw)); + if let Some(score) = written_score + && let Some(bounds) = self + .bounds + .get(&format!("{}.{}", score.state, score.field)) + .copied() + { + result.extend(crate::ir::score_bounds( + &self.holders[&score.state.to_string()], + &objective(score), + bounds, + )); + } + Ok(result) + } +} diff --git a/sand-core/src/compiler/program/mod.rs b/sand-core/src/compiler/program/mod.rs index f4c2ee92..234811a5 100644 --- a/sand-core/src/compiler/program/mod.rs +++ b/sand-core/src/compiler/program/mod.rs @@ -9,10 +9,20 @@ mod validate; pub use crate::compiler::runtime::{RuntimeAdvice, RuntimeReport}; pub use diagnostic::Diagnostic; pub use model::{ - Action, ExecutionContext, FieldReference, Flow, FlowHook, FlowHookPhase, FlowTransition, - Function, FunctionReference, Module, ModuleSource, Operation, Pack, Program, ProgramTarget, - ScoreComparison, ScoreField, State, TagMembership, + Action, Advancement, AdvancementCriterion, AdvancementDisplay, Amount, Audience, BiomeMatches, + BlockDataAddress, BlockMatches, BlockPosition, BossBar, BossBarColor, BossBarStyle, Condition, + CookingMethod, CustomBiome, CustomItem, DataField, DataOperand, DataProjection, DataReference, + DimensionMatches, EntitiesExist, EntityData, EntityFlag, EntityQuery, EntitySort, EventHook, + ExecutionContext, FieldReference, FlagSet, FlatDimension, Flow, FlowHook, FlowHookPhase, + FlowTransition, Function, FunctionReference, HudBossBar, HudDefinition, + InventoryTransferDefinition, ItemHeld, LootItem, LootPool, LootTable, MenuChoice, + MenuDefinition, MenuView, MessageChannel, Module, ModuleSource, NoticeDialog, Operation, Pack, + PlayerEvent, PlayerGameMode, Program, ProgramTarget, Rarity, Recipe, RecipeOutput, Relation, + ResourceTag, ScaledField, ScoreComparison, ScoreField, ScoreOperand, ScoreOperator, + ScoreRelation, State, StateAttached, TagKind, TagMembership, TeleportDestination, TextColor, + TextPart, TextStyle, Weather, WorldPredicate, WrittenBookContent, }; +pub use sand_commands::DataModifyOperation; use std::collections::BTreeMap; // Validation and host discovery consume one catalog as portable coverage grows. @@ -30,6 +40,53 @@ const CAPABILITIES: &[&str] = &[ "lifecycle", "function_tags", "raw_commands", + "score_operations", + "random", + "field_relations", + "messages", + "translated_text", + "interactive_text", + "written_books", + "advancements", + "advancement_completion_events", + "notice_dialogs", + "flat_dimensions", + "custom_biomes", + "structure_templates", + "sounds", + "particles", + "effects", + "items", + "schedule", + "owned_waits", + "player_events", + "control_flow", + "attributes", + "entities", + "custom_items", + "recipes", + "resource_tags", + "entity_state", + "teleport", + "timers", + "blocks", + "world_conditions", + "biome_conditions", + "experience", + "world_state", + "boss_bars", + "loot_tables", + "damage_types", + "predicates", + "smithing_recipes", + "recursion", + "entity_data", + "entity_data_queries", + "inventory_counts", + "runtime_item_removal", + "inventory_transfers", + "owner_huds", + "native_menus", ]; /// Complete deterministic pack output, ready for a host's publication adapter. @@ -55,6 +112,44 @@ pub struct CompiledPack { pub runtime_report: RuntimeReport, } +/// An inclusive line range in an emitted function and the operation it came from. +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::CommandSource", module = "sand::advanced::compiler", + summary = "Trace an emitted command range to its portable operation.", + context = "A location in the optional command source map of a portable compilation.", + minecraft = "Counts lines in the final mcfunction resource after export.", + use_when = ["Mapping generated command diagnostics back to a portable producer"], + avoid_when = ["Only deterministic datapack files are needed"], + example = "use sand::advanced::compiler::CommandSource;", + fields(lines = "Inclusive one-based generated command lines.", module = "Portable module identity.", pointer = "JSON pointer within the module."), +)] +pub struct CommandSource { + /// Inclusive one-based lines in the emitted resource. + pub lines: std::ops::RangeInclusive, + /// Portable module identity. + pub module: String, + /// JSON pointer within the portable module document. + pub pointer: String, +} + +/// Generated function paths and their command sources in line order. +#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::CommandSources", module = "sand::advanced::compiler", + summary = "Index emitted function line ranges by final pack-relative path.", + context = "Optional provenance index produced by portable compilation.", + minecraft = "Refers to the same mcfunction files emitted in CompiledPack.resources.", + use_when = ["Looking up source locations for generated commands"], + avoid_when = ["The host only needs published pack bytes"], + example = "use sand::advanced::compiler::CommandSources;", + fields(functions = "Final resource paths and their command source ranges."), +)] +pub struct CommandSources { + /// Final `.mcfunction` resource paths and their command source ranges. + pub functions: BTreeMap>, +} + /// Stateless portable compiler; repeated and concurrent calls share no state. /// /// Rust collection and JSON producers provide the same owned Program. Explicit @@ -150,8 +245,36 @@ impl Compiler { kind = "method", returns = "The validated result or located diagnostics; schema and capability methods return machine-readable JSON.", params(program = "Resolved owned program with an explicit target."), )] pub fn compile(program: &Program) -> Result> { + Self::compile_inner(program, None) + } + + /// Compile the same pack bytes as [`Self::compile`] and trace emitted command + /// lines to portable operations. Framework initialization without an + /// operation origin is omitted from the index. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Compiler::compile_with_command_sources", module = "sand::advanced::compiler", + summary = "Compile a portable pack and locate emitted command ranges.", + context = "Opt-in provenance for hosts that carry portable JSON pointers back to authored source.", + minecraft = "Emits the same bytes as ordinary portable compilation.", + use_when = ["Displaying source locations for emitted commands"], + avoid_when = ["The host only needs published pack bytes"], + example = "use sand::advanced::compiler::{Compiler, Program}; fn demo(program: &Program) { let _ = Compiler::compile_with_command_sources(program); }", + kind = "method", returns = "Compiled pack and command source index, or validation diagnostics.", params(program = "Resolved owned program with an explicit target."), + )] + pub fn compile_with_command_sources( + program: &Program, + ) -> Result<(CompiledPack, CommandSources), Vec> { + let mut sources = CommandSources::default(); + let pack = Self::compile_inner(program, Some(&mut sources.functions))?; + Ok((pack, sources)) + } + + fn compile_inner( + program: &Program, + sources: Option<&mut BTreeMap>>, + ) -> Result> { let target = validate::validate(program)?; - let lowered = lower::lower(program, &target)?; + let lowered = lower::lower(program, &target, sources)?; Ok(CompiledPack { target: target.resolved_name().into(), resources: lowered.resources, @@ -209,11 +332,25 @@ impl Compiler { kind = "method", returns = "The validated result or located diagnostics; schema and capability methods return machine-readable JSON.", )] pub fn capabilities() -> serde_json::Value { + let schema = Self::schema(); + let vocabulary = |definition: &str, field: &str| -> Vec { + schema["$defs"][definition]["oneOf"] + .as_array() + .into_iter() + .flatten() + .filter_map(|entry| { + entry["properties"][field]["const"] + .as_str() + .map(str::to_string) + }) + .collect() + }; serde_json::json!({ "format": "sand.program", "format_version": 1, "compiler": { "name": "sand", "version": env!("CARGO_PKG_VERSION") }, - "targets": ["26.1", "26.1.1", "26.1.2", "26.2"], - "operations": ["score_set", "score_add", "branch", "players", "call", "raw"], + "targets": sand_version::registry::targets().collect::>(), + "operations": vocabulary("Action", "op"), + "events": vocabulary("PlayerEvent", "kind"), "capabilities": CAPABILITIES, "raw_validation": "explicit opt-in; command-line safety and supported syntax only", "limits": { "document_bytes": limits::DOCUMENT_BYTES, "input_bytes": limits::INPUT_BYTES, diff --git a/sand-core/src/compiler/program/model/data.rs b/sand-core/src/compiler/program/model/data.rs new file mode 100644 index 00000000..6c3cf25c --- /dev/null +++ b/sand-core/src/compiler/program/model/data.rs @@ -0,0 +1,93 @@ +//! Typed projections and operands for component-owned storage values. +use super::{BlockPosition, FieldReference, ScoreOperand}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +/// A checked NBT path in the block entity at a position. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BlockDataAddress", module = "sand::advanced::compiler", + summary = "An addressed block entity value.", + context = "Defines a portable block position and checked NBT path shared by reads and writes.", + minecraft = "Lowers to the canonical block data target and does not load chunks.", + use_when = ["Reading or editing a known block entity field"], + avoid_when = ["Storing pack-owned data independently of a block entity"], + example = "use sand::advanced::compiler::BlockDataAddress;", + fields(at = "Block position.", path = "Checked NBT path within the block entity."), +)] +pub struct BlockDataAddress { + /// Absolute or relative block position. + pub at: BlockPosition, + /// The NBT path, validated before emission. + pub path: String, +} + +/// A State storage field and its checked nested projections. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::DataReference", module = "sand::advanced::compiler", + summary = "A State storage field and its checked nested projections.", + context = "Typed portable storage operands share the canonical State owner lifecycle and NBT command model.", + minecraft = "Values are copied through command storage; dynamic indices are integer macro arguments and authored text remains data.", + use_when = ["Lowering runtime strings, lists or record values from a typed frontend"], + avoid_when = ["An integer score operand is sufficient"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(field = "Owning State storage field.", path = "Nested members or list indices, in order."), +)] +pub struct DataReference { + /// Owning State storage field. + pub field: FieldReference, + /// Nested members or list indices, in order. An empty path selects the root. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub path: Vec, +} + +/// One typed step into a stored value. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::DataProjection", module = "sand::advanced::compiler", + summary = "One typed step into a stored value.", + context = "Typed portable storage operands share the canonical State owner lifecycle and NBT command model.", + minecraft = "Values are copied through command storage; dynamic indices are integer macro arguments and authored text remains data.", + use_when = ["Lowering runtime strings, lists or record values from a typed frontend"], + avoid_when = ["An integer score operand is sufficient"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Member = "Select a named compound member.", Index = "Select a nonnegative list index.", Each = "Select every list element as a modification source."), + variant_fields(Member(name = "Compound member identity."), Index(index = "Nonnegative index, evaluated before the modification.")), +)] +pub enum DataProjection { + /// Select a named compound member. + Member { name: String }, + /// Select a nonnegative list index. Missing or invalid selections skip writes. + Index { index: ScoreOperand }, + /// Select every list element; only valid as the final modification source. + Each, +} + +/// An NBT literal, stored value, or scoreboard integer used in a data write. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::DataOperand", module = "sand::advanced::compiler", + summary = "An NBT literal, stored value, or scoreboard integer used in a data write.", + context = "Typed portable storage operands share the canonical State owner lifecycle and NBT command model.", + minecraft = "Values are copied through command storage; dynamic indices are integer macro arguments and authored text remains data.", + use_when = ["Lowering runtime strings, lists or record values from a typed frontend"], + avoid_when = ["An integer score operand is sufficient"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Value = "A typed NBT literal.", Reference = "A stored value selection.", Score = "A scoreboard integer encoded as NBT int.", Block = "A selection from the native data of a block entity."), + variant_fields(Value(value = "Typed NBT literal; opaque raw SNBT is unsupported."), Reference(value = "Stored value selection."), Score(value = "Integer score operand."), Block(value = "Block entity and checked path.")), +)] +pub enum DataOperand { + /// A typed literal, staged outside any macro template. + Value { value: sand_commands::NbtValue }, + /// A selection from another owned storage field. + Reference { value: DataReference }, + /// A scoreboard integer encoded as NBT int. + Score { value: ScoreOperand }, + /// The selected value in a loaded block entity. + Block { value: BlockDataAddress }, +} diff --git a/sand-core/src/compiler/program/model/envelope.rs b/sand-core/src/compiler/program/model/envelope.rs index 7cb34d7b..acf3a88d 100644 --- a/sand-core/src/compiler/program/model/envelope.rs +++ b/sand-core/src/compiler/program/model/envelope.rs @@ -1,8 +1,13 @@ //! Owned portable envelope definitions. -use super::{Function, Operation, State, TagMembership}; -use sand_components::ResourceLocation; +use super::{ + Advancement, CustomBiome, EventHook, FlatDimension, Function, HudDefinition, + InventoryTransferDefinition, MenuDefinition, NoticeDialog, Operation, State, TagMembership, + WorldPredicate, +}; +use sand_components::{DamageType, ResourceLocation, StructureTemplate}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; /// A complete compilation request with explicit protocol and target metadata. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] @@ -15,7 +20,7 @@ use serde::{Deserialize, Serialize}; use_when = ["Integrating a language, DSL, or editor with Sand without Cargo per program"], avoid_when = ["Ordinary Rust gameplay authoring is better served by the prelude"], example = "let schema = sand::advanced::compiler::Compiler::schema();", - fields(format = "Protocol format discriminator, sand.program.", format_version = "Protocol revision, currently 1.", target = "ProgramTarget for this portable definition.", pack = "Pack for this portable definition.", requires = "Requires for this portable definition.", modules = "Modules for this portable definition."), + fields(format = "Protocol format discriminator, sand.program.", format_version = "Protocol revision, currently 1.", target = "ProgramTarget for this portable definition.", pack = "Pack for this portable definition.", requires = "Requires for this portable definition.", modules = "Modules for this portable definition.", structure_assets = "Gzip NBT bytes keyed by the source names in module structure templates. JSON represents each value as standard Base64."), )] pub struct Program { /// Must be `sand.program`. @@ -31,6 +36,17 @@ pub struct Program { pub requires: Vec, /// Flat module declarations. Resolved programs contain no paths. pub modules: Vec, + /// Binary structure template assets, supplied explicitly by the host. + /// + /// Keys match the package-relative paths in structure template declarations. + /// JSON encodes each byte sequence as standard Base64. + #[serde( + default, + skip_serializing_if = "BTreeMap::is_empty", + with = "asset_encoding" + )] + #[schemars(with = "BTreeMap")] + pub structure_assets: BTreeMap>, } /// A target supplied explicitly by the host, never inferred from environment. @@ -87,7 +103,7 @@ pub struct Pack { )] pub enum ModuleSource { /// A module embedded in the envelope. - Embedded(Module), + Embedded(Box), /// A path resolved by an explicit host resolver. Path(String), } @@ -103,7 +119,7 @@ pub enum ModuleSource { use_when = ["Integrating a language, DSL, or editor with Sand without Cargo per program"], avoid_when = ["Ordinary Rust gameplay authoring is better served by the prelude"], example = "let schema = sand::advanced::compiler::Compiler::schema();", - fields(flows = "State machines bound to canonical player or global State fields.", id = "Id for this portable definition.", states = "States for this portable definition.", functions = "Functions for this portable definition.", load = "Load for this portable definition.", tick = "Tick for this portable definition.", tags = "Tags for this portable definition."), + fields(flows = "State machines bound to canonical player or global State fields.", id = "Id for this portable definition.", states = "States for this portable definition.", functions = "Functions for this portable definition.", load = "Load for this portable definition.", tick = "Tick for this portable definition.", tags = "Tags for this portable definition.", events = "Player event handlers, dispatched in declaration order.", items = "Custom items referred to by id.", recipes = "Crafting, cooking, and stonecutting recipes.", resource_tags = "Item, block, and entity-type tags.", loot_tables = "Loot tables.", boss_bars = "Boss bars, created at load.", damage_types = "Native damage type definitions.", predicates = "Reusable native world predicates.", advancements = "Native advancement resources.", dialogs = "Native notice dialog resources.", dimensions = "Native flat dimension resources.", biomes = "Native custom biome resources.", structure_templates = "Native structure template resources backed by Program::structure_assets.", inventory_transfers = "Reusable inventory transfers between numbered player slots.", huds = "Reusable player-owned HUD definitions.", menus = "Player-owned native dialog menus."), )] pub struct Module { /// Explicit semantic identity, independent of source filename. @@ -127,4 +143,85 @@ pub struct Module { /// Typed function-tag membership. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub tags: Vec, + /// Player event handlers, dispatched in declaration order. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub events: Vec, + /// Custom items that operations and recipes refer to by id. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub items: Vec, + /// Crafting, cooking, and stonecutting recipes. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub recipes: Vec, + /// Item, block, and entity-type tags. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub resource_tags: Vec, + /// Loot tables. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub loot_tables: Vec, + /// Boss bars, created at load. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub boss_bars: Vec, + /// Native damage type definitions. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub damage_types: Vec, + /// Reusable native world predicates. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub predicates: Vec, + /// Native advancements declared by this module. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub advancements: Vec, + /// Native notice dialogs declared by this module. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub dialogs: Vec, + /// Native flat dimensions declared by this module. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub dimensions: Vec, + /// Native custom biomes declared by this module. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub biomes: Vec, + /// Native templates whose bytes are supplied in the envelope. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub structure_templates: Vec, + /// Named inventory transfer definitions owned by this module. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub inventory_transfers: Vec, + /// Named owner-scoped HUD definitions. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub huds: Vec, + /// Native menus with bounded sessions and ordered choices. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub menus: Vec, +} + +mod asset_encoding { + use super::BTreeMap; + use base64::{Engine, engine::general_purpose::STANDARD}; + use serde::{Deserialize, Deserializer, Serializer, ser::SerializeMap}; + + pub(super) fn serialize( + assets: &BTreeMap>, + serializer: S, + ) -> Result { + let mut map = serializer.serialize_map(Some(assets.len()))?; + for (name, bytes) in assets { + map.serialize_entry(name, &STANDARD.encode(bytes))?; + } + map.end() + } + + pub(super) fn deserialize<'de, D: Deserializer<'de>>( + deserializer: D, + ) -> Result>, D::Error> { + BTreeMap::::deserialize(deserializer)? + .into_iter() + .map(|(name, encoded)| { + let bytes = STANDARD.decode(encoded).map_err(|error| { + serde::de::Error::custom(format!( + "invalid Base64 for structure asset `{name}`: {error}" + )) + })?; + Ok((name, bytes)) + }) + .collect() + } } diff --git a/sand-core/src/compiler/program/model/function.rs b/sand-core/src/compiler/program/model/function.rs index 667cf77f..b9c55b41 100644 --- a/sand-core/src/compiler/program/model/function.rs +++ b/sand-core/src/compiler/program/model/function.rs @@ -15,13 +15,16 @@ use serde::{Deserialize, Serialize}; use_when = ["Integrating a language, DSL, or editor with Sand without Cargo per program"], avoid_when = ["Ordinary Rust gameplay authoring is better served by the prelude"], example = "let schema = sand::advanced::compiler::Compiler::schema();", - variants(Server = "Server semantic alternative; see Rustdoc for its execution behavior.", Player = "Player semantic alternative; see Rustdoc for its execution behavior."), + variants(Server = "Server semantic alternative; see Rustdoc for its execution behavior.", Player = "Player semantic alternative; see Rustdoc for its execution behavior.", Entity = "Runs as any entity, including players, without player State."), )] pub enum ExecutionContext { /// Does not access player self; callable in either context. Server, /// Requires a player executor; entry initializes player State. Player, + /// Requires an entity executor (any entity, including players); cannot + /// read player State or use player-only operations. + Entity, } /// An explicitly named function with an ordered typed body. diff --git a/sand-core/src/compiler/program/model/gameplay.rs b/sand-core/src/compiler/program/model/gameplay.rs new file mode 100644 index 00000000..220548ca --- /dev/null +++ b/sand-core/src/compiler/program/model/gameplay.rs @@ -0,0 +1,995 @@ +//! Owned portable gameplay vocabulary: arithmetic, conditions, text, and events. +use super::{FieldReference, FunctionReference, ScoreComparison}; +use sand_commands::ClickEvent; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +/// A vanilla scoreboard arithmetic operator applied to a State field. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::ScoreOperator", module = "sand::advanced::compiler", + summary = "A vanilla scoreboard arithmetic operator applied to a State field.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `scoreboard players operation`, which uses Minecraft's wrapping i32 arithmetic and floor division.", + use_when = ["Combining a State field with another field or a constant in a portable program"], + avoid_when = ["Adding a constant; ScoreAdd emits a single cheaper command"], + example = "let op = sand::advanced::compiler::ScoreOperator::Mul;", + variants(Set = "Copy the operand into the field.", Add = "Add the operand.", Sub = "Subtract the operand.", Mul = "Multiply by the operand.", Div = "Floor-divide by the operand; division by zero leaves the field unchanged.", Mod = "Floor modulo by the operand; modulo zero leaves the field unchanged.", Min = "Keep the smaller of the field and the operand.", Max = "Keep the larger of the field and the operand."), +)] +pub enum ScoreOperator { + /// Copy the operand into the field. + Set, + /// Add the operand. + Add, + /// Subtract the operand. + Sub, + /// Multiply by the operand. + Mul, + /// Floor-divide by the operand; dividing by zero leaves the field unchanged. + Div, + /// Floor modulo by the operand; modulo zero leaves the field unchanged. + Mod, + /// Keep the smaller of the field and the operand. + Min, + /// Keep the larger of the field and the operand. + Max, +} + +/// The right-hand side of a score operation: another field or a constant. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(untagged)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::ScoreOperand", module = "sand::advanced::compiler", + summary = "The right-hand side of a score operation: another field or a constant.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Fields are read from their declared player or global holder; constants use a compiler-owned constant holder.", + use_when = ["Supplying the operand of a ScoreOperation"], + avoid_when = ["Writing a literal with ScoreSet or ScoreAdd"], + example = "let operand = sand::advanced::compiler::ScoreOperand::Value(2);", + variants(Field = "Read another State field.", Value = "Use an integer constant."), + variant_fields(Field = ["The State field read as the operand."], Value = ["The constant operand."]), +)] +pub enum ScoreOperand { + /// Read another State field. + Field(FieldReference), + /// Use an integer constant. + Value(i32), +} + +/// How two State fields relate in a branch condition. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Relation", module = "sand::advanced::compiler", + summary = "How two State fields relate in a branch condition.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `execute if score `.", + use_when = ["Comparing two State fields"], + avoid_when = ["Comparing a field with constants; use a ScoreComparison range"], + example = "let relation = sand::advanced::compiler::Relation::Lt;", + variants(Lt = "Left is less than right.", Le = "Left is at most right.", Eq = "Both fields are equal.", Ge = "Left is at least right.", Gt = "Left is greater than right."), +)] +pub enum Relation { + /// Left is less than right. + Lt, + /// Left is at most right. + Le, + /// Both fields are equal. + Eq, + /// Left is at least right. + Ge, + /// Left is greater than right. + Gt, +} + +/// A comparison between two State fields. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::ScoreRelation", module = "sand::advanced::compiler", + summary = "A comparison between two State fields.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Both fields are read from their declared holders; absent scores make the comparison false.", + use_when = ["Branching on how two State fields relate"], + avoid_when = ["Testing one field against constant bounds"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(left = "The left-hand State field.", relation = "How the fields must relate.", right = "The right-hand State field."), +)] +pub struct ScoreRelation { + /// The left-hand State field. + pub left: FieldReference, + /// How the fields must relate. + pub relation: Relation, + /// The right-hand State field. + pub right: FieldReference, +} + +/// A portable condition evaluated with the current executor and position. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(untagged)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Condition", module = "sand::advanced::compiler", + summary = "A portable condition evaluated with the current executor and position.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Evaluated once using a native execute condition before one branch body runs.", + use_when = ["Choosing between two ordered bodies at runtime"], + avoid_when = ["Flow transition guards, which accept only ranges"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Range = "The field lies within inclusive constant bounds.", Relation = "Two fields satisfy a relation.", Attached = "The executor has an entity State attached.", Exists = "At least one entity matches.", Block = "A block matches at a position.", Dimension = "The execution dimension matches.", Biome = "The biome at a block position matches.", Holding = "The executor holds an item.", Flag = "The executor has an entity flag.", Predicate = "A native predicate matches at the execution origin.", Advancement = "The executing player completed an advancement or criterion."), + variant_fields(Range = ["The range test."], Relation = ["The field relation."], Attached = ["The attached State."], Exists = ["The tested query."], Block = ["The block test."], Dimension = ["The dimension test."], Biome = ["The biome test."], Holding = ["The held-item test."], Flag = ["The flag test."], Predicate(predicate = "The predicate resource identity."), Advancement(advancement = "The native advancement identity.", criterion = "Optional named criterion.")), +)] +pub enum Condition { + /// The field lies within inclusive constant bounds. + Range(ScoreComparison), + /// Two fields satisfy a relation. + Relation(ScoreRelation), + /// The executor has an entity State attached. + Attached(StateAttached), + /// At least one entity matches. + Exists(EntitiesExist), + /// A block matches at a position. + Block(BlockMatches), + /// The current command execution dimension matches. + Dimension(DimensionMatches), + /// A biome matches at a block position. + Biome(BiomeMatches), + /// The executor holds an item. + Holding(ItemHeld), + /// The executor has an entity flag. + Flag(FlagSet), + /// A native predicate evaluated in the current execution context. + Predicate { + #[schemars(with = "String")] + predicate: sand_components::ResourceLocation, + }, + /// Match the current player's advancement or named criterion completion. + Advancement { + #[schemars(with = "String")] + advancement: sand_components::ResourceLocation, + #[serde(default, skip_serializing_if = "Option::is_none")] + criterion: Option, + }, +} + +/// A test of the biome at a block position. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BiomeMatches", module = "sand::advanced::compiler", + summary = "Tests the biome at a block position.", + context = "A portable world predicate using the selected Minecraft target's registry.", + minecraft = "Lowers to `execute if biome `.", + use_when = ["Making a rule depend on the local biome"], + avoid_when = ["Looking for the nearest biome without an exact position"], + example = "use sand::advanced::compiler::BiomeMatches;", + fields(biome = "Namespaced biome identity.", at = "Position to test."), +)] +pub struct BiomeMatches { + /// Namespaced biome identity. + pub biome: String, + /// Absolute or relative position whose biome is tested. + pub at: BlockPosition, +} + +/// A test of the current execution dimension. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::DimensionMatches", module = "sand::advanced::compiler", + summary = "A test of the current execution dimension.", + context = "A portable branch condition that does not require an entity executor.", + minecraft = "Lowers to `execute if dimension `.", + use_when = ["Choosing dimension-specific world operations"], + avoid_when = ["Selecting a different execution dimension"], + example = "use sand::advanced::compiler::DimensionMatches;", + fields(dimension = "The dimension to test."), +)] +pub struct DimensionMatches { + /// Namespaced dimension compared with the current execution level. + #[schemars(with = "String")] + pub dimension: sand_components::ResourceLocation, +} + +/// A test that at least one entity matches a query. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::EntitiesExist", module = "sand::advanced::compiler", + summary = "A test that at least one entity matches a query.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `execute if entity @e[...]`.", + use_when = ["Branching on whether matching entities are present"], + avoid_when = ["Counting them; use CountEntities"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(exists = "The tested query."), +)] +pub struct EntitiesExist { + /// The tested query. + pub exists: EntityQuery, +} + +/// A block position: absolute, or relative to the executor. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BlockPosition", module = "sand::advanced::compiler", + summary = "A block position: absolute, or relative to the executor.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to block coordinates, with `~` for relative positions.", + use_when = ["Naming where a block operation or test applies"], + avoid_when = ["Entity destinations; use TeleportDestination"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Absolute = "World coordinates.", Relative = "Offset from the executor."), + variant_fields(Absolute(x = "X.", y = "Y.", z = "Z."), Relative(x = "X offset.", y = "Y offset.", z = "Z offset.")), +)] +pub enum BlockPosition { + /// World coordinates. + Absolute { x: i32, y: i32, z: i32 }, + /// Offset from the executor. + Relative { x: i32, y: i32, z: i32 }, +} + +/// A test that a block matches at a position. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BlockMatches", module = "sand::advanced::compiler", + summary = "A test that a block matches at a position.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `execute if block `.", + use_when = ["Branching on the world around the executor"], + avoid_when = ["Replacing blocks; use SetBlock"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(block = "Block identity or `#tag`.", at = "Tested position."), +)] +pub struct BlockMatches { + /// Block identity, or `#tag`. + pub block: String, + /// Tested position. + pub at: BlockPosition, +} + +/// A test that the executor holds an item. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::ItemHeld", module = "sand::advanced::compiler", + summary = "A test that the executor holds an item.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `execute if items entity @s weapon.mainhand `, or `weapon.offhand`; custom items match by identity.", + use_when = ["Branching on the held item"], + avoid_when = ["Inventory-wide searches"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(holding = "Vanilla or custom item identity.", offhand = "Test the off hand instead of the main hand.", slot = "Test an explicitly chosen hand or armor slot."), +)] +pub struct ItemHeld { + /// Vanilla or custom item identity. + pub holding: String, + /// Test the off hand instead of the main hand. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub offhand: bool, + /// Explicit hand or armor slot; mutually exclusive with `offhand: true`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub slot: Option, +} + +/// A movement or status flag of an entity. +#[derive( + Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema, +)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::EntityFlag", module = "sand::advanced::compiler", + summary = "A movement or status flag of an entity.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Tested through a generated `minecraft:entity_properties` predicate.", + use_when = ["Branching on what an entity is doing"], + avoid_when = ["Fields of State"], + example = "let flag = sand::advanced::compiler::EntityFlag::Sneaking;", + variants(Sneaking = "Crouching.", Sprinting = "Sprinting.", Swimming = "Swimming.", OnFire = "Burning."), +)] +pub enum EntityFlag { + /// Crouching. + Sneaking, + /// Sprinting. + Sprinting, + /// Swimming. + Swimming, + /// Burning. + OnFire, +} + +/// A test that the executor has an entity flag. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::FlagSet", module = "sand::advanced::compiler", + summary = "A test that the executor has an entity flag.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `execute if predicate` against a generated entity-properties predicate.", + use_when = ["Branching on sneaking, sprinting, swimming, or burning"], + avoid_when = ["Movement statistics, which PlayerEvent observes"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(flag = "The tested flag."), +)] +pub struct FlagSet { + /// The tested flag. + pub flag: EntityFlag, +} + +/// A number stored in the executing entity's data. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::EntityData", module = "sand::advanced::compiler", + summary = "A number stored in the executing entity's data.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Read with `data get entity @s `.", + use_when = ["Reading health, hunger, experience, air, or position into a State field"], + avoid_when = ["Attribute base values, which AttributeGet reads"], + example = "let value = sand::advanced::compiler::EntityData::Health;", + variants(Health = "Current health in half-hearts.", Absorption = "Absorption health.", Air = "Remaining air in ticks.", Fire = "Burning ticks left; negative when not burning.", FallDistance = "Blocks fallen since last on the ground.", OnGround = "One when standing on the ground.", X = "X coordinate.", Y = "Y coordinate.", Z = "Z coordinate.", VelocityX = "Velocity along X.", VelocityY = "Velocity along Y.", VelocityZ = "Velocity along Z.", Food = "Player hunger, 0 to 20.", Saturation = "Player food saturation.", XpLevel = "Player experience level.", XpTotal = "Player total experience points.", XpProgress = "Progress to the next level, 0 to 1.", SelectedSlot = "Player hotbar slot, 0 to 8."), +)] +pub enum EntityData { + /// Current health in half-hearts. + Health, + /// Absorption health. + Absorption, + /// Remaining air in ticks. + Air, + /// Burning ticks left; negative when not burning. + Fire, + /// Blocks fallen since last on the ground. + FallDistance, + /// One when standing on the ground. + OnGround, + /// X coordinate. + X, + /// Y coordinate. + Y, + /// Z coordinate. + Z, + /// X velocity in blocks per tick. + VelocityX, + /// Y velocity in blocks per tick. + VelocityY, + /// Z velocity in blocks per tick. + VelocityZ, + /// Player hunger, 0 to 20. + Food, + /// Player food saturation. + Saturation, + /// Player experience level. + XpLevel, + /// Player total experience points. + XpTotal, + /// Progress to the next level, 0 to 1. + XpProgress, + /// Player hotbar slot, 0 to 8. + SelectedSlot, +} + +impl EntityData { + /// The entity data path that holds this value. + /// + /// `DataGet` reads it with `data get entity @s `. + #[sand_macros::api(kind = "method", registry = sand_api_contract, path = "sand::advanced::compiler::EntityData::path", summary = "The entity data path that holds this value, such as `Health` or `Pos[1]`.", context = "Language hosts show it in editor help; lowering reads it with data get.", minecraft = "The NBT path passed to `data get entity @s`.", use_when = ["Explaining which entity data a DataGet reads"], avoid_when = ["Reading the value; emit a DataGet operation"], returns = "The entity data path.", example = "assert_eq!(sand::advanced::compiler::EntityData::Health.path(), \"Health\");")] + pub fn path(self) -> &'static str { + match self { + Self::Health => "Health", + Self::Absorption => "AbsorptionAmount", + Self::Air => "Air", + Self::Fire => "Fire", + Self::FallDistance => "FallDistance", + Self::OnGround => "OnGround", + Self::X => "Pos[0]", + Self::Y => "Pos[1]", + Self::Z => "Pos[2]", + Self::VelocityX => "Motion[0]", + Self::VelocityY => "Motion[1]", + Self::VelocityZ => "Motion[2]", + Self::Food => "foodLevel", + Self::Saturation => "foodSaturationLevel", + Self::XpLevel => "XpLevel", + Self::XpTotal => "XpTotal", + Self::XpProgress => "XpP", + Self::SelectedSlot => "SelectedItemSlot", + } + } + + /// Whether only players carry this value. + /// + /// Validation requires a player executor for these values. + #[sand_macros::api(kind = "method", registry = sand_api_contract, path = "sand::advanced::compiler::EntityData::player_only", summary = "Whether only players carry this value, such as food or experience.", context = "Language hosts reject reading these from other entities before validation does.", minecraft = "Players store hunger, experience, and the selected slot; other entities do not.", use_when = ["Checking whether a DataGet needs a player executor"], avoid_when = ["Values every living entity has, such as health"], returns = "True for player-only values.", example = "assert!(sand::advanced::compiler::EntityData::Food.player_only());")] + pub fn player_only(self) -> bool { + matches!( + self, + Self::Food + | Self::Saturation + | Self::XpLevel + | Self::XpTotal + | Self::XpProgress + | Self::SelectedSlot + ) + } +} + +/// A player game mode. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::PlayerGameMode", module = "sand::advanced::compiler", + summary = "A player game mode.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the `gamemode` command argument.", + use_when = ["Changing how a player interacts with the world"], + avoid_when = ["Testing the current mode"], + example = "let mode = sand::advanced::compiler::PlayerGameMode::Creative;", + variants(Survival = "Survival.", Creative = "Creative.", Adventure = "Adventure.", Spectator = "Spectator."), +)] +pub enum PlayerGameMode { + /// Survival. + Survival, + /// Creative. + Creative, + /// Adventure. + Adventure, + /// Spectator. + Spectator, +} + +/// World weather. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Weather", module = "sand::advanced::compiler", + summary = "World weather.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the `weather` command argument.", + use_when = ["Changing the weather"], + avoid_when = ["Testing the weather"], + example = "let weather = sand::advanced::compiler::Weather::Rain;", + variants(Clear = "Clear skies.", Rain = "Rain.", Thunder = "Thunderstorm."), +)] +pub enum Weather { + /// Clear skies. + Clear, + /// Rain. + Rain, + /// Thunderstorm. + Thunder, +} + +/// A test that the executor has an entity State attached. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::StateAttached", module = "sand::advanced::compiler", + summary = "A test that the executor has an entity State attached.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Matches when the State's presence score equals its revision, as Rust's attached-State conditions do.", + use_when = ["Branching on whether an entity carries a State"], + avoid_when = ["Player or global State, which is always present"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(attached = "The entity State."), +)] +pub struct StateAttached { + /// The entity State. + #[schemars(with = "String")] + pub attached: sand_components::ResourceLocation, +} + +impl From for Condition { + fn from(range: ScoreComparison) -> Self { + Self::Range(range) + } +} + +/// Who receives a message. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Audience", module = "sand::advanced::compiler", + summary = "Who receives a message.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "`player` targets `@s` and needs a player executor; `everyone` targets `@a`.", + use_when = ["Choosing the recipients of a Message"], + avoid_when = ["Targeting arbitrary entities; messages are player-facing"], + example = "let audience = sand::advanced::compiler::Audience::Everyone;", + variants(Player = "Only the executing player.", Everyone = "Every online player."), +)] +pub enum Audience { + /// Only the executing player. + Player, + /// Every online player. + Everyone, +} + +/// Where a message appears. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::MessageChannel", module = "sand::advanced::compiler", + summary = "Where a message appears.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `tellraw` or the matching `title` sub-command.", + use_when = ["Choosing how a Message is displayed"], + avoid_when = ["Persistent HUD elements such as boss bars"], + example = "let channel = sand::advanced::compiler::MessageChannel::Actionbar;", + variants(Chat = "A chat line.", Actionbar = "Text above the hotbar.", Title = "Large centred title text.", Subtitle = "Text under the title; shown with the next title."), +)] +pub enum MessageChannel { + /// A chat line. + Chat, + /// Text above the hotbar. + Actionbar, + /// Large centred title text. + Title, + /// Text under the title; shown with the next title. + Subtitle, +} + +/// One of Minecraft's sixteen named text colours. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TextColor", module = "sand::advanced::compiler", + summary = "One of Minecraft's sixteen named text colours.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the text component `color` name.", + use_when = ["Colouring part of a Message"], + avoid_when = ["Custom hex colours, which portable programs do not yet support"], + example = "let color = sand::advanced::compiler::TextColor::Gold;", + variants(Black = "black", DarkBlue = "dark_blue", DarkGreen = "dark_green", DarkAqua = "dark_aqua", DarkRed = "dark_red", DarkPurple = "dark_purple", Gold = "gold", Gray = "gray", DarkGray = "dark_gray", Blue = "blue", Green = "green", Aqua = "aqua", Red = "red", LightPurple = "light_purple", Yellow = "yellow", White = "white"), +)] +#[allow(missing_docs)] +pub enum TextColor { + Black, + DarkBlue, + DarkGreen, + DarkAqua, + DarkRed, + DarkPurple, + Gold, + Gray, + DarkGray, + Blue, + Green, + Aqua, + Red, + LightPurple, + Yellow, + White, +} + +/// Visual styling shared by every text part. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TextStyle", module = "sand::advanced::compiler", + summary = "Visual styling shared by every text part.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as text component style properties; unset properties inherit from the previous part.", + use_when = ["Styling part of a Message"], + avoid_when = ["Click and hover behavior, which belongs to an interactive text part"], + example = "let style = sand::advanced::compiler::TextStyle::default();", + fields(color = "Named text colour.", bold = "Bold text.", italic = "Italic text.", underlined = "Underlined text."), +)] +pub struct TextStyle { + /// Named text colour. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub color: Option, + /// Bold text. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub bold: bool, + /// Italic text. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub italic: bool, + /// Underlined text. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub underlined: bool, +} + +/// One styled piece of a message. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TextPart", module = "sand::advanced::compiler", + summary = "One styled piece of a message.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Each part becomes one text component; scores and names resolve when the message is shown.", + use_when = ["Building component text from literals, translations, live scores, and player names"], + avoid_when = ["Embedding raw Minecraft text JSON"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Text = "Literal text.", Score = "The live value of a State field.", PlayerName = "The executing player's name.", Stored = "A stored sequence of text characters.", Translation = "A translation key with ordered text substitutions.", Interactive = "Text with an optional tooltip or click action."), + variant_fields(Text(text = "Literal text.", style = "Styling."), Score(score = "Displayed State field.", style = "Styling."), PlayerName(style = "Styling."), Stored(value = "Storage field containing text characters.", style = "Styling."), Translation(key = "Client language-file key.", arguments = "One text component per placeholder.", style = "Styling."), Interactive(content = "Text displayed in chat or a written book.", tooltip = "Optional text shown on hover.", click = "Optional click action using Sand’s canonical native text model.")), +)] +pub enum TextPart { + /// A stored list of string characters, joined without separators. Read at + /// message execution time through the field's canonical State ownership. + Stored { + value: FieldReference, + #[serde(default)] + style: TextStyle, + }, + /// Literal text. + Text { + text: String, + #[serde(default)] + style: TextStyle, + }, + /// A client language-file key and one text component for each placeholder. + Translation { + key: String, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + arguments: Vec>, + #[serde(default)] + style: TextStyle, + }, + /// Text with an optional hover tooltip and click action. + Interactive { + content: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + tooltip: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + click: Option, + }, + /// The live value of a State field. + Score { + score: FieldReference, + #[serde(default)] + style: TextStyle, + }, + /// The executing player's name; needs a player executor. + PlayerName { + #[serde(default)] + style: TextStyle, + }, +} + +impl TextPart { + /// Maximum nesting of portable translated and interactive components. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TextPart::MAX_NESTING_DEPTH", + module = "sand::advanced::compiler", kind = "associated_const", + summary = "Maximum nesting of portable text components.", + context = "Substitutions and tooltips can themselves contain components. This limit bounds component depth before Minecraft receives the text.", + minecraft = "Portable nesting leaves room for wrapper components generated for substitutions and interactions.", + use_when = ["Validating a portable component tree in an authoring frontend"], + avoid_when = ["Choosing a different limit for the same portable model"], + example = "let limit = sand::advanced::compiler::TextPart::MAX_NESTING_DEPTH;", + )] + pub const MAX_NESTING_DEPTH: usize = 8; + + /// Whether this part and its substitutions can be rendered in a static resource. + #[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TextPart::is_static", + module = "sand::advanced::compiler", kind = "method", + summary = "Checks whether a text part belongs in a static resource.", + context = "Use when validating fixed item names, lore and boss bar titles. Literals and components with entirely fixed contents can be emitted without an executor. Each resource must still validate supported click or hover actions separately.", + minecraft = "Translation keys still resolve in the receiving client's language.", + use_when = ["Checking whether portable component text belongs in a static resource"], + avoid_when = ["Checking that a key exists in a client language file"], + returns = "Whether the part is independent of runtime State and executor context.", + example = "fn can_export(part: &sand::advanced::compiler::TextPart) -> bool { part.is_static() }", + )] + pub fn is_static(&self) -> bool { + let mut pending = vec![self]; + while let Some(part) = pending.pop() { + match part { + Self::Text { .. } => {} + Self::Translation { arguments, .. } => pending.extend(arguments.iter().flatten()), + Self::Interactive { + content, tooltip, .. + } => { + pending.extend(content.iter().chain(tooltip)); + } + _ => return false, + } + } + true + } +} + +/// A player occurrence that runs handler functions as that player. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::PlayerEvent", module = "sand::advanced::compiler", + summary = "A player occurrence that runs handler functions as that player.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Runs through namespace-owned observations or a native advancement reward function.", + use_when = ["Reacting to joins, deaths, kills, or item use in a portable program"], + avoid_when = ["Occurrences not listed here, which use the Rust event API"], + example = "let event = sand::advanced::compiler::PlayerEvent::Death;", + variants(Join = "Every join, including the first.", FirstJoin = "Only the first join ever.", Death = "The player died.", KillEntity = "The player killed any entity.", KillPlayer = "The player killed another player.", UseItem = "The player used an item.", Jump = "The player jumped.", DropItem = "The player dropped an item.", Sleep = "The player slept in a bed.", TakeDamage = "The player took damage.", DealDamage = "The player dealt damage.", CraftItem = "The player crafted an item.", PickUpItem = "The player picked up an item.", MineBlock = "The player mined a block.", KillEntityType = "The player killed an entity of one type.", KilledBy = "An entity of one type killed the player.", AdvancementCompleted = "The player completed one advancement authored by this program."), + variant_fields(UseItem(item = "Used item identity, such as `minecraft:carrot_on_a_stick`."), CraftItem(item = "Crafted item identity."), PickUpItem(item = "Picked-up item identity."), MineBlock(block = "Mined block identity."), KillEntityType(entity = "Killed entity type identity."), KilledBy(entity = "Killer entity type identity."), AdvancementCompleted(advancement = "The authored advancement identity.")), +)] +pub enum PlayerEvent { + /// Every join, including the first; observed on the next tick. + Join, + /// Only the first time a player ever joins. + FirstJoin, + /// The player died (any cause). + Death, + /// The player killed any entity. + KillEntity, + /// The player killed another player. + KillPlayer, + /// The player used (right-clicked or consumed) an item. + UseItem { + /// Used item identity, such as `minecraft:carrot_on_a_stick`. + item: String, + }, + /// The player jumped. + Jump, + /// The player dropped an item. + DropItem, + /// The player slept in a bed. + Sleep, + /// The player took damage. + TakeDamage, + /// The player dealt damage. + DealDamage, + /// The player crafted an item. + CraftItem { + /// Crafted item identity. + item: String, + }, + /// The player picked up an item. + PickUpItem { + /// Picked-up item identity. + item: String, + }, + /// The player mined a block. + MineBlock { + /// Mined block identity. + block: String, + }, + /// The player killed an entity of one type. + KillEntityType { + /// Killed entity type identity. + entity: String, + }, + /// An entity of one type killed the player. + KilledBy { + /// Killer entity type identity. + entity: String, + }, + /// Runs when the player completes a native advancement declared by the program. + AdvancementCompleted { + /// Advancement whose native reward function dispatches the handlers. + #[schemars(with = "String")] + advancement: sand_components::ResourceLocation, + }, +} + +impl PlayerEvent { + /// The identity this event filters on, with its kind, if any. + pub(crate) fn filter(&self) -> Option<(&str, &'static str)> { + match self { + PlayerEvent::UseItem { item } + | PlayerEvent::CraftItem { item } + | PlayerEvent::PickUpItem { item } => Some((item, "item")), + PlayerEvent::MineBlock { block } => Some((block, "block")), + PlayerEvent::KillEntityType { entity } | PlayerEvent::KilledBy { entity } => { + Some((entity, "entity type")) + } + _ => None, + } + } + + /// A stable, path-safe key that groups identical observations. + pub(crate) fn key(&self) -> String { + let base = match self { + PlayerEvent::Join => "join", + PlayerEvent::FirstJoin => "first_join", + PlayerEvent::Death => "death", + PlayerEvent::KillEntity => "kill_entity", + PlayerEvent::KillPlayer => "kill_player", + PlayerEvent::UseItem { .. } => "use_item", + PlayerEvent::Jump => "jump", + PlayerEvent::DropItem => "drop_item", + PlayerEvent::Sleep => "sleep", + PlayerEvent::TakeDamage => "take_damage", + PlayerEvent::DealDamage => "deal_damage", + PlayerEvent::CraftItem { .. } => "craft_item", + PlayerEvent::PickUpItem { .. } => "pick_up_item", + PlayerEvent::MineBlock { .. } => "mine_block", + PlayerEvent::KillEntityType { .. } => "kill_entity_type", + PlayerEvent::KilledBy { .. } => "killed_by", + PlayerEvent::AdvancementCompleted { advancement } => { + return format!( + "advancement/{}/{}", + advancement.namespace(), + advancement.path() + ); + } + }; + match self.filter() { + Some((id, _)) => format!("{base}/{}", id.replace(':', "/")), + None => base.to_owned(), + } + } + + /// The scoreboard criterion that observes this event, when one does. + pub(crate) fn criterion(&self) -> Option { + let stat = |kind: &str, id: &str| format!("minecraft.{kind}:{}", id.replace(':', ".")); + Some(match self { + PlayerEvent::Join => "minecraft.custom:minecraft.leave_game".into(), + PlayerEvent::FirstJoin | PlayerEvent::AdvancementCompleted { .. } => return None, + PlayerEvent::Death => "deathCount".into(), + PlayerEvent::KillEntity => "totalKillCount".into(), + PlayerEvent::KillPlayer => "playerKillCount".into(), + PlayerEvent::UseItem { item } => stat("used", item), + PlayerEvent::Jump => "minecraft.custom:minecraft.jump".into(), + PlayerEvent::DropItem => "minecraft.custom:minecraft.drop".into(), + PlayerEvent::Sleep => "minecraft.custom:minecraft.sleep_in_bed".into(), + PlayerEvent::TakeDamage => "minecraft.custom:minecraft.damage_taken".into(), + PlayerEvent::DealDamage => "minecraft.custom:minecraft.damage_dealt".into(), + PlayerEvent::CraftItem { item } => stat("crafted", item), + PlayerEvent::PickUpItem { item } => stat("picked_up", item), + PlayerEvent::MineBlock { block } => stat("mined", block), + PlayerEvent::KillEntityType { entity } => stat("killed", entity), + PlayerEvent::KilledBy { entity } => stat("killed_by", entity), + }) + } +} + +/// A handler for a player event. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::EventHook", module = "sand::advanced::compiler", + summary = "A handler for a player event.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Each tick, after State maintenance and flows, every observed player runs its handlers in declaration order.", + use_when = ["Running a function when a player event occurs"], + avoid_when = ["Periodic work; use module tick bodies"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(event = "Observed occurrence.", function = "Handler, run as the player."), +)] +pub struct EventHook { + /// Observed occurrence. + pub event: PlayerEvent, + /// Handler, run as the player. + pub function: FunctionReference, +} + +/// A number supplied to a command: a constant or a scaled State field. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(untagged)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Amount", module = "sand::advanced::compiler", + summary = "A number supplied to a command: a constant or a scaled State field.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Field amounts are copied into command storage and applied through a generated macro function.", + use_when = ["Passing a runtime value to a command argument"], + avoid_when = ["Integer arithmetic between fields; use ScoreOperation"], + example = "let amount = sand::advanced::compiler::Amount::Value(20.0);", + variants(Value = "A constant number.", Field = "A State field divided by its scale."), + variant_fields(Value = ["The constant number."], Field = ["The scaled field."]), +)] +pub enum Amount { + /// A constant number. + Value(f64), + /// A State field divided by its scale. + Field(ScaledField), +} + +/// A State field read as `value / scale`. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::ScaledField", module = "sand::advanced::compiler", + summary = "A State field read as `value / scale`.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Copied into command storage with `execute store result storage ... double <1/scale>`.", + use_when = ["Supplying a decimal command argument from an integer score"], + avoid_when = ["Constant amounts"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(score = "The State field.", scale = "Divisor; a score of 25 with scale 10 means 2.5."), +)] +pub struct ScaledField { + /// The State field. + pub score: FieldReference, + /// Divisor; a score of 25 with scale 10 means 2.5. + #[serde(default = "one")] + pub scale: f64, +} + +fn one() -> f64 { + 1.0 +} + +/// How matching entities are ordered before a limit applies. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::EntitySort", module = "sand::advanced::compiler", + summary = "How matching entities are ordered before a limit applies.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the target selector `sort` argument.", + use_when = ["Choosing which entities a limited query selects"], + avoid_when = ["Unlimited queries, where order rarely matters"], + example = "let sort = sand::advanced::compiler::EntitySort::Nearest;", + variants(Nearest = "Nearest to the executor first.", Furthest = "Furthest from the executor first.", Random = "Random order.", Arbitrary = "Minecraft's internal order; fastest."), +)] +pub enum EntitySort { + /// Nearest to the executor first. + Nearest, + /// Furthest from the executor first. + Furthest, + /// Random order. + Random, + /// Minecraft's internal order; fastest. + Arbitrary, +} + +/// Which entities an operation selects. +#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::EntityQuery", module = "sand::advanced::compiler", + summary = "Which entities an operation selects.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to an `@e[...]` target selector; distances are measured from the executor's position.", + use_when = ["Running work as, or counting, entities that match filters"], + avoid_when = ["Iterating players; use Players"], + example = "let query = sand::advanced::compiler::EntityQuery::default();", + fields(entity_type = "Entity type identity, such as `minecraft:zombie`.", tag = "Required entity tag.", with_state = "Only entities with this entity State attached.", min_distance = "Inclusive minimum distance in blocks.", max_distance = "Inclusive maximum distance in blocks.", limit = "Most entities selected.", sort = "Order before the limit applies.", score = "Inclusive range of a per-entity scoreboard field.", nbt = "Typed NBT compound to match."), +)] +pub struct EntityQuery { + /// Entity type identity, such as `minecraft:zombie`. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub entity_type: Option, + /// Required entity tag. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tag: Option, + /// Only entities with this entity State attached. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[schemars(with = "Option")] + pub with_state: Option, + /// Inclusive minimum distance in blocks. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub min_distance: Option, + /// Inclusive maximum distance in blocks. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub max_distance: Option, + /// Most entities selected. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub limit: Option, + /// Order before the limit applies. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub sort: Option, + /// Score bounds for a field on each candidate entity. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub score: Option, + /// Match a typed subset of each candidate entity's NBT. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub nbt: Option, +} + +/// Where a teleport moves the executor. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TeleportDestination", module = "sand::advanced::compiler", + summary = "Where a teleport moves the executor.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to `tp @s` with absolute coordinates, relative coordinates, or one selected entity.", + use_when = ["Moving the executing player or entity"], + avoid_when = ["Spreading many entities at once"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Position = "Absolute coordinates.", Offset = "Coordinates relative to the executor.", Entity = "The first entity matching a query."), + variant_fields(Position(x = "X coordinate.", y = "Y coordinate.", z = "Z coordinate."), Offset(x = "X offset.", y = "Y offset.", z = "Z offset."), Entity(query = "Destination entity; limited to one, nearest by default.")), +)] +pub enum TeleportDestination { + /// Absolute coordinates. + Position { x: Amount, y: Amount, z: Amount }, + /// Coordinates relative to the executor. + Offset { x: Amount, y: Amount, z: Amount }, + /// The first entity matching a query. + Entity { query: EntityQuery }, +} diff --git a/sand-core/src/compiler/program/model/mod.rs b/sand-core/src/compiler/program/model/mod.rs index 8e3b12b8..c47994af 100644 --- a/sand-core/src/compiler/program/model/mod.rs +++ b/sand-core/src/compiler/program/model/mod.rs @@ -1,11 +1,29 @@ //! Owned frontend-neutral gameplay model, shared by construction and decoding. +mod data; mod envelope; mod flow; mod function; +mod gameplay; mod operation; +mod resources; mod state; +pub use data::{BlockDataAddress, DataOperand, DataProjection, DataReference}; pub use envelope::{Module, ModuleSource, Pack, Program, ProgramTarget}; pub use flow::{Flow, FlowHook, FlowHookPhase, FlowTransition}; pub use function::{ExecutionContext, Function, FunctionReference, TagMembership}; +pub use gameplay::{ + Amount, Audience, BiomeMatches, BlockMatches, BlockPosition, Condition, DimensionMatches, + EntitiesExist, EntityData, EntityFlag, EntityQuery, EntitySort, EventHook, FlagSet, ItemHeld, + MessageChannel, PlayerEvent, PlayerGameMode, Relation, ScaledField, ScoreOperand, + ScoreOperator, ScoreRelation, StateAttached, TeleportDestination, TextColor, TextPart, + TextStyle, Weather, +}; pub use operation::{Action, Operation}; -pub use state::{FieldReference, ScoreComparison, ScoreField, State}; +pub use resources::{ + Advancement, AdvancementCriterion, AdvancementDisplay, BossBar, BossBarColor, BossBarStyle, + CookingMethod, CustomBiome, CustomItem, FlatDimension, HudBossBar, HudDefinition, + InventoryTransferDefinition, LootItem, LootPool, LootTable, MenuChoice, MenuDefinition, + MenuView, NoticeDialog, Rarity, Recipe, RecipeOutput, ResourceTag, TagKind, WorldPredicate, + WrittenBookContent, +}; +pub use state::{DataField, FieldReference, ScoreComparison, ScoreField, State}; diff --git a/sand-core/src/compiler/program/model/operation.rs b/sand-core/src/compiler/program/model/operation.rs index c10fb4ac..cabb5161 100644 --- a/sand-core/src/compiler/program/model/operation.rs +++ b/sand-core/src/compiler/program/model/operation.rs @@ -1,8 +1,15 @@ //! Owned portable operation definitions. -use super::{FieldReference, FunctionReference, ScoreComparison}; +use super::{ + Amount, Audience, BlockDataAddress, BlockPosition, Condition, DataOperand, DataReference, + EntityData, EntityQuery, FieldReference, FunctionReference, MessageChannel, PlayerGameMode, + ScoreOperand, ScoreOperator, TeleportDestination, TextPart, Weather, +}; +use sand_components::ResourceLocation; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use crate::entity::Relation; + /// A gameplay operation with optional host-provided source provenance. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] @@ -35,25 +42,402 @@ pub struct Operation { use_when = ["Integrating a language, DSL, or editor with Sand without Cargo per program"], avoid_when = ["Ordinary Rust gameplay authoring is better served by the prelude"], example = "let schema = sand::advanced::compiler::Compiler::schema();", - variants(ScoreSet = "ScoreSet semantic alternative; see Rustdoc for its execution behavior.", ScoreAdd = "ScoreAdd semantic alternative; see Rustdoc for its execution behavior.", Branch = "Branch semantic alternative; see Rustdoc for its execution behavior.", Players = "Players semantic alternative; see Rustdoc for its execution behavior.", Call = "Call semantic alternative; see Rustdoc for its execution behavior.", Raw = "Raw semantic alternative; see Rustdoc for its execution behavior."), - variant_fields(ScoreSet(score = "Score operand for this operation.", value = "Value operand for this operation."), ScoreAdd(score = "Score operand for this operation.", value = "Value operand for this operation."), Branch(condition = "Condition operand for this operation.", then = "Then operand for this operation.", otherwise = "Otherwise operand for this operation."), Players(body = "Body operand for this operation."), Call(function = "Function operand for this operation."), Raw(command = "Command operand for this operation.")), + variants(ScoreSet = "ScoreSet semantic alternative; see Rustdoc for its execution behavior.", ScoreAdd = "ScoreAdd semantic alternative; see Rustdoc for its execution behavior.", Branch = "Branch semantic alternative; see Rustdoc for its execution behavior.", Players = "Players semantic alternative; see Rustdoc for its execution behavior.", Call = "Call semantic alternative; see Rustdoc for its execution behavior.", Raw = "Raw semantic alternative; see Rustdoc for its execution behavior.", ScoreOperation = "Combine a field with another field or a constant.", ScoreRandom = "Store a uniformly random integer.", Message = "Show styled text.", Dialog = "Show or clear a native dialog for the executing player.", Sound = "Play a sound to the executing player.", Particle = "Spawn particles at the executor.", Effect = "Apply a status effect to the executing player.", ClearEffect = "Remove status effects from the executing player.", GiveItem = "Give items to the executing player.", SetEquipment = "Set or clear one equipment slot of the entity executor.", ClearItem = "Remove items from the executing player.", CountItems = "Count matching items in the executing player’s inventory.", TransferInventory = "Run a declared inventory transfer as the executing player.", Hud = "Start or cancel a player-owned HUD.", Menu = "Open or close a named native menu.", Schedule = "Run a server function after a delay.", Suspend = "Resume a continuation later with its own invocation fields and executor.", CancelWaits = "Cancel outstanding waits owned by the executing entity.", Return = "End the current function, or the current player's turn inside Players.", While = "Repeat a body while a condition holds.", AttributeGet = "Store an attribute base value of the executor in a State field.", AttributeSet = "Set the executor's attribute base value.", Entities = "Run a body as each matching entity, at its position.", Kill = "Kill the executing entity.", Ride = "Mount the executor on a retained non-player entity, or dismount it.", EntityTag = "Add or remove a tag on the executing entity.", Summon = "Summon an entity at the executor's position.", CaptureEntity = "Retain the executor or one related entity in a State field.", WithEntity = "Run as a retained entity when present.", Damage = "Damage the executing entity.", CountEntities = "Store how many entities match.", Teleport = "Move the executing entity.", SetVelocity = "Set the executing non-player entity’s velocity.", AttachState = "Attach an entity State to the executor.", DetachState = "Detach an entity State from the executor.", SetBlock = "Place a block.", PlaceTemplate = "Place a native structure template.", FillBlocks = "Fill a region with a block.", CloneBlocks = "Copy or move an inclusive block region.", InDimension = "Change the execution dimension for a body.", ReadBlockData = "Read a block entity value as an integer.", ReadEntityData = "Read an entity NBT path as an integer.", WriteBlockData = "Set or clear a path in a block entity.", AddExperience = "Give the executing player experience.", SetGameMode = "Change the executing player's game mode.", SetTime = "Set the time of day.", SetWeather = "Set the weather.", BossBarAudience = "Show or hide a boss bar.", SetBossBar = "Set a boss bar value or maximum.", GiveLoot = "Give the executing player a loot roll.", DropLoot = "Drop a loot roll at the executor.", PushFrame = "Save State fields before a call that may re-enter this function.", PopFrame = "Restore the State fields saved by the matching PushFrame.", DataGet = "Store a number read from the executor's entity data.", DataModify = "Modify an owned storage value.", DataRemove = "Remove a stored value selection.", DataRead = "Read an integer or collection length into a score.", DataEqual = "Compare stored values for deep equality."), + variant_fields(ScoreSet(score = "Score operand for this operation.", value = "Value operand for this operation."), ScoreAdd(score = "Score operand for this operation.", value = "Value operand for this operation."), Branch(condition = "Condition operand for this operation.", then = "Then operand for this operation.", otherwise = "Otherwise operand for this operation."), Players(body = "Body operand for this operation."), Call(function = "Function operand for this operation."), Raw(command = "Command operand for this operation."), ScoreOperation(score = "Written State field.", operator = "Arithmetic operator.", operand = "Field or constant operand."), ScoreRandom(score = "Written State field.", min = "Inclusive minimum.", max = "Inclusive maximum."), Message(audience = "Recipients.", channel = "Display channel.", text = "Styled text parts."), Dialog(dialog = "Dialog identity to show, or omitted to close the current dialog."), Sound(sound = "Sound event identity.", volume = "Volume; 1.0 is normal.", pitch = "Pitch from 0.5 to 2.0."), Particle(particle = "Particle type identity.", count = "Constant or runtime particle count, from 0 to 100000.", spread = "Constant or runtime offset in blocks on each axis, from 0 to 1000.", speed = "Constant or runtime speed, from 0 to 1000."), Effect(effect = "Status effect identity.", seconds = "Duration in seconds; omitted means infinite.", amplifier = "Level minus one.", hide_particles = "Hide effect particles."), ClearEffect(effect = "Effect to remove; omitted removes all."), GiveItem(item = "Item identity.", count = "Item count."), SetEquipment(slot = "Hand or armor slot.", item = "Item identity; omit it to clear the slot.", count = "Stack count, from one to 99."), ClearItem(item = "Item to remove; omitted removes all.", count = "Maximum constant or runtime count; omitted removes every match."), CountItems(item = "Vanilla or custom item identity.", score = "Score receiving the number of matching items."), TransferInventory(transfer = "The declared transfer definition."), Hud(hud = "The declared HUD definition.", show = "Start when true, cancel the current player’s instances when false."), Menu(menu = "Declared menu identity.", open = "Open a fresh session when true, close this menu’s session when false."), Schedule(function = "Server-context function to run.", ticks = "Delay in game ticks; at least one."), Suspend(ticks = "Positive loaded ticks as a constant or scoreboard field.", fields = "Global invocation slots retained for the continuation.", body = "Operations executed on resume."), While(condition = "Checked before every pass.", body = "Repeated body."), AttributeGet(score = "Written State field.", attribute = "Attribute identity.", scale = "Multiplier applied before truncation."), AttributeSet(attribute = "Attribute identity.", value = "Constant or State-derived value."), Entities(query = "Selected entities.", body = "Run as each entity."), Ride(vehicle = "Retained vehicle identity, omitted to dismount."), EntityTag(tag = "Tag name.", add = "Add when true, remove when false."), Summon(entity_type = "Entity type identity.", tag = "Tag given to the new entity."), CaptureEntity(score = "Field receiving the retained identity.", relation = "Optional single-entity relationship to traverse from the executor."), WithEntity(reference = "Retained entity identity.", players = "Resolve only online players.", body = "Body run as the resolved entity."), Damage(amount = "Damage in half-hearts.", by = "Retained attacker identity for kill credit.", damage_type = "Native damage type identity, defaulting to generic."), CountEntities(score = "Written State field.", query = "Counted entities."), Teleport(destination = "Where the executor moves."), SetVelocity(x = "X speed in blocks per tick.", y = "Y speed in blocks per tick.", z = "Z speed in blocks per tick."), AttachState(state = "Entity State to attach."), DetachState(state = "Entity State to detach."), SetBlock(block = "Block identity.", at = "Position."), PlaceTemplate(template = "Structure template identity.", at = "Origin of the placed template."), FillBlocks(block = "Block identity.", from = "One corner.", to = "Opposite corner."), CloneBlocks(from = "One source corner.", to = "Opposite source corner.", destination = "Lower corner of the destination.", masked = "Skip air blocks when true.", filter = "Optional block or block tag filter.", mode = "Vanilla overlap and move behavior."), InDimension(dimension = "Destination dimension.", body = "Body executed in the destination dimension."), ReadBlockData(target = "Block entity and checked path.", score = "Score receiving the vanilla data result."), ReadEntityData(path = "Checked NBT path into the executor.", score = "Written State field."), WriteBlockData(target = "Block entity and checked path.", value = "Typed value source, or omitted to remove the selection."), AddExperience(amount = "Experience, which may be negative.", levels = "Levels instead of points."), SetGameMode(mode = "New game mode."), SetTime(ticks = "Time of day in ticks."), SetWeather(weather = "New weather.", seconds = "Duration; omitted lets Minecraft choose."), BossBarAudience(bar = "Boss bar.", audience = "Who changes.", visible = "Show when true, hide when false."), SetBossBar(bar = "Boss bar.", value = "Constant or State field shown as the bar progress.", max = "Set the maximum instead of the value."), GiveLoot(table = "Loot table."), DropLoot(table = "Loot table."), PushFrame(fields = "Saved State fields, in order."), PopFrame(fields = "Restored State fields, in the PushFrame order."), DataGet(score = "Written State field.", value = "Entity data read.", scale = "Multiplier applied before truncation."), DataModify(target = "Written storage selection.", operator = "Canonical typed NBT modification.", source = "Typed value operand."), DataRemove(target = "Removed storage selection."), DataRead(score = "Written integer field.", source = "Read storage selection."), DataEqual(score = "Boolean result field.", left = "Left stored value.", right = "Right stored value.")), )] pub enum Action { + /// Modify an owned storage value. Source values and dynamic indices are + /// staged before the write, including when source and target alias. + DataModify { + target: DataReference, + operator: sand_commands::DataModifyOperation, + source: DataOperand, + }, + /// Remove a stored selection. A missing selection leaves the value unchanged. + DataRemove { target: DataReference }, + /// Read a stored integer, string length, or collection length into a score. + /// Missing values produce zero, following Minecraft's data-get conversion. + DataRead { + score: FieldReference, + source: DataReference, + }, + /// Compare two present stored values using Minecraft's deep NBT equality. + /// Missing selections compare false, even when both are absent. + DataEqual { + score: FieldReference, + left: DataReference, + right: DataReference, + }, + /// Assign an integer State field using its declared ownership. ScoreSet { score: FieldReference, value: i32 }, /// Add an integer to a State field using its declared ownership. ScoreAdd { score: FieldReference, value: i32 }, /// Evaluate the comparison once and execute exactly one ordered body. Branch { - condition: ScoreComparison, + condition: Condition, then: Vec, #[serde(default)] otherwise: Vec, }, - /// Execute the body as each player without changing positional context. + /// Execute the body as each player, positioned at that player. Players { body: Vec }, /// Invoke a named function with a checked execution-context requirement. Call { function: FunctionReference }, /// Explicit escape hatch; only command-line safety and syntax are checked. Raw { command: String }, + /// Combine a field with another field or a constant using scoreboard + /// arithmetic, then apply the field's declared bounds. + ScoreOperation { + score: FieldReference, + operator: ScoreOperator, + operand: ScoreOperand, + }, + /// Store a uniformly random integer from the inclusive range. + ScoreRandom { + score: FieldReference, + min: i32, + max: i32, + }, + /// Show styled text; a `player` audience needs a player executor. + Message { + audience: Audience, + channel: MessageChannel, + text: Vec, + }, + /// Show a native dialog to the player, or clear their open dialog. + Dialog { + #[schemars(with = "Option")] + #[serde(default, skip_serializing_if = "Option::is_none")] + dialog: Option, + }, + /// Play a sound to the executing player at their position. + Sound { + sound: String, + #[serde(default = "one")] + volume: Amount, + #[serde(default = "one")] + pitch: Amount, + }, + /// Spawn particles one block above the executor, with checked numeric options. + Particle { + particle: String, + #[serde(default = "one_operand")] + count: ScoreOperand, + #[serde(default = "zero_amount")] + spread: Amount, + #[serde(default = "zero_amount")] + speed: Amount, + }, + /// Apply a status effect to the executing player. + Effect { + effect: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + seconds: Option, + #[serde(default)] + amplifier: u8, + #[serde(default)] + hide_particles: bool, + }, + /// Remove one status effect, or all of them, from the executing player. + ClearEffect { + #[serde(default, skip_serializing_if = "Option::is_none")] + effect: Option, + }, + /// Give items to the executing player. Runtime counts outside 1..=6400 + /// perform no action; constants outside that range are rejected. + GiveItem { + item: String, + #[serde(default = "one_operand")] + count: ScoreOperand, + }, + /// Replace a hand or armor slot on the executor. An omitted item clears it. + SetEquipment { + slot: sand_components::EquipmentSlot, + #[serde(default, skip_serializing_if = "Option::is_none")] + item: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + count: Option, + }, + /// Remove matching items, or every item, from the executing player. + ClearItem { + #[serde(default, skip_serializing_if = "Option::is_none")] + item: Option, + /// Constant or runtime maximum. A negative runtime value skips removal. + #[serde(default, skip_serializing_if = "Option::is_none")] + count: Option, + }, + /// Count matching items in the executing player's inventory. + CountItems { + /// Vanilla item identity or name of a custom item defined by the pack. + item: String, + /// Score receiving Minecraft's quantity without changing the player's inventory. + score: FieldReference, + }, + /// Open or close a player-owned native menu session. + Menu { + /// Identity of a menu declared by this program. + #[schemars(with = "String")] + menu: sand_components::ResourceLocation, + /// Open a new session when true, or close this menu's current session. + open: bool, + }, + /// Start or cancel named presentation for the executing player. + Hud { + /// Identity of a HUD declared by this program. + #[schemars(with = "String")] + hud: sand_components::ResourceLocation, + /// Start a new instance when true, or cancel this player's instances. + show: bool, + }, + /// Run a named inventory transfer for the executing player. + TransferInventory { + /// Identity of an inventory transfer declared by this program. + #[schemars(with = "String")] + transfer: sand_components::ResourceLocation, + }, + /// Run a server-context function after a delay, replacing any pending + /// schedule of the same function. + Schedule { + function: FunctionReference, + ticks: u32, + }, + /// Run a continuation as the current entity after loaded ticks, retaining + /// the execution dimension, position, and values of explicit global slots. + Suspend { + /// Positive number of loaded ticks. An invalid runtime score resumes + /// immediately in the current execution context. + ticks: ScoreOperand, + /// Global slots copied into each admitted invocation. + fields: Vec, + /// Operations to resume with the retained values. + body: Vec, + }, + /// Cancel this executor's outstanding continuations for this pack. + CancelWaits, + /// End the current function. Inside a `Players` body it ends only the + /// current player's turn, like `continue`. + Return, + /// Check the condition before each pass and repeat the body while it holds. + /// Minecraft's command-chain limit bounds runaway loops. + While { + condition: Condition, + body: Vec, + }, + /// Store the executor's attribute base value, multiplied by + /// `scale` and truncated, in a State field. + AttributeGet { + score: FieldReference, + attribute: String, + #[serde(default = "one_f64")] + scale: f64, + }, + /// Set the executor's attribute base value to a constant or a + /// State-derived amount. + AttributeSet { attribute: String, value: Amount }, + /// Run the body as each matching entity, positioned at it. A `Return` + /// inside ends only the current entity's turn. + Entities { + query: EntityQuery, + body: Vec, + }, + /// Kill the executing entity. + Kill, + /// Mount the executor on a retained non-player entity, or dismount it. + Ride { + /// Vehicle identity. Absence requests a dismount. + #[serde(default, skip_serializing_if = "Option::is_none")] + vehicle: Option, + }, + /// Add or remove a tag on the executing entity. + EntityTag { tag: String, add: bool }, + /// Summon an entity at the executor's position. + Summon { + entity_type: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + tag: Option, + }, + /// Damage the executing entity, in half-hearts. + Damage { + amount: Amount, + #[serde(default, skip_serializing_if = "Option::is_none")] + #[schemars(with = "Option")] + damage_type: Option, + /// Retained attacker identity; absence uses unattributed generic damage. + #[serde(default, skip_serializing_if = "Option::is_none")] + by: Option, + }, + /// Retain the executor or one related entity in an unbounded score field. + /// Zero denotes no entity; identity allocation never wraps or reuses IDs. + CaptureEntity { + score: FieldReference, + /// Optional single-entity relationship to traverse from the executor. + #[serde(default, skip_serializing_if = "Option::is_none")] + relation: Option, + }, + /// Run a body as the retained entity, positioned at it. Missing, unloaded, + /// or dead entities skip the body. Players can resolve across dimensions; + /// non-player resolution uses the current dimension. + WithEntity { + reference: FieldReference, + #[serde(default)] + players: bool, + body: Vec, + }, + /// Store how many entities match the query. + CountEntities { + score: FieldReference, + query: EntityQuery, + }, + /// Move the executing entity. + Teleport { destination: TeleportDestination }, + /// Replace a non-player executor's velocity in blocks per tick. + /// Runtime operands outside the native range skip the write. + SetVelocity { x: Amount, y: Amount, z: Amount }, + /// Attach an entity State to the executor: fields without a value take + /// their defaults, then the State is marked present. + AttachState { + #[schemars(with = "String")] + state: sand_components::ResourceLocation, + }, + /// Detach an entity State from the executor, clearing its fields. + DetachState { + #[schemars(with = "String")] + state: sand_components::ResourceLocation, + }, + /// Place a block. + SetBlock { block: String, at: BlockPosition }, + /// Fill a region, corners inclusive, with a block. + FillBlocks { + block: String, + from: BlockPosition, + to: BlockPosition, + }, + /// Copy or move the blocks in an inclusive region to another position. + CloneBlocks { + /// One source corner. + from: BlockPosition, + /// Opposite source corner. + to: BlockPosition, + /// Lower corner of the destination. + destination: BlockPosition, + /// Skip air blocks. Mutually exclusive with a block filter. + #[serde(default)] + masked: bool, + /// Optional block identity or tag to clone selectively. + #[serde(default, skip_serializing_if = "Option::is_none")] + filter: Option, + /// Vanilla overlap and move behavior. + #[serde(default)] + mode: sand_commands::CloneMode, + }, + /// Place a native structure template at an absolute or relative block position. + PlaceTemplate { + /// A declared template or the namespaced identity of an external template. + #[schemars(with = "String")] + template: sand_components::ResourceLocation, + /// Minimum corner of the template, using its authored orientation. + at: BlockPosition, + }, + /// Run a body in another dimension, retaining the current executor. + InDimension { + /// Namespaced destination dimension. + #[schemars(with = "String")] + dimension: sand_components::ResourceLocation, + /// Body with the changed dimension and unchanged executor. + body: Vec, + }, + /// Read a path on the executing entity using vanilla's integer data result. + ReadEntityData { + /// NBT path validated by the native data command builder. + path: String, + /// Score receiving the result, with zero on a failed read. + score: FieldReference, + }, + /// Read a block entity NBT value using vanilla's integer `data get` result. + ReadBlockData { + /// Block entity and checked path. + target: BlockDataAddress, + /// Score receiving the result, with zero on a failed read. + score: FieldReference, + }, + /// Set or remove a typed value in a loaded block entity. + WriteBlockData { + /// Block entity and checked path. + target: BlockDataAddress, + /// Typed value to set, or omitted to remove the selection. + #[serde(default, skip_serializing_if = "Option::is_none")] + value: Option, + }, + /// Give the executing player experience points or levels. + AddExperience { + amount: ScoreOperand, + #[serde(default)] + levels: bool, + }, + /// Change the executing player's game mode. + SetGameMode { mode: PlayerGameMode }, + /// Set the time of day, in ticks. + SetTime { ticks: u32 }, + /// Set the weather, for a duration or until Minecraft changes it. + SetWeather { + weather: Weather, + #[serde(default, skip_serializing_if = "Option::is_none")] + seconds: Option, + }, + /// Show or hide a boss bar for the executing player or everyone. + BossBarAudience { + #[schemars(with = "String")] + bar: sand_components::ResourceLocation, + audience: Audience, + visible: bool, + }, + /// Set a boss bar's value, or its maximum. + SetBossBar { + #[schemars(with = "String")] + bar: sand_components::ResourceLocation, + value: ScoreOperand, + #[serde(default)] + max: bool, + }, + /// Give the executing player one roll of a loot table. + GiveLoot { + #[schemars(with = "String")] + table: sand_components::ResourceLocation, + }, + /// Drop one roll of a loot table at the executor's position. + DropLoot { + #[schemars(with = "String")] + table: sand_components::ResourceLocation, + }, + /// Save State fields on the call-frame stack before a call that may + /// re-enter the running function, so recursion keeps each call's values. + /// Every `PushFrame` is followed by a `PopFrame` naming the same fields. + PushFrame { fields: Vec }, + /// Restore the fields saved by the matching `PushFrame` and drop its frame. + PopFrame { fields: Vec }, + /// Store a number read from the executing entity's data, multiplied by + /// `scale` and truncated, in a State field. + DataGet { + score: FieldReference, + value: EntityData, + #[serde(default = "one_f64")] + scale: f64, + }, +} + +fn one_f64() -> f64 { + 1.0 +} + +fn one() -> Amount { + Amount::Value(1.0) +} + +fn zero_amount() -> Amount { + Amount::Value(0.0) +} + +fn one_operand() -> ScoreOperand { + ScoreOperand::Value(1) } diff --git a/sand-core/src/compiler/program/model/resources.rs b/sand-core/src/compiler/program/model/resources.rs new file mode 100644 index 00000000..850da3f1 --- /dev/null +++ b/sand-core/src/compiler/program/model/resources.rs @@ -0,0 +1,856 @@ +//! Owned portable data resources: custom items, recipes, and registry tags. +use super::{FieldReference, FunctionReference, ScoreOperand, TextPart, Weather}; +use sand_components::{MobCategory, ResourceLocation, SpawnCost, SpawnEntry}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; + +/// How rare an item looks; colours its name. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Rarity", module = "sand::advanced::compiler", + summary = "How rare an item looks; colours its name.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the `minecraft:rarity` item component.", + use_when = ["Styling a custom item's name colour"], + avoid_when = ["Explicit name colours, which a styled name already sets"], + example = "let rarity = sand::advanced::compiler::Rarity::Epic;", + variants(Common = "White name.", Uncommon = "Yellow name.", Rare = "Aqua name.", Epic = "Light purple name."), +)] +pub enum Rarity { + /// White name. + Common, + /// Yellow name. + Uncommon, + /// Aqua name. + Rare, + /// Light purple name. + Epic, +} + +/// A custom item: a vanilla base item with identity and display components. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::CustomItem", module = "sand::advanced::compiler", + summary = "A custom item: a vanilla base item with identity and display components.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers to Sand's canonical CustomItem, identified by a `custom_data` marker equal to its id; give, clear, and recipe results use that identity.", + use_when = ["Declaring a named item that operations and recipes refer to by id"], + avoid_when = ["Plain vanilla items, which operations name directly"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(id = "Identity, also the custom_data marker.", base = "Vanilla base item.", name = "Display name parts.", lore = "Lore lines.", glint = "Force the enchantment glint on or off.", unbreakable = "Never loses durability.", max_stack = "Largest stack size.", rarity = "Name rarity colour.", enchantments = "Enchantment identities and levels.", custom_model_data = "Resource-pack model selector.", book = "Fixed written-book title, author and pages."), +)] +pub struct CustomItem { + /// Identity, also the `custom_data` marker. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Vanilla base item, such as `minecraft:diamond_sword`. + pub base: String, + /// Display name parts; text only. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub name: Vec, + /// Lore lines; text only. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub lore: Vec>, + /// Force the enchantment glint on or off. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub glint: Option, + /// Never loses durability. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub unbreakable: bool, + /// Largest stack size, 1 to 99. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub max_stack: Option, + /// Name rarity colour. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rarity: Option, + /// Enchantment identities and levels. + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub enchantments: BTreeMap, + /// Resource-pack model selector. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub custom_model_data: Option, + /// Written-book content for a `minecraft:written_book` base item. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub book: Option, +} + +/// Fixed pages for a custom written book, using portable rich text. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::WrittenBookContent", module = "sand::advanced::compiler", + summary = "Fixed pages for a custom written book, using portable rich text.", + context = "Attach it to a CustomItem whose base is minecraft:written_book. Pages accept styles, translations, tooltips, and native page links. Sand lowers them through the same WrittenBook builder used by Rust.", + minecraft = "Emits native written_book_content on item commands and recipe results.", + use_when = ["Declaring a portable written manual or a fixed journal"], + avoid_when = ["Capturing writable-book input or formatting a runtime State snapshot"], + fields(title = "Native title, limited to 32 UTF-16 code units.", author = "Book author.", pages = "Ordered rich-text pages, up to 100."), + example = "use sand::advanced::compiler::WrittenBookContent;", +)] +pub struct WrittenBookContent { + /// Native title, limited to 32 UTF-16 code units. + pub title: String, + /// Book author shown by the native interface. + pub author: String, + /// Ordered rich-text pages, up to 100. + pub pages: Vec>, +} + +/// The item a recipe produces. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::RecipeOutput", module = "sand::advanced::compiler", + summary = "The item a recipe produces.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the recipe `result`; a custom item id produces the item with its components.", + use_when = ["Naming a recipe result"], + avoid_when = ["Ingredients, which match by item id or tag"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(item = "Vanilla item or custom item id.", count = "Stack size produced."), +)] +pub struct RecipeOutput { + /// Vanilla item or declared custom item id. + pub item: String, + /// Stack size produced. + #[serde(default = "one")] + pub count: u32, +} + +fn one() -> u32 { + 1 +} + +/// Which furnace-like block cooks a recipe. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::CookingMethod", module = "sand::advanced::compiler", + summary = "Which furnace-like block cooks a recipe.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Selects the `minecraft:smelting`, `blasting`, `smoking`, or `campfire_cooking` recipe type.", + use_when = ["Declaring a cooking recipe"], + avoid_when = ["Crafting-table recipes"], + example = "let method = sand::advanced::compiler::CookingMethod::Smelting;", + variants(Smelting = "Furnace.", Blasting = "Blast furnace.", Smoking = "Smoker.", Campfire = "Campfire."), +)] +pub enum CookingMethod { + /// Furnace. + Smelting, + /// Blast furnace. + Blasting, + /// Smoker. + Smoking, + /// Campfire. + Campfire, +} + +/// A crafting, cooking, stonecutting, or smithing recipe. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Recipe", module = "sand::advanced::compiler", + summary = "A crafting, cooking, stonecutting, or smithing recipe.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers through Sand's typed recipe builders to `data//recipe/.json`. Ingredients are item ids or `#tag` ids.", + use_when = ["Adding a recipe to a portable program"], + avoid_when = ["Special recipes, which need the Rust API"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + variants(Shaped = "A crafting-table pattern.", Shapeless = "Crafting ingredients in any arrangement.", Cooking = "A furnace-like recipe.", Stonecutting = "A stonecutter recipe.", Smithing = "A smithing-table upgrade.", SmithingTrim = "A smithing-table armor trim."), + variant_fields(Shaped(id = "Identity.", pattern = "One to three equal-width rows.", key = "Pattern character to ingredient.", result = "Produced item."), Shapeless(id = "Identity.", ingredients = "One to nine ingredients.", result = "Produced item."), Cooking(id = "Identity.", method = "Cooking block.", ingredient = "Cooked ingredient.", result = "Produced item.", experience = "Experience awarded.", time = "Cooking time in ticks."), Stonecutting(id = "Identity.", ingredient = "Cut ingredient.", result = "Produced item."), Smithing(id = "Identity.", template = "Smithing template.", base = "Upgraded item.", addition = "Upgrade material.", result = "Produced item."), SmithingTrim(id = "Identity.", template = "Trim template ingredient.", base = "Armor ingredient.", addition = "Trim material ingredient.", pattern = "Registry identity of the applied trim pattern.")), +)] +pub enum Recipe { + /// A crafting-table pattern. + Shaped { + #[schemars(with = "String")] + id: ResourceLocation, + pattern: Vec, + key: BTreeMap, + result: RecipeOutput, + }, + /// Crafting ingredients in any arrangement. + Shapeless { + #[schemars(with = "String")] + id: ResourceLocation, + ingredients: Vec, + result: RecipeOutput, + }, + /// A furnace-like recipe. + Cooking { + #[schemars(with = "String")] + id: ResourceLocation, + method: CookingMethod, + ingredient: String, + result: RecipeOutput, + #[serde(default)] + experience: f32, + #[serde(default, skip_serializing_if = "Option::is_none")] + time: Option, + }, + /// A stonecutter recipe. + Stonecutting { + #[schemars(with = "String")] + id: ResourceLocation, + ingredient: String, + result: RecipeOutput, + }, + /// A smithing-table upgrade. + Smithing { + #[schemars(with = "String")] + id: ResourceLocation, + template: String, + base: String, + addition: String, + result: RecipeOutput, + }, + /// Apply an armor trim while preserving the input armor and its components. + SmithingTrim { + #[schemars(with = "String")] + id: ResourceLocation, + template: String, + base: String, + addition: String, + #[schemars(with = "String")] + pattern: ResourceLocation, + }, +} + +impl Recipe { + /// The recipe identity. + pub(crate) fn id(&self) -> &ResourceLocation { + match self { + Recipe::Shaped { id, .. } + | Recipe::Shapeless { id, .. } + | Recipe::Cooking { id, .. } + | Recipe::Stonecutting { id, .. } + | Recipe::Smithing { id, .. } + | Recipe::SmithingTrim { id, .. } => id, + } + } +} + +/// Which registry a tag groups. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::TagKind", module = "sand::advanced::compiler", + summary = "Which registry a tag groups.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Selects `data//tags/item`, `tags/block`, or `tags/entity_type`.", + use_when = ["Declaring a registry tag"], + avoid_when = ["Function tags, which modules declare as tag memberships"], + example = "let kind = sand::advanced::compiler::TagKind::Item;", + variants(Item = "Items.", Block = "Blocks.", EntityType = "Entity types."), +)] +pub enum TagKind { + /// Items. + Item, + /// Blocks. + Block, + /// Entity types. + EntityType, +} + +/// A registry tag: a named group of ids and other tags. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::ResourceTag", module = "sand::advanced::compiler", + summary = "A registry tag: a named group of ids and other tags.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers through Sand's typed tags; `#ns:name` values reference other tags.", + use_when = ["Grouping items, blocks, or entity types for recipes and queries"], + avoid_when = ["Function tags"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(kind = "Grouped registry.", id = "Tag identity.", values = "Ids or `#tag` references.", replace = "Replace lower-priority definitions instead of merging."), +)] +pub struct ResourceTag { + /// Grouped registry. + pub kind: TagKind, + /// Tag identity. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Ids or `#tag` references. + pub values: Vec, + /// Replace lower-priority definitions instead of merging. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub replace: bool, +} + +/// One choice in a loot table. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::LootItem", module = "sand::advanced::compiler", + summary = "One choice in a loot table.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as a `minecraft:item` loot entry, with `set_count` when more than one.", + use_when = ["Listing what a loot table can produce"], + avoid_when = ["Custom items, whose components need the Rust API"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(item = "Vanilla item identity.", weight = "Relative chance.", count = "Stack size produced."), +)] +pub struct LootItem { + /// Vanilla item identity. + pub item: String, + /// Relative chance. + #[serde(default = "one")] + pub weight: u32, + /// Stack size produced. + #[serde(default = "one")] + pub count: u32, +} + +/// One independently rolled group of weighted loot choices. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::LootPool", module = "sand::advanced::compiler", + summary = "One independently rolled group of weighted loot choices.", + context = "The portable program model retains author-defined pool order and optional conditions.", + minecraft = "Lowers into Sand's typed loot pool with vanilla random chance and weather conditions.", + use_when = ["Combining fixed and conditional loot in the same resource"], + avoid_when = ["Using a function that requires a custom loot context"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(rolls = "Choices drawn from this pool.", items = "Weighted item choices.", chance = "Probability that this pool runs.", weather = "Required weather in the loot context.", predicate = "A reusable predicate file checked in the loot context."), +)] +pub struct LootPool { + /// Choices drawn from this pool. + #[serde(default = "one")] + pub rolls: u32, + /// Weighted item choices. + pub items: Vec, + /// Probability that this pool runs, from zero to one. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub chance: Option, + /// Required weather in the loot context. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weather: Option, + /// Optional reusable predicate that this pool requires. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[schemars(with = "Option")] + pub predicate: Option, +} + +/// A loot table containing one or more independently rolled pools. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::LootTable", module = "sand::advanced::compiler", + summary = "A loot table containing one or more independently rolled pools.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Lowers through Sand's typed loot builder to `data//loot_table/.json`.", + use_when = ["Handing out or dropping randomized rewards"], + avoid_when = ["Using custom loot functions that require the Rust API"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(id = "Identity.", pools = "Ordered independent, optionally conditional pools."), +)] +pub struct LootTable { + /// Identity. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Ordered independent, optionally conditional pools. + pub pools: Vec, +} + +/// A reusable native test of location or weather, optionally gated by chance. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::WorldPredicate", module = "sand::advanced::compiler", + summary = "A reusable native test of location or weather.", + context = "All selected constraints must pass at the predicate execution origin.", + minecraft = "Exports a named predicate using Sand's typed PredicateRoot model.", + use_when = ["Sharing a native world condition between functions and loot pools"], + avoid_when = ["Testing a mutable scoreboard value without compiling a predicate resource"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(id = "Predicate identity.", biome = "Biome identity.", dimension = "Required dimension.", block = "Required block.", weather = "Required weather.", chance = "Probability the predicate passes."), +)] +pub struct WorldPredicate { + /// Predicate identity. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Biome at the execution origin. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub biome: Option, + /// Dimension of the execution origin. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[schemars(with = "Option")] + pub dimension: Option, + /// Block at the execution origin. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block: Option, + /// Current weather. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub weather: Option, + /// Probability between zero and one. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub chance: Option, +} + +/// The colour of a boss bar. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BossBarColor", module = "sand::advanced::compiler", + summary = "The colour of a boss bar.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the `bossbar set color` argument.", + use_when = ["Declaring a boss bar"], + avoid_when = ["Text colours; use TextColor"], + example = "let color = sand::advanced::compiler::BossBarColor::Red;", + variants(Blue = "Blue.", Green = "Green.", Pink = "Pink.", Purple = "Purple.", Red = "Red.", White = "White.", Yellow = "Yellow."), +)] +pub enum BossBarColor { + /// Blue. + Blue, + /// Green. + Green, + /// Pink. + Pink, + /// Purple. + Purple, + /// Red. + Red, + /// White. + White, + /// Yellow. + Yellow, +} + +/// How a boss bar is divided. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BossBarStyle", module = "sand::advanced::compiler", + summary = "How a boss bar is divided.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Serialized as the `bossbar set style` argument.", + use_when = ["Declaring a boss bar"], + avoid_when = ["Text styling; use TextStyle"], + example = "let style = sand::advanced::compiler::BossBarStyle::Progress;", + variants(Progress = "One solid bar.", Notched6 = "Six notches.", Notched10 = "Ten notches.", Notched12 = "Twelve notches.", Notched20 = "Twenty notches."), +)] +pub enum BossBarStyle { + /// One solid bar. + Progress, + /// Six notches. + Notched6, + /// Ten notches. + Notched10, + /// Twelve notches. + Notched12, + /// Twenty notches. + Notched20, +} + +/// A named bar shown at the top of the screen. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::BossBar", module = "sand::advanced::compiler", + summary = "A named bar shown at the top of the screen.", + context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", + minecraft = "Created and refreshed at load with `bossbar add` and `bossbar set`.", + use_when = ["Showing progress or boss health"], + avoid_when = ["Text that needs no bar; use Message"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(id = "Identity.", title = "Title parts; text only.", color = "Bar colour.", style = "Bar division.", max = "Largest value."), +)] +pub struct BossBar { + /// Identity. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Title parts; text only. + pub title: Vec, + /// Bar colour. + pub color: BossBarColor, + /// Bar division. + pub style: BossBarStyle, + /// Largest value. + #[serde(default = "hundred")] + pub max: u32, +} + +fn hundred() -> u32 { + 100 +} + +/// A named native advancement with typed criteria and optional presentation. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::Advancement", module = "sand::advanced::compiler", + summary = "A named native advancement with typed criteria and optional presentation.", + context = "Criteria names retain player progress across reload. Use the display only for a visible milestone, and set require_any when its criteria are alternatives.", + minecraft = "Lowers through the canonical Advancement component to a native advancement and optional experience reward.", + use_when = ["Declaring a player milestone in a portable program"], + avoid_when = ["Polling scoreboard State for native advancement progress"], + fields(id = "Advancement identity.", display = "Optional presentation for a visible milestone.", criteria = "Stable authored names and native conditions.", require_any = "Complete on any criterion instead of requiring all.", experience = "Experience awarded at completion."), + example = "use sand::advanced::compiler::Advancement;", +)] +pub struct Advancement { + /// Advancement identity. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Optional presentation for a visible milestone. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub display: Option, + /// Nonempty map of stable names to native criteria. + pub criteria: BTreeMap, + /// Whether one criterion is sufficient for completion. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub require_any: bool, + /// Experience points awarded at completion, or zero for no reward. + #[serde(default)] + pub experience: i32, +} + +/// The optional native presentation of an advancement. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::AdvancementDisplay", module = "sand::advanced::compiler", + summary = "The optional native presentation of an advancement.", + context = "The icon is a vanilla item and the title and description support static rich text. A displayed root needs an explicit background on Minecraft 26.3.", + minecraft = "Becomes the advancement menu icon, title, description and root background.", + use_when = ["Showing a portable advancement in the vanilla player menu"], + avoid_when = ["An internal advancement used as a native signal"], + fields(icon = "Vanilla item identity.", title = "Static rich title.", description = "Static rich description.", background = "Optional root texture identity."), + example = "use sand::advanced::compiler::AdvancementDisplay;", +)] +pub struct AdvancementDisplay { + /// Vanilla item identity used as the icon. + pub icon: String, + /// Static rich title. + pub title: Vec, + /// Static rich description. + pub description: Vec, + /// Root texture identity. Minecraft 26.3 requires one for displayed roots. + #[schemars(with = "Option")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub background: Option, +} + +/// A vanilla condition that records one piece of player advancement progress. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(tag = "kind", rename_all = "snake_case", deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::AdvancementCriterion", module = "sand::advanced::compiler", + summary = "A vanilla condition that records one piece of player advancement progress.", + context = "Give each condition a stable name in its Advancement. The game tracks each player's completion and persists criterion progress.", + minecraft = "Uses inventory_changed, placed_block, or player_killed_entity.", + use_when = ["Composing native advancement criteria"], + avoid_when = ["Executing an arbitrary script as a criterion"], + variants(InventoryItem = "Acquire an item.", PlaceBlock = "Place the selected block.", KillEntity = "Kill an entity of the selected type."), + variant_fields(InventoryItem(item = "Vanilla item identity."), PlaceBlock(block = "Vanilla block identity."), KillEntity(entity = "Vanilla entity type identity.")), + example = "use sand::advanced::compiler::AdvancementCriterion;", +)] +pub enum AdvancementCriterion { + /// Have an item on a matching inventory change. + InventoryItem { item: String }, + /// Place a block of the given type. + PlaceBlock { block: String }, + /// Receive player kill credit for an entity of the given type. + KillEntity { entity: String }, +} + +/// A native notice dialog with static rich text and a dismiss button. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::NoticeDialog", module = "sand::advanced::compiler", + summary = "A native notice dialog with static rich text and a dismiss button.", + context = "Use Action::Dialog to display the resource for the executing player. Translated text resolves in the player's client language.", + minecraft = "Lowers through the canonical Dialog builder to a minecraft:notice resource.", + use_when = ["Showing a tutorial or information panel"], + avoid_when = ["Capturing form submissions or executing custom button actions"], + fields(id = "Dialog identity.", title = "Static rich title.", body = "Ordered static text blocks.", button = "Optional dismiss label, defaulting to the localized Done label."), + example = "use sand::advanced::compiler::NoticeDialog;", +)] +pub struct NoticeDialog { + /// Dialog identity. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Static rich title. + pub title: Vec, + /// Ordered static text blocks. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub body: Vec>, + /// Optional dismiss label. An empty list uses the client's Done label. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub button: Vec, +} + +/// A native dimension with an ordered stack of flat terrain layers. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::FlatDimension", module = "sand::advanced::compiler", + summary = "A native dimension with an ordered stack of flat terrain layers.", + context = "Declare the dimension before starting the world. Portable entity continuations can resume in this dimension while its chunks are loaded.", + minecraft = "Lowers through the canonical Dimension and FlatGenerator to a minecraft:flat dimension resource.", + use_when = ["Defining a dedicated gameplay or test world"], + avoid_when = ["Configuring a noise generator or defining a new dimension type"], + fields(id = "Dimension identity.", dimension_type = "Existing dimension type identity.", flat = "Bottom-to-top layers and shared flat generator settings."), + example = "use sand::advanced::compiler::FlatDimension;", +)] +pub struct FlatDimension { + /// Identity used by dimension-scoped operations. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Existing dimension type, which defines height and environmental rules. + #[schemars(with = "String")] + pub dimension_type: sand_components::DimensionTypeId, + /// Canonical bottom-to-top layers and flat-world settings. + pub flat: sand_components::FlatGenerator, +} + +/// Climate, visual settings, and natural spawn rules for a native custom biome. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::CustomBiome", module = "sand::advanced::compiler", + summary = "Climate, visual settings, and natural spawn rules for a native custom biome.", + context = "Reference the biome from FlatDimension or a block-position biome condition. Install the pack before starting the world to register the biome.", + minecraft = "Lowers through Biome, BiomeEffects, and the shared weighted spawn model to a native worldgen biome.", + use_when = ["Giving an authored dimension its own climate and colors"], + avoid_when = ["Declaring placed features or terrain carvers"], + fields(id = "Biome identity.", precipitation = "Whether rain or snow occurs.", temperature = "Climate temperature.", downfall = "Humidity from zero to one.", fog_color = "Fog RGB.", water_color = "Water surface RGB.", water_fog_color = "Underwater fog RGB.", sky_color = "Sky RGB.", grass_color = "Grass RGB override.", foliage_color = "Foliage RGB override.", spawners = "Ordered weighted entries within each mob category.", spawn_costs = "Population density budgets and charges by entity type."), + example = "use sand::advanced::compiler::CustomBiome;", +)] +pub struct CustomBiome { + /// Identity used in world generators and biome conditions. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Whether the biome has rain or snow. Defaults to true. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub precipitation: Option, + /// Climate temperature. Defaults to 0.5. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub temperature: Option, + /// Humidity from zero to one. Defaults to 0.5. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub downfall: Option, + /// Fog color, as an RGB integer. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fog_color: Option, + /// Water surface color, as an RGB integer. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub water_color: Option, + /// Underwater fog color, as an RGB integer. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub water_fog_color: Option, + /// Sky color, as an RGB integer. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub sky_color: Option, + /// Optional grass color override, as an RGB integer. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub grass_color: Option, + /// Optional foliage color override, as an RGB integer. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub foliage_color: Option, + /// Natural spawn entries in authored order within each vanilla category. + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub spawners: BTreeMap>, + /// Optional population-density budget and charge for each entity. + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] + pub spawn_costs: BTreeMap, +} + +/// A reusable native player inventory transfer between two numbered slots. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::InventoryTransferDefinition", module = "sand::advanced::compiler", + summary = "A reusable native player inventory transfer between two numbered slots.", + context = "Action::TransferInventory attempts the move as the executing player. Use distinct slots. An exact amount splits the source stack, and omitted amount moves the full stack.", + minecraft = "Lowers through InventoryTransfer with shared identity, stack capacity, locking, and callback semantics.", + use_when = ["Moving whole stacks or exact quantities without dropping overflow"], + avoid_when = ["Moving stacks to a block or entity outside the current player's numbered inventory"], + fields(id = "The transfer identity.", from = "Numbered source slot.", to = "Numbered destination slot.", amount = "Exact quantity, from 1 to 99. Omit for a whole stack.", success = "Optional function invoked as the player after success.", rejected = "Optional function invoked as the player when an admitted transfer is rejected."), + example = "use sand::advanced::compiler::InventoryTransferDefinition;", +)] +pub struct InventoryTransferDefinition { + /// Identity used by transfer operations. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Numbered source slot, from 0 to 35. + #[schemars(with = "u8", range(max = 35))] + pub from: crate::item::InventoryIndex, + /// Numbered destination slot, from 0 to 35. + #[schemars(with = "u8", range(max = 35))] + pub to: crate::item::InventoryIndex, + /// Exact quantity to move. The default moves the whole source stack. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub amount: Option, + /// Invoked as the player after a completed move. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub success: Option, + /// Invoked as the player after an admitted move is rejected. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rejected: Option, +} + +/// Owner-scoped presentation that lasts for a bounded number of loaded ticks. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::HudDefinition", module = "sand::advanced::compiler", + summary = "Owner-scoped presentation that lasts for a bounded number of loaded ticks.", + context = "Use Action::Hud to start or stop presentation as the current player. Supply an actionbar, a private boss bar, or both.", + minecraft = "Lowers through Hud and Lifetime with owner isolation, exclusive actionbar leases, and cleanup.", + use_when = ["Presenting player-specific gameplay progress for a loaded duration"], + avoid_when = ["Showing one shared bar to a group; use BossBar"], + fields(id = "HUD identity.", ticks = "Positive lifetime in loaded ticks.", every = "Refresh period in loaded ticks; defaults to one.", actionbar = "Optional rich actionbar text.", bossbar = "Optional private progress bar."), + example = "use sand::advanced::compiler::HudDefinition;", +)] +pub struct HudDefinition { + /// Identity used to start or cancel the HUD. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Loaded ticks before the native presentation expires. + pub ticks: u32, + /// Refresh cadence, defaulting to every loaded tick. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub every: Option, + /// Static rich text displayed in the owner's actionbar. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub actionbar: Vec, + /// A native private boss bar with a constant or State-backed value. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub bossbar: Option, +} + +/// The title, current value, and maximum of a player's private HUD boss bar. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::HudBossBar", module = "sand::advanced::compiler", + summary = "The title, current value, and maximum of a player's private HUD boss bar.", + context = "The value is read in player context each time Hud refreshes and is clamped to 0..=max.", + minecraft = "Lowers to one native boss bar per admitted player-owned HUD instance.", + use_when = ["Showing a private progress or resource meter"], + avoid_when = ["Using one shared boss bar value for all players"], + fields(title = "Static rich title.", value = "Constant or State score available to the player.", max = "Positive maximum."), + example = "use sand::advanced::compiler::HudBossBar;", +)] +pub struct HudBossBar { + /// Text shown over the bar. + pub title: Vec, + /// Current value read on each refresh. + pub value: ScoreOperand, + /// Positive bar maximum. + pub max: u32, +} + +/// An ordered native dialog menu with one-shot callbacks as the owning player. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::MenuDefinition", module = "sand::advanced::compiler", + summary = "An ordered native dialog menu with one-shot callbacks as the owning player.", + context = "Use Action::Menu to open or close the player’s session. Reopening creates fresh input tokens. The shared Menu runtime validates expiry, ownership, and navigation.", + minecraft = "Lowers through the native Menu system to paginated dialog buttons with generation-bound input.", + use_when = ["Offering a player a bounded list of gameplay actions"], + avoid_when = ["Showing a fixed dismissible message; use NoticeDialog"], + fields(id = "Menu identity.", title = "Static rich title.", ticks = "Positive number of online ticks before expiration.", page_size = "Optional number of choices per page, from 1 to 64.", choices = "Ordered buttons in the main view.", views = "Named secondary views.", start = "Initial view, which defaults to main.", while_open = "Optional score that must equal one throughout a session."), + example = "use sand::advanced::compiler::MenuDefinition;", +)] +pub struct MenuDefinition { + /// Identity used to open or close a session. + #[schemars(with = "String")] + pub id: ResourceLocation, + /// Title of each native dialog page. + pub title: Vec, + /// Online ticks before the open session expires. + pub ticks: u32, + /// Optional count of choices per page. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub page_size: Option, + /// Buttons in authored order. + pub choices: Vec, + /// Additional views in declaration order. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub views: Vec, + /// Initial view name. Omission selects the main view. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub start: Option, + /// When present, the referenced score must equal one while the session is open. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub while_open: Option, +} + +impl MenuDefinition { + pub(crate) fn view_index(&self, name: &str) -> Option { + if name == "main" { + Some(0) + } else { + self.views + .iter() + .position(|view| view.name == name) + .map(|index| (index + 1) as i32) + } + } + + pub(crate) fn choice_lists(&self) -> impl Iterator { + std::iter::once((&self.choices[..], "choices".into())).chain( + self.views + .iter() + .enumerate() + .map(|(index, view)| (&view.choices[..], format!("views/{index}/choices"))), + ) + } +} + +/// A named view within a native conversation. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::MenuView", module = "sand::advanced::compiler", + summary = "A named view in a native menu.", + context = "The menu may start here or enter it through a choice. An entered view receives newly issued player tokens.", + minecraft = "Uses the shared native Menu pagination and navigation.", + use_when = ["Building a conversation or confirmation screen"], + avoid_when = ["Persisting progress; store durable decisions in State"], + fields(name = "Name referenced by choices or the opening view.", title = "Rich heading on this view.", choices = "Ordered buttons for this view."), + example = "use sand::advanced::compiler::MenuView;", +)] +pub struct MenuView { + /// Identifier used for transitions into the view. + pub name: String, + /// Heading displayed on each page of this view. + pub title: Vec, + /// Buttons in authored order. + pub choices: Vec, +} + +/// A native menu button and the gameplay function it invokes. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::MenuChoice", module = "sand::advanced::compiler", + summary = "A native menu button and the gameplay function it invokes.", + context = "The menu consumes the player’s session before invoking the parameterless action, which may open new presentation.", + minecraft = "Uses a typed Menu choice and the shared one-shot native dialog routing.", + use_when = ["Adding one action to a player's menu"], + avoid_when = ["Adding a fixed notice's dismiss label"], + fields(label = "Static rich button label.", action = "Optional function invoked as the player after the session is consumed.", next = "Optional destination view entered after the callback.", when = "Optional score that must equal one at dispatch."), + example = "use sand::advanced::compiler::MenuChoice;", +)] +pub struct MenuChoice { + /// Label shown on the button. + pub label: Vec, + /// Function invoked with the choosing player as executor. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub action: Option, + /// View to open after the optional callback completes. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next: Option, + /// When present, the referenced score must equal one to authorize the choice. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub when: Option, +} diff --git a/sand-core/src/compiler/program/model/state.rs b/sand-core/src/compiler/program/model/state.rs index 48577fda..c30973eb 100644 --- a/sand-core/src/compiler/program/model/state.rs +++ b/sand-core/src/compiler/program/model/state.rs @@ -3,18 +3,18 @@ use sand_components::ResourceLocation; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -/// Revision-one player or global score State with explicit integer defaults and canonical ownership. +/// Revision-one State with typed score and storage fields and canonical ownership. #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] #[sand_macros::api( registry = sand_api_contract, path = "sand::advanced::compiler::State", module = "sand::advanced::compiler", - summary = "Revision-one player or global score State with explicit integer defaults and canonical ownership.", + summary = "Revision-one State with typed score and storage fields and canonical ownership.", context = "Owned portable gameplay definitions and diagnostics shared by Rust construction and strict JSON decoding.", minecraft = "Validates explicit targets and emits deterministic datapack resources through canonical State and command lowering.", use_when = ["Integrating a language, DSL, or editor with Sand without Cargo per program"], avoid_when = ["Ordinary Rust gameplay authoring is better served by the prelude"], example = "let schema = sand::advanced::compiler::Compiler::schema();", - fields(id = "Id for this portable definition.", scope = "Scope for this portable definition.", revision = "Revision for this portable definition.", fields = "Fields for this portable definition."), + fields(id = "Id for this portable definition.", scope = "Scope for this portable definition.", revision = "Revision for this portable definition.", fields = "Fields for this portable definition.", data_fields = "Typed storage-backed fields with the same State ownership."), )] pub struct State { /// Namespaced State identity. @@ -27,6 +27,31 @@ pub struct State { pub revision: u32, /// Named integer score fields. pub fields: Vec, + /// Typed storage-backed fields, initialized only when absent. Player and + /// entity values are keyed by UUID through the canonical State lifecycle. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub data_fields: Vec, +} + +/// A component-owned storage value with a typed NBT default. +#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[serde(deny_unknown_fields)] +#[sand_macros::api( + registry = sand_api_contract, path = "sand::advanced::compiler::DataField", module = "sand::advanced::compiler", + summary = "A component-owned storage value with a typed NBT default.", + context = "Storage fields share State presence, UUID ownership, initialization and removal with Rust-authored components.", + minecraft = "Global fields use command storage; player and entity fields are isolated by UUID.", + use_when = ["Lowering strings or collections from a typed frontend"], + avoid_when = ["An integer score field is sufficient"], + example = "let schema = sand::advanced::compiler::Compiler::schema();", + fields(name = "Field identity within its State.", default = "Typed default applied only when the field is absent."), +)] +pub struct DataField { + /// Field identity within its State; shared namespace with score fields. + pub name: String, + /// Typed default applied only when the field is absent. Opaque raw SNBT + /// cannot be serialized in a portable program. + pub default: sand_commands::NbtValue, } /// An integer State field whose default initializes only an absent value. @@ -40,7 +65,7 @@ pub struct State { use_when = ["Integrating a language, DSL, or editor with Sand without Cargo per program"], avoid_when = ["Ordinary Rust gameplay authoring is better served by the prelude"], example = "let schema = sand::advanced::compiler::Compiler::schema();", - fields(name = "Name for this portable definition.", default = "Default for this portable definition.", bounds = "Optional inclusive bounds applied after score writes."), + fields(name = "Name for this portable definition.", default = "Default for this portable definition.", bounds = "Optional inclusive bounds applied after score writes.", timer = "Whether the score counts down by one each tick until zero."), )] pub struct ScoreField { /// Field identity within its owning State. @@ -55,10 +80,14 @@ pub struct ScoreField { /// arithmetic before clamping; these bounds do not prevent overflow. #[serde(default, skip_serializing_if = "Option::is_none")] pub bounds: Option<(i32, i32)>, + /// Count down by one each tick until zero, through the same State lifecycle + /// that drives Rust `Timer` and `Cooldown` fields. Timers cannot have bounds. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub timer: bool, } /// A field reference binds a field identity to its declaring State. -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] #[sand_macros::api( registry = sand_api_contract, path = "sand::advanced::compiler::FieldReference", module = "sand::advanced::compiler", @@ -79,7 +108,7 @@ pub struct FieldReference { } /// Inclusive integer comparison bounds for a State score. -#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)] #[serde(deny_unknown_fields)] #[sand_macros::api( registry = sand_api_contract, path = "sand::advanced::compiler::ScoreComparison", module = "sand::advanced::compiler", diff --git a/sand-core/src/compiler/program/validate.rs b/sand-core/src/compiler/program/validate.rs index 3369e485..abb19e14 100644 --- a/sand-core/src/compiler/program/validate.rs +++ b/sand-core/src/compiler/program/validate.rs @@ -1,5 +1,6 @@ //! Whole-program validation before any output allocation or publication. use super::{diagnostic::Diagnostic, limits, model::*}; +use sand_commands::ClickEvent; use sand_components::ResourceLocation; use std::collections::{BTreeMap, BTreeSet}; @@ -92,7 +93,7 @@ pub(super) fn validate( module .states .iter() - .map(|state| state.fields.len()) + .map(|state| state.fields.len().saturating_add(state.data_fields.len())) .sum::(), ) }) @@ -129,16 +130,26 @@ pub(super) fn validate( "invalid or duplicate State identity", )); } - if !matches!(state.scope.as_str(), "player" | "global") || state.revision != 1 { + if !matches!(state.scope.as_str(), "player" | "entity" | "global") + || state.revision != 1 + { errors.push(Diagnostic::error( "SAND_PROGRAM_STATE", &owner, &ptr, - "v1 requires player or global State revision 1", + "v1 requires player, entity, or global State revision 1", )); } let mut fields = BTreeSet::new(); for (index, field) in state.fields.iter().enumerate() { + if field.timer && field.bounds.is_some() { + errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + &module.id.to_string(), + &format!("{ptr}/fields/{index}/bounds"), + "timer fields count down on their own and cannot have bounds", + )); + } if field.bounds.is_some_and(|(min, max)| min > max) { errors.push(Diagnostic::error( "SAND_PROGRAM_STATE", @@ -165,6 +176,42 @@ pub(super) fn validate( )); } } + for (index, field) in state.data_fields.iter().enumerate() { + let field_ptr = format!("{ptr}/data_fields/{index}"); + if field.name.is_empty() + || matches!( + field.name.as_str(), + "presence" | "suppressed" | "numeric_scratch" + ) + || !field + .name + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'_') + || !fields.insert(&field.name) + { + errors.push(Diagnostic::error("SAND_PROGRAM_STATE", &owner, &field_ptr, + "storage fields require unique simple names and share the score field namespace")); + } + let profile = sand_commands::CommandProfile::new(&program.target.minecraft, false); + let command = sand_commands::DataTarget::storage("sand:validate") + .path("value") + .set(field.default.clone()); + if serde_json::to_value(&field.default).is_err() { + errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + &owner, + &field_ptr, + "portable storage defaults require typed NBT; raw SNBT is unsupported", + )); + } else if let Err(error) = command.try_render(&profile) { + errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + &owner, + &field_ptr, + error, + )); + } + } } for (index, function) in module.functions.iter().enumerate() { if !valid_id(&function.id) @@ -194,6 +241,51 @@ pub(super) fn validate( }) .collect(); let mut validator = Validator { + dialogs_supported: target.as_ref().is_some_and(|profile| { + profile + .caps() + .supports(sand_version::ComponentFeature::Dialogs) + }), + menus: program + .modules + .iter() + .flat_map(|module| &module.menus) + .map(|menu| menu.id.to_string()) + .collect(), + huds: program + .modules + .iter() + .flat_map(|module| &module.huds) + .map(|hud| hud.id.to_string()) + .collect(), + transfers: program + .modules + .iter() + .flat_map(|module| &module.inventory_transfers) + .map(|transfer| transfer.id.to_string()) + .collect(), + advancements: program + .modules + .iter() + .flat_map(|module| &module.advancements) + .map(|item| (item.id.to_string(), item.criteria.keys().cloned().collect())) + .collect(), + target: &program.target.minecraft, + boss_bars: program + .modules + .iter() + .flat_map(|m| m.boss_bars.iter().map(|b| b.id.to_string())) + .collect(), + loot_tables: program + .modules + .iter() + .flat_map(|m| m.loot_tables.iter().map(|t| t.id.to_string())) + .collect(), + custom_items: program + .modules + .iter() + .flat_map(|m| m.items.iter().map(|i| i.id.to_string())) + .collect(), states: states .into_iter() .map(|(id, state)| { @@ -210,7 +302,34 @@ pub(super) fn validate( ) }) .collect(), + data_fields: program + .modules + .iter() + .flat_map(|module| &module.states) + .map(|state| { + ( + state.id.to_string(), + state + .data_fields + .iter() + .map(|field| field.name.as_str()) + .collect(), + ) + }) + .collect(), functions, + identity_unsafe: program + .modules + .iter() + .flat_map(|m| &m.states) + .flat_map(|state| { + state + .fields + .iter() + .filter(|field| field.timer || field.bounds.is_some()) + .map(|field| format!("{}.{}", state.id, field.name)) + }) + .collect(), operations: 0, flow_bytes: 0, raw: program.requires.iter().any(|v| v == "raw_commands"), @@ -231,6 +350,19 @@ pub(super) fn validate( "invalid or duplicate flow identity", )); } + if validator + .states + .get(&flow.state.state.to_string()) + .is_some_and(|(scope, _)| *scope == "entity") + { + validator.errors.push(Diagnostic::error( + "SAND_PROGRAM_FLOW", + &owner, + &format!("{ptr}/state"), + "flows run over player or global State, not entity State", + )); + continue; + } let context = if validator .states .get(&flow.state.state.to_string()) @@ -318,199 +450,1666 @@ pub(super) fn validate( }; validator.call(&tag.function, context, &owner, &format!("{ptr}/function")); } - } - if errors.is_empty() { - let value = serde_json::to_value(program).expect("owned program serializes"); - let mut pending = vec![(&value, 0usize)]; - while let Some((value, depth)) = pending.pop() { - if depth > limits::JSON_DEPTH { - errors.push(Diagnostic::error( - "SAND_PROGRAM_LIMIT", - "", - "", - "constructed program exceeds JSON nesting limit", - )); - break; + for (index, menu) in module.menus.iter().enumerate() { + let ptr = format!("/menus/{index}"); + let context = ExecutionContext::Player; + if let Some(score) = &menu.while_open { + validator.score(score, context, &owner, &format!("{ptr}/while_open")); } - match value { - serde_json::Value::Array(values) => { - pending.extend(values.iter().map(|value| (value, depth + 1))) - } - serde_json::Value::Object(values) => { - pending.extend(values.values().map(|value| (value, depth + 1))) + for (choices, path) in menu.choice_lists() { + for (choice_index, choice) in choices.iter().enumerate() { + let ptr = format!("{ptr}/{path}/{choice_index}"); + if let Some(action) = &choice.action { + validator.call(action, context, &owner, &format!("{ptr}/action")); + } + if let Some(score) = &choice.when { + validator.score(score, context, &owner, &format!("{ptr}/when")); + } } - _ => {} } } - match serde_json::to_vec(&value) { - Ok(bytes) if bytes.len() <= limits::INPUT_BYTES => {} - _ => errors.push(Diagnostic::error( - "SAND_PROGRAM_LIMIT", - "", - "", - "constructed program exceeds 8 MiB", - )), + for (index, hud) in module.huds.iter().enumerate() { + if let Some(HudBossBar { + value: ScoreOperand::Field(score), + .. + }) = &hud.bossbar + { + validator.score( + score, + ExecutionContext::Player, + &owner, + &format!("/huds/{index}/bossbar/value"), + ); + } } - } - if errors.is_empty() { - Ok(target.expect("validated target")) - } else { - Err(errors) - } -} - -fn safe_path(value: &str) -> bool { - super::decode::safe_module_path(value) -} -fn valid_id(id: &ResourceLocation) -> bool { - safe_path(id.namespace()) && safe_path(id.path()) && id.namespace() != "__sand_local" -} - -struct Validator<'a, 'e> { - states: BTreeMap)>, - functions: BTreeMap, - operations: usize, - flow_bytes: usize, - raw: bool, - errors: &'e mut Vec, -} -impl Validator<'_, '_> { - // Count copied hook invocations before the shared compiler materializes - // transition bodies. Input declaration limits alone cannot bound this - // transition × hook expansion. This is a lower bound on emitted bytes; - // the normal output limits still check every complete generated resource. - fn reserve_flow_expansion(&mut self, flow: &Flow, owner: &str, ptr: &str) -> bool { - let mut enter = BTreeMap::::new(); - let mut exit = BTreeMap::::new(); - let mut calls = 0usize; - let mut bytes = 0usize; - for hook in &flow.hooks { - let id = match &hook.function { - FunctionReference::Internal { id } | FunctionReference::External { id, .. } => id, - }; - let size = id.to_string().len().saturating_add("function ".len() + 1); - let counters = match hook.phase { - FlowHookPhase::Enter => enter.entry(hook.state).or_default(), - FlowHookPhase::Exit => exit.entry(hook.state).or_default(), - FlowHookPhase::Tick => { - calls = calls.saturating_add(1); - bytes = bytes.saturating_add(size); - continue; + for (index, transfer) in module.inventory_transfers.iter().enumerate() { + for (field, callback) in [ + ("success", &transfer.success), + ("rejected", &transfer.rejected), + ] { + if let Some(callback) = callback { + validator.call( + callback, + ExecutionContext::Player, + &owner, + &format!("/inventory_transfers/{index}/{field}"), + ); } - }; - counters.0 = counters.0.saturating_add(1); - counters.1 = counters.1.saturating_add(size); - } - let mut oversized = false; - for transition in &flow.transitions { - let before = exit.get(&transition.from).copied().unwrap_or_default(); - let after = enter.get(&transition.to).copied().unwrap_or_default(); - calls = calls.saturating_add(before.0).saturating_add(after.0); - let body_bytes = before.1.saturating_add(after.1); - oversized |= body_bytes > limits::DOCUMENT_BYTES; - bytes = bytes.saturating_add(body_bytes); - } - self.operations = self.operations.saturating_add(calls); - self.flow_bytes = self.flow_bytes.saturating_add(bytes); - if oversized - || self.operations > limits::OPERATIONS - || self.flow_bytes > limits::OUTPUT_BYTES - { - self.errors.push(Diagnostic::error( - "SAND_PROGRAM_LIMIT", - owner, - ptr, - "expanded flow hooks exceed operation or generated-output limits", - )); - false - } else { - true + } } - } - - fn comparison( - &mut self, - condition: &ScoreComparison, - context: ExecutionContext, - owner: &str, - ptr: &str, - ) { - self.score(&condition.score, context, owner, &format!("{ptr}/score")); - if condition - .min - .zip(condition.max) - .is_some_and(|(min, max)| min > max) - { - self.errors.push(Diagnostic::error( - "SAND_PROGRAM_RANGE", - owner, - ptr, - "comparison minimum exceeds maximum", - )); + for (index, hook) in module.events.iter().enumerate() { + let ptr = format!("/events/{index}"); + if let Some((id, kind)) = hook.event.filter() { + validator.resource(id, &owner, &format!("{ptr}/event"), kind); + } + if let PlayerEvent::AdvancementCompleted { advancement } = &hook.event + && !validator + .advancements + .contains_key(&advancement.to_string()) + { + validator.errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &format!("{ptr}/event/advancement"), + format!("advancement completion requires an authored advancement, found `{advancement}`"), + )); + } + // Handlers run as the observed player. + validator.call( + &hook.function, + ExecutionContext::Player, + &owner, + &format!("{ptr}/function"), + ); } } - - fn score(&mut self, score: &FieldReference, context: ExecutionContext, owner: &str, ptr: &str) { - if context != ExecutionContext::Player - && self - .states - .get(&score.state.to_string()) - .is_some_and(|(scope, _)| *scope == "player") - { - self.errors.push(Diagnostic::error( - "SAND_PROGRAM_CONTEXT", - owner, - ptr, - "player-self State requires player execution context", - )); - } - if !self - .states - .get(&score.state.to_string()) - .is_some_and(|(_, fields)| fields.contains(score.field.as_str())) - { - self.errors.push(Diagnostic::error( - "SAND_PROGRAM_REFERENCE", - owner, - ptr, - "unresolved State field", + let custom_items: BTreeSet = program + .modules + .iter() + .flat_map(|m| m.items.iter().map(|i| i.id.to_string())) + .collect(); + let mut resource_ids = BTreeSet::new(); + for module in &program.modules { + let owner = module.id.to_string(); + let mut push = |ptr: String, message: String| { + errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + &owner, + &ptr, + message, )); - } - } - fn call( - &mut self, - reference: &FunctionReference, - context: ExecutionContext, - owner: &str, - ptr: &str, - ) { - let (id, requirement) = match reference { - FunctionReference::Internal { id } => { - (id, self.functions.get(&id.to_string()).copied()) + }; + let syntax_id = |id: &str| { + id.strip_prefix('#').is_none() + && id.parse::().is_ok() + && id.contains(':') + }; + let available = |id: &str, registry: &str| { + !id.starts_with("minecraft:") + || sand_version::registry::contains(&program.target.minecraft, registry, id) + != Some(false) + }; + let item_id = |id: &str| syntax_id(id) && available(id, "minecraft:item"); + let block_id = |id: &str| syntax_id(id) && available(id, "minecraft:block"); + let ingredient = |id: &str| { + id.strip_prefix('#') + .unwrap_or(id) + .parse::() + .is_ok() + && id.contains(':') + }; + for (index, item) in module.items.iter().enumerate() { + let ptr = format!("/items/{index}"); + if !resource_ids.insert(format!("item {}", item.id)) { + push( + format!("{ptr}/id"), + format!("duplicate custom item `{}`", item.id), + ); } - FunctionReference::External { id, context } => { - if self.functions.contains_key(&id.to_string()) { - self.errors.push(Diagnostic::error( - "SAND_PROGRAM_REFERENCE", - owner, - ptr, - "external function reference resolves to a declared internal function", - )); + if item.id.namespace() == "minecraft" { + push( + format!("{ptr}/id"), + "custom items must not use the `minecraft` namespace".into(), + ); + } + if !item_id(&item.base) || custom_items.contains(&item.base) { + push( + format!("{ptr}/base"), + format!("`{}` is not a vanilla base item", item.base), + ); + } + let item_text = + std::iter::once(item.name.as_slice()).chain(item.lore.iter().map(Vec::as_slice)); + for parts in item_text { + if let Some(error) = static_text_error(parts, None) { + push(ptr.clone(), error); } - (id, Some(*context)) } - }; - if !valid_id(id) || id.path().starts_with("__sand_") { - self.errors.push(Diagnostic::error( - "SAND_PROGRAM_REFERENCE", - owner, - ptr, - "invalid or compiler-private function reference", - )); - } - match requirement { - None => self.errors.push(Diagnostic::error( - "SAND_PROGRAM_REFERENCE", + if let Some(book) = &item.book { + if item.base != "minecraft:written_book" { + push( + format!("{ptr}/book"), + "book content needs a minecraft:written_book base item".into(), + ); + } + for (index, page) in book.pages.iter().enumerate() { + if let Some(error) = static_text_error(page, Some(book.pages.len())) { + push(format!("{ptr}/book/pages/{index}"), error); + } + } + } + if item.max_stack.is_some_and(|n| !(1..=99).contains(&n)) { + push( + format!("{ptr}/max_stack"), + "max stack must be 1..=99".into(), + ); + } + for (enchantment, level) in &item.enchantments { + if !available(enchantment, "minecraft:enchantment") { + push( + format!("{ptr}/enchantments"), + format!( + "no enchantment `{enchantment}` in Minecraft {}", + program.target.minecraft + ), + ); + } else if !syntax_id(enchantment) || !(1..=255).contains(level) { + push( + format!("{ptr}/enchantments"), + format!("enchantment `{enchantment}` needs an id and a level of 1..=255"), + ); + } + } + } + for (index, recipe) in module.recipes.iter().enumerate() { + let ptr = format!("/recipes/{index}"); + if !resource_ids.insert(format!("recipe {}", recipe.id())) { + push( + format!("{ptr}/id"), + format!("duplicate recipe `{}`", recipe.id()), + ); + } + let mut inputs: Vec<(String, &String)> = Vec::new(); + let result = match recipe { + Recipe::Shaped { + pattern, + key, + result, + .. + } => { + let width = pattern.first().map(|r| r.chars().count()).unwrap_or(0); + if pattern.is_empty() + || pattern.len() > 3 + || width == 0 + || width > 3 + || pattern.iter().any(|r| r.chars().count() != width) + { + push(format!("{ptr}/pattern"), "a shaped pattern has one to three rows of equal width, at most three wide".into()); + } + let used: BTreeSet = pattern + .iter() + .flat_map(|r| r.chars()) + .filter(|c| *c != ' ') + .collect(); + for c in &used { + if !key.contains_key(&c.to_string()) { + push( + format!("{ptr}/key"), + format!("pattern character `{c}` has no key"), + ); + } + } + for (symbol, item) in key { + let mut chars = symbol.chars(); + let single = chars.next().filter(|c| *c != ' ' && chars.next().is_none()); + match single { + None => push( + format!("{ptr}/key"), + format!("key `{symbol}` must be one character other than space"), + ), + Some(c) if !used.contains(&c) => push( + format!("{ptr}/key"), + format!("key `{symbol}` is not used in the pattern"), + ), + Some(_) => {} + } + inputs.push((format!("{ptr}/key/{symbol}"), item)); + } + Some(result) + } + Recipe::Shapeless { + ingredients, + result, + .. + } => { + if ingredients.is_empty() || ingredients.len() > 9 { + push( + format!("{ptr}/ingredients"), + "a shapeless recipe has one to nine ingredients".into(), + ); + } + inputs.extend( + ingredients + .iter() + .enumerate() + .map(|(i, item)| (format!("{ptr}/ingredients/{i}"), item)), + ); + Some(result) + } + Recipe::Cooking { + ingredient, + result, + experience, + time, + .. + } => { + if !(experience.is_finite() && *experience >= 0.0) || *time == Some(0) { + push( + ptr.clone(), + "cooking experience must be non-negative and time positive".into(), + ); + } + inputs.push((format!("{ptr}/ingredient"), ingredient)); + Some(result) + } + Recipe::Stonecutting { + ingredient, result, .. + } => { + inputs.push((format!("{ptr}/ingredient"), ingredient)); + Some(result) + } + Recipe::Smithing { + template, + base, + addition, + result, + .. + } => { + inputs.push((format!("{ptr}/template"), template)); + inputs.push((format!("{ptr}/base"), base)); + inputs.push((format!("{ptr}/addition"), addition)); + Some(result) + } + Recipe::SmithingTrim { + template, + base, + addition, + pattern, + .. + } => { + inputs.push((format!("{ptr}/template"), template)); + inputs.push((format!("{ptr}/base"), base)); + inputs.push((format!("{ptr}/addition"), addition)); + if !available(&pattern.to_string(), "minecraft:trim_pattern") { + push( + format!("{ptr}/pattern"), + format!( + "no trim pattern `{pattern}` in Minecraft {}", + program.target.minecraft + ), + ); + } + None + } + }; + for (input_ptr, item) in inputs { + if custom_items.contains(item.as_str()) { + push( + input_ptr, + format!( + "custom item `{item}` cannot be a recipe ingredient: vanilla recipes match only by item id or tag" + ), + ); + } else if !ingredient(item) + || (!item.starts_with('#') && !available(item, "minecraft:item")) + { + push(input_ptr, format!("`{item}` is not an item id or `#tag`")); + } + } + if let Some(result) = result + && (!item_id(&result.item) || !(1..=99).contains(&result.count)) + { + push( + format!("{ptr}/result"), + "a recipe result is an item id with a count of 1..=99".into(), + ); + } + } + for (index, menu) in module.menus.iter().enumerate() { + let ptr = format!("/menus/{index}"); + if !resource_ids.insert(format!("menu {}", menu.id)) { + push(format!("{ptr}/id"), format!("duplicate menu `{}`", menu.id)); + } + if !(1..=i32::MAX as u32).contains(&menu.ticks) { + push( + format!("{ptr}/ticks"), + "menu timeout must be in 1..=2147483647".into(), + ); + } + if menu + .page_size + .is_some_and(|value| !(1..=64).contains(&value)) + { + push( + format!("{ptr}/page_size"), + "menu page size must be in 1..=64".into(), + ); + } + let mut names = BTreeSet::from(["main"]); + for (index, view) in menu.views.iter().enumerate() { + let ptr = format!("{ptr}/views/{index}"); + if view.name.is_empty() + || !view + .name + .bytes() + .all(|byte| byte.is_ascii_alphanumeric() || byte == b'_') + || !names.insert(&view.name) + { + push(format!("{ptr}/name"), "expected a unique menu view name using letters, digits, or underscores; main is reserved".into()); + } + if let Some(error) = static_text_error(&view.title, None) { + push(format!("{ptr}/title"), error); + } + } + if menu + .start + .as_deref() + .is_some_and(|name| !names.contains(name)) + { + push(format!("{ptr}/start"), "unknown starting menu view".into()); + } + if menu + .choice_lists() + .map(|(choices, _)| choices.len()) + .sum::() + > 256 + { + push( + format!("{ptr}/choices"), + "a menu supports at most 256 choices across all views".into(), + ); + } + if let Some(error) = static_text_error(&menu.title, None) { + push(format!("{ptr}/title"), error); + } + for (choices, path) in menu.choice_lists() { + if choices.is_empty() { + push( + format!("{ptr}/{path}"), + "each menu view needs between 1 and 256 choices".into(), + ); + } + for (choice_index, choice) in choices.iter().enumerate() { + let ptr = format!("{ptr}/{path}/{choice_index}"); + if choice.action.is_none() && choice.next.is_none() { + push( + ptr.clone(), + "a menu choice needs an action or destination".into(), + ); + } + if choice + .next + .as_deref() + .is_some_and(|name| !names.contains(name)) + { + push( + format!("{ptr}/next"), + "unknown destination menu view".into(), + ); + } + if let Some(error) = static_text_error(&choice.label, None) { + push(format!("{ptr}/label"), error); + } + } + } + } + for (index, hud) in module.huds.iter().enumerate() { + let ptr = format!("/huds/{index}"); + if !resource_ids.insert(format!("hud {}", hud.id)) { + push(format!("{ptr}/id"), format!("duplicate HUD `{}`", hud.id)); + } + for (field, value) in + std::iter::once(("ticks", hud.ticks)).chain(hud.every.map(|every| ("every", every))) + { + if !(1..=i32::MAX as u32).contains(&value) { + push( + format!("{ptr}/{field}"), + "HUD ticks must be in 1..=2147483647".into(), + ); + } + } + if hud.actionbar.is_empty() && hud.bossbar.is_none() { + push(ptr.clone(), "a HUD needs an actionbar or a boss bar".into()); + } + if let Some(error) = static_text_error(&hud.actionbar, None) { + push(format!("{ptr}/actionbar"), error); + } + if let Some(bar) = &hud.bossbar { + if !(1..=i32::MAX as u32).contains(&bar.max) { + push( + format!("{ptr}/bossbar/max"), + "HUD bar maximum must be in 1..=2147483647".into(), + ); + } + if let Some(error) = static_text_error(&bar.title, None) { + push(format!("{ptr}/bossbar/title"), error); + } + } + } + for (index, transfer) in module.inventory_transfers.iter().enumerate() { + let ptr = format!("/inventory_transfers/{index}"); + if !resource_ids.insert(format!("inventory transfer {}", transfer.id)) { + push( + format!("{ptr}/id"), + format!("duplicate inventory transfer `{}`", transfer.id), + ); + } + if transfer.from == transfer.to { + push( + format!("{ptr}/to"), + "source and destination must be distinct numbered player slots".into(), + ); + } + if transfer + .amount + .is_some_and(|amount| !(1..=99).contains(&amount)) + { + push( + format!("{ptr}/amount"), + "inventory transfers require 1..=99 items".into(), + ); + } + } + for (index, template) in module.structure_templates.iter().enumerate() { + use sand_components::component::DatapackComponent; + let ptr = format!("/structure_templates/{index}"); + let id = template.resource_location(); + if !resource_ids.insert(format!("structure template {id}")) { + push( + format!("{ptr}/id"), + format!("duplicate structure template `{id}`"), + ); + } + if let Err(error) = template.validate() { + push(format!("{ptr}/source"), error.to_string()); + continue; + } + let source = template.source_path(); + match program.structure_assets.get(source) { + Some(bytes) if bytes.len() >= 18 && bytes.starts_with(&[0x1f, 0x8b, 8]) => {} + Some(_) => push( + format!("{ptr}/source"), + format!("structure asset `{source}` must be a gzip NBT file"), + ), + None => push( + format!("{ptr}/source"), + format!("missing structure asset `{source}`"), + ), + } + } + for (index, biome) in module.biomes.iter().enumerate() { + let ptr = format!("/biomes/{index}"); + if !resource_ids.insert(format!("biome {}", biome.id)) { + push( + format!("{ptr}/id"), + format!("duplicate biome `{}`", biome.id), + ); + } + if biome + .downfall + .is_some_and(|value| !(0.0..=1.0).contains(&value)) + { + push( + format!("{ptr}/downfall"), + "downfall must be between zero and one".into(), + ); + } + let spawn_entity_exists = |id: &str| { + syntax_id(id) + && sand_version::registry::contains( + &program.target.minecraft, + "minecraft:entity_type", + id, + ) != Some(false) + }; + for (category, entries) in &biome.spawners { + for (index, entry) in entries.iter().enumerate() { + let entity = entry.entity_type().to_string(); + if !spawn_entity_exists(&entity) { + push( + format!("{ptr}/spawners/{}/{index}/entity_type", category.as_str()), + format!("unknown entity type `{entity}`"), + ); + } + } + } + for entity in biome.spawn_costs.keys() { + if !spawn_entity_exists(entity) { + push( + format!("{ptr}/spawn_costs/{entity}"), + format!("unknown entity type `{entity}`"), + ); + } + } + } + for (index, dimension) in module.dimensions.iter().enumerate() { + let ptr = format!("/dimensions/{index}"); + if !resource_ids.insert(format!("dimension {}", dimension.id)) { + push( + format!("{ptr}/id"), + format!("duplicate dimension `{}`", dimension.id), + ); + } + let biome = dimension.flat.biome_id.to_string(); + if !available(&biome, "minecraft:worldgen/biome") { + push( + format!("{ptr}/flat/biome_id"), + format!("unknown biome `{biome}`"), + ); + } + for (layer_index, layer) in dimension.flat.layers.iter().enumerate() { + let block = layer.block.to_string(); + if !block_id(&block) { + push( + format!("{ptr}/flat/layers/{layer_index}/block"), + format!("unknown block `{block}`"), + ); + } + } + } + for (index, dialog) in module.dialogs.iter().enumerate() { + let ptr = format!("/dialogs/{index}"); + if !resource_ids.insert(format!("dialog {}", dialog.id)) { + push( + format!("{ptr}/id"), + format!("duplicate dialog `{}`", dialog.id), + ); + } + let text_blocks = std::iter::once(("title".to_owned(), &dialog.title)) + .chain( + dialog + .body + .iter() + .enumerate() + .map(|(i, text)| (format!("body/{i}"), text)), + ) + .chain(std::iter::once(("button".to_owned(), &dialog.button))); + for (field, text) in text_blocks { + if let Some(error) = static_text_error(text, None) { + push(format!("{ptr}/{field}"), error); + } + } + } + for (index, advancement) in module.advancements.iter().enumerate() { + let ptr = format!("/advancements/{index}"); + if !resource_ids.insert(format!("advancement {}", advancement.id)) { + push( + format!("{ptr}/id"), + format!("duplicate advancement `{}`", advancement.id), + ); + } + if advancement.criteria.is_empty() { + push( + format!("{ptr}/criteria"), + "an advancement needs at least one criterion".into(), + ); + } + if advancement.experience < 0 { + push( + format!("{ptr}/experience"), + "advancement experience must be nonnegative".into(), + ); + } + for (name, criterion) in &advancement.criteria { + let criteria_path = format!( + "{ptr}/criteria/{}", + name.replace('~', "~0").replace('/', "~1") + ); + if name.trim().is_empty() || name.chars().any(char::is_control) { + push( + criteria_path.clone(), + "criterion names must be nonblank and contain no control characters".into(), + ); + } + let (id, registry, field) = match criterion { + AdvancementCriterion::InventoryItem { item } => { + (item, "minecraft:item", "item") + } + AdvancementCriterion::PlaceBlock { block } => { + (block, "minecraft:block", "block") + } + AdvancementCriterion::KillEntity { entity } => { + (entity, "minecraft:entity_type", "entity") + } + }; + if !syntax_id(id) + || !available(id, registry) + || (field == "item" && custom_items.contains(id)) + { + push( + format!("{criteria_path}/{field}"), + format!("`{id}` is not a vanilla {field} identity"), + ); + } + } + if let Some(display) = &advancement.display { + if !item_id(&display.icon) || custom_items.contains(&display.icon) { + push( + format!("{ptr}/display/icon"), + "an advancement icon needs a vanilla item".into(), + ); + } + for (field, text) in [ + ("title", &display.title), + ("description", &display.description), + ] { + if let Some(error) = static_text_error(text, None) { + push(format!("{ptr}/display/{field}"), error); + } + } + } + } + for (index, predicate) in module.predicates.iter().enumerate() { + let ptr = format!("/predicates/{index}"); + if !resource_ids.insert(format!("predicate {}", predicate.id)) { + push( + format!("{ptr}/id"), + format!("duplicate predicate `{}`", predicate.id), + ); + } + if predicate.biome.is_none() + && predicate.dimension.is_none() + && predicate.block.is_none() + && predicate.weather.is_none() + && predicate.chance.is_none() + { + push( + ptr.clone(), + "a world predicate needs at least one condition".into(), + ); + } + if let Some(biome) = &predicate.biome + && !(syntax_id(biome) && available(biome, "minecraft:worldgen/biome")) + { + push( + format!("{ptr}/biome"), + format!( + "`{biome}` is not a biome in Minecraft {}", + program.target.minecraft + ), + ); + } + if predicate + .block + .as_ref() + .is_some_and(|block| !block_id(block)) + { + push( + format!("{ptr}/block"), + "predicate block must exist in the selected target".into(), + ); + } + if predicate + .chance + .is_some_and(|chance| !(0.0..=1.0).contains(&chance)) + { + push( + format!("{ptr}/chance"), + "predicate chance must be between zero and one".into(), + ); + } + } + for (index, damage_type) in module.damage_types.iter().enumerate() { + let ptr = format!("/damage_types/{index}"); + use sand_components::DatapackComponent; + let id = damage_type.resource_location(); + if !resource_ids.insert(format!("damage_type {id}")) { + push(format!("{ptr}/id"), format!("duplicate damage type `{id}`")); + } + if let Err(error) = damage_type.validate() { + push(ptr, error.to_string()); + } + } + for (index, table) in module.loot_tables.iter().enumerate() { + let ptr = format!("/loot_tables/{index}"); + if !resource_ids.insert(format!("loot {}", table.id)) { + push( + format!("{ptr}/id"), + format!("duplicate loot table `{}`", table.id), + ); + } + if table.pools.is_empty() { + push( + format!("{ptr}/pools"), + "a loot table needs at least one pool".into(), + ); + } + for (index, pool) in table.pools.iter().enumerate() { + let ptr = format!("{ptr}/pools/{index}"); + if !(1..=1000).contains(&pool.rolls) || pool.items.is_empty() { + push( + ptr.clone(), + "a loot pool needs 1..=1000 rolls and at least one item".into(), + ); + } + if pool + .chance + .is_some_and(|chance| !(0.0..=1.0).contains(&chance)) + { + push( + format!("{ptr}/chance"), + "loot pool chance must be between zero and one".into(), + ); + } + for (index, item) in pool.items.iter().enumerate() { + let ptr = format!("{ptr}/items/{index}"); + if !item_id(&item.item) || custom_items.contains(&item.item) { + push( + format!("{ptr}/item"), + format!("`{}` is not a vanilla item id", item.item), + ); + } + if !(1..=i32::MAX as u32).contains(&item.weight) + || !(1..=99).contains(&item.count) + { + push( + ptr, + "loot weight must be a positive scoreboard integer and count 1..=99" + .into(), + ); + } + } + } + } + for (index, bar) in module.boss_bars.iter().enumerate() { + let ptr = format!("/boss_bars/{index}"); + if !resource_ids.insert(format!("bossbar {}", bar.id)) { + push( + format!("{ptr}/id"), + format!("duplicate boss bar `{}`", bar.id), + ); + } + if bar.max == 0 || bar.max > i32::MAX as u32 { + push(format!("{ptr}/max"), "boss bar max must be positive".into()); + } + if let Some(error) = static_text_error(&bar.title, None) { + push(format!("{ptr}/title"), error); + } + } + for (index, tag) in module.resource_tags.iter().enumerate() { + let ptr = format!("/resource_tags/{index}"); + if !resource_ids.insert(format!("tag {:?} {}", tag.kind, tag.id)) { + push(format!("{ptr}/id"), format!("duplicate tag `{}`", tag.id)); + } + for (i, value) in tag.values.iter().enumerate() { + let registry = match tag.kind { + TagKind::Item => "minecraft:item", + TagKind::Block => "minecraft:block", + TagKind::EntityType => "minecraft:entity_type", + }; + if !ingredient(value) + || custom_items.contains(value.as_str()) + || (!value.starts_with('#') && !available(value, registry)) + { + push( + format!("{ptr}/values/{i}"), + format!("`{value}` is not a vanilla id or `#tag`"), + ); + } + } + } + } + if errors.is_empty() { + let value = serde_json::to_value(program).expect("owned program serializes"); + let mut pending = vec![(&value, 0usize)]; + while let Some((value, depth)) = pending.pop() { + if depth > limits::JSON_DEPTH { + errors.push(Diagnostic::error( + "SAND_PROGRAM_LIMIT", + "", + "", + "constructed program exceeds JSON nesting limit", + )); + break; + } + match value { + serde_json::Value::Array(values) => { + pending.extend(values.iter().map(|value| (value, depth + 1))) + } + serde_json::Value::Object(values) => { + pending.extend(values.values().map(|value| (value, depth + 1))) + } + _ => {} + } + } + match serde_json::to_vec(&value) { + Ok(bytes) if bytes.len() <= limits::INPUT_BYTES => {} + _ => errors.push(Diagnostic::error( + "SAND_PROGRAM_LIMIT", + "", + "", + "constructed program exceeds 8 MiB", + )), + } + } + if errors.is_empty() { + Ok(target.expect("validated target")) + } else { + Err(errors) + } +} + +fn safe_path(value: &str) -> bool { + super::decode::safe_module_path(value) +} +fn valid_id(id: &ResourceLocation) -> bool { + safe_path(id.namespace()) && safe_path(id.path()) && id.namespace() != "__sand_local" +} + +fn text_shape_error( + text: &[TextPart], + depth: usize, + interactive: bool, + book_pages: Option, +) -> Option { + for part in text { + if depth >= TextPart::MAX_NESTING_DEPTH + && matches!( + part, + TextPart::Translation { .. } | TextPart::Interactive { .. } + ) + { + return Some("text exceeds the component nesting limit".into()); + } + match part { + TextPart::Translation { key, arguments, .. } => { + if key.trim().is_empty() || key.chars().any(char::is_control) { + return Some( + "translation keys must be nonblank and contain no control characters" + .into(), + ); + } + if let Some(error) = arguments + .iter() + .find_map(|parts| text_shape_error(parts, depth + 1, interactive, book_pages)) + { + return Some(error); + } + } + TextPart::Interactive { + content, + tooltip, + click, + } => { + if !interactive { + return Some( + "interactive text is supported in chat messages and written-book pages" + .into(), + ); + } + if content.is_empty() || (click.is_none() && tooltip.is_empty()) { + return Some( + "interactive text needs text and a tooltip or click action".into(), + ); + } + if let Some(click) = click { + match click { + ClickEvent::RunCommand(_) => { + return Some( + "portable text can suggest a command without running it".into(), + ); + } + ClickEvent::ChangePage(page) + if book_pages.is_none_or(|count| (*page as usize) > count) => + { + return Some( + "page navigation needs a valid page in the same written book" + .into(), + ); + } + _ => {} + } + if let Err(error) = click.validate() { + return Some(error.to_string()); + } + } + if let Some(error) = text_shape_error(content, depth + 1, interactive, book_pages) + .or_else(|| text_shape_error(tooltip, depth + 1, interactive, book_pages)) + { + return Some(error); + } + } + _ => {} + } + } + None +} + +fn static_text_error(text: &[TextPart], book_pages: Option) -> Option { + text_shape_error(text, 0, book_pages.is_some(), book_pages).or_else(|| { + text.iter() + .any(|part| !part.is_static()) + .then(|| "static text cannot use stored values, scores or player names".into()) + }) +} + +struct Validator<'a, 'e> { + dialogs_supported: bool, + advancements: BTreeMap>, + transfers: BTreeSet, + huds: BTreeSet, + menus: BTreeSet, + target: &'a str, + boss_bars: BTreeSet, + loot_tables: BTreeSet, + custom_items: BTreeSet, + states: BTreeMap)>, + data_fields: BTreeMap>, + functions: BTreeMap, + identity_unsafe: BTreeSet, + operations: usize, + flow_bytes: usize, + raw: bool, + errors: &'e mut Vec, +} +impl Validator<'_, '_> { + fn message_parts( + &mut self, + text: &[TextPart], + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + for (index, part) in text.iter().enumerate() { + let part_ptr = format!("{ptr}/{index}"); + match part { + TextPart::Stored { value, .. } => self.data_reference( + &DataReference { + field: value.clone(), + path: Vec::new(), + }, + context, + owner, + &format!("{part_ptr}/value"), + false, + ), + TextPart::Score { score, .. } => { + self.score(score, context, owner, &format!("{part_ptr}/score")); + } + TextPart::PlayerName { .. } => { + self.player(context, owner, &part_ptr, "the executing player's name") + } + TextPart::Translation { arguments, .. } => { + for (index, parts) in arguments.iter().enumerate() { + self.message_parts( + parts, + context, + owner, + &format!("{part_ptr}/arguments/{index}"), + ); + } + } + TextPart::Interactive { + content, tooltip, .. + } => { + self.message_parts(content, context, owner, &format!("{part_ptr}/content")); + self.message_parts(tooltip, context, owner, &format!("{part_ptr}/tooltip")); + } + TextPart::Text { .. } => {} + } + } + } + + // Count copied hook invocations before the shared compiler materializes + // transition bodies. Input declaration limits alone cannot bound this + // transition × hook expansion. This is a lower bound on emitted bytes; + // the normal output limits still check every complete generated resource. + fn reserve_flow_expansion(&mut self, flow: &Flow, owner: &str, ptr: &str) -> bool { + let mut enter = BTreeMap::::new(); + let mut exit = BTreeMap::::new(); + let mut calls = 0usize; + let mut bytes = 0usize; + for hook in &flow.hooks { + let id = match &hook.function { + FunctionReference::Internal { id } | FunctionReference::External { id, .. } => id, + }; + let size = id.to_string().len().saturating_add("function ".len() + 1); + let counters = match hook.phase { + FlowHookPhase::Enter => enter.entry(hook.state).or_default(), + FlowHookPhase::Exit => exit.entry(hook.state).or_default(), + FlowHookPhase::Tick => { + calls = calls.saturating_add(1); + bytes = bytes.saturating_add(size); + continue; + } + }; + counters.0 = counters.0.saturating_add(1); + counters.1 = counters.1.saturating_add(size); + } + let mut oversized = false; + for transition in &flow.transitions { + let before = exit.get(&transition.from).copied().unwrap_or_default(); + let after = enter.get(&transition.to).copied().unwrap_or_default(); + calls = calls.saturating_add(before.0).saturating_add(after.0); + let body_bytes = before.1.saturating_add(after.1); + oversized |= body_bytes > limits::DOCUMENT_BYTES; + bytes = bytes.saturating_add(body_bytes); + } + self.operations = self.operations.saturating_add(calls); + self.flow_bytes = self.flow_bytes.saturating_add(bytes); + if oversized + || self.operations > limits::OPERATIONS + || self.flow_bytes > limits::OUTPUT_BYTES + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_LIMIT", + owner, + ptr, + "expanded flow hooks exceed operation or generated-output limits", + )); + false + } else { + true + } + } + + fn comparison( + &mut self, + condition: &ScoreComparison, + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + self.score(&condition.score, context, owner, &format!("{ptr}/score")); + if condition + .min + .zip(condition.max) + .is_some_and(|(min, max)| min > max) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + ptr, + "comparison minimum exceeds maximum", + )); + } + } + + fn player(&mut self, context: ExecutionContext, owner: &str, ptr: &str, what: &str) { + if context != ExecutionContext::Player { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_CONTEXT", + owner, + ptr, + format!("{what} requires player execution context"), + )); + } + } + + fn condition( + &mut self, + condition: &Condition, + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + match condition { + Condition::Range(range) => self.comparison(range, context, owner, ptr), + Condition::Relation(relation) => { + self.score(&relation.left, context, owner, &format!("{ptr}/left")); + self.score(&relation.right, context, owner, &format!("{ptr}/right")); + } + Condition::Attached(test) => { + self.attachable_state(&test.attached, context, owner, &format!("{ptr}/attached")) + } + Condition::Exists(test) => self.query(&test.exists, owner, &format!("{ptr}/exists")), + Condition::Block(test) => { + self.block_selector(&test.block, owner, &format!("{ptr}/block")); + } + Condition::Biome(test) => { + self.resource(&test.biome, owner, &format!("{ptr}/biome"), "biome"); + } + Condition::Dimension(test) => self.resource( + &test.dimension.to_string(), + owner, + &format!("{ptr}/dimension"), + "dimension", + ), + Condition::Holding(test) => { + self.executor(context, owner, ptr, "testing a held item"); + if let Some(slot) = test.slot { + self.equipment_slot(slot, owner, &format!("{ptr}/slot")); + if test.offhand { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_OPTION", + owner, + ptr, + "choose either slot or offhand", + )); + } + } + if !self.custom_items.contains(&test.holding) { + self.resource(&test.holding, owner, &format!("{ptr}/holding"), "item"); + } + } + Condition::Advancement { + advancement, + criterion, + } => { + self.player(context, owner, ptr, "advancement progress"); + let id = advancement.to_string(); + self.resource(&id, owner, &format!("{ptr}/advancement"), "advancement"); + if let Some(criterion) = criterion { + let error = + if criterion.trim().is_empty() || criterion.chars().any(char::is_control) { + Some( + "criterion names must be nonblank and contain no control characters" + .into(), + ) + } else if self + .advancements + .get(&id) + .is_some_and(|names| !names.contains(criterion)) + { + Some(format!("advancement `{id}` has no criterion `{criterion}`")) + } else { + None + }; + if let Some(error) = error { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + owner, + &format!("{ptr}/criterion"), + error, + )); + } + } + } + Condition::Predicate { predicate } => { + self.resource( + &predicate.to_string(), + owner, + &format!("{ptr}/predicate"), + "predicate", + ); + } + Condition::Flag(_) => self.executor(context, owner, ptr, "testing an entity flag"), + } + } + + fn equipment_slot(&mut self, slot: sand_components::EquipmentSlot, owner: &str, ptr: &str) { + if let Err(error) = crate::item::location::equipment_item_slot(slot) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_OPTION", + owner, + ptr, + error.to_string(), + )); + } + } + + /// An entity State reference, used where `@s` must be some entity. + fn attachable_state( + &mut self, + state: &ResourceLocation, + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + if !self.is_attachable_state(state) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + ptr, + format!("`{state}` is not a declared entity State"), + )); + } + self.executor(context, owner, ptr, "an entity State"); + } + + fn is_attachable_state(&self, state: &ResourceLocation) -> bool { + self.states + .get(&state.to_string()) + .is_some_and(|(scope, _)| *scope == "entity") + } + + fn frame_fields( + &mut self, + fields: &[FieldReference], + context: ExecutionContext, + owner: &str, + ptr: &str, + global: bool, + ) { + let mut seen = std::collections::BTreeSet::new(); + for (index, field) in fields.iter().enumerate() { + let field_ptr = format!("{ptr}/{index}"); + if global + && self + .states + .get(&field.state.to_string()) + .is_some_and(|(scope, _)| *scope != "global") + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + owner, + &field_ptr, + "a wait retains global invocation slots; player and entity State stay live", + )); + } + if self + .data_fields + .get(&field.state.to_string()) + .is_some_and(|fields| fields.contains(field.field.as_str())) + { + self.data_reference( + &DataReference { + field: field.clone(), + path: Vec::new(), + }, + context, + owner, + &field_ptr, + false, + ); + } else { + self.score(field, context, owner, &field_ptr); + } + if !seen.insert((field.state.to_string(), field.field.clone())) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + owner, + &field_ptr, + "a call frame names each field once", + )); + } + } + } + + fn executor(&mut self, context: ExecutionContext, owner: &str, ptr: &str, what: &str) { + if context == ExecutionContext::Server { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_CONTEXT", + owner, + ptr, + format!("{what} requires a player or entity executor"), + )); + } + } + + fn boss_bar(&mut self, bar: &ResourceLocation, owner: &str, ptr: &str) { + if !self.boss_bars.contains(&bar.to_string()) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + ptr, + format!("`{bar}` is not a declared boss bar"), + )); + } + } + + fn tag_name(&mut self, tag: &str, owner: &str, ptr: &str) { + if tag.is_empty() + || !tag + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b"_.+-".contains(&b)) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_ID", + owner, + ptr, + format!("`{tag}` is not a valid entity tag (letters, digits, `_ . + -`)"), + )); + } + } + + fn query(&mut self, query: &EntityQuery, owner: &str, ptr: &str) { + if let Some(state) = &query.with_state + && !self.is_attachable_state(state) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + &format!("{ptr}/with_state"), + format!("`{state}` is not a declared entity State"), + )); + } + if let Some(entity_type) = &query.entity_type { + self.resource( + entity_type, + owner, + &format!("{ptr}/entity_type"), + "entity type", + ); + } + if let Some(tag) = &query.tag { + self.tag_name(tag, owner, &format!("{ptr}/tag")); + } + if let Some(filter) = &query.score { + let field = &filter.score; + if !self + .states + .get(&field.state.to_string()) + .is_some_and(|(scope, fields)| { + matches!(*scope, "player" | "entity") && fields.contains(field.field.as_str()) + }) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + &format!("{ptr}/score/score"), + "a query score filter requires a declared player or entity scoreboard field", + )); + } + if (filter.min.is_none() && filter.max.is_none()) + || filter + .min + .zip(filter.max) + .is_some_and(|(min, max)| min > max) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/score"), + "query score bounds must be ordered with at least one bound", + )); + } + } + if let Some(nbt) = &query.nbt { + use sand_commands::Validate; + let profile = sand_commands::CommandProfile::unprofiled(); + let selector = sand_commands::Selector::all_entities().nbt_raw(nbt.to_string()); + if let Err(error) = nbt + .validate(&profile) + .and_then(|()| selector.validate(&profile)) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_VALUE", + owner, + &format!("{ptr}/nbt"), + error.to_string(), + )); + } + } + let distance = |d: Option| d.is_none_or(|d| d.is_finite() && d >= 0.0); + if !distance(query.min_distance) + || !distance(query.max_distance) + || query + .min_distance + .zip(query.max_distance) + .is_some_and(|(min, max)| min > max) + || query.limit == Some(0) + || query.limit.is_some_and(|l| l > i32::MAX as u32) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + ptr, + "entity query distances must be non-negative and ordered, and limits positive", + )); + } + } + + fn amount( + &mut self, + amount: &Amount, + context: ExecutionContext, + owner: &str, + ptr: &str, + bounds: Option<(f64, f64)>, + ) -> bool { + let valid = match amount { + Amount::Value(value) => { + value.is_finite() && bounds.is_none_or(|(min, max)| *value >= min && *value <= max) + } + Amount::Field(field) => { + self.score(&field.score, context, owner, ptr); + field.scale.is_finite() && field.scale > 0.0 && (1.0 / field.scale).is_finite() + } + }; + if !valid { + self.errors.push(Diagnostic::error("SAND_PROGRAM_RANGE", owner, ptr, "numeric argument must be finite, within its command bounds, and use a positive finite scale")); + } + valid + } + + fn resource(&mut self, id: &str, owner: &str, ptr: &str, kind: &str) { + let registry = match kind { + "item" => Some("minecraft:item"), + "block" => Some("minecraft:block"), + "biome" => Some("minecraft:worldgen/biome"), + "damage type" => Some("minecraft:damage_type"), + "entity type" => Some("minecraft:entity_type"), + "sound" => Some("minecraft:sound_event"), + "particle" => Some("minecraft:particle_type"), + "attribute" => Some("minecraft:attribute"), + "effect" => Some("minecraft:mob_effect"), + "potion" => Some("minecraft:potion"), + _ => None, + }; + if id.starts_with("minecraft:") + && !(kind == "item" && self.custom_items.contains(id)) + && let Some(registry) = registry + && let Some(false) = sand_version::registry::contains(self.target, registry, id) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_TARGET", + owner, + ptr, + format!("Minecraft {} has no {kind} `{id}`", self.target), + )); + } + + if id.parse::().is_err() || !id.contains(':') { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_ID", + owner, + ptr, + format!("`{id}` is not a namespaced {kind} identity such as `minecraft:example`"), + )); + } + } + + fn block_selector(&mut self, selector: &str, owner: &str, ptr: &str) { + if let Some(tag) = selector.strip_prefix('#') { + self.resource(tag, owner, ptr, "block tag"); + } else { + self.resource(selector, owner, ptr, "block"); + } + } + + fn field_context( + &mut self, + score: &FieldReference, + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + if context == ExecutionContext::Server + && self + .states + .get(&score.state.to_string()) + .is_some_and(|(scope, _)| *scope == "entity") + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_CONTEXT", + owner, + ptr, + "entity State requires a player or entity executor", + )); + } + if context != ExecutionContext::Player + && self + .states + .get(&score.state.to_string()) + .is_some_and(|(scope, _)| *scope == "player") + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_CONTEXT", + owner, + ptr, + "player-self State requires player execution context", + )); + } + } + + fn score(&mut self, score: &FieldReference, context: ExecutionContext, owner: &str, ptr: &str) { + self.field_context(score, context, owner, ptr); + if !self + .states + .get(&score.state.to_string()) + .is_some_and(|(_, fields)| fields.contains(score.field.as_str())) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + ptr, + "unresolved State field", + )); + } + } + fn data_reference( + &mut self, + reference: &DataReference, + context: ExecutionContext, + owner: &str, + ptr: &str, + each: bool, + ) { + self.field_context(&reference.field, context, owner, ptr); + if !self + .data_fields + .get(&reference.field.state.to_string()) + .is_some_and(|fields| fields.contains(reference.field.field.as_str())) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + ptr, + "unresolved State storage field", + )); + } + if reference.path.len() > 32 { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_LIMIT", + owner, + ptr, + "storage projections support at most 32 steps", + )); + return; + } + for (index, projection) in reference.path.iter().enumerate() { + let location = format!("{ptr}/path/{index}"); + match projection { + DataProjection::Member { name } => { + if name.is_empty() + || !name.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'_') + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + &location, + "storage members require nonempty simple names", + )); + } + } + DataProjection::Index { + index: ScoreOperand::Field(score), + } => self.score(score, context, owner, &location), + DataProjection::Index { + index: ScoreOperand::Value(value), + } if *value < 0 => { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &location, + "storage indices must be nonnegative", + )); + } + DataProjection::Each if !each || index + 1 != reference.path.len() => { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + &location, + "all-elements selection is only valid at the end of a modification source", + )); + } + _ => {} + } + } + } + + fn data_operand( + &mut self, + value: &DataOperand, + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + match value { + DataOperand::Value { value } => self.data_literal(value, owner, ptr), + DataOperand::Reference { value } => { + self.data_reference(value, context, owner, ptr, true) + } + DataOperand::Score { + value: ScoreOperand::Field(score), + } => self.score(score, context, owner, ptr), + DataOperand::Score { .. } | DataOperand::Block { .. } => {} + } + } + + fn data_literal(&mut self, value: &sand_commands::NbtValue, owner: &str, ptr: &str) { + let profile = sand_commands::CommandProfile::new(self.target, false); + let command = sand_commands::DataTarget::storage("sand:validate") + .path("value") + .set(value.clone()); + if serde_json::to_value(value).is_err() { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + owner, + ptr, + "portable data requires typed NBT; raw SNBT is unsupported", + )); + } else if let Err(error) = command.try_render(&profile) { + self.errors + .push(Diagnostic::error("SAND_PROGRAM_STATE", owner, ptr, error)); + } + } + + fn call( + &mut self, + reference: &FunctionReference, + context: ExecutionContext, + owner: &str, + ptr: &str, + ) { + let (id, requirement) = match reference { + FunctionReference::Internal { id } => { + (id, self.functions.get(&id.to_string()).copied()) + } + FunctionReference::External { id, context } => { + if self.functions.contains_key(&id.to_string()) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + ptr, + "external function reference resolves to a declared internal function", + )); + } + (id, Some(*context)) + } + }; + if !valid_id(id) || id.path().starts_with("__sand_") { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + ptr, + "invalid or compiler-private function reference", + )); + } + match requirement { + None => self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", owner, ptr, format!("unresolved internal function {id}"), @@ -523,6 +2122,14 @@ impl Validator<'_, '_> { "callee requires a player executor", )) } + Some(ExecutionContext::Entity) if context == ExecutionContext::Server => { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_CONTEXT", + owner, + ptr, + "callee requires an entity executor", + )) + } _ => {} } } @@ -556,64 +2163,807 @@ impl Validator<'_, '_> { if depth > limits::JSON_DEPTH { origin_valid = false; self.errors.push(Diagnostic::error( - "SAND_PROGRAM_LIMIT", + "SAND_PROGRAM_LIMIT", + owner, + &ptr, + "origin nesting limit exceeded", + )); + break; + } + match value { + serde_json::Value::Array(values) => { + pending.extend(values.iter().map(|value| (value, depth + 1))) + } + serde_json::Value::Object(values) => { + pending.extend(values.values().map(|value| (value, depth + 1))) + } + _ => {} + } + } + } + match &operation.action { + Action::DataModify { target, source, .. } => { + self.data_reference( + target, + context, + owner, + &format!("{ptr}/action/target"), + false, + ); + self.data_operand(source, context, owner, &format!("{ptr}/action/source")); + } + Action::DataRemove { target } => self.data_reference( + target, + context, + owner, + &format!("{ptr}/action/target"), + false, + ), + Action::DataRead { score, source } => { + self.score(score, context, owner, &format!("{ptr}/action/score")); + self.data_reference( + source, + context, + owner, + &format!("{ptr}/action/source"), + false, + ); + } + Action::DataEqual { score, left, right } => { + self.score(score, context, owner, &format!("{ptr}/action/score")); + self.data_reference(left, context, owner, &format!("{ptr}/action/left"), false); + self.data_reference( + right, + context, + owner, + &format!("{ptr}/action/right"), + false, + ); + } + Action::ScoreSet { score, .. } | Action::ScoreAdd { score, .. } => { + self.score(score, context, owner, &format!("{ptr}/action/score")) + } + Action::Call { function } => { + self.call(function, context, owner, &format!("{ptr}/action/function")) + } + Action::Players { body } => self.body( + body, + ExecutionContext::Player, + owner, + &format!("{ptr}/action/body"), + depth + 1, + ), + Action::Branch { + condition, + then, + otherwise, + } => { + let condition_ptr = format!("{ptr}/action/condition"); + self.condition(condition, context, owner, &condition_ptr); + self.body( + then, + context, + owner, + &format!("{ptr}/action/then"), + depth + 1, + ); + self.body( + otherwise, + context, + owner, + &format!("{ptr}/action/otherwise"), + depth + 1, + ); + } + Action::ScoreOperation { + score, + operator, + operand, + } => { + self.score(score, context, owner, &format!("{ptr}/action/score")); + match operand { + ScoreOperand::Field(field) => { + self.score(field, context, owner, &format!("{ptr}/action/operand")) + } + ScoreOperand::Value(0) + if matches!(operator, ScoreOperator::Div | ScoreOperator::Mod) => + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/operand"), + "division or modulo by the constant zero has no effect", + )); + } + ScoreOperand::Value(_) => {} + } + } + Action::ScoreRandom { score, min, max } => { + self.score(score, context, owner, &format!("{ptr}/action/score")); + if min > max { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action"), + "random minimum exceeds maximum", + )); + } + } + Action::Message { + audience, + channel, + text, + } => { + if *audience == Audience::Player { + self.player(context, owner, &ptr, "a message to the executing player"); + } + if text.is_empty() { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_TEXT", + owner, + &format!("{ptr}/action/text"), + "message text must contain at least one part", + )); + } + let text_ptr = format!("{ptr}/action/text"); + if let Some(error) = + text_shape_error(text, 0, *channel == MessageChannel::Chat, None) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_TEXT", + owner, + &text_ptr, + error, + )); + } else { + self.message_parts(text, context, owner, &text_ptr); + } + } + Action::Dialog { dialog } => { + self.player(context, owner, &ptr, "showing or clearing a dialog"); + if !self.dialogs_supported { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_TARGET", owner, &ptr, - "origin nesting limit exceeded", + format!("Minecraft {} does not support native dialogs", self.target), )); - break; } - match value { - serde_json::Value::Array(values) => { - pending.extend(values.iter().map(|value| (value, depth + 1))) + if let Some(dialog) = dialog { + self.resource( + &dialog.to_string(), + owner, + &format!("{ptr}/action/dialog"), + "dialog", + ); + } + } + Action::Sound { + sound, + volume, + pitch, + } => { + self.player(context, owner, &ptr, "a sound for the executing player"); + self.resource(sound, owner, &format!("{ptr}/action/sound"), "sound"); + self.amount( + volume, + context, + owner, + &format!("{ptr}/action/volume"), + Some((0.0, f32::MAX as f64)), + ); + self.amount( + pitch, + context, + owner, + &format!("{ptr}/action/pitch"), + Some((0.0, 2.0)), + ); + } + Action::Particle { + particle, + count, + spread, + speed, + } => { + self.resource( + particle, + owner, + &format!("{ptr}/action/particle"), + "particle", + ); + for (name, value) in [("spread", spread), ("speed", speed)] { + self.amount( + value, + context, + owner, + &format!("{ptr}/action/{name}"), + Some((0.0, 1000.0)), + ); + } + let count_path = format!("{ptr}/action/count"); + match count { + ScoreOperand::Value(value) if !(0..=100_000).contains(value) => { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &count_path, + "particle count must be from 0 to 100000", + )); } - serde_json::Value::Object(values) => { - pending.extend(values.values().map(|value| (value, depth + 1))) + ScoreOperand::Field(score) => { + self.score(score, context, owner, &count_path) } _ => {} } } - } - match &operation.action { - Action::ScoreSet { score, .. } | Action::ScoreAdd { score, .. } => { - self.score(score, context, owner, &format!("{ptr}/action/score")) + Action::Effect { + effect, seconds, .. + } => { + self.player( + context, + owner, + &ptr, + "a status effect on the executing player", + ); + self.resource(effect, owner, &format!("{ptr}/action/effect"), "effect"); + if seconds.is_some_and(|s| s == 0 || s > 1_000_000) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/seconds"), + "effect duration must be 1..=1000000 seconds; omit it for infinite", + )); + } } - Action::Call { function } => { - self.call(function, context, owner, &format!("{ptr}/action/function")) + Action::ClearEffect { effect } => { + self.player( + context, + owner, + &ptr, + "clearing the executing player's effects", + ); + if let Some(effect) = effect { + self.resource(effect, owner, &format!("{ptr}/action/effect"), "effect"); + } } - Action::Players { body } => self.body( + Action::GiveItem { item, count } => { + self.player(context, owner, &ptr, "giving items to the executing player"); + self.resource(item, owner, &format!("{ptr}/action/item"), "item"); + if let ScoreOperand::Field(score) = count { + self.score(score, context, owner, &format!("{ptr}/action/count")); + } + if matches!(count, ScoreOperand::Value(count) if *count < 1 || *count > 6400) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/count"), + "item count must be 1..=6400", + )); + } + } + Action::SetEquipment { slot, item, count } => { + self.executor(context, owner, &ptr, "changing equipment"); + self.equipment_slot(*slot, owner, &format!("{ptr}/action/slot")); + if let Some(item) = item + && !self.custom_items.contains(item) + { + self.resource(item, owner, &format!("{ptr}/action/item"), "item"); + } + if count.is_some_and(|count| !(1..=99).contains(&count)) + || (item.is_none() && count.is_some()) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/count"), + "equipment stack count requires an item and must be 1..=99", + )); + } + } + Action::ClearItem { item, count } => { + self.player( + context, + owner, + &ptr, + "clearing the executing player's items", + ); + if let Some(item) = item { + self.resource(item, owner, &format!("{ptr}/action/item"), "item"); + } + let pointer = format!("{ptr}/action/count"); + if count.is_some() && item.is_none() { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + owner, + &pointer, + "an item-removal count requires an item", + )); + } + match count { + Some(ScoreOperand::Field(score)) => { + self.score(score, context, owner, &pointer); + } + Some(ScoreOperand::Value(count)) if *count < 0 => { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &pointer, + "item-removal count must be nonnegative", + )); + } + _ => {} + } + } + Action::Menu { menu, .. } => { + self.player( + context, + owner, + &ptr, + "opening or closing the executing player's menu", + ); + if !self.menus.contains(&menu.to_string()) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + owner, + &format!("{ptr}/action/menu"), + format!("unknown menu `{menu}`"), + )); + } + } + Action::Hud { hud, .. } => { + self.player(context, owner, &ptr, "showing the executing player's HUD"); + if !self.huds.contains(&hud.to_string()) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + owner, + &format!("{ptr}/action/hud"), + format!("unknown HUD `{hud}`"), + )); + } + } + Action::TransferInventory { transfer } => { + self.player(context, owner, &ptr, "moving the executing player's items"); + if !self.transfers.contains(&transfer.to_string()) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RESOURCE", + owner, + &format!("{ptr}/action/transfer"), + format!("unknown inventory transfer `{transfer}`"), + )); + } + } + Action::CountItems { item, score } => { + self.player( + context, + owner, + &ptr, + "counting the executing player's items", + ); + self.resource(item, owner, &format!("{ptr}/action/item"), "item"); + self.score(score, context, owner, &format!("{ptr}/action/score")); + } + Action::Schedule { function, ticks } => { + // Scheduled functions run later on the server, without an executor. + self.call( + function, + ExecutionContext::Server, + owner, + &format!("{ptr}/action/function"), + ); + if *ticks == 0 { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/ticks"), + "schedule delay must be at least one tick", + )); + } + } + Action::Return => {} + Action::Suspend { + ticks, + fields, body, - ExecutionContext::Player, - owner, - &format!("{ptr}/action/body"), - depth + 1, - ), - Action::Branch { - condition, - then, - otherwise, } => { - self.comparison( - condition, + self.executor(context, owner, &ptr, "suspending a function"); + match ticks { + ScoreOperand::Field(score) => { + self.score(score, context, owner, &format!("{ptr}/action/ticks")) + } + ScoreOperand::Value(ticks) if *ticks < 1 => { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/ticks"), + "wait delay must be a positive scoreboard integer", + )); + } + ScoreOperand::Value(_) => {} + } + if fields.len() > 64 { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_LIMIT", + owner, + &format!("{ptr}/action/fields"), + "at most 64 local slots can be retained by a wait", + )); + } + self.frame_fields( + fields, context, owner, - &format!("{ptr}/action/condition"), + &format!("{ptr}/action/fields"), + true, ); self.body( - then, + body, context, owner, - &format!("{ptr}/action/then"), + &format!("{ptr}/action/body"), depth + 1, ); + } + Action::CancelWaits => self.executor(context, owner, &ptr, "cancelling a wait"), + Action::While { condition, body } => { + let condition_ptr = format!("{ptr}/action/condition"); + self.condition(condition, context, owner, &condition_ptr); self.body( - otherwise, + body, context, owner, - &format!("{ptr}/action/otherwise"), + &format!("{ptr}/action/body"), + depth + 1, + ); + } + Action::AttributeGet { + score, + attribute, + scale, + } => { + self.executor(context, owner, &ptr, "reading the executor's attribute"); + self.score(score, context, owner, &format!("{ptr}/action/score")); + self.resource( + attribute, + owner, + &format!("{ptr}/action/attribute"), + "attribute", + ); + if !(scale.is_finite() && *scale > 0.0) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/scale"), + "attribute scale must be finite and positive", + )); + } + } + Action::AttributeSet { attribute, value } => { + self.executor(context, owner, &ptr, "setting the executor's attribute"); + self.resource( + attribute, + owner, + &format!("{ptr}/action/attribute"), + "attribute", + ); + let valid = match value { + Amount::Value(value) => value.is_finite(), + Amount::Field(field) => { + self.score( + &field.score, + context, + owner, + &format!("{ptr}/action/value/score"), + ); + field.scale.is_finite() && field.scale > 0.0 + } + }; + if !valid { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/value"), + "attribute values must be finite and scales positive", + )); + } + } + Action::Entities { query, body } => { + self.query(query, owner, &format!("{ptr}/action/query")); + self.body( + body, + ExecutionContext::Entity, + owner, + &format!("{ptr}/action/body"), + depth + 1, + ); + } + Action::CaptureEntity { score, relation } => { + if *relation == Some(crate::entity::Relation::Passengers) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_TARGET", + owner, + &format!("{ptr}/action/relation"), + "retaining an entity requires a single-entity relationship", + )); + } + if self + .identity_unsafe + .contains(&format!("{}.{}", score.state, score.field)) + { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + owner, + &format!("{ptr}/action/score"), + "entity identities require an unbounded, non-timer field", + )); + } + self.executor(context, owner, &ptr, "capturing an entity identity"); + self.score(score, context, owner, &format!("{ptr}/action/score")); + } + Action::WithEntity { + reference, + players, + body, + } => { + self.score( + reference, + context, + owner, + &format!("{ptr}/action/reference"), + ); + self.body( + body, + if *players { + ExecutionContext::Player + } else { + ExecutionContext::Entity + }, + owner, + &format!("{ptr}/action/body"), + depth + 1, + ); + } + Action::Kill => self.executor(context, owner, &ptr, "killing the executor"), + Action::Ride { vehicle } => { + self.executor(context, owner, &ptr, "changing the executor's vehicle"); + if let Some(vehicle) = vehicle { + self.score(vehicle, context, owner, &format!("{ptr}/action/vehicle")); + } + } + Action::PushFrame { fields } | Action::PopFrame { fields } => { + if fields.is_empty() { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_STATE", + owner, + &format!("{ptr}/action/fields"), + "a call frame saves at least one field", + )); + } + self.frame_fields( + fields, + context, + owner, + &format!("{ptr}/action/fields"), + false, + ); + } + Action::DataGet { + score, + value, + scale, + } => { + if value.player_only() { + self.player(context, owner, &ptr, "reading player data"); + } else { + self.executor(context, owner, &ptr, "reading entity data"); + } + self.score(score, context, owner, &format!("{ptr}/action/score")); + if !(scale.is_finite() && *scale > 0.0) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/scale"), + "data scale must be finite and positive", + )); + } + } + Action::Damage { + amount, + by, + damage_type, + } => { + if let Some(damage_type) = damage_type { + self.resource( + &damage_type.to_string(), + owner, + &format!("{ptr}/action/damage_type"), + "damage type", + ); + } + if let Some(by) = by { + self.score(by, context, owner, &format!("{ptr}/action/by")); + } + self.executor(context, owner, &ptr, "damaging the executor"); + self.amount( + amount, + context, + owner, + &format!("{ptr}/action/amount"), + Some((0.01, 1_000_000.0)), + ); + } + Action::EntityTag { tag, .. } => { + self.executor(context, owner, &ptr, "tagging the executor"); + self.tag_name(tag, owner, &format!("{ptr}/action/tag")); + } + Action::Summon { entity_type, tag } => { + self.resource( + entity_type, + owner, + &format!("{ptr}/action/entity_type"), + "entity type", + ); + if let Some(tag) = tag { + self.tag_name(tag, owner, &format!("{ptr}/action/tag")); + } + } + Action::CountEntities { score, query } => { + self.score(score, context, owner, &format!("{ptr}/action/score")); + self.query(query, owner, &format!("{ptr}/action/query")); + } + Action::SetVelocity { x, y, z } => { + self.executor(context, owner, &ptr, "setting entity velocity"); + for (axis, value) in [("x", x), ("y", y), ("z", z)] { + self.amount( + value, + context, + owner, + &format!("{ptr}/action/{axis}"), + Some((-10.0, 10.0)), + ); + } + } + Action::Teleport { destination } => { + self.executor(context, owner, &ptr, "teleporting the executor"); + let finite = match destination { + TeleportDestination::Position { x, y, z } + | TeleportDestination::Offset { x, y, z } => { + let x = self.amount( + x, + context, + owner, + &format!("{ptr}/action/destination/x"), + None, + ); + let y = self.amount( + y, + context, + owner, + &format!("{ptr}/action/destination/y"), + None, + ); + let z = self.amount( + z, + context, + owner, + &format!("{ptr}/action/destination/z"), + None, + ); + x && y && z + } + TeleportDestination::Entity { query } => { + self.query(query, owner, &format!("{ptr}/action/destination/query")); + true + } + }; + if !finite { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/destination"), + "teleport coordinates must be finite", + )); + } + } + Action::AttachState { state } | Action::DetachState { state } => { + self.attachable_state(state, context, owner, &format!("{ptr}/action/state")) + } + Action::SetBlock { block, .. } | Action::FillBlocks { block, .. } => { + self.resource(block, owner, &format!("{ptr}/action/block"), "block"); + } + Action::CloneBlocks { masked, filter, .. } => { + if let Some(filter) = filter { + self.block_selector(filter, owner, &format!("{ptr}/action/filter")); + if *masked { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_TARGET", + owner, + &ptr, + "choose either a clone filter or a masked clone", + )); + } + } + } + Action::PlaceTemplate { template, .. } => { + self.resource( + &template.to_string(), + owner, + &format!("{ptr}/action/template"), + "structure template", + ); + } + Action::InDimension { dimension, body } => { + self.resource( + &dimension.to_string(), + owner, + &format!("{ptr}/action/dimension"), + "dimension", + ); + self.body( + body, + context, + owner, + &format!("{ptr}/action/body"), depth + 1, ); } + Action::ReadEntityData { score, .. } => { + self.executor(context, owner, &ptr, "reading entity data"); + self.score(score, context, owner, &format!("{ptr}/action/score")); + } + Action::ReadBlockData { score, .. } => { + self.score(score, context, owner, &format!("{ptr}/action/score")); + } + Action::WriteBlockData { value, .. } => { + if let Some(value) = value { + self.data_operand(value, context, owner, &format!("{ptr}/action/value")); + } + } + Action::AddExperience { amount, .. } => { + self.player(context, owner, &ptr, "giving experience"); + if let ScoreOperand::Field(score) = amount { + self.score(score, context, owner, &format!("{ptr}/action/amount")); + } + } + Action::SetGameMode { .. } => { + self.player(context, owner, &ptr, "changing game mode"); + } + Action::SetTime { .. } => {} + Action::SetWeather { seconds, .. } => { + if *seconds == Some(0) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_RANGE", + owner, + &format!("{ptr}/action/seconds"), + "weather duration must be positive", + )); + } + } + Action::BossBarAudience { bar, audience, .. } => { + self.boss_bar(bar, owner, &format!("{ptr}/action/bar")); + if *audience == Audience::Player { + self.player(context, owner, &ptr, "showing a boss bar to one player"); + } + } + Action::SetBossBar { bar, value, .. } => { + self.boss_bar(bar, owner, &format!("{ptr}/action/bar")); + if let ScoreOperand::Field(field) = value { + self.score(field, context, owner, &format!("{ptr}/action/value")); + } + } + Action::GiveLoot { table } | Action::DropLoot { table } => { + if !self.loot_tables.contains(&table.to_string()) { + self.errors.push(Diagnostic::error( + "SAND_PROGRAM_REFERENCE", + owner, + &format!("{ptr}/action/table"), + format!("`{table}` is not a declared loot table"), + )); + } + if matches!(operation.action, Action::GiveLoot { .. }) { + self.player(context, owner, &ptr, "giving loot"); + } + } Action::Raw { command } => { if !self.raw { self.errors.push(Diagnostic::error( diff --git a/sand-core/src/entity/keyed_migration.rs b/sand-core/src/entity/keyed_migration.rs index 4d173959..a19d99b2 100644 --- a/sand-core/src/entity/keyed_migration.rs +++ b/sand-core/src/entity/keyed_migration.rs @@ -207,7 +207,7 @@ pub(crate) fn lifecycle(storage: &str) -> (String, String, String) { /// Gate the complete component transition, including its presence publication. pub(crate) fn guard( - fields: &[super::state::StateDataFieldDescriptor], + fields: &[super::state::StateDataFieldDescriptor<'_>], commands: Vec, ) -> Vec { let storages = fields diff --git a/sand-core/src/entity/relation.rs b/sand-core/src/entity/relation.rs index bbe4fc1b..5ee53260 100644 --- a/sand-core/src/entity/relation.rs +++ b/sand-core/src/entity/relation.rs @@ -24,7 +24,11 @@ use sand_commands::Selector; variants(Attacker = "The entity that last damaged this entity.", Controller = "The entity steering this entity's vehicle (e.g. a boat's rower).", Leasher = "The entity leashing this entity.", Origin = "The entity that fired/summoned this entity (e.g. a projectile's shooter).", Owner = "The entity that owns this entity (e.g. a tamed wolf's owner).", Passengers = "The entities riding this entity. Many-cardinality.", Target = "This entity's current attack/follow target (mobs only).", Vehicle = "The vehicle this entity is riding."), )] /// A vanilla entity relationship reachable via `execute on `. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive( + Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema, +)] +#[serde(rename_all = "snake_case")] +#[schemars(rename = "EntityRelation")] pub enum Relation { /// The entity that owns this entity (e.g. a tamed wolf's owner). Owner, diff --git a/sand-core/src/entity/state.rs b/sand-core/src/entity/state.rs index ea9004fe..18110862 100644 --- a/sand-core/src/entity/state.rs +++ b/sand-core/src/entity/state.rs @@ -345,7 +345,7 @@ pub trait EntityState: 'static { returns = "The `& 'static [StateDataFieldDescriptor]` value produced to storage-backed fields owned by this component.", example = "use sand::prelude::*;\n\nfn demonstrate() {\n let data_fields = ::data_fields();\n}", )] - fn data_fields() -> &'static [StateDataFieldDescriptor] { + fn data_fields() -> &'static [StateDataFieldDescriptor<'static>] { &[] } } @@ -353,20 +353,16 @@ pub trait EntityState: 'static { /// Compiler metadata for one component-owned typed storage path. #[doc(hidden)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct StateDataFieldDescriptor { - pub storage: &'static str, - pub path: &'static str, - pub default_snbt: &'static str, +pub struct StateDataFieldDescriptor<'a> { + pub storage: &'a str, + pub path: &'a str, + pub default_snbt: &'a str, pub keyed: bool, } -impl StateDataFieldDescriptor { +impl<'a> StateDataFieldDescriptor<'a> { #[doc(hidden)] - pub const fn new( - storage: &'static str, - path: &'static str, - default_snbt: &'static str, - ) -> Self { + pub const fn new(storage: &'a str, path: &'a str, default_snbt: &'a str) -> Self { Self { storage, path, @@ -376,11 +372,7 @@ impl StateDataFieldDescriptor { } #[doc(hidden)] - pub const fn keyed( - storage: &'static str, - path: &'static str, - default_snbt: &'static str, - ) -> Self { + pub const fn keyed(storage: &'a str, path: &'a str, default_snbt: &'a str) -> Self { Self { storage, path, @@ -2723,7 +2715,7 @@ impl KeyedData { } } -pub(crate) fn state_data_initialize_commands(field: StateDataFieldDescriptor) -> Vec { +pub(crate) fn state_data_initialize_commands(field: StateDataFieldDescriptor<'_>) -> Vec { if !field.keyed { return vec![format!( "execute unless data storage {} {} run data modify storage {} {} set value {}", @@ -2755,7 +2747,7 @@ pub(crate) fn state_data_initialize_commands(field: StateDataFieldDescriptor) -> ) } -fn state_data_remove_commands(field: StateDataFieldDescriptor) -> Vec { +pub(crate) fn state_data_remove_commands(field: StateDataFieldDescriptor<'_>) -> Vec { if field.keyed { let commands = keyed_data_call( field.storage, @@ -2777,6 +2769,42 @@ fn state_data_remove_commands(field: StateDataFieldDescriptor) -> Vec { } } +/// Copy through the canonical owner resolver. Only compiler-owned paths enter +/// the macro template; arbitrary stored values are never substituted as text. +pub(crate) fn state_data_copy_commands( + field: StateDataFieldDescriptor<'_>, + scratch_storage: &str, + scratch_path: &str, + write: bool, +) -> Vec { + let path = if field.keyed { + keyed_path(field.path) + } else { + field.path.to_owned() + }; + let command = if write { + format!( + "data modify storage {} {path} set from storage {scratch_storage} {scratch_path}", + field.storage + ) + } else { + format!( + "data modify storage {scratch_storage} {scratch_path} set from storage {} {path}", + field.storage + ) + }; + if field.keyed { + let command = if write { + format!("{}\n${command}", keyed_create_owner(field.storage)) + } else { + format!("${command}") + }; + keyed_data_call(field.storage, command) + } else { + vec![command] + } +} + fn keyed_uuid() -> &'static str { "$(uuid)" } diff --git a/sand-core/src/gameplay/identity.rs b/sand-core/src/gameplay/identity.rs index 0ea65a98..e954b72e 100644 --- a/sand-core/src/gameplay/identity.rs +++ b/sand-core/src/gameplay/identity.rs @@ -6,6 +6,7 @@ use crate::{ }; use sand_commands::{CommandResult, ObjectiveName}; use sand_components::ResourceLocation; +use std::fmt; /// The compilation's pack namespace, independent of a definition's resource /// namespace. Shared admission/transaction state must cover imported definitions @@ -35,16 +36,38 @@ pub(crate) fn task_tag(scope: &ResourceLocation) -> CommandResult { } /// Retained compiler-only context traversal from an owned runtime instance. -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct OwnedContext { pub(crate) scope: ResourceLocation, pub(crate) kind: &'static str, pub(crate) field: &'static str, + pub(crate) position_at_target: bool, pub(crate) body: Actions, pub(crate) child: Option, pub(crate) damage: Option<(sand_commands::DamageAmount, sand_commands::DamageKind)>, } +impl fmt::Debug for OwnedContext { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut context = formatter.debug_struct("OwnedContext"); + context + .field("scope", &self.scope) + .field("kind", &self.kind) + .field("field", &self.field); + // Generated helper identities hash this representation. Preserve the + // established key for owner-position actions and encode the alternate + // positioning mode explicitly. + if !self.position_at_target { + context.field("position_at_target", &self.position_at_target); + } + context + .field("body", &self.body) + .field("child", &self.child) + .field("damage", &self.damage) + .finish() + } +} + impl OwnedContext { pub(crate) fn lower(&self, _owner: &ResourceLocation) -> CommandResult> { let objective = objective(&self.scope)?; @@ -75,6 +98,11 @@ impl OwnedContext { "sand/runtime/owned_body", self.body.clone(), ); + let position = if self.position_at_target { + " at @s" + } else { + "" + }; selectors( self.kind, &objective.to_string(), @@ -82,7 +110,9 @@ impl OwnedContext { ) .into_iter() .map(|selector| { - format!("$execute as {selector} at @s run return run function __sand_local:{body}") + format!( + "$execute as {selector}{position} run return run function __sand_local:{body}" + ) }) .collect::>() }; @@ -110,12 +140,16 @@ pub(crate) fn selectors(kind: &str, objective: &str, value: &str) -> Vec "player" => vec![format!("@a[{score}]")], "entity" => vec![ format!("@a[{score}]"), - format!("@e[type=!minecraft:player,distance=0..,{score}]"), + non_player_selector(objective, value), ], kind => vec![format!("@e[type=minecraft:{kind},distance=0..,{score}]")], } } +pub(crate) fn non_player_selector(objective: &str, value: &str) -> String { + format!("@e[type=!minecraft:player,distance=0..,scores={{{objective}={value}}},limit=1]") +} + pub(crate) fn call(scope: &ResourceLocation, suffix: &str) -> Actions { Cmd::Function(resource(scope, suffix).to_string()).into_commands() } diff --git a/sand-core/src/gameplay/inventory_transfer.rs b/sand-core/src/gameplay/inventory_transfer.rs index d0af449a..36f2ad31 100644 --- a/sand-core/src/gameplay/inventory_transfer.rs +++ b/sand-core/src/gameplay/inventory_transfer.rs @@ -82,7 +82,11 @@ impl InventoryTransfer { /// Attempt the registered move for the executing player. #[sand_macros::api(registry = sand_api_contract, path = "sand::systems::InventoryTransfer::transfer", module = "sand::systems", summary = "Attempt the registered quantity-aware player move.", context = "Use from player-context functions, menus, or interaction callbacks.", minecraft = "Admission precedes checked destination mutation and source clearing.", use_when = ["Invoking a registered move"], avoid_when = ["Running outside player context"], returns = "Retained gameplay actions.", example = "use sand::systems::InventoryTransfer;")] pub fn transfer(&self) -> Actions { - identity::call(&self.id, "inventory_transfer_move") + Self::invoke(&self.id) + } + + pub(crate) fn invoke(id: &ResourceLocation) -> Actions { + identity::call(id, "inventory_transfer_move") } } impl IntoDatapack for InventoryTransfer { diff --git a/sand-core/src/gameplay/lifetime.rs b/sand-core/src/gameplay/lifetime.rs index 3555d55a..0ee21919 100644 --- a/sand-core/src/gameplay/lifetime.rs +++ b/sand-core/src/gameplay/lifetime.rs @@ -7,7 +7,7 @@ use crate::{ ir::{Actions, Cmd}, registration::{DatapackRegistration, IntoDatapack, LifecycleContribution}, }; -use sand_commands::{Anchor, CommandError, CommandResult, ObjectiveName}; +use sand_commands::{Anchor, CommandError, CommandResult, ObjectiveName, ScoreHolder}; use sand_components::{ ComponentContent, DatapackComponent, DimensionId, ResourceLocation, effect::Ticks, }; @@ -56,11 +56,20 @@ impl TaskContext { example = "use sand::prelude::*;\nuse sand::systems::{TaskContext, Lifetime};\n\nfn demonstrate(value: TaskContext) {\n let _result = value.owner(|_| cmd::say(\"Owner callback\"));\n}", )] pub fn owner(&self, body: impl FnOnce(EntityContext) -> R) -> Actions { + self.owner_actions(body(EntityContext::default()).into_commands(), true) + } + + pub(crate) fn owner_at_instance(&self, body: impl IntoCommands) -> Actions { + self.owner_actions(body.into_commands(), false) + } + + fn owner_actions(&self, body: Actions, position_at_target: bool) -> Actions { Cmd::OwnedContext(Box::new(identity::OwnedContext { scope: self.scope.clone(), kind: K::LABEL, field: "owner", - body: body(EntityContext::default()).into_commands(), + position_at_target, + body, child: None, damage: None, })) @@ -87,6 +96,7 @@ example = "use sand::systems::{TaskContext, Scene}; fn demo(ctx: TaskContext, sc scope: self.scope.clone(), kind: K::LABEL, field: "owner", + position_at_target: true, body: Actions::default(), child: Some(child.as_ref().id.clone()), damage: None, @@ -207,9 +217,11 @@ pub struct Lifetime { required: Vec, pub(super) diagnostics: Vec<(crate::condition::Condition, String)>, duration: Ticks, + duration_score: Option<(ScoreHolder, ObjectiveName)>, interval: Ticks, capacity: u32, origin: Anchor, + invocation_position: bool, dimensions: Vec, pub(super) step: Option<&'static str>, pub(super) start: Option>, @@ -249,9 +261,11 @@ impl Lifetime { required: vec![], diagnostics: vec![], duration, + duration_score: None, interval: Ticks::new(1), capacity: 128, origin: Anchor::Feet, + invocation_position: false, dimensions: ["overworld", "the_nether", "the_end"] .into_iter() .map(|name| DimensionId::minecraft(name).expect("vanilla dimension")) @@ -264,6 +278,17 @@ impl Lifetime { detach: vec![], } } + /// Read the lifetime and first callback interval from the executor's + /// score at admission. The resulting timer belongs to the spawned instance. + pub(crate) fn with_duration_score( + mut self, + holder: ScoreHolder, + objective: ObjectiveName, + ) -> Self { + self.duration_score = Some((holder, objective)); + self + } + /// Require a canonical State query to match the owner. Scoped State, bundles /// and composed `StateQuery` declarations share their normal membership rules. /// A missing required component, obsolete schema version or present forbidden @@ -339,6 +364,23 @@ impl Lifetime { self.origin = origin; self } + + pub(crate) fn include_dimensions( + mut self, + dimensions: impl IntoIterator, + ) -> Self { + for dimension in dimensions { + if !self.dimensions.contains(&dimension) { + self.dimensions.push(dimension); + } + } + self + } + + pub(crate) fn at_invocation_position(mut self) -> Self { + self.invocation_position = true; + self + } /// Replace the dimensions scanned for this definition. No chunks are loaded. #[sand_macros::api( registry = sand_api_contract, @@ -608,6 +650,7 @@ impl RuntimeFunction { let tag = identity::task_tag(&d.id)?; let resource = |part| identity::resource(&id, part).to_string(); let storage = format!("{}:__sand_runtime", id.namespace()); + let spawn_origin = if d.invocation_position { "" } else { " at @s" }; let task_ledger = resource("task_ledger"); let context = || TaskContext { scope: d.id.clone(), @@ -710,6 +753,20 @@ impl RuntimeFunction { .collect::>(); dimensions.sort(); dimensions.dedup(); + let (initial_delay, initial_phase, duration_prefix) = if d.duration_score.is_some() { + ("$(duration)".to_owned(), "$(duration)".to_owned(), "$") + } else { + ( + d.duration.get().to_string(), + d.interval.get().to_string(), + "", + ) + }; + let child_duration = if d.duration_score.is_some() { + ",duration:$(duration)" + } else { + "" + }; let mut lines:Vec = match self.part { "load"=> vec![ format!("data remove storage {task_ledger} active"), @@ -739,7 +796,7 @@ impl RuntimeFunction { format!("scoreboard players add #next {owner} 1"), format!("execute store result storage {storage} spawn.instance int 1 run scoreboard players get #next {owner}"), format!("execute store result storage {storage} spawn.epoch int 1 run scoreboard players get #epoch {epoch}"), - format!("execute at @s rotated as @s anchored {} positioned ^ ^ ^ summon minecraft:marker run function {} with storage {storage} spawn", d.origin,resource("init")), + format!("execute{spawn_origin} rotated as @s anchored {} positioned ^ ^ ^ summon minecraft:marker run function {} with storage {storage} spawn", d.origin,resource("init")), format!("data remove storage {storage} spawn")] }, "init"=>{ @@ -748,7 +805,13 @@ impl RuntimeFunction { format!("data modify entity @s data.stop set value \"{}\"", resource("stop")), format!("execute unless data storage {task_ledger} active run data modify storage {task_ledger} active set value []"), format!("$data modify storage {task_ledger} active append value {{instance:$(instance),owner:$(owner),generation:$(generation),children:0}}"), - format!("tag @s add {tag}"),"$data merge entity @s {data:{owner:$(owner),instance:$(instance),epoch:$(epoch),generation:$(generation)}}".into(),format!("$scoreboard players set @s {owner} $(instance)"),format!("$scoreboard players set @s {epoch} $(epoch)"),format!("scoreboard players set @s {remaining} {}",d.duration.get()),format!("scoreboard players set @s {phase} {}",d.interval.get()),format!("scoreboard players set @s {active} 1"),format!("scoreboard players add #live {active} 1"),"tp @s ~ ~ ~ ~ ~".into()]; + format!("tag @s add {tag}"),"$data merge entity @s {data:{owner:$(owner),instance:$(instance),epoch:$(epoch),generation:$(generation)}}".into(),format!("$scoreboard players set @s {owner} $(instance)"),format!("$scoreboard players set @s {epoch} $(epoch)"),format!("{duration_prefix}scoreboard players set @s {remaining} {initial_delay}"),format!("{duration_prefix}scoreboard players set @s {phase} {initial_phase}"),format!("scoreboard players set @s {active} 1"),format!("scoreboard players add #live {active} 1"),"tp @s ~ ~ ~ ~ ~".into()]; + if d.invocation_position { + // A continuation started from a tick callback must first + // spend a tick on the following game tick, even when its + // own lifetime scans later in the same lifecycle pass. + lines.push(format!("execute store result score @s {visited} run time query gametime")); + } lines.push(format!("function {}",resource("commit"))); for attach in &d.attach { lines.extend(attach("@s")); } lines.push(format!("execute unless entity @s[type=minecraft:marker,tag={tag}] run return 0")); @@ -803,7 +866,7 @@ impl RuntimeFunction { "init_child"=> vec![ "$data modify entity @s data.ancestors set value $(ancestors)".into(), format!("function {} with entity @s data.ancestors[-1]",resource("child_added")), - format!("$function {} {{owner:$(owner),instance:$(instance),epoch:$(epoch),generation:$(generation)}}", resource("init")), + format!("$function {} {{owner:$(owner),instance:$(instance),epoch:$(epoch),generation:$(generation){child_duration}}}", resource("init")), ], "retire"=>vec![ format!("execute if data entity @s data.ancestors[-1] run function {} with entity @s data.ancestors[-1]",resource("child_removed")), @@ -835,6 +898,19 @@ impl RuntimeFunction { "status_admit"|"status_refresh"|"status_remove"=>vec![], _=>unreachable!() }; + if matches!(self.part, "admit" | "admit_child") + && let Some((holder, objective)) = &d.duration_score + { + lines.insert( + 0, + format!("execute unless score {holder} {objective} matches 1.. run return 0"), + ); + let index = lines + .iter() + .position(|line| line.contains("summon minecraft:marker")) + .expect("admission summons an instance"); + lines.insert(index, format!("execute store result storage {storage} spawn.duration int 1 run scoreboard players get {holder} {objective}")); + } if self.part == "admit_child" { let index = lines .iter() diff --git a/sand-core/src/gameplay/menu.rs b/sand-core/src/gameplay/menu.rs index 163c0d68..b9a01c57 100644 --- a/sand-core/src/gameplay/menu.rs +++ b/sand-core/src/gameplay/menu.rs @@ -105,12 +105,12 @@ example = "use sand::systems::Menu;")] /// title and appends choices; gameplay state belongs in ordinary State. #[sand_macros::api(registry = sand_api_contract, path = "sand::systems::Menu::view", module = "sand::systems", summary = "Author a typed conversation view within one menu session.", context = "Subsequent choices belong to this enum encoding. Views share session ownership and exact object binding; gameplay progression remains canonical State.", minecraft = "Exports paginated native dialogs with bounded per-player routing and fresh action tokens.", use_when = ["Branching conversations and confirmations"], avoid_when = ["Persisting gameplay progress in menu navigation"], params(view = "Canonical State enum key for this view.", title = "Title shown on this view's pages."), returns = "The configured menu.", example = "use sand::systems::Menu;")] - pub fn view( - mut self, - view: T, - title: TextComponent, - ) -> Self { - self.authoring_view = view.encode(); + pub fn view(self, view: T, title: TextComponent) -> Self { + self.encoded_view(view.encode(), title) + } + + pub(crate) fn encoded_view(mut self, view: i32, title: TextComponent) -> Self { + self.authoring_view = view; if self.authoring_view == 0 { self.title = title; } else { @@ -123,8 +123,12 @@ summary = "Author a typed conversation view within one menu session.", context = /// resumes an old ephemeral conversation session. #[sand_macros::api(registry = sand_api_contract, path = "sand::systems::Menu::start_at", module = "sand::systems", summary = "Choose the entry view of a conversation.", context = "The selected view must have choices. Every new opening starts there; persistent progression is authored through State guards and callbacks.", minecraft = "Initializes the private page routing score before session admission.", use_when = ["Choosing a typed entry point"], avoid_when = ["Resuming an expired native dialog"], params(view = "Canonical State enum key of the entry view."), returns = "The configured menu.", example = "use sand::systems::Menu;")] - pub fn start_at(mut self, view: T) -> Self { - self.entry_view = view.encode(); + pub fn start_at(self, view: T) -> Self { + self.encoded_start(view.encode()) + } + + pub(crate) fn encoded_start(mut self, view: i32) -> Self { + self.entry_view = view; self } @@ -141,12 +145,22 @@ summary = "Transition between conversation views after a guarded callback.", con allowed: Condition, destination: T, action: impl Fn() -> R + 'static, + ) -> Self { + self.encoded_choice(label, allowed, Some(destination.encode()), action) + } + + pub(crate) fn encoded_choice( + self, + label: TextComponent, + allowed: Condition, + destination: Option, + action: impl Fn() -> R + 'static, ) -> Self { let mut menu = self.choice(label, allowed, action); menu.choices .last_mut() .expect("appended choice") - .destination = Some(destination.encode()); + .destination = destination; menu } diff --git a/sand-core/src/gameplay/projectile.rs b/sand-core/src/gameplay/projectile.rs index ba158b8f..26ba62f9 100644 --- a/sand-core/src/gameplay/projectile.rs +++ b/sand-core/src/gameplay/projectile.rs @@ -221,6 +221,7 @@ impl TaskContext { scope: self.scope.clone(), kind: K::LABEL, field: "target", + position_at_target: true, body: Actions::default(), child: None, damage: Some((amount.into(), kind)), @@ -251,6 +252,7 @@ impl TaskContext { scope: self.scope.clone(), kind: "entity", field: "target", + position_at_target: true, body: body(EntityContext::default()).into_commands(), child: None, damage: None, diff --git a/sand-core/src/item/location.rs b/sand-core/src/item/location.rs index d04cfee9..48f16244 100644 --- a/sand-core/src/item/location.rs +++ b/sand-core/src/item/location.rs @@ -40,9 +40,17 @@ type LocationKind = &'static str; /// A validated player inventory slot index (`0..=35`, matching vanilla's /// `Inventory` list: `0..=8` hotbar, `9..=35` main inventory). #[sand_macros::api(registry = sand_api_contract, path = "sand::inventory::InventoryIndex", aliases = ["sand::item::InventoryIndex", "sand::item::location::InventoryIndex", "sand::prelude::InventoryIndex"], summary = "Validates a slot in a player's complete 36-slot inventory.", context = "This distinct type prevents a general player-inventory index from being confused with a hotbar-only or block-container index.", minecraft = "Maps to the Inventory[{Slot:N}] entity NBT entry used by vanilla inventory commands.", use_when = ["Addressing any numbered player inventory slot from 0 through 35"], avoid_when = ["Addressing only the hotbar or a block container"], example = "let slot = InventoryIndex::new(9)?;")] -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, serde::Serialize)] +#[serde(transparent)] pub struct InventoryIndex(u8); +impl<'de> serde::Deserialize<'de> for InventoryIndex { + fn deserialize>(decoder: D) -> Result { + let index = ::deserialize(decoder)?; + Self::new(index).map_err(serde::de::Error::custom) + } +} + impl InventoryIndex { #[sand_macros::api(kind = "associated_const", registry = sand_api_contract, path = "sand::inventory::InventoryIndex::MAX", summary = "The highest valid player inventory index.", context = "It exposes the vanilla 36-slot range without repeating a magic number.", minecraft = "Matches the final Inventory list slot, index 35.", use_when = ["Validating generated UI or iteration bounds"], avoid_when = ["Representing a hotbar-only bound"], example = "assert_eq!(InventoryIndex::MAX, 35);")] pub const MAX: u8 = 35; @@ -881,7 +889,7 @@ impl EntityInventorySlot { } } -fn equipment_item_slot(slot: EquipmentSlot) -> Result { +pub(crate) fn equipment_item_slot(slot: EquipmentSlot) -> Result { match slot { EquipmentSlot::Head => Ok(ItemSlot::Head), EquipmentSlot::Chest => Ok(ItemSlot::Chest), diff --git a/sand-core/src/lib.rs b/sand-core/src/lib.rs index b60338e3..a615b17b 100644 --- a/sand-core/src/lib.rs +++ b/sand-core/src/lib.rs @@ -619,6 +619,21 @@ impl sand_commands::resource::RegistryReference + for generated::ParticleType +{ +} +impl sand_commands::resource::RegistryReference + for generated::ParticleType +{ + fn registry_id( + &self, + ) -> sand_commands::resource::RegistryId { + sand_commands::resource::RegistryId::new(self.resource_location()) + .expect("generated vanilla particle IDs are valid resource locations") + } +} + /// Compiler and facade wiring that is deliberately outside Sand's supported /// author-facing API surface. #[doc(hidden)] diff --git a/sand-core/src/state/owned.rs b/sand-core/src/state/owned.rs index 70d092e8..d73a4251 100644 --- a/sand-core/src/state/owned.rs +++ b/sand-core/src/state/owned.rs @@ -1,4 +1,4 @@ -//! Owned adaptation of the supported player/global score State slice. +//! Owned adaptation of portable State through canonical lifecycle lowering. //! //! Strings are borrowed only while canonical lifecycle generation runs. No //! descriptor is interned, leaked or registered in link-time inventory. @@ -8,6 +8,7 @@ use std::collections::BTreeMap; use super::GlobalStateHolder; use super::registry::{AutomaticLifecycle, automatic_lifecycle_with_hooks}; use super::registry::{StateDescriptor, StateLifecycleDescriptor, StateScope}; +use crate::entity::state::StateDataFieldDescriptor; use crate::entity::{StateFieldDescriptor, StateFieldKind}; use crate::compiler::program::model::{ScoreField, State}; @@ -18,6 +19,7 @@ impl TryFrom> for State { fn try_from(descriptor: StateDescriptor<'_>) -> Result { let scope = match descriptor.scope { StateScope::Player => "player", + StateScope::Entity => "entity", StateScope::Global(holder) if holder == GlobalStateHolder::new(descriptor.id).as_str() => { @@ -35,7 +37,7 @@ impl TryFrom> for State { || !descriptor.migrations.is_empty() { return Err(format!( - "State `{}` is outside the player/global score v1 slice", + "State `{}` is outside the player/entity/global score v1 slice", descriptor.id )); } @@ -43,11 +45,10 @@ impl TryFrom> for State { if field.field.kind != StateFieldKind::Score || field.criterion != "dummy" || field.display_name.is_some() - || field.auto_tick || field.objective != format!("{}.{}", descriptor.id, field.field.name) { return Err(format!( - "State field `{}.{}` is outside the player/global score v1 slice", + "State field `{}.{}` is outside the player/entity/global score v1 slice", descriptor.id, field.field.name )); } @@ -61,6 +62,7 @@ impl TryFrom> for State { )); } Ok(Self { + data_fields: Vec::new(), id: descriptor .id .parse() @@ -74,6 +76,7 @@ impl TryFrom> for State { name: field.field.name.to_owned(), default: field.field.default, bounds: field.field.bounds, + timer: field.auto_tick, }) .collect(), }) @@ -83,7 +86,7 @@ impl TryFrom> for State { /// Resolve the scoreboard owner from the same identity used by lifecycle lowering. pub(crate) fn holder(state: &State) -> sand_commands::ScoreHolder { match state.scope.as_str() { - "player" => sand_commands::ScoreHolder::self_(), + "player" | "entity" => sand_commands::ScoreHolder::self_(), "global" => { sand_commands::ScoreHolder::fake(GlobalStateHolder::new(&state.id.to_string()).as_str()) } @@ -91,6 +94,40 @@ pub(crate) fn holder(state: &State) -> sand_commands::ScoreHolder { } } +/// Borrow one portable field through the same canonical storage identity used +/// by derived Rust State components. +pub(crate) fn with_data_field( + state: &State, + name: &str, + lower: impl FnOnce(StateDataFieldDescriptor<'_>) -> R, +) -> R { + let field = state + .data_fields + .iter() + .find(|field| field.name == name) + .expect("validated storage field"); + let (storage, path, default) = data_identity(state, field); + lower(if state.scope == "global" { + StateDataFieldDescriptor::new(&storage, &path, &default) + } else { + StateDataFieldDescriptor::keyed(&storage, &path, &default) + }) +} + +fn data_identity( + state: &State, + field: &crate::compiler::program::model::DataField, +) -> (String, String, String) { + let id = state.id.to_string(); + let (namespace, component) = id.split_once(':').expect("validated State identity"); + let component = serde_json::to_string(component).expect("component key serializes"); + ( + format!("{namespace}:state"), + format!("components.{component}.{}", field.name), + field.default.to_string(), + ) +} + /// Lower explicit owned inputs through the same lifecycle implementation used /// by Rust descriptors, without collecting or executing Rust hooks. pub(crate) fn lifecycle(states: &[State]) -> Result { @@ -130,7 +167,7 @@ pub(crate) fn with_descriptors( .iter() .zip(objectives) .map(|(field, objective)| { - StateLifecycleDescriptor::new( + let descriptor = StateLifecycleDescriptor::new( objective, StateFieldDescriptor::new( &field.name, @@ -138,29 +175,66 @@ pub(crate) fn with_descriptors( field.default, field.bounds, ), - ) + ); + if field.timer { + descriptor.auto_tick() + } else { + descriptor + } }) .collect() }) .collect(); - let descriptors = states.iter().zip(&identities).zip(&fields).map( - |((state, (id, holder, presence, suppression, _)), fields)| { - StateDescriptor::new( - id, - 1, - match state.scope.as_str() { - "player" => StateScope::Player, - "global" => StateScope::Global(holder.as_str()), - _ => unreachable!("owned State scopes are validated before lowering"), - }, - presence, - suppression, - fields, - &[], - &[], - ) - }, - ); + let data_storage: Vec<_> = states + .iter() + .map(|state| { + state + .data_fields + .iter() + .map(|field| data_identity(state, field)) + .collect::>() + }) + .collect(); + let data_fields: Vec> = states + .iter() + .zip(&data_storage) + .map(|(state, fields)| { + fields + .iter() + .map(|(storage, path, default)| { + if state.scope == "global" { + StateDataFieldDescriptor::new(storage, path, default) + } else { + StateDataFieldDescriptor::keyed(storage, path, default) + } + }) + .collect() + }) + .collect(); + let descriptors = states + .iter() + .zip(&identities) + .zip(&fields) + .zip(&data_fields) + .map( + |(((state, (id, holder, presence, suppression, _)), fields), data_fields)| { + StateDescriptor::new( + id, + 1, + match state.scope.as_str() { + "player" => StateScope::Player, + "entity" => StateScope::Entity, + "global" => StateScope::Global(holder.as_str()), + _ => unreachable!("owned State scopes are validated before lowering"), + }, + presence, + suppression, + fields, + &[], + data_fields, + ) + }, + ); lower(descriptors.collect()) } @@ -168,6 +242,48 @@ pub(crate) fn with_descriptors( mod tests { use super::*; + #[test] + fn owned_data_defaults_share_canonical_storage_lifecycle_without_static_allocations() { + for scope in ["player", "entity", "global"] { + let state = State { + id: "demo:notes".parse().unwrap(), + scope: scope.into(), + revision: 1, + fields: Vec::new(), + data_fields: vec![crate::compiler::program::model::DataField { + name: "text".into(), + default: sand_commands::NbtValue::String("$(uuid)".into()), + }], + }; + let storage = String::from("demo:state"); + let path = String::from("components.\"notes\".text"); + let default = String::from("\"$(uuid)\""); + let field = if scope == "global" { + StateDataFieldDescriptor::new(&storage, &path, &default) + } else { + StateDataFieldDescriptor::keyed(&storage, &path, &default) + }; + let holder = GlobalStateHolder::new("demo:notes"); + let fields = [field]; + let descriptor = StateDescriptor::new( + "demo:notes", + 1, + match scope { + "player" => StateScope::Player, + "entity" => StateScope::Entity, + _ => StateScope::Global(holder.as_str()), + }, + "demo:notes.presence", + "demo:notes.suppressed", + &[], + &[], + &fields, + ); + let expected = automatic_lifecycle_with_hooks([descriptor], &BTreeMap::new()).unwrap(); + assert_eq!(lifecycle(&[state]).unwrap(), expected); + } + } + #[test] fn owned_state_matches_static_lifecycle_without_static_allocations() { let holder = GlobalStateHolder::new("demo:counter"); @@ -202,6 +318,7 @@ mod tests { #[test] fn multi_field_player_helpers_are_owned_and_do_not_pollute_pending_resources() { let state = State { + data_fields: Vec::new(), id: "demo:pair".parse().unwrap(), scope: "player".into(), revision: 1, @@ -210,11 +327,13 @@ mod tests { name: "first".into(), default: -7, bounds: None, + timer: false, }, ScoreField { name: "second".into(), default: 42, bounds: None, + timer: false, }, ], }; @@ -237,6 +356,7 @@ mod tests { #[test] fn owned_counter_provisions_and_initializes_canonical_objectives() { let output = lifecycle(&[State { + data_fields: Vec::new(), id: "demo:counter".parse().unwrap(), scope: "player".into(), revision: 1, @@ -244,6 +364,7 @@ mod tests { name: "value".to_owned(), default: 0, bounds: None, + timer: false, }], }]) .unwrap(); @@ -267,6 +388,7 @@ mod tests { #[test] fn owned_and_rust_only_states_share_objective_collision_checks() { let owned = [State { + data_fields: Vec::new(), id: "demo:counter".parse().unwrap(), scope: "player".into(), revision: 1, @@ -274,6 +396,7 @@ mod tests { name: "value".to_owned(), default: 0, bounds: None, + timer: false, }], }]; const CONFLICTING_FIELDS: &[StateLifecycleDescriptor] = &[StateLifecycleDescriptor::new( diff --git a/sand-core/src/state/registry.rs b/sand-core/src/state/registry.rs index 07c7dd54..6a8876ff 100644 --- a/sand-core/src/state/registry.rs +++ b/sand-core/src/state/registry.rs @@ -92,7 +92,7 @@ pub struct StateDescriptor<'a> { /// Ordered component-version transitions. pub migrations: &'a [StateMigrationDescriptor], /// Component-owned typed storage paths. - pub data_fields: &'a [StateDataFieldDescriptor], + pub data_fields: &'a [StateDataFieldDescriptor<'a>], } /// One contiguous component presence/version transition. @@ -119,7 +119,7 @@ impl<'a> StateDescriptor<'a> { suppression_objective: &'a str, fields: &'a [StateLifecycleDescriptor<'a>], migrations: &'a [StateMigrationDescriptor], - data_fields: &'a [StateDataFieldDescriptor], + data_fields: &'a [StateDataFieldDescriptor<'a>], ) -> Self { Self { id, diff --git a/sand-core/src/state/storage.rs b/sand-core/src/state/storage.rs index 4b384c88..de777e90 100644 --- a/sand-core/src/state/storage.rs +++ b/sand-core/src/state/storage.rs @@ -1408,32 +1408,33 @@ mod tests { } #[test] - fn typed_snbt_controls_report_structured_errors() { - for value in ["line1\nline2", "col1\tcol2", "a\rb", "nul\0byte"] { + fn typed_snbt_controls_escape_values_and_reject_compound_keys() { + let profile = sand_commands::CommandProfile::unprofiled(); + for (value, escaped) in [ + ("line1\nline2", r#"line1\u000aline2"#), + ("col1\tcol2", r#"col1\u0009col2"#), + ("a\rb", r#"a\u000db"#), + ("nul\0byte", r#"nul\u0000byte"#), + ] { let command = Nbt::storage_raw("sand:data").path("value").set(value); assert_eq!( - command - .try_render(&sand_commands::CommandProfile::unprofiled()) - .unwrap_err() - .code, - "SAND-DATA-TARGET" + command.try_render(&profile).unwrap(), + format!(r#"data modify storage sand:data value set value "{escaped}""#), ); } let compound = Nbt::storage_raw("sand:data") .path("value") .set(NbtCompound::new().field("key\nwith\nnewline", 1_i32)); - assert!( - compound - .try_render(&sand_commands::CommandProfile::unprofiled()) - .is_err() + assert_eq!( + compound.try_render(&profile).unwrap_err().code, + "SAND-DATA-TARGET" ); let string = Nbt::storage_raw("sand:data") .path("player.name") .set_string("line1\nline2"); - assert!( - string - .try_render(&sand_commands::CommandProfile::unprofiled()) - .is_err() + assert_eq!( + string.try_render(&profile).unwrap(), + r#"data modify storage sand:data player.name set value "line1\u000aline2""#, ); } } diff --git a/sand-core/src/state/typed_state.rs b/sand-core/src/state/typed_state.rs index 6c2be3d4..e8555784 100644 --- a/sand-core/src/state/typed_state.rs +++ b/sand-core/src/state/typed_state.rs @@ -264,7 +264,7 @@ impl GameState { summary = "`scoreboard objectives add dummy` — register the objective.", context = "`scoreboard objectives add dummy` — register the objective. Call this in your `load` function.", minecraft = "Operations render validated scoreboard commands or conditions against the selected score holder, with lifecycle setup emitted at load when required.", - use_when = ["Call this in your `load` function."], + use_when = ["Define custom state objectives in the pack’s load function"], avoid_when = ["Manually reproducing metadata generated by #[derive(State)]"], returns = "The string value produced to emit the documented `scoreboard objectives add dummy` — register the objective form.", example = "use sand::advanced::state::*;\n\nfn demonstrate(game_state_value: &sand::advanced::state::GameState < S >) {\n let define = game_state_value.define();\n}", diff --git a/sand-core/tests/portable_data.rs b/sand-core/tests/portable_data.rs new file mode 100644 index 00000000..41c32527 --- /dev/null +++ b/sand-core/tests/portable_data.rs @@ -0,0 +1,191 @@ +use sand::advanced::compiler::{Action, Compiler, DataOperand, Program}; +use serde_json::{Value, json}; +use std::collections::BTreeMap; + +fn field(name: &str) -> Value { + json!({"state":"data:values", "field":name}) +} +fn stored(name: &str) -> Value { + json!({"field":field(name)}) +} +fn document() -> Value { + json!({ + "format":"sand.program", "format_version":1, "target":{"minecraft":"26.2"}, + "pack":{"namespace":"data", "description":"Owned storage regression"}, + "modules":[{"id":"data:module", "states":[{ + "id":"data:values", "scope":"player", "revision":1, + "fields":[{"name":"index"}, {"name":"result"}], + "data_fields":[ + {"name":"text", "default":{"type":"list","value":[]}}, + {"name":"other", "default":{"type":"list","value":[]}} + ] + }], "functions":[{"id":"data:run", "context":"player", "body":[ + {"action":{"op":"data_modify", "target":stored("text"), "operator":{"kind":"set"}, "source":{"kind":"value", "value":{"type":"list", "value":[{"type":"string", "value":"$(uuid)\n\0🌍"}]}}}}, + {"action":{"op":"push_frame", "fields":[field("text"),field("index")]}}, + {"action":{"op":"data_modify", "target":stored("other"), "operator":{"kind":"append"}, "source":{"kind":"reference", "value":{"field":field("text"), "path":[{"kind":"index", "index":field("index")}]}}}}, + {"action":{"op":"data_read", "score":field("index"), "source":{"field":field("text"), "path":[{"kind":"index", "index":field("index")}]}}}, + {"action":{"op":"data_equal", "score":field("result"), "left":stored("text"), "right":stored("other")}}, + {"action":{"op":"pop_frame", "fields":[field("text"),field("index")]}}, + {"action":{"op":"message", "audience":"player", "channel":"chat", "text":[{"kind":"stored","value":field("text")}]}}, + {"action":{"op":"data_remove", "target":{"field":field("other"), "path":[{"kind":"index", "index":0}]}}} + ]}]}] + }) +} +fn decode(document: Value) -> Program { + Compiler::decode(document.to_string().as_bytes(), &BTreeMap::new()).unwrap() +} + +#[test] +fn owned_storage_exports_safe_macros_frames_and_plain_text_deterministically() { + let program = decode(document()); + let pack = Compiler::compile(&program).unwrap(); + assert_eq!( + pack.resources, + Compiler::compile(&program).unwrap().resources + ); + let commands = pack + .resources + .iter() + .filter(|(path, _)| path.ends_with(".mcfunction")) + .flat_map(|(_, bytes)| std::str::from_utf8(bytes).unwrap().lines()) + .collect::>(); + assert!( + commands + .iter() + .any(|line| line.contains("stack[-1].f0 set from storage")) + ); + assert!( + commands + .iter() + .any(|line| line.contains("\\u000a\\u0000🌍")) + ); + assert!( + commands + .iter() + .any(|line| line.contains("\"interpret\":false") && line.contains("__program_text")) + ); + for line in commands.iter().filter(|line| line.starts_with('$')) { + assert!( + !line.contains("$(uuid)\\u000a"), + "authored text entered a macro template: {line}" + ); + } +} + +#[test] +fn translation_substitutions_use_their_enclosing_executor_and_text_style() { + let mut source = document(); + let message = &mut source["modules"][0]["functions"][0]["body"][6]["action"]; + message["text"] = json!([{ + "kind":"translation", "key":"chat.type.text", "style":{"bold":true}, + "arguments":[ + [{"kind":"player_name"}], + [{"kind":"stored", "value":field("text")}] + ] + }]); + let pack = Compiler::compile(&decode(source.clone())).unwrap(); + let function = + std::str::from_utf8(&pack.resources["data/data/function/run.mcfunction"]).unwrap(); + assert!(function.contains(r#""translate":"chat.type.text""#)); + assert!(function.contains(r#""bold":true"#)); + assert!(function.contains(r#""nbt":"p0_1_0[]""#)); + + let functions = &mut source["modules"][0]["functions"]; + functions[0] = json!({ + "id":"data:server", "context":"server", "body":[{"action":{ + "op":"message", "audience":"everyone", "channel":"chat", + "text":[{"kind":"translation", "key":"demo.text", "arguments":[[{"kind":"player_name"}]]}] + }}] + }); + let Err(errors) = Compiler::compile(&decode(source)) else { + panic!("a server message accepted a nested player name"); + }; + assert!( + errors + .iter() + .any(|error| error.pointer.contains("/arguments/0/0")) + ); +} + +#[test] +fn interactive_components_cannot_bypass_channel_or_click_validation() { + let text = json!([{ + "kind":"interactive", + "content":[{"kind":"text", "text":"A link"}], + "tooltip":[{"kind":"stored", "value":field("text")}], + "click":{"kind":"open_url", "value":"https://example.com"} + }]); + let mut source = document(); + source["modules"][0]["functions"][0]["body"][6]["action"]["text"] = text; + let pack = Compiler::compile(&decode(source.clone())).unwrap(); + let command = + std::str::from_utf8(&pack.resources["data/data/function/run.mcfunction"]).unwrap(); + assert!(command.contains(r#""action":"open_url""#)); + assert!(command.contains(r#""action":"show_text""#)); + assert!(command.contains(r#""nbt":"p0_1_0[]""#)); + + for (field, value) in [ + ("channel", json!("title")), + ("text/0/click/kind", json!("run_command")), + ("text/0/click/value", json!("file:///path")), + ] { + let mut input = source.clone(); + let message = &mut input["modules"][0]["functions"][0]["body"][6]["action"]; + *message.pointer_mut(&format!("/{field}")).unwrap() = value; + assert!( + Compiler::compile(&decode(input)).is_err(), + "accepted {field}" + ); + } +} + +#[test] +fn storage_references_preserve_context_types_and_checked_projections() { + let mut invalid = Vec::new(); + let mut server = document(); + server["modules"][0]["functions"][0]["context"] = json!("server"); + invalid.push(server); + let mut duplicate = document(); + duplicate["modules"][0]["states"][0]["data_fields"][0]["name"] = json!("index"); + invalid.push(duplicate); + let mut member = document(); + member["modules"][0]["functions"][0]["body"][0]["action"]["target"]["path"] = + json!([{"kind":"member", "name":"x run say unsafe"}]); + invalid.push(member); + let mut score = document(); + score["modules"][0]["functions"][0]["body"][3]["action"]["score"] = field("text"); + invalid.push(score); + let mut negative = document(); + negative["modules"][0]["functions"][0]["body"][0]["action"]["target"]["path"] = + json!([{"kind":"index", "index":-1}]); + invalid.push(negative); + for invalid in invalid { + assert!(Compiler::compile(&decode(invalid)).is_err()); + } + let mut raw = decode(document()); + let Action::DataModify { source, .. } = &mut raw.modules[0].functions[0].body[0].action else { + unreachable!() + }; + *source = DataOperand::Value { + value: sand::data::NbtValue::List(vec![sand::data::NbtValue::raw("[]")]), + }; + assert!(Compiler::compile(&raw).is_err()); +} + +#[test] +fn literal_storage_reads_fit_a_small_vanilla_command_budget() { + let mut source = document(); + source["modules"][0]["states"][0]["scope"] = json!("global"); + source["modules"][0]["functions"][0]["context"] = json!("server"); + source["modules"][0]["functions"][0]["body"] = json!([ + {"action":{"op":"data_read", "score":field("result"), "source":stored("text")}}, + {"action":{"op":"data_read", "score":field("result"), "source":stored("other")}}, + {"action":{"op":"data_read", "score":field("result"), "source":{"field":field("text"), "path":[{"kind":"index", "index":0}]}}} + ]); + let pack = Compiler::compile(&decode(source)).unwrap(); + let body = std::str::from_utf8(&pack.resources["data/data/function/run.mcfunction"]).unwrap(); + assert!( + body.lines().count() <= 24, + "three reads exceed their command budget:\n{body}" + ); +} diff --git a/sand-core/tests/portable_gameplay.rs b/sand-core/tests/portable_gameplay.rs new file mode 100644 index 00000000..50cf47f7 --- /dev/null +++ b/sand-core/tests/portable_gameplay.rs @@ -0,0 +1,486 @@ +//! Portable gameplay vocabulary: score operations, relations, text, sounds, +//! effects, items, schedules, and player events decoded from strict JSON. +use sand::advanced::compiler::{Compiler, Program}; +use std::collections::BTreeMap; + +fn decode(document: serde_json::Value) -> Program { + Compiler::decode(document.to_string().as_bytes(), &BTreeMap::new()) + .unwrap_or_else(|errors| panic!("decode failed: {errors:#?}")) +} + +fn program(functions: serde_json::Value, events: serde_json::Value) -> serde_json::Value { + serde_json::json!({ + "format": "sand.program", "format_version": 1, "target": {"minecraft": "26.2"}, + "pack": {"namespace": "play", "description": "Portable gameplay"}, + "modules": [{ + "id": "play:module", + "states": [ + {"id": "play:stats", "scope": "player", "revision": 1, "fields": [ + {"name": "gold", "bounds": [0, 100]}, {"name": "best"}]}, + {"id": "play:world", "scope": "global", "revision": 1, "fields": [{"name": "round"}]} + ], + "functions": functions, + "events": events + }] + }) +} + +fn field(state: &str, name: &str) -> serde_json::Value { + serde_json::json!({"state": format!("play:{state}"), "field": name}) +} + +fn function_text(pack: &sand::advanced::compiler::CompiledPack, path: &str) -> String { + String::from_utf8(pack.resources[&format!("data/play/function/{path}.mcfunction")].clone()) + .unwrap() +} + +#[test] +fn gameplay_actions_lower_to_typed_commands() { + let gold = field("stats", "gold"); + let best = field("stats", "best"); + let round = field("world", "round"); + let document = program( + serde_json::json!([ + {"id": "play:reward", "context": "player", "body": [ + {"action": {"op": "score_operation", "score": gold, "operator": "mul", "operand": 3}}, + {"action": {"op": "score_operation", "score": best, "operator": "max", "operand": gold}}, + {"action": {"op": "score_random", "score": best, "min": 1, "max": 6}}, + {"action": {"op": "branch", + "condition": {"left": gold, "relation": "gt", "right": best}, + "then": [{"action": {"op": "message", "audience": "player", "channel": "title", + "text": [{"kind": "text", "text": "Gold: ", "style": {"color": "gold", "bold": true}}, + {"kind": "score", "score": gold}, + {"kind": "player_name"}]}}]}}, + {"action": {"op": "sound", "sound": "minecraft:entity.player.levelup", "pitch": 1.5}}, + {"action": {"op": "particle", "particle": "minecraft:heart", "count": 3}}, + {"action": {"op": "effect", "effect": "minecraft:speed", "seconds": 5, "amplifier": 1}}, + {"action": {"op": "clear_effect"}}, + {"action": {"op": "give_item", "item": "minecraft:diamond", "count": 2}}, + {"action": {"op": "clear_item", "item": "minecraft:dirt"}} + ]}, + {"id": "play:tick", "context": "server", "body": [ + {"action": {"op": "message", "audience": "everyone", "channel": "chat", + "text": [{"kind": "text", "text": "Round "}, {"kind": "score", "score": round}]}}, + {"action": {"op": "schedule", "function": {"kind": "internal", "id": "play:tick"}, "ticks": 40}} + ]} + ]), + serde_json::json!([ + {"event": {"kind": "death"}, "function": {"kind": "internal", "id": "play:reward"}}, + {"event": {"kind": "use_item", "item": "minecraft:carrot_on_a_stick"}, + "function": {"kind": "internal", "id": "play:reward"}} + ]), + ); + let pack = Compiler::compile(&decode(document)).unwrap(); + let reward = function_text(&pack, "reward"); + for expected in [ + "scoreboard players operation @s ", + " *= #c3 ", + " > @s ", + "run random value 1..6", + "playsound minecraft:entity.player.levelup master @s ~ ~ ~ 1 1.5", + "particle minecraft:heart ~ ~1 ~ 0 0 0 0 3", + "effect give @s minecraft:speed 5 1", + "effect clear @s", + "give @s minecraft:diamond 2", + "clear @s minecraft:dirt", + ] { + assert!( + reward.contains(expected), + "missing {expected:?} in\n{reward}" + ); + } + // Bounded fields are clamped after operations, like additions. + assert!(reward.contains("matches 101.. run scoreboard players set @s")); + let tick = function_text(&pack, "tick"); + assert!(tick.starts_with("tellraw @a "), "{tick}"); + assert!( + tick.contains("schedule function play:tick 40t replace"), + "{tick}" + ); + let branch = pack + .resources + .iter() + .find(|(path, bytes)| { + path.ends_with("/then.mcfunction") && String::from_utf8_lossy(bytes).contains("title") + }) + .map(|(_, bytes)| String::from_utf8_lossy(bytes).into_owned()) + .expect("title branch"); + assert!( + branch.contains(r#"{"bold":true,"color":"gold","text":"Gold: "}"#), + "{branch}" + ); + + let load = function_text(&pack, "__sand_lifecycle_load"); + assert!(load.contains(" deathCount"), "{load}"); + assert!(load.contains("scoreboard players set #c3 "), "{load}"); + let tick = function_text(&pack, "__sand_lifecycle_tick"); + assert!( + tick.contains( + "run function play:__sand_program/event/use_item/minecraft/carrot_on_a_stick" + ), + "{tick}" + ); +} + +#[test] +fn gameplay_actions_validate_context_ranges_and_identities() { + let gold = field("stats", "gold"); + let document = program( + serde_json::json!([ + {"id": "play:server", "context": "server", "body": [ + {"action": {"op": "sound", "sound": "minecraft:block.bell.use"}}, + {"action": {"op": "give_item", "item": "diamond", "count": 0}}, + {"action": {"op": "score_operation", "score": gold, "operator": "div", "operand": 0}}, + {"action": {"op": "schedule", "function": {"kind": "internal", "id": "play:player"}, "ticks": 0}} + ]}, + {"id": "play:player", "context": "player", "body": []} + ]), + serde_json::json!([]), + ); + let errors = Compiler::check(&decode(document)).unwrap_err(); + let messages: Vec<_> = errors + .iter() + .map(|e| (e.pointer.as_str(), e.message.as_str())) + .collect(); + for (pointer, message) in [ + ( + "/functions/0/body/0", + "a sound for the executing player requires player execution context", + ), + ( + "/functions/0/body/1/action/item", + "`diamond` is not a namespaced item identity such as `minecraft:example`", + ), + ( + "/functions/0/body/1/action/count", + "item count must be 1..=6400", + ), + ( + "/functions/0/body/2/action/operand", + "division or modulo by the constant zero has no effect", + ), + ( + "/functions/0/body/3/action/function", + "callee requires a player executor", + ), + ( + "/functions/0/body/3/action/ticks", + "schedule delay must be at least one tick", + ), + ] { + assert!( + messages.contains(&(pointer, message)), + "missing {pointer} {message:?} in {messages:#?}" + ); + } +} + +#[test] +fn existing_range_branches_still_decode() { + let gold = field("stats", "gold"); + let document = program( + serde_json::json!([{"id": "play:f", "context": "player", "body": [ + {"action": {"op": "branch", "condition": {"score": gold, "min": 1, "max": null}, + "then": [{"action": {"op": "score_add", "score": gold, "value": 1}}]}} + ]}]), + serde_json::json!([]), + ); + Compiler::compile(&decode(document)).unwrap(); +} + +#[test] +fn return_while_and_attributes_lower_to_function_results_and_macros() { + let gold = field("stats", "gold"); + let best = field("stats", "best"); + let document = program( + serde_json::json!([{"id": "play:f", "context": "player", "body": [ + {"action": {"op": "branch", "condition": {"score": gold, "min": null, "max": 0}, + "then": [{"action": {"op": "return"}}]}}, + {"action": {"op": "while", "condition": {"score": best, "min": 1, "max": null}, + "body": [{"action": {"op": "score_add", "score": best, "value": -1}}]}}, + {"action": {"op": "attribute_get", "score": best, "attribute": "minecraft:max_health"}}, + {"action": {"op": "attribute_set", "attribute": "minecraft:max_health", "value": 24.0}}, + {"action": {"op": "attribute_set", "attribute": "minecraft:movement_speed", + "value": {"score": best, "scale": 1000.0}}} + ]}]), + serde_json::json!([]), + ); + let pack = Compiler::compile(&decode(document)).unwrap(); + let f = function_text(&pack, "f"); + let lines: Vec<_> = f.lines().collect(); + assert!( + lines[1].starts_with("execute if function play:__sand_program/") + && lines[1].ends_with(" run return 1"), + "{f}" + ); + assert!( + lines[2].contains("matches 1..2147483647 run function play:__sand_program/"), + "{f}" + ); + assert!( + f.contains("run attribute @s minecraft:max_health base get 1"), + "{f}" + ); + assert!( + f.contains("attribute @s minecraft:max_health base set 24"), + "{f}" + ); + assert!( + f.contains("store result storage play:sand.args value double 0.001"), + "{f}" + ); + let find = |suffix: &str| { + pack.resources + .iter() + .find(|(path, _)| path.ends_with(suffix)) + .map(|(_, bytes)| String::from_utf8_lossy(bytes).into_owned()) + .unwrap() + }; + let branch = find("/branch.mcfunction"); + assert_eq!( + branch + .lines() + .filter(|l| l.contains("return run function")) + .count(), + 2, + "{branch}" + ); + assert_eq!(find("/then.mcfunction"), "return 1"); + assert!(find("/loop.mcfunction").contains("run return run function")); + assert_eq!( + find("/attribute.mcfunction"), + "$attribute @s minecraft:movement_speed base set $(value)" + ); +} + +#[test] +fn custom_items_recipes_and_tags_lower_through_typed_components() { + let mut document = program( + serde_json::json!([{"id": "play:f", "context": "player", "body": [ + {"action": {"op": "give_item", "item": "play:ruby_sword", "count": 1}}, + {"action": {"op": "clear_item", "item": "play:ruby_sword"}} + ]}]), + serde_json::json!([]), + ); + let module = &mut document["modules"][0]; + module["items"] = serde_json::json!([{ + "id": "play:ruby_sword", "base": "minecraft:diamond_sword", + "name": [{"kind": "text", "text": "Ruby Sword", "style": {"color": "red"}}], + "unbreakable": true, "rarity": "epic" + }]); + module["recipes"] = serde_json::json!([ + {"kind": "shaped", "id": "play:ruby_sword", "pattern": [" R ", " R ", " S "], + "key": {"R": "minecraft:redstone_block", "S": "#minecraft:planks"}, + "result": {"item": "play:ruby_sword"}}, + {"kind": "cooking", "id": "play:leather", "method": "smelting", + "ingredient": "minecraft:rotten_flesh", "result": {"item": "minecraft:leather"}, "experience": 0.1} + ]); + module["resource_tags"] = serde_json::json!([ + {"kind": "item", "id": "play:ores", "values": ["minecraft:iron_ore", "#minecraft:coal_ores"]} + ]); + let pack = Compiler::compile(&decode(document)).unwrap(); + let f = function_text(&pack, "f"); + assert!( + f.contains("give @s minecraft:diamond_sword[") + && f.contains("custom_data={\"play:ruby_sword\":1b}"), + "{f}" + ); + assert!( + f.contains( + "clear @s minecraft:diamond_sword[minecraft:custom_data~{\"play:ruby_sword\":1b}]" + ), + "{f}" + ); + let json = |path: &str| -> serde_json::Value { + serde_json::from_slice(&pack.resources[path]).unwrap_or_else(|_| panic!("{path}")) + }; + let shaped = json("data/play/recipe/ruby_sword.json"); + assert_eq!(shaped["type"], "minecraft:crafting_shaped"); + assert_eq!(shaped["result"]["id"], "minecraft:diamond_sword"); + assert!( + shaped["result"]["components"] + .to_string() + .contains("play:ruby_sword"), + "{shaped}" + ); + assert_eq!( + json("data/play/recipe/leather.json")["type"], + "minecraft:smelting" + ); + let tag = json("data/play/tags/item/ores.json"); + assert_eq!( + tag["values"], + serde_json::json!(["minecraft:iron_ore", "#minecraft:coal_ores"]) + ); + + let mut bad = program(serde_json::json!([]), serde_json::json!([])); + bad["modules"][0]["items"] = + serde_json::json!([{"id": "play:gem", "base": "minecraft:emerald"}]); + bad["modules"][0]["recipes"] = serde_json::json!([ + {"kind": "shaped", "id": "play:x", "pattern": ["AB"], "key": {"A": "play:gem", "C": "minecraft:stick"}, + "result": {"item": "minecraft:stick"}} + ]); + let errors = Compiler::check(&decode(bad)).unwrap_err(); + let messages: Vec<_> = errors.iter().map(|e| e.message.as_str()).collect(); + for expected in [ + "pattern character `B` has no key", + "key `C` is not used in the pattern", + "custom item `play:gem` cannot be a recipe ingredient: vanilla recipes match only by item id or tag", + ] { + assert!( + messages.contains(&expected), + "missing {expected:?} in {messages:#?}" + ); + } +} + +#[test] +fn retained_entity_actions_initialize_identity_and_snapshot_resolution() { + let reference = field("world", "round"); + let doc = program( + serde_json::json!([ + {"id":"play:capture", "context":"entity", "body":[{"action":{"op":"capture_entity","score":reference}}]}, + {"id":"play:resolve", "context":"server", "body":[{"action":{"op":"with_entity","reference":reference,"players":true,"body":[{"action":{"op":"give_item","item":"minecraft:bread","count":1}}]}}]}, + {"id":"play:hit", "context":"entity", "body":[{"action":{"op":"damage","amount":2.5,"by":reference}}]} + ]), + serde_json::json!([]), + ); + let pack = Compiler::compile(&decode(doc)).unwrap(); + let all = pack + .resources + .values() + .filter_map(|b| std::str::from_utf8(b).ok()) + .collect::>() + .join("\n"); + let identity = sand_commands::ObjectiveName::logical("sand runtime owner play").to_string(); + let load = function_text(&pack, "__sand_score_init"); + assert!( + load.contains(&format!("scoreboard objectives add {identity} dummy")), + "{load}" + ); + assert!(all.contains(&format!("scoreboard players add #next {identity} 1"))); + assert!(all.contains("0..2147483645")); + assert!(all.contains("minecraft:generic by @a[scores=")); + assert!(all.contains("reference:$(reference)")); +} + +#[test] +fn retained_entity_capture_rejects_bounded_identity_storage() { + let doc = program( + serde_json::json!([ + {"id":"play:capture", "context":"player", "body":[{"action":{"op":"capture_entity","score":field("stats", "gold")}}]} + ]), + serde_json::json!([]), + ); + let errors = match Compiler::compile(&decode(doc)) { + Err(errors) => errors, + Ok(_) => panic!("bounded capture must fail"), + }; + assert!( + errors + .iter() + .any(|e| e.message.contains("unbounded, non-timer")), + "{errors:?}" + ); +} + +#[test] +fn related_entity_capture_keeps_the_original_executor_as_the_destination() { + let doc = |relation: &str| { + program( + serde_json::json!([ + {"id":"play:capture", "context":"player", "body":[{"action":{"op":"capture_entity","score":field("stats", "best"),"relation":relation}}]} + ]), + serde_json::json!([]), + ) + }; + let pack = Compiler::compile(&decode(doc("vehicle"))).unwrap(); + let capture = function_text(&pack, "capture"); + assert!( + capture.lines().any(|line| { + line.starts_with("execute store result score @s ") + && line.contains(" on vehicle run function ") + }), + "{capture}" + ); + let errors = Compiler::check(&decode(doc("passengers"))).unwrap_err(); + assert!( + errors + .iter() + .any(|error| error.message.contains("single-entity relationship")) + ); +} + +#[test] +fn generated_command_locations_follow_final_lifecycle_and_player_prefixes() { + let mut doc = program( + serde_json::json!([ + {"id":"play:reward", "context":"player", "body":[ + {"action":{"op":"score_operation","score":field("stats", "best"),"operator":"add","operand":2}} + ]} + ]), + serde_json::json!([]), + ); + let module = &mut doc["modules"][0]; + // Compiler setup has its own lifecycle contribution even when this ID is authored. + module["id"] = "play:__sand_program/events".into(); + for (phase, value) in [("load", 17), ("tick", 29)] { + module[phase] = serde_json::json!([ + {"action":{"op":"score_set","score":field("world", "round"),"value":value}} + ]); + } + let program = decode(doc); + let (pack, sources) = Compiler::compile_with_command_sources(&program).unwrap(); + let sources = sources.functions; + assert_eq!( + pack.resources, + Compiler::compile(&program).unwrap().resources + ); + let reward = function_text(&pack, "reward"); + assert!( + reward + .lines() + .next() + .unwrap() + .contains("__sand_lifecycle_init") + ); + let source = &sources["data/play/function/reward.mcfunction"][0]; + assert_eq!(source.lines, 2..=2); + assert_eq!(source.pointer, "/functions/0/body/0"); + for (phase, value) in [("load", 17), ("tick", 29)] { + let path = format!("__sand_lifecycle_{phase}"); + let content = function_text(&pack, &path); + let [source] = sources[&format!("data/play/function/{path}.mcfunction")].as_slice() else { + panic!("unexpected sources for {path}: {sources:?}"); + }; + assert_eq!(source.module, "play:__sand_program/events"); + assert_eq!(source.pointer, format!("/{phase}/0")); + let command = content.lines().nth(source.lines.start() - 1).unwrap(); + assert!(command.ends_with(&format!(" {value}")), "{command}"); + } +} + +#[test] +fn suspended_portable_bodies_check_delay_context_and_captured_storage() { + let bad = program( + serde_json::json!([ + {"id":"play:delay", "context":"server", "body":[{"action":{ + "op":"suspend", "ticks":0, "fields":[field("stats","best")], + "body":[{"action":{"op":"kill"}}] + }}]} + ]), + serde_json::json!([]), + ); + let errors = Compiler::check(&decode(bad)).unwrap_err(); + for expected in [ + "suspending a function requires", + "positive scoreboard integer", + "global invocation slots", + "killing the executor requires", + ] { + assert!( + errors.iter().any(|error| error.message.contains(expected)), + "{errors:#?}" + ); + } +} diff --git a/sand-core/tests/portable_program.rs b/sand-core/tests/portable_program.rs index 266b8aa1..e8b00bcb 100644 --- a/sand-core/tests/portable_program.rs +++ b/sand-core/tests/portable_program.rs @@ -19,11 +19,29 @@ fn counter() -> Program { namespace: "demo".into(), description: "Player counter".into(), }, + structure_assets: Default::default(), requires: vec![], modules: vec![Module { + events: vec![], + items: vec![], + recipes: vec![], + resource_tags: vec![], + loot_tables: vec![], + boss_bars: vec![], + damage_types: vec![], + predicates: vec![], + advancements: vec![], + dialogs: vec![], + dimensions: vec![], + biomes: vec![], + structure_templates: vec![], + inventory_transfers: vec![], + huds: vec![], + menus: vec![], flows: vec![], id: "demo:counter_module".parse().unwrap(), states: vec![State { + data_fields: Vec::new(), id: "demo:counter".parse().unwrap(), scope: "player".into(), revision: 1, @@ -31,6 +49,7 @@ fn counter() -> Program { name: "value".into(), default: 0, bounds: None, + timer: false, }], }], functions: vec![ @@ -262,7 +281,8 @@ fn branch_uses_one_guard_and_returns_before_otherwise() { score: score.clone(), min: Some(0), max: Some(0), - }, + } + .into(), then: vec![operation(Action::ScoreSet { score: score.clone(), value: 1, @@ -743,7 +763,8 @@ fn runtime_report_attributes_helpers_and_load_contributions() { score: score.clone(), min: Some(0), max: Some(0), - }, + } + .into(), then: vec![operation(Action::ScoreSet { score: score.clone(), value: 1, @@ -1066,3 +1087,62 @@ fn bounded_constant_branch_keeps_one_decision_and_owned_return_run_helpers() { compiled.resources ); } + +#[test] +fn block_data_copies_checked_values_without_interpolating_authored_paths() { + let mut program = counter(); + let module = &mut program.modules[0]; + let state = &mut module.states[0]; + let source = DataReference { + field: FieldReference { + state: state.id.clone(), + field: "items".into(), + }, + path: Vec::new(), + }; + state.data_fields.push(DataField { + name: "items".into(), + default: sand::data::NbtValue::List(vec![]), + }); + let from = BlockDataAddress { + at: BlockPosition::Absolute { x: 1, y: 80, z: 2 }, + path: "Items".into(), + }; + let to = BlockDataAddress { + at: BlockPosition::Absolute { x: 3, y: 80, z: 4 }, + path: r#""$(literal)""#.into(), + }; + let projection = DataReference { + field: source.field.clone(), + path: vec![DataProjection::Index { + index: ScoreOperand::Field(FieldReference { + state: state.id.clone(), + field: "value".into(), + }), + }], + }; + module.functions[1].body = vec![ + operation(Action::DataModify { + target: source, + operator: DataModifyOperation::Set, + source: DataOperand::Block { value: from }, + }), + operation(Action::WriteBlockData { + target: to, + value: Some(DataOperand::Reference { value: projection }), + }), + ]; + let pack = Compiler::compile(&program).unwrap(); + let entry = + std::str::from_utf8(&pack.resources["data/demo/function/increment.mcfunction"]).unwrap(); + assert!(entry.contains("input set from block 1 80 2 Items")); + assert!(entry.contains( + r#"data modify block 3 80 4 "$(literal)" set from storage demo:__program_data output"# + )); + assert!(pack.resources.iter().any(|(path, source)| { + path.ends_with("/data_value.mcfunction") + && String::from_utf8_lossy(source) + .contains("output set from storage demo:__program_data input[$(i0)]") + && !String::from_utf8_lossy(source).contains("$(literal)") + })); +} diff --git a/sand-example/src/lib.rs b/sand-example/src/lib.rs index 5ead4a9d..a92392ee 100644 --- a/sand-example/src/lib.rs +++ b/sand-example/src/lib.rs @@ -754,12 +754,16 @@ mod tests { #[test] fn smithing_trim_recipe_json_output() { use sand_core::{Ingredient, SmithingTrimRecipe}; - let recipe = SmithingTrimRecipe::new("hello_world:armor_trim".parse().unwrap()) - .template(Ingredient::tag("minecraft:trim_templates")) - .base(Ingredient::tag("minecraft:trimmable_armor")) - .addition(Ingredient::tag("minecraft:trim_materials")); + let recipe = SmithingTrimRecipe::new( + "hello_world:armor_trim".parse().unwrap(), + "minecraft:sentry".parse().unwrap(), + ) + .template(Ingredient::tag("minecraft:trim_templates")) + .base(Ingredient::tag("minecraft:trimmable_armor")) + .addition(Ingredient::tag("minecraft:trim_materials")); let json = recipe.to_json(); assert_eq!(json["type"].as_str().unwrap(), "minecraft:smithing_trim"); + assert_eq!(json["pattern"], "minecraft:sentry"); assert_eq!( json["template"].as_str().unwrap(), "#minecraft:trim_templates" diff --git a/sand-lang/Cargo.toml b/sand-lang/Cargo.toml new file mode 100644 index 00000000..2e18e0f4 --- /dev/null +++ b/sand-lang/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "sand-lang" +description = "The Sand language: a Rust-flavoured source language that compiles to Minecraft datapacks through Sand's portable compiler" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true +rust-version.workspace = true +keywords = ["minecraft", "datapack", "language", "compiler", "gamedev"] +categories = ["compilers", "game-development"] + +[dependencies] +sand = { path = "../sand" } +sand-version = { path = "../sand-version" } +pest = "2.8" +pest_derive = "2.8" +serde_json = "1" + +[dev-dependencies] diff --git a/sand-lang/src/analysis/callables.rs b/sand-lang/src/analysis/callables.rs new file mode 100644 index 00000000..26eeab9c --- /dev/null +++ b/sand-lang/src/analysis/callables.rs @@ -0,0 +1,820 @@ +//! Callable values carry a checked target and an owned environment. Dispatch only invokes +//! checked targets from this compilation and never substitutes a storage path +//! or function name from user-controlled data. +use super::*; +use sand::data::{NbtCompound, NbtValue}; + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +pub(super) struct Signature { + pub parameters: Vec, + pub returns: Option, +} + +#[derive(Default)] +pub(super) struct Callables { + types: BTreeMap, + targets: BTreeMap>, + dispatchers: BTreeMap, + closures: BTreeMap<(ModuleId, Span, String), String>, +} + +#[derive(Clone)] +struct CallableTarget { + def: DefId, + captures: Vec, + file: FileId, + span: Span, +} + +impl Cx { + pub(super) fn callable_type(&mut self, module: ModuleId, signature: Signature) -> Ty { + if let Some(def) = self.callables.types.get(&signature) { + return Ty::Callable(*def); + } + let mut name = format!( + "fn({})", + signature + .parameters + .iter() + .map(|ty| self.ty_name(*ty)) + .collect::>() + .join(", ") + ); + if let Some(ty) = signature.returns { + name.push_str(&format!(" -> {}", self.ty_name(ty))); + } + let def = self.push_def(Def { + kind: DefKind::Struct, + name, + module, + file: self.package.module(module).file, + name_span: Span::default(), + span: Span::default(), + docs: Vec::new(), + is_pub: false, + parent: Some(DefId(self.defs.len())), + info: DefInfo::Callable { + parameters: signature.parameters.clone(), + returns: signature.returns, + }, + }); + self.callables.types.insert(signature, def); + Ty::Callable(def) + } + + pub(super) fn callable_signature(&self, ty: Ty) -> Option { + let Ty::Callable(def) = ty else { return None }; + let DefInfo::Callable { + parameters, + returns, + } = &self.defs[def.0].info + else { + return None; + }; + Some(Signature { + parameters: parameters.clone(), + returns: *returns, + }) + } + + pub(super) fn named_function_type(&mut self, module: ModuleId, def: DefId) -> Ty { + let Some(slots) = self.fn_slots.get(&def) else { + return Ty::Unknown; + }; + self.callable_type( + module, + Signature { + parameters: slots.params.iter().map(|(_, _, ty)| *ty).collect(), + returns: slots.ret.as_ref().map(|(_, ty)| *ty), + }, + ) + } + + pub(super) fn emit_function_value( + &mut self, + body: &BodyCx, + dest: &pc::FieldReference, + expected: Ty, + path: &Path, + ops: &mut Vec, + ) -> Option<()> { + let function = + self.expect_path(body.module, path, &[DefKind::Function], "a named function")?; + let DefInfo::Function { id, .. } = &self.defs[function.0].info else { + return None; + }; + let id = id.clone(); + if !path.arguments().is_empty() + || self.generics.origins.contains_key(&function) + || self.generics.templates.contains_key(&function) + || self.test_functions.contains(&function) + || self + .methods + .get(&function) + .is_some_and(|method| method.receiver.is_some()) + { + self.error("callable", body.file, path.span, "a function value must name an ordinary non-generic function or associated function"); + return None; + } + let found = self.named_function_type(body.module, function); + let Ty::Callable(signature) = found else { + return None; + }; + if !self.types_agree(body.file, path.span, expected, found) { + return None; + } + let key = format!("{id} {}", self.ty_name(found)); + self.register_callable_target( + signature, + key.clone(), + CallableTarget { + def: function, + captures: Vec::new(), + file: body.file, + span: path.span, + }, + )?; + ops.push(op_at( + Self::initialize_leaf( + dest.clone(), + text::LeafDefault::Data(Self::callable_payload(key)), + ), + body.file, + path.span, + )); + Some(()) + } + + pub(super) fn empty_callable() -> NbtValue { + NbtValue::Compound(NbtCompound::new()) + } + + fn callable_payload(id: String) -> NbtValue { + let mut data = NbtCompound::new(); + data.insert("target", NbtValue::String(id)); + data.insert("captures", NbtValue::Compound(NbtCompound::new())); + NbtValue::Compound(data) + } + + fn register_callable_target( + &mut self, + signature: DefId, + key: String, + candidate: CallableTarget, + ) -> Option<()> { + let targets = self.callables.targets.entry(signature).or_default(); + if let Some(target) = targets.get(&key) { + if target.def != candidate.def { + self.diagnostics.push( + Diagnostic::error( + "callable", + candidate.file, + candidate.span, + "these callable target identities collide", + ) + .with_note( + target.file, + target.span, + "other callable target", + ), + ); + return None; + } + } else { + if targets.len() >= 256 { + self.error( + "callable", + candidate.file, + candidate.span, + "a callable signature supports at most 256 targets", + ); + return None; + } + targets.insert(key, candidate); + } + Some(()) + } + + pub(super) fn emit_callable( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let span = expr.span(); + match expr { + Expr::Closure(closure) => self.emit_closure(body, dest, ty, closure, ops), + Expr::Path(path) => { + if let Some(local) = Self::local_of(body, expr) { + if !self.types_agree(body.file, span, ty, self.local_ty(local)) { + return None; + } + body.used.insert(local); + self.references.push(Reference { + file: body.file, + span: path.last().span, + def: local, + }); + let source = self.local_ref(local); + self.copy_value(dest, &source, ty, body.file, span, ops); + Some(()) + } else { + self.emit_function_value(body, dest, ty, path, ops) + } + } + Expr::Place(place) => { + let source = self.place_value(body, place, false)?; + if !self.types_agree(body.file, span, ty, source.ty) { + return None; + } + self.copy_value(dest, &source.reference, ty, body.file, span, ops); + Some(()) + } + Expr::Call { path, args, .. } => self.emit_call(body, dest, ty, path, args, span, ops), + Expr::Method { + receiver, + name, + type_arguments, + args, + .. + } => { + let receiver_ty = self.type_of(body, receiver); + if self.list_element(receiver_ty).is_some() { + return self.emit_list_method(body, dest, ty, expr, ops); + } + if self.array_shape(receiver_ty).is_some() { + return self.emit_array_method(body, dest, ty, expr, ops); + } + self.emit_method( + body, + dest, + ty, + receiver, + name, + type_arguments, + args, + span, + ops, + ) + } + Expr::Project(value, field, _) => { + self.emit_projection(body, dest, ty, value, field, ops) + } + Expr::Index(..) => self.emit_index(body, dest, ty, expr, ops), + _ => { + self.error("callable", body.file, span, "expected a function value"); + None + } + } + } + + pub(super) fn indirect_call( + &mut self, + body: &BodyCx, + path: &Path, + local: DefId, + args: &[Arg], + ) -> Option<(DefId, Vec)> { + let ty = self.local_ty(local); + let Ty::Callable(signature) = ty else { + self.error( + "callable", + body.file, + path.span, + "this local does not hold a function", + ); + return None; + }; + if !path.arguments().is_empty() { + self.error( + "callable", + body.file, + path.span, + "function values have a concrete signature", + ); + return None; + } + let dispatcher = self.callable_dispatcher(body, signature, path.span); + let mut actual = Vec::with_capacity(args.len() + 1); + actual.push(Arg { + name: None, + value: ArgValue::Expr(Expr::Path(path.clone())), + span: path.span, + }); + actual.extend_from_slice(args); + Some((dispatcher, actual)) + } + + fn callable_dispatcher(&mut self, body: &BodyCx, signature: DefId, span: Span) -> DefId { + if let Some(def) = self.callables.dispatchers.get(&signature) { + return *def; + } + let name = self.defs[signature.0].name.clone(); + let id = format!("{}:sand.lang_call/{}", self.namespace(), signature.0); + let def = self.push_def(Def { + kind: DefKind::Function, + name: name.clone(), + module: body.module, + file: body.file, + name_span: Span::default(), + span, + docs: Vec::new(), + is_pub: false, + parent: Some(signature), + info: DefInfo::Function { + id, + context: Context::Server, + player_reason: None, + entry: Vec::new(), + signature: name, + }, + }); + let sig = self + .callable_signature(Ty::Callable(signature)) + .expect("interned signature"); + let mut params = Vec::new(); + for (index, ty) in std::iter::once(Ty::Callable(signature)) + .chain(sig.parameters) + .enumerate() + { + let name = format!("argument_{index}"); + let param = self.push_def(Def { + kind: DefKind::Local, + name: name.clone(), + module: body.module, + file: body.file, + name_span: Span::default(), + span: Span::default(), + docs: Vec::new(), + is_pub: false, + parent: Some(def), + info: DefInfo::Local { + mutable: false, + param: true, + owner: Some(def), + ty, + }, + }); + params.push((format!("v{}_{name}", param.0), param, ty)); + } + let ret = sig.returns.map(|ty| (format!("f{}_ret", def.0), ty)); + self.fn_slots.insert( + def, + FnSlots { + params, + ret, + receiver_out: None, + }, + ); + self.callables.dispatchers.insert(signature, def); + def + } + + pub(super) fn lower_callable_dispatchers(&mut self, lowerer: &mut Lowering) { + for (signature, def) in self.callables.dispatchers.clone() { + let d = self.defs[def.0].clone(); + let DefInfo::Function { id, .. } = d.info else { + continue; + }; + let slots = self.fn_slots[&def].clone(); + let call_value = self.slot(slots.params[0].0.clone()); + self.value_slots(&call_value, Ty::Callable(signature)); + let mut target_selection = Self::data_reference(&call_value); + target_selection.path.push(pc::DataProjection::Member { + name: "target".into(), + }); + let mut body = BodyCx::new(d.module, d.file, false); + body.owner = Some(def); + body.slot = format!("f{}", def.0); + let mut arguments = Vec::new(); + for (_, param, _) in slots.params.iter().skip(1) { + let name = self.defs[param.0].name.clone(); + body.scopes[0].push((name.clone(), *param)); + let path = Path { + segments: vec![Ident { + name, + span: Span::default(), + }], + applications: Vec::new(), + span: Span::default(), + }; + arguments.push(Arg { + name: None, + value: ArgValue::Expr(Expr::Path(path)), + span: d.span, + }); + } + let targets: Vec<_> = self + .callables + .targets + .get(&signature) + .into_iter() + .flatten() + .map(|(key, target)| (key.clone(), target.clone())) + .collect(); + let mut ops = Vec::new(); + if let Some((field, ty)) = &slots.ret { + let result = self.slot(field.clone()); + if let Some(defaults) = self.record_constant(d.module, d.file, None, *ty) { + for ((score, _), default) in + self.value_slots(&result, *ty).into_iter().zip(defaults) + { + ops.push(op_at(Self::initialize_leaf(score, default), d.file, d.span)); + } + } + body.ret = Some((result, *ty)); + } + let expected_target = self.temp(&mut body); + self.register_data_slot(&expected_target, Self::empty_callable()); + let comparison = self.temp(&mut body); + for (key, target) in targets { + ops.push(op_at( + Self::initialize_leaf( + expected_target.clone(), + text::LeafDefault::Data(NbtValue::String(key)), + ), + d.file, + d.span, + )); + ops.push(op_at( + pc::Action::DataEqual { + score: comparison.clone(), + left: target_selection.clone(), + right: Self::data_reference(&expected_target), + }, + d.file, + d.span, + )); + let mut then = Vec::new(); + let mut all_arguments = Vec::new(); + for (index, ty) in target.captures.iter().enumerate() { + let name = format!("capture_{}", body.scopes[0].len()); + let local = self.callback_local(def, &name, *ty); + body.scopes[0].push((name.clone(), local)); + let slot = self.local_ref(local); + if let Some(defaults) = self.record_constant(d.module, d.file, None, *ty) { + for ((field, _), default) in + self.value_slots(&slot, *ty).into_iter().zip(defaults) + { + then.push(op_at(Self::initialize_leaf(field, default), d.file, d.span)); + } + } + let source = Self::capture_selection(&call_value, index); + self.unpack_value(&mut body, &slot, source, *ty, d.span, &mut then); + all_arguments.push(Self::local_argument(name, d.span)); + } + all_arguments.extend_from_slice(&arguments); + let target = target.def; + let name = self.defs[target.0].name.clone(); + let path = Path { + segments: vec![Ident { name, span: d.span }], + applications: Vec::new(), + span: d.span, + }; + if let Some((dest, ty)) = body.ret.clone() { + self.emit_user_result( + &mut body, + &dest, + ty, + target, + &path, + &all_arguments, + d.span, + &mut then, + ); + } else { + let target_slots = self.fn_slots[&target].clone(); + self.call_user( + &mut body, + target, + &target_slots, + &path, + &all_arguments, + d.span, + &mut then, + ); + } + then.push(op_at(pc::Action::Return, d.file, d.span)); + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: comparison.clone(), + min: Some(1), + max: Some(1), + }), + then, + otherwise: Vec::new(), + }, + d.file, + d.span, + )); + } + lowerer.facts.insert( + def, + Facts { + entity_direct: None, + entity_loop_calls: Vec::new(), + all_calls: body.all_calls, + schedules: Vec::new(), + forced: None, + direct: None, + calls: body.calls, + entry: Vec::new(), + file: d.file, + }, + ); + lowerer.functions.push(PendingFn { + module: d.module, + file: d.file, + def: Some(def), + fixed: None, + id, + name_span: d.span, + body: ops, + }); + } + } + + fn callback_local(&mut self, owner: DefId, name: &str, ty: Ty) -> DefId { + let declaration = &self.defs[owner.0]; + self.push_def(Def { + kind: DefKind::Local, + name: name.into(), + module: declaration.module, + file: declaration.file, + name_span: Span::default(), + span: Span::default(), + docs: Vec::new(), + is_pub: false, + parent: Some(owner), + info: DefInfo::Local { + ty, + mutable: false, + param: true, + owner: Some(owner), + }, + }) + } + + fn local_argument(name: String, span: Span) -> Arg { + Arg { + name: None, + span, + value: ArgValue::Expr(Expr::Path(Path { + segments: vec![Ident { + name, + span: Span::default(), + }], + applications: Vec::new(), + span: Span::default(), + })), + } + } + + fn capture_selection(value: &pc::FieldReference, index: usize) -> pc::DataReference { + let mut selection = Self::data_reference(value); + selection.path.push(pc::DataProjection::Member { + name: "captures".into(), + }); + selection.path.push(pc::DataProjection::Member { + name: format!("c{index}"), + }); + selection + } + + pub(super) fn closure_type(&mut self, module: ModuleId, closure: &ClosureExpr) -> Ty { + let parameters = closure + .parameters + .iter() + .map(|parameter| self.resolve_type(module, ¶meter.ty)) + .collect(); + let returns = closure + .returns + .as_ref() + .map(|ty| self.resolve_type(module, ty)); + self.callable_type( + module, + Signature { + parameters, + returns, + }, + ) + } + + fn emit_closure( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + expected: Ty, + closure: &ClosureExpr, + ops: &mut Vec, + ) -> Option<()> { + let Ty::Callable(signature) = self.closure_type(body.module, closure) else { + return None; + }; + if !self.types_agree(body.file, closure.span, expected, Ty::Callable(signature)) { + return None; + } + let mut captured = BTreeMap::new(); + let source = &self.package.files[body.file.0].text; + let text = source + .get(closure.body.span.start..closure.body.span.end) + .unwrap_or_default(); + // Keep identifiers in interpolation as well as ordinary expressions. + // Shadowed mentions may add a harmless immutable snapshot. + let tokens: HashSet<_> = text + .split(|ch: char| !ch.is_ascii_alphanumeric() && ch != '_') + .collect(); + for scope in &body.scopes { + for (name, local) in scope { + if tokens.contains(name.as_str()) + && !closure + .parameters + .iter() + .any(|parameter| parameter.name.name == *name) + { + captured.insert(name.clone(), *local); + } + } + } + if captured.len() > 64 { + self.error( + "callable", + body.file, + closure.span, + "a closure supports at most 64 captured locals", + ); + return None; + } + + let site = (body.module, closure.span, body.slot.clone()); + let target = if let Some(target) = self.callables.closures.get(&site) { + target.clone() + } else { + if self.callables.closures.len() >= 256 { + self.error( + "callable", + body.file, + closure.span, + "a package supports at most 256 concrete closures", + ); + return None; + } + let target = self.declare_closure(body, closure, signature, &captured)?; + self.callables.closures.insert(site, target.clone()); + target + }; + let depth = body.temp_depth; + let staged = self.temp(body); + self.value_slots(&staged, Ty::Callable(signature)); + ops.push(op_at( + Self::initialize_leaf( + staged.clone(), + text::LeafDefault::Data(Self::callable_payload(target)), + ), + body.file, + closure.span, + )); + for (index, local) in captured.into_values().enumerate() { + body.used.insert(local); + let source = self.local_ref(local); + self.pack_value( + body, + Self::capture_selection(&staged, index), + &source, + self.local_ty(local), + closure.span, + ops, + ); + } + self.copy_value( + dest, + &staged, + Ty::Callable(signature), + body.file, + closure.span, + ops, + ); + body.temp_depth = depth; + Some(()) + } + + fn declare_closure( + &mut self, + body: &BodyCx, + closure: &ClosureExpr, + signature: DefId, + captured: &BTreeMap, + ) -> Option { + let index = self.callables.closures.len(); + let id = format!("{}:sand.lang_closure/{index}", self.namespace()); + let name = format!("closure_{index}"); + let func = self.push_def(Def { + kind: DefKind::Function, + name: name.clone(), + module: body.module, + file: body.file, + name_span: Span::default(), + span: closure.span, + docs: Vec::new(), + is_pub: false, + parent: Some(signature), + info: DefInfo::Function { + id: id.clone(), + context: Context::Server, + player_reason: None, + entry: Vec::new(), + signature: String::new(), + }, + }); + self.declare_slots( + body.module, + body.file, + func, + &closure.parameters, + closure.returns.as_ref(), + ); + let mut params = Vec::new(); + let mut capture_types = Vec::new(); + let mut schema = String::new(); + for (name, source) in captured { + let ty = self.local_ty(*source); + let local = self.callback_local(func, name, ty); + self.generics.origins.insert( + local, + self.generics + .origins + .get(source) + .copied() + .unwrap_or(*source), + ); + params.push((format!("v{}_{name}", local.0), local, ty)); + capture_types.push(ty); + schema.push_str(&format!(" {name}:{}", self.ty_name(ty))); + } + let slots = self.fn_slots.get_mut(&func).expect("declared closure"); + params.append(&mut slots.params); + slots.params = params; + let function = FnItem { + bounds: Vec::new(), + generics: Vec::new(), + receiver: None, + name: Ident { + name, + span: closure.span, + }, + params: closure.parameters.clone(), + ret: closure.returns.clone(), + body: closure.body.clone(), + }; + let key = format!( + "{id} {}:{}{schema}", + self.package.module(body.module).display_path(), + closure.span.start + ); + self.register_callable_target( + signature, + key.clone(), + CallableTarget { + def: func, + captures: capture_types, + file: body.file, + span: closure.span, + }, + )?; + self.queue_generated_body( + func, + Item { + docs: Vec::new(), + attrs: Vec::new(), + is_pub: false, + kind: ItemKind::Fn(function), + span: closure.span, + }, + ); + Some(key) + } + + pub(super) fn validate_callable_contexts(&mut self) { + for targets in self.callables.targets.values() { + for target in targets.values() { + if !matches!( + self.defs[target.def.0].info, + DefInfo::Function { + context: Context::Server, + .. + } + ) { + self.diagnostics.push(Diagnostic::error( + "callable", + target.file, + target.span, + "a function value must be callable without a player or entity executor", + )); + } + } + } + } +} diff --git a/sand-lang/src/analysis/collections.rs b/sand-lang/src/analysis/collections.rs new file mode 100644 index 00000000..42548236 --- /dev/null +++ b/sand-lang/src/analysis/collections.rs @@ -0,0 +1,1004 @@ +//! Homogeneous collections reuse the canonical aggregate leaf/call model. +use super::*; + +impl Cx { + pub(super) fn array_type(&mut self, module: ModuleId, element: Ty, length: usize) -> Ty { + if length > 1024 { + self.error( + "type", + self.package.module(module).file, + Span::default(), + "arrays support at most 1024 elements", + ); + return Ty::Unknown; + } + if let Some(def) = self.array_types.get(&(element, length)) { + return Ty::Struct(*def); + } + let file = self.package.module(module).file; + let def = self.push_def(Def { + kind: DefKind::Struct, + name: format!("[{}; {length}]", self.ty_name(element)), + module, + file, + name_span: Span::default(), + span: Span::default(), + docs: Vec::new(), + is_pub: false, + parent: Some(DefId(self.defs.len())), + info: DefInfo::Array { + element, + fields: Vec::new(), + }, + }); + let mut fields = Vec::with_capacity(length); + for index in 0..length { + fields.push(self.push_def(Def { + kind: DefKind::Field, + name: format!("i{index}"), + module, + file, + name_span: Span::default(), + span: Span::default(), + docs: Vec::new(), + is_pub: false, + parent: Some(def), + info: DefInfo::Field { + ty: element, + default: None, + bounds: None, + timer: false, + }, + })); + } + self.defs[def.0].info = DefInfo::Array { element, fields }; + if self.layout_leaves(Ty::Struct(def)).is_none() { + self.error( + "type", + file, + Span::default(), + "array layouts must be finite, at most 32 levels deep and 1024 scalar leaves", + ); + self.defs[def.0].info = DefInfo::Array { + element, + fields: Vec::new(), + }; + return Ty::Unknown; + } + self.array_types.insert((element, length), def); + Ty::Struct(def) + } + + pub(super) fn array_shape(&self, ty: Ty) -> Option<(Ty, usize)> { + let Ty::Struct(def) = ty else { + return None; + }; + match &self.defs[def.0].info { + DefInfo::Array { element, fields } => Some((*element, fields.len())), + _ => None, + } + } +} + +impl Cx { + pub(super) fn emit_array( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + if let Expr::ArrayRepeat { + value, + length: count, + span, + } = expr + { + let (element, length) = self.array_shape(ty)?; + let count = self.eval_i32(body.module, body.file, count, Some(Ty::Number), None)?; + if count != length as i64 { + self.error( + "type", + body.file, + *span, + format!("expected {length} array elements, found {count}"), + ); + return None; + } + let depth = body.temp_depth; + let repeated = self.temp(body); + self.emit(body, &repeated, element, value, ops)?; + self.value_slots(dest, ty); + for index in 0..length { + self.copy_value( + &super::values::child(dest, &format!("i{index}")), + &repeated, + element, + body.file, + *span, + ops, + ); + } + body.temp_depth = depth; + return Some(()); + } + let Expr::Array(values, location) = expr else { + unreachable!() + }; + let span = *location; + let Some((element, length)) = self.array_shape(ty) else { + self.error( + "type", + body.file, + span, + "an array literal needs an array type", + ); + return None; + }; + if values.len() != length { + self.error( + "type", + body.file, + span, + format!("expected {length} array elements, found {}", values.len()), + ); + return None; + } + self.value_slots(dest, ty); + for (index, value) in values.iter().enumerate() { + let field = super::values::child(dest, &format!("i{index}")); + self.emit(body, &field, element, value, ops)?; + } + Some(()) + } + + pub(super) fn emit_index( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Index(value, index, span) = expr else { + unreachable!() + }; + let array_ty = self.type_of(body, value); + if self.list_element(array_ty).is_some() { + return self.emit_list_index(body, dest, ty, expr, ops); + } + let Some((element, length)) = self.array_shape(array_ty) else { + self.error( + "type", + body.file, + value.span(), + "indexing needs an array value", + ); + return None; + }; + if !self.types_agree(body.file, *span, ty, element) { + return None; + } + let depth = body.temp_depth; + let array = self.temp(body); + self.emit(body, &array, array_ty, value, ops)?; + if Self::is_const_in(body, index) { + let offset = self.eval_i32(body.module, body.file, index, Some(Ty::Number), None)?; + if offset < 0 || offset as usize >= length { + self.error( + "index", + body.file, + index.span(), + format!("index {offset} is outside an array of length {length}"), + ); + body.temp_depth = depth; + return None; + } + self.copy_value( + dest, + &super::values::child(&array, &format!("i{offset}")), + element, + body.file, + *span, + ops, + ); + } else { + let selected = self.temp(body); + self.emit(body, &selected, Ty::Number, index, ops)?; + let defaults = self.record_constant(body.module, body.file, None, element)?; + for ((score, _), value) in self.value_slots(dest, element).into_iter().zip(defaults) { + ops.push(op_at(Self::initialize_leaf(score, value), body.file, *span)); + } + for offset in 0..length { + let mut then = Vec::new(); + self.copy_value( + dest, + &super::values::child(&array, &format!("i{offset}")), + element, + body.file, + *span, + &mut then, + ); + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: selected.clone(), + min: Some(offset as i32), + max: Some(offset as i32), + }), + then, + otherwise: Vec::new(), + }, + body.file, + *span, + )); + } + } + body.temp_depth = depth; + Some(()) + } +} + +/// An assignable aggregate or leaf, with frozen indexes for indirect elements. +pub(super) struct ValueAddress { + ty: Ty, + cells: Vec, + valid: Vec, + possible: bool, +} +#[derive(Clone)] +struct AddressCell { + target: AddressTarget, + guards: Vec, +} +#[derive(Clone)] +enum AddressTarget { + Slots(pc::FieldReference), + Data(pc::DataReference), +} + +impl Cx { + pub(super) fn value_address( + &mut self, + body: &mut BodyCx, + expr: &Expr, + ops: &mut Vec, + ) -> Option { + self.value_address_access(body, expr, true, ops) + } + + pub(super) fn value_address_access( + &mut self, + body: &mut BodyCx, + expr: &Expr, + write: bool, + ops: &mut Vec, + ) -> Option { + match expr { + Expr::Path(_) | Expr::Place(_) => { + let reference = if write { + self.receiver_destination(body, expr)? + } else { + match expr { + Expr::Path(path) + if path.segments.len() == 1 && path.applications.is_empty() => + { + let local = Self::lookup_local(body, &path.last().name)?; + body.used.insert(local); + self.references.push(Reference { + file: body.file, + span: path.last().span, + def: local, + }); + self.local_ref(local) + } + Expr::Place(place) => self.place_value(body, place, false)?.reference, + _ => return None, + } + }; + let ty = self.type_of(body, expr); + Some(ValueAddress { + ty, + cells: vec![AddressCell { + target: AddressTarget::Slots(reference), + guards: Vec::new(), + }], + valid: Vec::new(), + possible: true, + }) + } + Expr::Project(value, field, _) => { + let mut address = self.value_address_access(body, value, write, ops)?; + let Some(member) = self.record_member(address.ty, &field.name) else { + self.error( + "field", + body.file, + field.span, + format!("no field `{}` on this value", field.name), + ); + return None; + }; + if !self.visible( + body.module, + self.defs[member.0].module, + self.defs[member.0].is_pub, + ) { + self.error( + "privacy", + body.file, + field.span, + format!("field `{}` is private", field.name), + ); + return None; + } + self.references.push(Reference { + file: body.file, + span: field.span, + def: member, + }); + for cell in &mut address.cells { + cell.target = match &cell.target { + AddressTarget::Slots(reference) => { + AddressTarget::Slots(super::values::child(reference, &field.name)) + } + AddressTarget::Data(reference) => { + let mut reference = reference.clone(); + reference.path.push(pc::DataProjection::Member { + name: field.name.clone(), + }); + AddressTarget::Data(reference) + } + }; + } + address.ty = self.field_ty(member); + Some(address) + } + Expr::Index(value, index, _) => self.index_address(body, value, index, write, ops), + _ => { + self.error( + "mutability", + body.file, + expr.span(), + "this expression is not writable; use a mutable variable or State field", + ); + None + } + } + } + + fn index_address( + &mut self, + body: &mut BodyCx, + value: &Expr, + index: &Expr, + write: bool, + ops: &mut Vec, + ) -> Option { + let address = self.value_address_access(body, value, write, ops)?; + if let Some(element) = self.list_element(address.ty) { + if Self::is_const_in(body, index) + && self.eval_i32(body.module, body.file, index, Some(Ty::Number), None)? < 0 + { + self.error( + "index", + body.file, + index.span(), + "vector indices must be nonnegative", + ); + return None; + } + let selected = self.temp(body); + self.emit(body, &selected, Ty::Number, index, ops)?; + let any_valid = self.temp(body); + ops.push(op_at( + pc::Action::ScoreSet { + score: any_valid.clone(), + value: 0, + }, + body.file, + index.span(), + )); + let mut cells = Vec::new(); + for mut parent in address.cells { + let mut source = match &parent.target { + AddressTarget::Slots(reference) => Self::data_reference(reference), + AddressTarget::Data(reference) => reference.clone(), + }; + let valid = + self.storage_index_valid(body, source.clone(), &selected, index.span(), ops); + let guard = pc::ScoreComparison { + score: valid, + min: Some(1), + max: Some(1), + }; + parent.guards.push(guard); + let mark = vec![op_at( + pc::Action::ScoreSet { + score: any_valid.clone(), + value: 1, + }, + body.file, + index.span(), + )]; + ops.extend(self.guard_cell(body, &parent, index.span(), mark)); + source.path.push(pc::DataProjection::Index { + index: pc::ScoreOperand::Field(selected.clone()), + }); + cells.push(AddressCell { + target: AddressTarget::Data(source), + guards: parent.guards, + }); + } + let mut valid = address.valid; + valid.push(pc::ScoreComparison { + score: any_valid, + min: Some(1), + max: Some(1), + }); + return Some(ValueAddress { + ty: element, + cells, + valid, + possible: address.possible, + }); + } + let Some((element, length)) = self.array_shape(address.ty) else { + self.error( + "type", + body.file, + value.span(), + "mutable indexing needs an array or vector value", + ); + return None; + }; + let offset = if Self::is_const_in(body, index) { + let offset = self.eval_i32(body.module, body.file, index, Some(Ty::Number), None)?; + if offset < 0 || offset as usize >= length { + self.error( + "index", + body.file, + index.span(), + format!("index {offset} is outside an array of length {length}"), + ); + return None; + } + Some(offset as usize) + } else { + None + }; + let selected = if offset.is_none() { + let selected = self.temp(body); + self.emit(body, &selected, Ty::Number, index, ops)?; + Some(selected) + } else { + None + }; + let mut valid = address.valid; + let possible = address.possible && length > 0; + if let Some(selected) = &selected + && length > 0 + { + valid.push(pc::ScoreComparison { + score: selected.clone(), + min: Some(0), + max: Some(length as i32 - 1), + }); + } + let mut cells = Vec::new(); + for parent in address.cells { + if let AddressTarget::Data(reference) = &parent.target { + let mut reference = reference.clone(); + reference.path.push(pc::DataProjection::Index { + index: selected.clone().map_or( + pc::ScoreOperand::Value(offset.unwrap_or(0) as i32), + pc::ScoreOperand::Field, + ), + }); + cells.push(AddressCell { + target: AddressTarget::Data(reference), + guards: parent.guards, + }); + continue; + } + let AddressTarget::Slots(reference) = &parent.target else { + unreachable!() + }; + for offset in offset.map_or(0..length, |offset| offset..offset + 1) { + let mut guards = parent.guards.clone(); + if let Some(selected) = &selected { + guards.push(pc::ScoreComparison { + score: selected.clone(), + min: Some(offset as i32), + max: Some(offset as i32), + }); + } + cells.push(AddressCell { + target: AddressTarget::Slots(super::values::child( + reference, + &format!("i{offset}"), + )), + guards, + }); + } + } + Some(ValueAddress { + ty: element, + cells, + valid, + possible, + }) + } + + pub(super) fn address_is_guarded(&self, address: &ValueAddress) -> bool { + !address.possible || !address.valid.is_empty() + } + + pub(super) fn guard_address( + &self, + body: &BodyCx, + address: &ValueAddress, + span: Span, + mut inner: Vec, + ) -> Vec { + if !address.possible { + return Vec::new(); + } + for guard in address.valid.iter().rev() { + inner = vec![op_at( + pc::Action::Branch { + condition: pc::Condition::Range(guard.clone()), + then: inner, + otherwise: Vec::new(), + }, + body.file, + span, + )]; + } + inner + } + + fn guard_cell( + &self, + body: &BodyCx, + cell: &AddressCell, + span: Span, + mut inner: Vec, + ) -> Vec { + for guard in cell.guards.iter().rev() { + inner = vec![op_at( + pc::Action::Branch { + condition: pc::Condition::Range(guard.clone()), + then: inner, + otherwise: Vec::new(), + }, + body.file, + span, + )]; + } + inner + } + + pub(super) fn read_address( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + address: &ValueAddress, + span: Span, + ops: &mut Vec, + ) -> Option<()> { + if self.address_is_guarded(address) + || address.cells.len() != 1 + || !address.cells[0].guards.is_empty() + { + let defaults = self.record_constant(body.module, body.file, None, address.ty)?; + for ((score, _), value) in self.value_slots(dest, address.ty).into_iter().zip(defaults) + { + ops.push(op_at(Self::initialize_leaf(score, value), body.file, span)); + } + } + for cell in &address.cells { + let mut inner = Vec::new(); + match &cell.target { + AddressTarget::Slots(reference) => { + self.copy_value(dest, reference, address.ty, body.file, span, &mut inner) + } + AddressTarget::Data(reference) => { + self.unpack_value(body, dest, reference.clone(), address.ty, span, &mut inner) + } + } + let inner = self.guard_cell(body, cell, span, inner); + ops.extend(self.guard_address(body, address, span, inner)); + } + Some(()) + } + + pub(super) fn write_address( + &mut self, + body: &mut BodyCx, + address: &ValueAddress, + source: &pc::FieldReference, + span: Span, + ops: &mut Vec, + ) { + for cell in &address.cells { + let mut inner = Vec::new(); + match &cell.target { + AddressTarget::Slots(reference) => { + self.copy_value(reference, source, address.ty, body.file, span, &mut inner) + } + AddressTarget::Data(reference) => self.pack_value( + body, + reference.clone(), + source, + address.ty, + span, + &mut inner, + ), + } + let inner = self.guard_cell(body, cell, span, inner); + ops.extend(self.guard_address(body, address, span, inner)); + } + } + + pub(super) fn lower_value_assignment( + &mut self, + body: &mut BodyCx, + target: &Expr, + operator: AssignOp, + value: &Expr, + ops: &mut Vec, + ) { + let depth = body.temp_depth; + let span = target.span().to(value.span()); + let Some(address) = self.value_address(body, target, ops) else { + body.temp_depth = depth; + return; + }; + let rhs = self.temp(body); + if self.emit(body, &rhs, address.ty, value, ops).is_none() { + body.temp_depth = depth; + return; + } + let result = if operator == AssignOp::Set { + rhs + } else if address.ty == Ty::String && operator == AssignOp::Add { + let current = self.temp(body); + if self + .read_address(body, ¤t, &address, span, ops) + .is_none() + { + body.temp_depth = depth; + return; + } + ops.push(op_at(Self::append_text(¤t, &rhs), body.file, span)); + current + } else { + if !matches!(address.ty, Ty::Number | Ty::Float) { + self.error( + "type", + body.file, + span, + "compound assignment needs a numeric element", + ); + body.temp_depth = depth; + return; + } + let current = self.temp(body); + if self + .read_address(body, ¤t, &address, span, ops) + .is_none() + { + body.temp_depth = depth; + return; + } + let bin = match operator { + AssignOp::Add => BinOp::Add, + AssignOp::Sub => BinOp::Sub, + AssignOp::Mul => BinOp::Mul, + AssignOp::Div => BinOp::Div, + AssignOp::Rem => BinOp::Rem, + AssignOp::Set => unreachable!(), + }; + if self + .apply( + body.file, + ¤t, + address.ty, + bin, + super::statements::Value::Read(rhs), + span, + ops, + ) + .is_none() + { + body.temp_depth = depth; + return; + } + current + }; + self.write_address(body, &address, &result, span, ops); + body.temp_depth = depth; + } +} + +impl Cx { + pub(super) fn emit_array_method( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Method { + receiver, + name, + args, + span, + .. + } = expr + else { + unreachable!() + }; + let array_ty = self.type_of(body, receiver); + let (element, length) = self.array_shape(array_ty)?; + let Some(builtin) = crate::builtins::array_method(&name.name) else { + self.error( + "method", + body.file, + name.span, + format!("arrays have no method `{}`", name.name), + ); + return None; + }; + if builtin.kind != crate::builtins::BuiltinKind::Expression { + self.error( + "type", + body.file, + *span, + "this array method does not return a value", + ); + return None; + } + self.references_builtin(body.file, name.span, builtin); + let bound = self.bind_args(body, builtin, args, *span)?; + let result_ty = match name.name.as_str() { + "len" => Ty::Number, + "get_or" => element, + _ => Ty::Bool, + }; + if !self.types_agree(body.file, *span, ty, result_ty) { + return None; + } + let depth = body.temp_depth; + let array = self.temp(body); + self.emit(body, &array, array_ty, receiver, ops)?; + match name.name.as_str() { + "len" | "is_empty" => ops.push(op_at( + pc::Action::ScoreSet { + score: dest.clone(), + value: if name.name == "len" { + length as i32 + } else { + i32::from(length == 0) + }, + }, + body.file, + *span, + )), + "contains" => { + let ArgValue::Expr(value) = &bound["value"].value else { + return None; + }; + let needle = self.temp(body); + self.emit(body, &needle, element, value, ops)?; + ops.push(op_at( + pc::Action::ScoreSet { + score: dest.clone(), + value: 0, + }, + body.file, + *span, + )); + let equal = self.temp(body); + for index in 0..length { + let source = super::values::child(&array, &format!("i{index}")); + ops.push(op_at( + pc::Action::ScoreSet { + score: equal.clone(), + value: 1, + }, + body.file, + *span, + )); + for ((left, leaf_ty), (right, _)) in self + .value_slots(&source, element) + .into_iter() + .zip(self.value_slots(&needle, element)) + { + let condition = if leaf_ty == Ty::String { + let matched = self.temp(body); + ops.push(op_at( + pc::Action::DataEqual { + score: matched.clone(), + left: Self::data_reference(&left), + right: Self::data_reference(&right), + }, + body.file, + *span, + )); + pc::Condition::Range(pc::ScoreComparison { + score: matched, + min: Some(1), + max: Some(1), + }) + } else { + pc::Condition::Relation(pc::ScoreRelation { + left, + relation: pc::Relation::Eq, + right, + }) + }; + ops.push(op_at( + pc::Action::Branch { + condition, + then: Vec::new(), + otherwise: vec![op_at( + pc::Action::ScoreSet { + score: equal.clone(), + value: 0, + }, + body.file, + *span, + )], + }, + body.file, + *span, + )); + } + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: equal.clone(), + min: Some(1), + max: Some(1), + }), + then: vec![op_at( + pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + }, + body.file, + *span, + )], + otherwise: Vec::new(), + }, + body.file, + *span, + )); + } + } + "get_or" => { + let mut index = None; + let mut fallback = None; + for arg in args { + let ArgValue::Expr(value) = &arg.value else { + return None; + }; + let temp = self.temp(body); + if std::ptr::eq(arg, bound["index"]) { + self.emit(body, &temp, Ty::Number, value, ops)?; + index = Some(temp); + } else { + self.emit(body, &temp, element, value, ops)?; + fallback = Some(temp); + } + } + self.copy_value(dest, &fallback?, element, body.file, *span, ops); + let index = index?; + for offset in 0..length { + let mut then = Vec::new(); + self.copy_value( + dest, + &super::values::child(&array, &format!("i{offset}")), + element, + body.file, + *span, + &mut then, + ); + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: index.clone(), + min: Some(offset as i32), + max: Some(offset as i32), + }), + then, + otherwise: Vec::new(), + }, + body.file, + *span, + )); + } + } + _ => unreachable!(), + } + body.temp_depth = depth; + Some(()) + } + + pub(super) fn lower_array_statement( + &mut self, + body: &mut BodyCx, + expr: &Expr, + ops: &mut Vec, + ) { + let Expr::Method { + receiver, + name, + args, + span, + .. + } = expr + else { + unreachable!() + }; + let Some(builtin) = crate::builtins::array_method(&name.name) else { + self.error( + "method", + body.file, + name.span, + format!("arrays have no method `{}`", name.name), + ); + return; + }; + if name.name != "fill" { + let ty = self.type_of(body, expr); + let depth = body.temp_depth; + let ignored = self.temp(body); + self.emit(body, &ignored, ty, expr, ops); + body.temp_depth = depth; + return; + } + self.references_builtin(body.file, name.span, builtin); + let Some(bound) = self.bind_args(body, builtin, args, *span) else { + return; + }; + let depth = body.temp_depth; + let Some(address) = self.value_address(body, receiver, ops) else { + return; + }; + let Some((element, length)) = self.array_shape(address.ty) else { + return; + }; + let ArgValue::Expr(value) = &bound["value"].value else { + self.error( + "argument", + body.file, + bound["value"].span, + "array fill needs a value expression", + ); + return; + }; + let replacement = self.temp(body); + if self.emit(body, &replacement, element, value, ops).is_none() { + body.temp_depth = depth; + return; + } + let array = self.temp(body); + self.value_slots(&array, address.ty); + for index in 0..length { + self.copy_value( + &super::values::child(&array, &format!("i{index}")), + &replacement, + element, + body.file, + *span, + ops, + ); + } + self.write_address(body, &address, &array, *span, ops); + body.temp_depth = depth; + } +} diff --git a/sand-lang/src/analysis/continuations.rs b/sand-lang/src/analysis/continuations.rs new file mode 100644 index 00000000..df0be1a8 --- /dev/null +++ b/sand-lang/src/analysis/continuations.rs @@ -0,0 +1,261 @@ +//! Retain each invocation across wait boundaries and join conditional paths. +use super::*; +use crate::builtins::{self, BuiltinKind}; +use std::collections::BTreeSet; + +pub(super) struct WaitSite { + setup: Vec, + ticks: pc::ScoreOperand, + fields: Vec, + span: Span, +} + +impl WaitSite { + pub(super) fn suspend(mut self, file: FileId, body: Vec) -> Vec { + self.setup.push(op_at( + pc::Action::Suspend { + ticks: self.ticks, + fields: self.fields, + body, + }, + file, + self.span, + )); + self.setup + } +} + +impl Cx { + pub(super) fn is_wait(&self, body: &BodyCx, path: &Path) -> bool { + path.segments.len() == 1 + && path.last().name == "wait" + && Self::lookup_local(body, "wait").is_none() + && !self.scopes[body.module.0].contains_key("wait") + } + + pub(super) fn lower_wait( + &mut self, + body: &mut BodyCx, + path: &Path, + args: &[Arg], + span: Span, + ) -> Option { + let file = body.file; + let builtin = builtins::find("wait", BuiltinKind::Statement).expect("registered builtin"); + self.references_builtin(file, path.span, builtin); + if body.owner.is_none() + || body.wait_block_depth != body.block_ends.len() + || body.ret.is_some() + || body.receiver_out.is_some() + { + self.error("wait", file, span, "use `wait` directly in a function body or an if/else branch, with no return value or mutable borrowed receiver"); + return None; + } + let bound = self.bind_args(body, builtin, args, span)?; + let (duration, scale) = match (bound.get("ticks"), bound.get("seconds")) { + (Some(arg), None) => (*arg, 1), + (None, Some(arg)) => (*arg, 20), + _ => { + self.error( + "wait", + file, + span, + "provide exactly one of `ticks` or `seconds`", + ); + return None; + } + }; + let ArgValue::Expr(expr) = &duration.value else { + self.error( + "type", + file, + duration.span, + "expected a number duration, found a range", + ); + return None; + }; + let mut setup = Vec::new(); + let max = i32::MAX / scale; + let ticks = if Self::is_const_in(body, expr) { + pc::ScoreOperand::Value(self.arg_int(body, duration, 1, max.into())? as i32 * scale) + } else { + let found = self.type_of(body, expr); + if !self.types_agree(file, expr.span(), Ty::Number, found) { + return None; + } + let depth = body.temp_depth; + let score = self.temp(body); + let result = self.emit(body, &score, Ty::Number, expr, &mut setup); + body.temp_depth = depth; + result?; + if scale != 1 { + setup.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: score.clone(), + min: Some(1), + max: Some(max), + }), + then: vec![op_at( + pc::Action::ScoreOperation { + score: score.clone(), + operator: pc::ScoreOperator::Mul, + operand: pc::ScoreOperand::Value(scale), + }, + file, + span, + )], + otherwise: vec![op_at( + pc::Action::ScoreSet { + score: score.clone(), + value: 0, + }, + file, + span, + )], + }, + file, + span, + )); + } + pc::ScoreOperand::Field(score) + }; + body.note_executor(span, "retains the executing entity across a wait".into()); + + // An outer binding hidden by a branch local becomes visible again + // after the branch joins. A later declaration in the same scope + // permanently hides the earlier one. + let mut seen = BTreeSet::new(); + let mut definitions = BTreeSet::new(); + for scope in body.scopes.iter().rev() { + if body.block_ends.len() > 1 { + seen.clear(); + } + definitions.extend( + scope + .iter() + .rev() + .filter_map(|(name, def)| seen.insert(name).then_some(*def)), + ); + } + let mut fields = Vec::new(); + for def in definitions { + let root = self.local_ref(def); + let ty = self.local_ty(def); + fields.extend(self.value_slots(&root, ty).into_iter().map(|(field, ty)| { + if matches!(ty, Ty::String | Ty::List(_) | Ty::Callable(_)) { + Self::data_reference(&field).field + } else { + field + } + })); + } + if fields.len() > 64 { + self.error( + "wait", + file, + span, + "a wait can retain at most 64 local fields, including fields of records", + ); + return None; + } + Some(WaitSite { + setup, + ticks, + fields, + span, + }) + } +} + +/// Whether control flow in this function frame can suspend. Selector bodies, +/// loops and value blocks are lowered independently and cannot suspend here. +pub(super) fn may_suspend(operations: &[pc::Operation]) -> bool { + operations.iter().any(|operation| match &operation.action { + pc::Action::Suspend { .. } => true, + pc::Action::Branch { + then, otherwise, .. + } => may_suspend(then) || may_suspend(otherwise), + _ => false, + }) +} + +/// Outline shared suffixes once. Reaching the end of either branch calls its +/// suffix, and suspending retains the suffix call for the resumed path. +pub(super) fn join_wait_paths(function: &mut pc::Function) -> Vec { + if !may_suspend(&function.body) { + return Vec::new(); + } + let mut joins = WaitJoins { + id: &function.id, + context: function.context, + functions: Vec::new(), + }; + joins.rewrite(&mut function.body, None); + joins.functions +} + +struct WaitJoins<'a> { + id: &'a sand::ResourceLocation, + context: pc::ExecutionContext, + functions: Vec, +} + +impl WaitJoins<'_> { + fn rewrite(&mut self, operations: &mut Vec, fallthrough: Option) { + if !may_suspend(operations) { + if !matches!( + operations.last().map(|op| &op.action), + Some(pc::Action::Return) + ) { + operations.extend(fallthrough); + } + return; + } + let mut suffix: Vec<_> = fallthrough.into_iter().collect(); + for mut operation in std::mem::take(operations).into_iter().rev() { + match &mut operation.action { + pc::Action::Suspend { body, .. } => { + // The frontend embeds all following statements in this + // body, so only an enclosing branch contributes a suffix. + debug_assert!(suffix.len() <= 1); + self.rewrite(body, suffix.pop()); + } + pc::Action::Branch { + then, otherwise, .. + } if may_suspend(then) || may_suspend(otherwise) => { + let fallthrough = match suffix.len() { + 0 => None, + 1 if matches!(suffix[0].action, pc::Action::Call { .. }) => suffix.pop(), + _ => { + suffix.reverse(); + let id = sand::ResourceLocation::new( + self.id.namespace(), + format!("__wait/{}/{}", self.functions.len(), self.id.path()), + ) + .expect("validated continuation identity"); + let origin = suffix.first().and_then(|op| op.origin.clone()); + self.functions.push(pc::Function { + id: id.clone(), + context: self.context, + body: std::mem::take(&mut suffix), + }); + Some(pc::Operation { + action: pc::Action::Call { + function: pc::FunctionReference::Internal { id }, + }, + origin, + }) + } + }; + self.rewrite(then, fallthrough.clone()); + self.rewrite(otherwise, fallthrough); + } + _ => {} + } + suffix.push(operation); + } + suffix.reverse(); + *operations = suffix; + } +} diff --git a/sand-lang/src/analysis/generics.rs b/sand-lang/src/analysis/generics.rs new file mode 100644 index 00000000..dab88959 --- /dev/null +++ b/sand-lang/src/analysis/generics.rs @@ -0,0 +1,843 @@ +//! Generic templates have authored identities; concrete instances have separate +//! slots, contexts and call-graph nodes, with references retaining their origins. +use super::*; +use std::collections::{BTreeSet, VecDeque}; + +type TypeBindings = BTreeMap; + +#[derive(Clone)] +pub(super) struct GenericImpl { + contract: Option, + span: Span, + module: ModuleId, + arguments: Vec, + parameters: Vec<(Ident, DefId)>, + methods: Vec<(DefId, Item)>, +} + +pub(super) struct PendingBody { + def: DefId, + source: DefId, + item: Item, + bindings: TypeBindings, +} + +#[derive(Default)] +pub(super) struct Generics { + pub records: BTreeMap)>, + pub record_instances: BTreeMap<(DefId, Vec), DefId>, + pub record_arguments: BTreeMap)>, + pub record_depth: usize, + pub templates: BTreeMap)>, + pub instances: BTreeMap<(DefId, Vec), DefId>, + pub implementations: BTreeMap>, + pub bases: BTreeMap, + pub pending: VecDeque, + pub bindings: BTreeMap, + pub active: Option, + pub origins: BTreeMap, + pub source_defs: BTreeMap<(DefId, FileId, Span), DefId>, +} + +impl Cx { + pub(super) fn register_generic(&mut self, def: DefId, item: &Item, function: &FnItem) { + let owner = self.defs[def.0].clone(); + if let Some(receiver) = &function.receiver + && !self.methods.contains_key(&def) + { + self.error( + "receiver", + owner.file, + receiver.span, + "`self` parameters belong inside an impl block", + ); + } + let parameters = self.generic_parameters(def, &function.generics); + self.collect_trait_bounds(def, function); + for attr in &item.attrs { + if attr.name() != "player" { + self.error( + "generic", + owner.file, + attr.span, + "generic functions are called with concrete types and cannot be entry points", + ); + } + } + if let DefInfo::Function { signature, .. } = &mut self.defs[def.0].info { + let text = &self.package.files[owner.file.0].text; + *signature = text + .get(function.name.span.end..function.body.span.start) + .unwrap_or("") + .trim() + .to_owned(); + } + self.generics + .templates + .insert(def, (item.clone(), parameters)); + } + + pub(super) fn generic_parameters(&mut self, def: DefId, declared: &[Ident]) -> Vec { + let owner = self.defs[def.0].clone(); + self.generic_parameters_at(def, declared, owner.module, owner.file, owner.span) + } + + fn generic_parameters_at( + &mut self, + def: DefId, + declared: &[Ident], + module: ModuleId, + file: FileId, + scope: Span, + ) -> Vec { + let mut names = HashSet::new(); + let mut parameters = Vec::new(); + for name in declared { + if matches!( + name.name.as_str(), + "number" | "float" | "bool" | "string" | "EntityRef" | "Self" | "Vec" + ) { + self.error( + "generic", + file, + name.span, + "a type parameter cannot shadow a builtin type", + ); + } + if !names.insert(name.name.clone()) { + self.error("generic", file, name.span, "duplicate type parameter"); + } + let parameter = self.push_def(Def { + kind: DefKind::TypeParameter, + name: name.name.clone(), + module, + file, + name_span: name.span, + span: scope, + docs: Vec::new(), + is_pub: false, + parent: Some(def), + info: DefInfo::TypeParameter, + }); + let source = self.generics.origins.get(&def).copied().unwrap_or(def); + let key = (source, file, name.span); + if let Some(origin) = self.generics.source_defs.get(&key).copied() { + self.generics.origins.insert(parameter, origin); + } else { + self.generics.source_defs.insert(key, parameter); + } + parameters.push(parameter); + } + parameters + } + + /// Resolve a callable, specializing a template with inferred or explicit types. + pub(super) fn resolve_call( + &mut self, + body: &BodyCx, + path: &Path, + args: &[Arg], + expected: Option, + report: bool, + ) -> Option { + let def = if report { + self.expect_path( + body.module, + path, + &[DefKind::Function, DefKind::ExternFunction], + "a function", + )? + } else { + self.resolve_path(body.module, path).ok()?.0 + }; + self.specialize_call(body, def, path, args, expected, report) + } + + pub(super) fn specialize_call( + &mut self, + body: &BodyCx, + def: DefId, + path: &Path, + args: &[Arg], + expected: Option, + report: bool, + ) -> Option { + let Some((item, parameters)) = self.generics.templates.get(&def).cloned() else { + if !path.arguments().is_empty() && report { + self.error( + "generic", + body.file, + path.span, + "this function has no type parameters", + ); + return None; + } + return Some(def); + }; + let ItemKind::Fn(function) = &item.kind else { + return None; + }; + let mut inferred = BTreeMap::new(); + if !path.arguments().is_empty() { + if path.arguments().len() != parameters.len() { + if report { + self.error( + "generic", + body.file, + path.span, + format!( + "expected {} type arguments, found {}", + parameters.len(), + path.arguments().len() + ), + ); + } + return None; + } + for (name, annotation) in function.generics.iter().zip(path.arguments()) { + let ty = self.resolve_type(body.module, annotation); + inferred.insert(name.name.clone(), ty); + } + } + for (param, arg) in function.params.iter().zip(args) { + if let ArgValue::Expr(value) = &arg.value { + let ty = self.type_of(body, value); + self.infer_type_arguments( + self.defs[def.0].module, + ¶m.ty, + ty, + &function.generics, + &mut inferred, + ); + } + } + if let (Some(ret), Some(expected)) = (&function.ret, expected) { + self.infer_type_arguments( + self.defs[def.0].module, + ret, + expected, + &function.generics, + &mut inferred, + ); + } + let mut types = Vec::new(); + for name in &function.generics { + let ty = inferred.get(&name.name).copied().unwrap_or(Ty::Unknown); + if ty == Ty::Unknown { + if report { + self.error( + "generic", + body.file, + path.span, + format!( + "cannot infer `{}`; supply explicit type arguments with `::<...>`", + name.name + ), + ); + } + return None; + } + types.push(ty); + } + if let Some(bounds) = self.traits.function_bounds.get(&def) { + for &(index, contract) in bounds { + let ty = types[index]; + if !self.trait_bound_holds(ty, contract) { + if report { + self.error( + "trait", + body.file, + path.span, + format!( + "`{}` does not implement trait `{}` required by `{}`", + self.ty_name(ty), + self.defs[contract.0].name, + function.generics[index].name + ), + ); + } + return None; + } + } + } + if let Some(instance) = self.generics.instances.get(&(def, types.clone())) { + let instance = *instance; + if report { + self.specialized_reference(body, path, def, instance); + } + return Some(instance); + } + if self.generics.instances.len() >= 256 { + if report { + self.error( + "generic", + body.file, + path.span, + "a package supports at most 256 generic function specializations", + ); + } + return None; + } + let mut bindings = self.generics.bases.get(&def).cloned().unwrap_or_default(); + bindings.extend( + function + .generics + .iter() + .zip(types.iter().copied()) + .zip(parameters) + .map(|((name, ty), parameter)| (name.name.clone(), (ty, parameter))) + .collect::>(), + ); + let mut concrete = self.defs[def.0].clone(); + if let DefInfo::Function { id, .. } = &mut concrete.info { + *id = format!("{}.generic/{}", id, self.generics.instances.len()); + } + let source = self.generics.origins.get(&def).copied().unwrap_or(def); + let active = self.generics.active.replace(source); + let saved = std::mem::replace(&mut self.generics.bindings, bindings.clone()); + let instance = self.push_def(concrete); + self.generics.origins.insert(instance, source); + self.generics.instances.insert((def, types), instance); + if let Some(method) = self.methods.get(&def).cloned() { + self.methods.insert(instance, method); + } + self.declare_slots( + self.defs[def.0].module, + self.defs[def.0].file, + instance, + &function.params, + function.ret.as_ref(), + ); + self.generics.bindings = saved; + self.generics.active = active; + self.generics.pending.push_back(PendingBody { + def: instance, + source, + item: item.clone(), + bindings, + }); + if report { + self.specialized_reference(body, path, def, instance); + } + Some(instance) + } + + fn specialized_reference( + &mut self, + body: &BodyCx, + path: &Path, + template: DefId, + instance: DefId, + ) { + if let Some(reference) = self + .references + .iter_mut() + .rev() + .find(|r| r.file == body.file && r.span == path.last().span && r.def == template) + { + reference.def = instance; + } + } + + pub(super) fn register_generic_impl( + &mut self, + module: ModuleId, + file: FileId, + target: DefId, + implementation: ImplItem, + scope: Span, + contract: Option, + ) { + let Some((record, _)) = self.generics.records.get(&target) else { + return; + }; + if implementation.target.arguments().len() != record.generics.len() { + self.error( + "generic", + file, + implementation.target.span, + format!( + "this impl needs {} target type arguments", + record.generics.len() + ), + ); + return; + } + for parameter in &implementation.generics { + if !implementation + .target + .arguments() + .iter() + .any(|ty| mentions_parameter(ty, ¶meter.name)) + { + self.error( + "generic", + file, + parameter.span, + "impl type parameter is not determined by the target type", + ); + } + } + let parameter_ids = + self.generic_parameters_at(target, &implementation.generics, module, file, scope); + let mut methods = Vec::new(); + for method in implementation.methods { + if let Some((def, item)) = self.collect_method(module, file, target, false, method) { + if let ItemKind::Fn(function) = &item.kind + && !function.generics.is_empty() + { + self.register_generic(def, &item, function); + } + methods.push((def, item)); + } + } + self.generics + .implementations + .entry(target) + .or_default() + .push(GenericImpl { + contract, + span: scope, + module, + arguments: implementation.target.arguments().to_vec(), + parameters: implementation + .generics + .into_iter() + .zip(parameter_ids) + .collect(), + methods, + }); + } + + fn instantiate_record_methods(&mut self, template: DefId, instance: DefId) { + let implementations = self + .generics + .implementations + .get(&template) + .cloned() + .unwrap_or_default(); + let (_, actual) = self.generics.record_arguments[&instance].clone(); + for implementation in &implementations { + let names: Vec<_> = implementation + .parameters + .iter() + .map(|(name, _)| name.clone()) + .collect(); + let mut inferred = BTreeMap::new(); + for (annotation, ty) in implementation.arguments.iter().zip(&actual) { + self.infer_type_arguments( + implementation.module, + annotation, + *ty, + &names, + &mut inferred, + ); + } + let mut bindings = BTreeMap::new(); + let mut missing = false; + for (name, parameter) in &implementation.parameters { + if let Some(ty) = inferred.get(&name.name) { + bindings.insert(name.name.clone(), (*ty, *parameter)); + } else { + self.error( + "generic", + self.defs[template.0].file, + name.span, + "impl type parameter is not determined by the target type", + ); + missing = true; + } + } + if missing { + continue; + } + bindings.insert("Self".into(), (Ty::Struct(instance), template)); + let saved = std::mem::replace(&mut self.generics.bindings, bindings.clone()); + let resolved: Vec<_> = implementation + .arguments + .iter() + .map(|ty| self.resolve_type(implementation.module, ty)) + .collect(); + if resolved != actual { + self.generics.bindings = saved; + continue; + } + if let Some(contract) = implementation.contract { + self.register_trait_impl( + contract, + instance, + self.package.module(implementation.module).file, + implementation.span, + ); + } + for (source, item) in &implementation.methods { + let ItemKind::Fn(function) = &item.kind else { + continue; + }; + let mut concrete = self.defs[source.0].clone(); + concrete.parent = Some(instance); + if let DefInfo::Function { id, .. } = &mut concrete.info { + *id = format!("{id}.type/{}", instance.0); + } + let active = self.generics.active.replace(*source); + let def = self.push_def(concrete); + self.generics.origins.insert(def, *source); + let mut method = self.methods[source].clone(); + method.target = instance; + self.methods.insert(def, method); + self.members + .get_mut(&instance) + .expect("record members") + .insert(function.name.name.clone(), def); + if function.generics.is_empty() { + self.declare_slots( + implementation.module, + self.defs[source.0].file, + def, + &function.params, + function.ret.as_ref(), + ); + self.generics.pending.push_back(PendingBody { + def, + source: *source, + item: item.clone(), + bindings: bindings.clone(), + }); + } else { + self.register_generic(def, item, function); + self.generics.bases.insert(def, bindings.clone()); + } + self.generics.active = active; + } + self.generics.bindings = saved; + } + } + + /// Instantiate a record using the existing nominal field/layout model. + pub(super) fn instantiate_record( + &mut self, + template: DefId, + types: Vec, + file: FileId, + span: Span, + ) -> Option { + let Some((record, parameters)) = self.generics.records.get(&template).cloned() else { + self.error("generic", file, span, "this type has no type parameters"); + return None; + }; + if types.len() != parameters.len() { + self.error( + "generic", + file, + span, + format!( + "expected {} type arguments, found {}", + parameters.len(), + types.len() + ), + ); + return None; + } + if types.contains(&Ty::Unknown) { + return None; + } + if let Some(instance) = self + .generics + .record_instances + .get(&(template, types.clone())) + { + return Some(Ty::Struct(*instance)); + } + if self.generics.record_instances.len() >= 256 || self.generics.record_depth >= 64 { + self.error( + "generic", + file, + span, + "generic record expansion exceeds 256 instances or 64 nested specializations", + ); + return None; + } + let owner = self.defs[template.0].clone(); + let mut concrete = owner.clone(); + concrete.name = format!( + "{}<{}>", + owner.name, + types + .iter() + .map(|ty| self.ty_name(*ty)) + .collect::>() + .join(", ") + ); + concrete.info = DefInfo::Struct { fields: Vec::new() }; + let active = self.generics.active.replace(template); + let instance = self.push_def(concrete); + self.generics.origins.insert(instance, template); + self.generics + .record_instances + .insert((template, types.clone()), instance); + self.generics + .record_arguments + .insert(instance, (template, types.clone())); + let mut bindings: BTreeMap<_, _> = record + .generics + .iter() + .zip(types) + .zip(parameters) + .map(|((name, ty), parameter)| (name.name.clone(), (ty, parameter))) + .collect(); + bindings.insert("Self".into(), (Ty::Struct(instance), template)); + let saved = std::mem::replace(&mut self.generics.bindings, bindings); + self.generics.record_depth += 1; + let mut fields = Vec::new(); + let mut members = BTreeMap::new(); + for field in self.struct_fields(template) { + let mut concrete = self.defs[field.0].clone(); + concrete.parent = Some(instance); + let next = self.push_def(concrete); + self.generics.origins.insert(next, field); + members.insert(self.defs[field.0].name.clone(), next); + fields.push(next); + } + self.defs[instance.0].info = DefInfo::Struct { + fields: fields.clone(), + }; + self.members.insert(instance, members); + for (field, declared) in fields.into_iter().zip(&record.fields) { + let ty = self.resolve_type(owner.module, &declared.ty); + self.defs[field.0].info = DefInfo::Field { + ty, + default: None, + bounds: None, + timer: false, + }; + } + self.instantiate_record_methods(template, instance); + self.generics.record_depth -= 1; + self.generics.bindings = saved; + self.generics.active = active; + if self.layout_leaves(Ty::Struct(instance)).is_none() { + self.error( + "struct", + file, + span, + "struct layouts must be finite, at most 32 levels deep and 1024 scalar fields", + ); + self.defs[instance.0].info = DefInfo::Struct { fields: Vec::new() }; + return None; + } + Some(Ty::Struct(instance)) + } + + /// A contextual literal can omit arguments; otherwise infer from its fields. + #[allow(clippy::too_many_arguments)] + pub(super) fn record_literal_type( + &mut self, + body: Option<&BodyCx>, + module: ModuleId, + file: FileId, + path: &Path, + fields: &[(Ident, Expr)], + expected: Option, + report: bool, + ) -> Option { + let def = if report { + self.expect_path(module, path, &[DefKind::Struct], "a struct")? + } else { + self.resolve_path(module, path).ok()?.0 + }; + let Some((record, _)) = self.generics.records.get(&def).cloned() else { + if !path.arguments().is_empty() { + if report { + self.error( + "generic", + file, + path.span, + "this record has no type parameters", + ); + } + return None; + } + return Some(Ty::Struct(def)); + }; + if path.arguments().is_empty() + && let Some(Ty::Struct(instance)) = expected + && self + .generics + .record_arguments + .get(&instance) + .is_some_and(|(template, _)| *template == def) + { + return Some(Ty::Struct(instance)); + } + let types = if !path.arguments().is_empty() { + path.arguments() + .iter() + .map(|ty| self.resolve_type(module, ty)) + .collect() + } else { + let mut inferred = BTreeMap::new(); + if let Some(body) = body { + for (name, value) in fields { + if let Some(field) = record + .fields + .iter() + .find(|field| field.name.name == name.name) + { + let ty = self.type_of(body, value); + self.infer_type_arguments( + self.defs[def.0].module, + &field.ty, + ty, + &record.generics, + &mut inferred, + ); + } + } + } + let mut types = Vec::new(); + for name in &record.generics { + let Some(ty) = inferred.get(&name.name).copied() else { + if report { + self.error( + "generic", + file, + path.span, + format!( + "cannot infer `{}`; annotate the value or use `::<...>`", + name.name + ), + ); + } + return None; + }; + types.push(ty); + } + types + }; + self.instantiate_record(def, types, file, path.span) + } + + /// Unification records candidates; the ordinary concrete call checks conflicts. + fn infer_type_arguments( + &mut self, + module: ModuleId, + annotation: &Type, + ty: Ty, + parameters: &[Ident], + inferred: &mut BTreeMap, + ) { + match &annotation.kind { + TypeKind::Named(path) + if path.segments.len() == 1 + && parameters.iter().any(|p| p.name == path.last().name) => + { + if ty != Ty::Unknown { + inferred.entry(path.last().name.clone()).or_insert(ty); + } + } + TypeKind::Applied { path, arguments } + if path.last().name == "Vec" && arguments.len() == 1 => + { + if let Some(element) = self + .list_element(ty) + .or_else(|| self.array_shape(ty).map(|(ty, _)| ty)) + { + self.infer_type_arguments(module, &arguments[0], element, parameters, inferred); + } + } + TypeKind::Applied { path, arguments } => { + if let Ty::Struct(instance) = ty + && let Some((template, types)) = + self.generics.record_arguments.get(&instance).cloned() + && self + .resolve_path(module, path) + .ok() + .is_some_and(|(def, _)| def == template) + { + for (annotation, ty) in arguments.iter().zip(&types) { + self.infer_type_arguments(module, annotation, *ty, parameters, inferred); + } + } + } + TypeKind::Function { + parameters: types, + returns, + } => { + if let Some(signature) = self.callable_signature(ty) { + for (annotation, actual) in types.iter().zip(signature.parameters) { + self.infer_type_arguments(module, annotation, actual, parameters, inferred); + } + if let (Some(annotation), Some(actual)) = (returns, signature.returns) { + self.infer_type_arguments(module, annotation, actual, parameters, inferred); + } + } + } + TypeKind::Array { element, .. } => { + if let Some((ty, _)) = self.array_shape(ty) { + self.infer_type_arguments(module, element, ty, parameters, inferred); + } + } + _ => {} + } + } + + pub(super) fn queue_generated_body(&mut self, def: DefId, item: Item) { + self.generics.pending.push_back(PendingBody { + def, + source: def, + item, + bindings: self.generics.bindings.clone(), + }); + } + + pub(super) fn lower_generic_instances( + &mut self, + modules: &mut [pc::Module], + lowerer: &mut Lowering, + ) { + let mut checked_traits = BTreeSet::new(); + loop { + self.validate_trait_signatures(&mut checked_traits); + let Some(pending) = self.generics.pending.pop_front() else { + break; + }; + let ItemKind::Fn(function) = &pending.item.kind else { + continue; + }; + let module = self.defs[pending.def.0].module; + let file = self.defs[pending.def.0].file; + let saved = std::mem::replace(&mut self.generics.bindings, pending.bindings); + let active = self.generics.active.replace(pending.source); + self.lower_fn( + module, + file, + &pending.item, + function, + pending.def, + &mut modules[module.0], + lowerer, + ); + self.generics.bindings = saved; + self.generics.active = active; + } + } +} + +fn mentions_parameter(ty: &Type, name: &str) -> bool { + match &ty.kind { + TypeKind::Named(path) => path.segments.len() == 1 && path.last().name == name, + TypeKind::Applied { arguments, .. } => { + arguments.iter().any(|ty| mentions_parameter(ty, name)) + } + TypeKind::Function { + parameters, + returns, + } => { + parameters.iter().any(|ty| mentions_parameter(ty, name)) + || returns + .as_ref() + .is_some_and(|ty| mentions_parameter(ty, name)) + } + TypeKind::Array { element, .. } => mentions_parameter(element, name), + } +} diff --git a/sand-lang/src/analysis/mod.rs b/sand-lang/src/analysis/mod.rs new file mode 100644 index 00000000..23e252a0 --- /dev/null +++ b/sand-lang/src/analysis/mod.rs @@ -0,0 +1,5570 @@ +//! Name resolution, type checking, execution-context inference, and lowering. +//! +//! Analysis turns a loaded [`Package`] into Sand's portable +//! [`Program`](sand::advanced::compiler::Program). The portable compiler then +//! validates and emits the datapack, so the language shares one backend with +//! Rust-authored packs. Analysis also records every definition and resolved +//! reference, which powers hover, go-to-definition, references, and rename. + +use crate::ast::*; +use crate::diagnostic::Diagnostic; +use crate::package::{ModuleId, Package}; +use crate::source::FileId; +use sand::advanced::compiler as pc; +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; + +// Minecraft uses floor division, including when the divisor is negative. +// Rust's truncating and Euclidean operations each differ for some signs. +fn floor_div(a: i64, b: i64) -> Option { + let quotient = a.checked_div(b)?; + if a.checked_rem(b)? != 0 && (a < 0) != (b < 0) { + quotient.checked_sub(1) + } else { + Some(quotient) + } +} + +fn floor_rem(a: i64, b: i64) -> Option { + let remainder = a.checked_rem(b)?; + if remainder != 0 && (remainder < 0) != (b < 0) { + remainder.checked_add(b) + } else { + Some(remainder) + } +} + +mod callables; +mod collections; +mod continuations; +mod generics; +mod resources; +mod sequence_methods; +mod sequences; +mod source_map; +mod statements; +mod testing; +mod text; +mod traits; +mod values; + +pub use testing::TestCase; + +/// Index of a definition within an [`Analysis`]. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct DefId(pub usize); + +/// The value type of a constant, field, or expression. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +pub enum Ty { + /// A whole number, stored directly in a score. + Number, + /// A decimal stored as fixed point: the score holds `value * 1000`. + Float, + /// `true` or `false`, stored as one or zero. + Bool, + /// Owned Unicode text stored as a sequence of scalar characters. + String, + /// A growable owned homogeneous sequence. + List(DefId), + /// An enum whose variants are integer phases. + Enum(DefId), + /// A named, copyable record layout. + Struct(DefId), + /// A retained, pack-owned entity identity; zero is empty. + EntityRef, + /// An opaque reference to a checked function with a concrete signature. + Callable(DefId), + /// A type that failed to resolve; suppresses follow-up errors. + Unknown, +} + +/// Where a function runs: on the server, or as a player. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Context { + /// No player executor; callable from anywhere. + Server, + /// Requires a player executor. + Player, + /// Requires an entity executor (any entity, including players). + Entity, +} + +impl Context { + /// Source-facing name. + pub fn name(self) -> &'static str { + match self { + Context::Server => "server", + Context::Player => "player", + Context::Entity => "entity", + } + } +} + +/// What a definition is. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum DefKind { + /// `mod name`. + Module, + /// `const NAME`. + Const, + /// `enum Name`. + Enum, + /// A named record value type. + Struct, + /// A generic declaration's type parameter. + TypeParameter, + /// A named method contract. + Trait, + /// An enum variant. + Variant, + /// `player state` or `global state`. + State, + /// A State field. + Field, + /// `fn name`. + Function, + /// `extern "id" fn name`. + ExternFunction, + /// `flow Name`. + Flow, + /// A `let` binding or function parameter. + Local, + /// `item Name { ... }`. + CustomItem, + /// `recipe name { ... }`. + Recipe, + /// `tag Name: Type { ... }`. + Tag, + /// `event Name(...)`. + Event, + /// `bossbar Name { ... }`. + BossBar, + /// `loot Name { ... }`. + Loot, + /// `damage_type Name { ... }`. + DamageType, + /// `predicate Name { ... }`. + Predicate, + /// `advancement Name { ... }`. + Advancement, + /// `dialog Name { ... }`. + Dialog, + /// `dimension Name { ... }`. + Dimension, + /// `biome Name { ... }`. + Biome, + /// `structure_template Name { ... }`. + StructureTemplate, + /// `inventory_transfer Name { ... }`. + InventoryTransfer, + /// `hud Name { ... }`. + Hud, + /// `menu Name { ... }`. + Menu, +} + +impl DefKind { + /// Source-facing description. + pub fn describe(self) -> &'static str { + match self { + DefKind::Module => "module", + DefKind::Const => "constant", + DefKind::Enum => "enum", + DefKind::Struct => "struct", + DefKind::TypeParameter => "type parameter", + DefKind::Trait => "trait", + DefKind::Variant => "variant", + DefKind::State => "state", + DefKind::Field => "field", + DefKind::Function => "function", + DefKind::ExternFunction => "external function", + DefKind::Flow => "flow", + DefKind::Local => "local variable", + DefKind::CustomItem => "custom item", + DefKind::Recipe => "recipe", + DefKind::Tag => "tag", + DefKind::Event => "event", + DefKind::BossBar => "boss bar", + DefKind::Loot => "loot table", + DefKind::DamageType => "damage type", + DefKind::Predicate => "predicate", + DefKind::Advancement => "advancement", + DefKind::Dialog => "dialog", + DefKind::Dimension => "dimension", + DefKind::Biome => "biome", + DefKind::StructureTemplate => "structure template", + DefKind::InventoryTransfer => "inventory transfer", + DefKind::Hud => "HUD", + DefKind::Menu => "menu", + } + } +} + +/// Kind-specific facts about a definition. +#[derive(Debug, Clone)] +pub enum DefInfo { + /// An interned callable signature. + Callable { + /// Argument types in call order. + parameters: Vec, + /// Return type when the callable produces a value. + returns: Option, + }, + /// A generic type parameter, resolved by each concrete specialization. + TypeParameter, + /// An authored contract with required method signatures. + Trait, + /// A module; `None` when its file could not be loaded. + Module { + /// Loaded module. + target: Option, + }, + /// A constant. + Const { + /// Declared type. + ty: Ty, + /// Evaluated value. + value: Option, + }, + /// An enum. + Enum { + /// Variants in order. + variants: Vec, + }, + /// A named record layout, shared by locals, arguments, returns, and State. + Struct { + /// Field definitions in declaration order. + fields: Vec, + }, + /// An interned fixed-size array using the same leaf layout as records. + Array { + /// Element type. + element: Ty, + /// Compiler-owned element field definitions in index order. + fields: Vec, + }, + /// An interned growable collection; its element may contain nested values. + List { element: Ty }, + /// An enum variant. + Variant { + /// Evaluated discriminant. + value: Option, + }, + /// A State. + State { + /// Ownership scope. + scope: Scope, + /// Minecraft State identity. + id: String, + /// Fields in order. + fields: Vec, + }, + /// A State field. + Field { + /// Value type. + ty: Ty, + /// Initial value. + default: Option, + /// Inclusive clamp bounds. + bounds: Option<(i32, i32)>, + /// Whether the field counts down by itself. + timer: bool, + }, + /// A function. + Function { + /// Minecraft function identity. + id: String, + /// Inferred or declared execution context. + context: Context, + /// Why the function needs a player, when it does. + player_reason: Option, + /// Function tags the function joins, including `#[tick]`/`#[load]`. + entry: Vec, + /// Parameters and return type as written, such as `(cost: number) -> number`. + signature: String, + }, + /// An external function. + ExternFunction { + /// Minecraft function identity. + id: String, + /// Declared context. + context: Context, + }, + /// A flow. + Flow { + /// Minecraft flow identity. + id: String, + }, + /// A data resource declaration. + Data { + /// Declaration kind. + kind: crate::ast::DataKind, + /// Minecraft resource identity. + id: String, + /// The grouped type of a `tag`: `Item`, `Block`, or `Entity`. + tag_type: Option<&'static str>, + }, + /// A local variable or parameter. + Local { + /// Value type. + ty: Ty, + /// Whether it may be reassigned. + mutable: bool, + /// Whether it is a function parameter. + param: bool, + /// The function that owns it. + owner: Option, + }, +} + +/// A named declaration. +#[derive(Debug, Clone)] +pub struct Def { + /// Kind. + pub kind: DefKind, + /// Declared name. + pub name: String, + /// Module the definition belongs to. + pub module: ModuleId, + /// File holding the declaration. + pub file: FileId, + /// Location of the declared name. + pub name_span: Span, + /// Location of the whole declaration. + pub span: Span, + /// Documentation lines. + pub docs: Vec, + /// Whether the definition is visible outside its module. + pub is_pub: bool, + /// Enclosing enum or State for variants and fields. + pub parent: Option, + /// Kind-specific facts. + pub info: DefInfo, +} + +/// A resolved use of a definition. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Reference { + /// File of the use. + pub file: FileId, + /// Location of the referring identifier. + pub span: Span, + /// Referenced definition. + pub def: DefId, +} + +/// Pack metadata from `#![pack(...)]`. +#[derive(Debug, Clone)] +pub struct PackInfo { + /// Namespace for every generated identity. + pub namespace: String, + /// Exact Minecraft target. + pub minecraft: String, + /// `pack.mcmeta` description. + pub description: String, +} + +/// A concrete function's value signature, projected from the shared call slots. +#[derive(Debug, Clone)] +pub struct FunctionType { + /// Parameter definitions in call order, including a struct receiver. + pub parameters: Vec, + /// Returned value type, absent for a statement-only function. + pub returns: Option, +} + +/// The complete result of analysing a package. +#[derive(Debug, Clone)] +pub struct Analysis { + /// The analysed package. + pub package: Package, + /// Every definition. + pub defs: Vec, + /// Concrete specialization definitions mapped to their authored origin. + pub origins: BTreeMap, + /// Concrete signatures shared by compiler and editor value inference. + pub function_types: BTreeMap, + /// Sand-authored tests, in discovery order. + pub tests: Vec, + /// Every resolved reference. + pub references: Vec, + /// Syntax, resolution, and type diagnostics. + pub diagnostics: Vec, + /// Pack metadata, when declared. + pub pack: Option, + /// The lowered portable program; present only without errors. + pub program: Option, + /// Uses of builtin statements and macros, for hover and navigation. + pub builtin_uses: Vec<(FileId, Span, &'static str, crate::builtins::BuiltinKind)>, + /// Where each local variable is visible, for scope-aware completion. + pub local_scopes: Vec<(FileId, Span, DefId)>, + /// Typed vanilla values such as `Item::Diamond`, for hover. + pub vanilla_uses: Vec, + /// Entity properties such as `Player.health`, for hover. + pub property_uses: Vec, + /// Loop bodies where a binding is an entity handle: (file, body, name, + /// whether it is a player), for completion after `zombie.`. + pub handle_scopes: Vec<(FileId, Span, String, bool)>, + /// Program pointers mapped back to source, for backend diagnostics. + pointers: Vec<(String, String, FileId, Span)>, +} + +impl Analysis { + /// Whether any diagnostic is an error. + pub fn has_errors(&self) -> bool { + self.diagnostics + .iter() + .any(|d| d.severity == crate::diagnostic::Severity::Error) + } + + /// The definition a source location names, if any. + pub fn def_at(&self, file: FileId, offset: usize) -> Option { + self.references + .iter() + .filter(|r| r.file == file && r.span.contains(offset)) + .map(|r| (r.span, r.def)) + .chain( + self.defs + .iter() + .enumerate() + .filter(|(_, d)| d.file == file && d.name_span.contains(offset)) + .map(|(i, d)| (d.name_span, DefId(i))), + ) + // Shorthand patterns name both a field and a binding. The local + // is the symbol the author declares or reads at that location. + .min_by_key(|(span, def)| { + ( + span.end - span.start, + self.defs[def.0].kind != DefKind::Local, + ) + }) + .map(|(_, def)| def) + } + + /// Authored identity of a concrete specialization definition. + pub fn origin(&self, def: DefId) -> DefId { + self.origins.get(&def).copied().unwrap_or(def) + } + + /// Definition by id. + pub fn def(&self, id: DefId) -> &Def { + &self.defs[id.0] + } + + /// Compile the lowered program through Sand's portable compiler. + /// + /// Backend diagnostics are mapped back to the Sand source that produced + /// the offending operation or declaration. + pub fn compile(&self) -> Result> { + let Some(program) = &self.program else { + return Err(self.diagnostics.clone()); + }; + pc::Compiler::compile(program) + .map_err(|errors| errors.iter().map(|e| self.map_backend(e)).collect()) + } + + fn map_backend(&self, error: &pc::Diagnostic) -> Diagnostic { + let located = error + .origin + .as_ref() + .and_then(|origin| { + let file = origin.get("file")?.as_u64()? as usize; + let start = origin.get("start")?.as_u64()? as usize; + let end = origin.get("end")?.as_u64()? as usize; + (file < self.package.files.len()).then_some((FileId(file), Span::new(start, end))) + }) + .or_else(|| { + let mut pointer = error.pointer.as_str(); + loop { + if let Some((_, _, file, span)) = self + .pointers + .iter() + .find(|(module, p, _, _)| *module == error.module && p == pointer) + { + return Some((*file, *span)); + } + let (head, _) = pointer.rsplit_once('/')?; + pointer = head; + } + }) + .unwrap_or((FileId(0), Span::default())); + Diagnostic::error( + &format!("backend/{}", error.code), + located.0, + located.1, + error.message.clone(), + ) + } +} + +/// Shared spelling for naming diagnostics and editor rename fixes. +pub(crate) fn name_suggestion(def: &Def) -> Option<(&'static str, String)> { + let name = def.name.trim_start_matches('_'); + if name.is_empty() || def.name_span == Span::default() { + return None; + } + let (style, fixed) = match def.kind { + DefKind::Function + | DefKind::ExternFunction + | DefKind::Field + | DefKind::Local + | DefKind::Module => ("snake_case", snake_case(name).to_ascii_lowercase()), + DefKind::Const => ( + "SCREAMING_SNAKE_CASE", + snake_case(name).to_ascii_uppercase(), + ), + _ => ("PascalCase", pascal_case(name)), + }; + if fixed == name || fixed.is_empty() { + return None; + } + let prefix = &def.name[..def.name.len() - name.len()]; + Some((style, format!("{prefix}{fixed}"))) +} + +/// Convert an identifier to the snake_case used in Minecraft identities. +/// `ruby_sword` or `RUBY_SWORD` -> `RubySword`. +pub fn pascal_case(name: &str) -> String { + snake_case(name) + .split('_') + .filter(|word| !word.is_empty()) + .map(|word| { + let mut chars = word.chars(); + chars + .next() + .map(|first| first.to_ascii_uppercase().to_string() + chars.as_str()) + .unwrap_or_default() + }) + .collect() +} + +/// Lowercase words joined by underscores: `heartPrice` -> `heart_price`. +pub fn snake_case(name: &str) -> String { + let chars: Vec = name.chars().collect(); + let mut out = String::new(); + for (i, &c) in chars.iter().enumerate() { + if c.is_uppercase() { + let prev = i.checked_sub(1).map(|p| chars[p]); + let next = chars.get(i + 1); + let boundary = prev.is_some_and(|p| p.is_lowercase() || p.is_ascii_digit()) + || (prev.is_some_and(char::is_uppercase) && next.is_some_and(|n| n.is_lowercase())); + if boundary && !out.ends_with('_') { + out.push('_'); + } + out.extend(c.to_lowercase()); + } else { + out.push(c); + } + } + out +} + +/// Analyse a loaded package. +pub fn analyze(package: Package) -> Analysis { + analyze_mode(package, false) +} + +/// Lower a package with its discovered test entry points enabled. +pub fn analyze_tests(package: Package) -> Analysis { + analyze_mode(package, true) +} + +fn analyze_mode(package: Package, test_mode: bool) -> Analysis { + let mut cx = Cx { + diagnostics: package.diagnostics.clone(), + package, + defs: Vec::new(), + references: Vec::new(), + scopes: Vec::new(), + members: BTreeMap::new(), + methods: BTreeMap::new(), + record_defaults: BTreeMap::new(), + array_types: BTreeMap::new(), + list_types: BTreeMap::new(), + const_src: BTreeMap::new(), + variant_src: BTreeMap::new(), + memo: BTreeMap::new(), + pack: None, + pointers: Vec::new(), + builtin_uses: Vec::new(), + local_scopes: Vec::new(), + pattern_bindings: BTreeMap::new(), + inferred_block_locals: BTreeMap::new(), + vanilla_uses: Vec::new(), + local_fields: Vec::new(), + local_data_fields: BTreeMap::new(), + text_constants: BTreeMap::new(), + fn_slots: BTreeMap::new(), + generics: generics::Generics::default(), + traits: traits::Traits::default(), + callables: callables::Callables::default(), + test_mode, + tests: BTreeMap::new(), + test_functions: Default::default(), + event_handlers: BTreeMap::new(), + handler_attrs: HashSet::new(), + call_frames: Vec::new(), + property_uses: Vec::new(), + handle_scopes: Vec::new(), + }; + cx.collect(); + cx.resolve_imports(); + cx.pack_info(); + cx.declare_constant_types(); + cx.evaluate_structs(); + cx.evaluate_declarations(); + let program = cx.lower(); + cx.references + .retain(|reference| reference.span.start < reference.span.end); + cx.naming_lints(); + cx.diagnostics + .sort_by_key(|d| (d.file, d.span.start, d.span.end)); + let has_errors = cx + .diagnostics + .iter() + .any(|d| d.severity == crate::diagnostic::Severity::Error); + Analysis { + package: cx.package, + defs: cx.defs, + origins: cx.generics.origins, + tests: cx.tests.into_values().collect(), + function_types: cx + .fn_slots + .into_iter() + .map(|(def, slots)| { + ( + def, + FunctionType { + parameters: slots.params.into_iter().map(|(_, def, _)| def).collect(), + returns: slots.ret.map(|(_, ty)| ty), + }, + ) + }) + .collect(), + references: cx.references, + diagnostics: cx.diagnostics, + pack: cx.pack, + program: if has_errors { None } else { program }, + pointers: cx.pointers, + builtin_uses: cx.builtin_uses, + local_scopes: cx.local_scopes, + vanilla_uses: cx.vanilla_uses, + property_uses: cx.property_uses, + handle_scopes: cx.handle_scopes, + } +} + +#[derive(Debug, Clone, Copy)] +struct Binding { + def: DefId, + is_pub: bool, +} + +#[derive(Clone)] +struct ConstSrc { + module: ModuleId, + file: FileId, + expr: Expr, + ty: Ty, +} + +struct VariantSrc { + module: ModuleId, + file: FileId, + expr: Option, + prev: Option, +} + +#[derive(Debug, Clone, Copy)] +enum Memo { + Evaluating, + Done(Option), +} + +enum Cur { + Module(ModuleId), + Def(DefId), +} + +struct Cx { + package: Package, + defs: Vec, + references: Vec, + diagnostics: Vec, + scopes: Vec>, + members: BTreeMap>, + methods: BTreeMap, + record_defaults: BTreeMap>, + array_types: BTreeMap<(Ty, usize), DefId>, + list_types: BTreeMap, + const_src: BTreeMap, + variant_src: BTreeMap, + memo: BTreeMap, + pack: Option, + pointers: Vec<(String, String, FileId, Span)>, + builtin_uses: Vec<(FileId, Span, &'static str, crate::builtins::BuiltinKind)>, + local_scopes: Vec<(FileId, Span, DefId)>, + pattern_bindings: BTreeMap<(FileId, Span, String), Vec>, + inferred_block_locals: BTreeMap<(FileId, Span, String), DefId>, + vanilla_uses: Vec, + /// Fields of the compiler-owned locals State, in allocation order. + local_fields: Vec, + local_data_fields: BTreeMap, + text_constants: BTreeMap, + /// Parameter and return slots per function. + fn_slots: BTreeMap, + generics: generics::Generics, + traits: traits::Traits, + callables: callables::Callables, + test_mode: bool, + tests: BTreeMap, + test_functions: std::collections::BTreeSet, + /// Handlers of each custom event, in declaration order. + event_handlers: BTreeMap>, + /// `#[on(Event)]` attributes that name a custom event. + handler_attrs: HashSet<(FileId, Span)>, + /// Caller and callee of each frame marker, indexed by marker number. + call_frames: Vec<(Option, DefId)>, + property_uses: Vec, + handle_scopes: Vec<(FileId, Span, String, bool)>, +} + +/// How many score units represent `1.0` in a `float`, matching Rust's +/// default fixed-point scale. +pub(crate) const FLOAT_SCALE: i64 = 1_000; + +/// Whether an expression is a whole-number literal, optionally negated. +pub(crate) fn is_int_literal(expr: &Expr) -> bool { + match expr { + Expr::Int(..) => true, + Expr::Neg(inner, _) => is_int_literal(inner), + _ => false, + } +} + +/// What `value as T` does to the stored score. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(super) enum CastStep { + /// The score is already right. + Same, + /// Multiply by the fixed-point scale. + ToFloat, + /// Divide by the fixed-point scale, rounding down. + ToNumber, + /// One when nonzero, zero otherwise. + ToBool, +} + +/// One entity property written in source, such as `Player.health`. +#[derive(Debug, Clone)] +pub struct PropertyUse { + /// File containing the use. + pub file: FileId, + /// The property name's span. + pub span: Span, + /// The handle as written: `Player` or a loop binding. + pub handle: String, + /// The property. + pub property: crate::properties::Property, +} + +/// One typed vanilla value written in source, such as `Item::Diamond`. +#[derive(Debug, Clone)] +pub struct VanillaUse { + /// File containing the value. + pub file: FileId, + /// The whole `Registry::Variant` path. + pub span: Span, + /// Registry name, such as `Item`. + pub registry: &'static str, + /// Variant name, such as `Diamond`. + pub variant: String, + /// Namespaced identity, such as `minecraft:diamond`. + pub id: String, +} + +/// Where a function's parameters and return value live. +#[derive(Debug, Clone)] +pub(crate) struct FnSlots { + params: Vec<(String, DefId, Ty)>, + ret: Option<(String, Ty)>, + receiver_out: Option<(String, Ty)>, +} + +type Resolved = Result<(DefId, Vec), Box>; + +impl Cx { + fn error(&mut self, code: &str, file: FileId, span: Span, message: impl Into) { + self.diagnostics + .push(Diagnostic::error(code, file, span, message)); + } + + fn push_def(&mut self, def: Def) -> DefId { + let id = DefId(self.defs.len()); + if let Some(template) = self.generics.active { + let key = (template, def.file, def.name_span); + if let Some(origin) = self.generics.source_defs.get(&key) { + self.generics.origins.insert(id, *origin); + } else { + self.generics.source_defs.insert(key, id); + } + } + self.defs.push(def); + id + } + + fn namespace(&self) -> String { + self.pack + .as_ref() + .map(|p| p.namespace.clone()) + .unwrap_or_else(|| "sand".into()) + } + + fn item_id(&self, module: ModuleId, name: &str) -> String { + let module = self.package.module(module); + let mut path: Vec = module.path.clone(); + path.push(snake_case(name)); + format!("{}:{}", self.namespace(), path.join("/")) + } + + /// Warn about names that break the language's naming convention: + /// PascalCase for declared things and typed sets, snake_case for + /// functions, fields, variables, and modules, SCREAMING_SNAKE_CASE for + /// constants. Mirrors Rust's naming lints. + fn naming_lints(&mut self) { + for index in 0..self.defs.len() { + if self.generics.origins.contains_key(&DefId(index)) { + continue; + } + let def = &self.defs[index]; + let Some((style, fixed)) = name_suggestion(def) else { + continue; + }; + let what = def.kind.describe(); + let (file, span) = (def.file, def.name_span); + self.diagnostics.push( + Diagnostic::warning( + "naming", + file, + span, + format!("{what} `{}` should have a {style} name", def.name), + ) + .with_help(format!("rename it to `{fixed}`")), + ); + } + } + + // ── Collection ────────────────────────────────────────────────────────── + + fn collect(&mut self) { + self.scopes = vec![BTreeMap::new(); self.package.modules.len()]; + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + let items = self.package.module(module).items.clone(); + for item in &items { + self.collect_item(module, file, item); + } + } + } + + fn bind(&mut self, module: ModuleId, name: &Ident, file: FileId, binding: Binding) { + if let Some(existing) = self.scopes[module.0].get(&name.name).copied() { + let prior = &self.defs[existing.def.0]; + let diagnostic = Diagnostic::error( + "duplicate", + file, + name.span, + format!("the name `{}` is defined multiple times", name.name), + ) + .with_note(prior.file, prior.name_span, "previous definition here"); + self.diagnostics.push(diagnostic); + return; + } + self.scopes[module.0].insert(name.name.clone(), binding); + } + + fn collect_item(&mut self, module: ModuleId, file: FileId, item: &Item) { + let Some(name) = item.name().cloned() else { + return; + }; + let base = |kind, info| Def { + kind, + name: name.name.clone(), + module, + file, + name_span: name.span, + span: item.span, + docs: item.docs.clone(), + is_pub: item.is_pub, + parent: None, + info, + }; + let def = match &item.kind { + ItemKind::Mod(_) => { + let target = self + .package + .module(module) + .children + .get(&name.name) + .copied(); + let docs = target + .filter(|t| self.package.module(*t).file != file) + .map(|t| { + self.package.files[self.package.module(t).file.0] + .ast + .docs + .clone() + }) + .unwrap_or_default(); + let mut def = base(DefKind::Module, DefInfo::Module { target }); + def.docs.extend(docs); + self.push_def(def) + } + ItemKind::Const(c) => { + let id = self.push_def(base( + DefKind::Const, + DefInfo::Const { + ty: Ty::Unknown, + value: None, + }, + )); + self.const_src.insert( + id, + ConstSrc { + module, + file, + expr: c.value.clone(), + ty: Ty::Unknown, + }, + ); + id + } + ItemKind::Enum(e) => { + let id = self.push_def(base( + DefKind::Enum, + DefInfo::Enum { + variants: Vec::new(), + }, + )); + let mut variants = Vec::new(); + let mut members = BTreeMap::new(); + let mut prev = None; + for variant in &e.variants { + let vid = self.push_def(Def { + kind: DefKind::Variant, + name: variant.name.name.clone(), + module, + file, + name_span: variant.name.span, + span: variant.name.span, + docs: variant.docs.clone(), + is_pub: item.is_pub, + parent: Some(id), + info: DefInfo::Variant { value: None }, + }); + if members.insert(variant.name.name.clone(), vid).is_some() { + self.error( + "duplicate", + file, + variant.name.span, + format!("variant `{}` is declared more than once", variant.name.name), + ); + } + self.variant_src.insert( + vid, + VariantSrc { + module, + file, + expr: variant.value.clone(), + prev, + }, + ); + prev = Some(vid); + variants.push(vid); + } + if variants.is_empty() { + self.error( + "enum", + file, + name.span, + "an enum needs at least one variant to be stored in State", + ); + } + self.defs[id.0].info = DefInfo::Enum { variants }; + self.members.insert(id, members); + id + } + ItemKind::Struct(record) => self.collect_struct(module, file, item, record), + ItemKind::Trait(declaration) => { + self.reject_attrs(file, item); + let def = self.push_def(base(DefKind::Trait, DefInfo::Trait)); + self.collect_trait(def, declaration); + def + } + ItemKind::State(s) => { + let state_id = self.item_id(module, &name.name); + let id = self.push_def(base( + DefKind::State, + DefInfo::State { + scope: s.scope, + id: state_id, + fields: Vec::new(), + }, + )); + let mut fields = Vec::new(); + let mut members = BTreeMap::new(); + for field in &s.fields { + let fid = self.push_def(Def { + kind: DefKind::Field, + name: field.name.name.clone(), + module, + file, + name_span: field.name.span, + span: field.span, + docs: field.docs.clone(), + is_pub: item.is_pub, + parent: Some(id), + info: DefInfo::Field { + ty: Ty::Unknown, + default: None, + bounds: None, + timer: false, + }, + }); + if members.insert(field.name.name.clone(), fid).is_some() { + self.error( + "duplicate", + file, + field.name.span, + format!("field `{}` is declared more than once", field.name.name), + ); + } + fields.push(fid); + } + if let DefInfo::State { fields: f, .. } = &mut self.defs[id.0].info { + *f = fields; + } + self.members.insert(id, members); + id + } + ItemKind::Flow(_) => { + let flow_id = self.item_id(module, &name.name); + self.push_def(base(DefKind::Flow, DefInfo::Flow { id: flow_id })) + } + ItemKind::Fn(_) => { + let fn_id = self.item_id(module, &name.name); + self.push_def(base( + DefKind::Function, + DefInfo::Function { + id: fn_id, + context: Context::Server, + player_reason: None, + entry: Vec::new(), + signature: "()".into(), + }, + )) + } + ItemKind::Event(_) => { + // An event compiles to a dispatcher function, so it takes part + // in context inference and recursion checks like one. + self.push_def(base( + DefKind::Event, + DefInfo::Function { + id: event_id(&self.item_id(module, &name.name)), + context: Context::Server, + player_reason: None, + entry: Vec::new(), + signature: "()".into(), + }, + )) + } + ItemKind::ExternFn(e) => { + let context = if item.attr("player").is_some() { + Context::Player + } else { + Context::Server + }; + self.push_def(base( + DefKind::ExternFunction, + DefInfo::ExternFunction { + id: e.id.clone(), + context, + }, + )) + } + ItemKind::Data(data) => { + let kind = match data.kind { + crate::ast::DataKind::Item => DefKind::CustomItem, + crate::ast::DataKind::Recipe => DefKind::Recipe, + crate::ast::DataKind::Tag => DefKind::Tag, + crate::ast::DataKind::BossBar => DefKind::BossBar, + crate::ast::DataKind::Loot => DefKind::Loot, + crate::ast::DataKind::DamageType => DefKind::DamageType, + crate::ast::DataKind::Predicate => DefKind::Predicate, + crate::ast::DataKind::Advancement => DefKind::Advancement, + crate::ast::DataKind::Dialog => DefKind::Dialog, + crate::ast::DataKind::Dimension => DefKind::Dimension, + crate::ast::DataKind::Biome => DefKind::Biome, + crate::ast::DataKind::StructureTemplate => DefKind::StructureTemplate, + crate::ast::DataKind::InventoryTransfer => DefKind::InventoryTransfer, + crate::ast::DataKind::Hud => DefKind::Hud, + crate::ast::DataKind::Menu => DefKind::Menu, + }; + let tag_type = match (&data.kind, &data.tag_type) { + (crate::ast::DataKind::Tag, Some(ty)) => match ty.name.as_str() { + "Item" => Some("Item"), + "Block" => Some("Block"), + "Entity" => Some("Entity"), + other => { + self.diagnostics.push( + Diagnostic::error( + "tag", + file, + ty.span, + format!("cannot make a tag of `{other}`"), + ) + .with_help("tags group `Item`, `Block`, or `Entity` values"), + ); + None + } + }, + (crate::ast::DataKind::Tag, None) => { + self.diagnostics.push( + Diagnostic::error( + "tag", + file, + name.span, + "a tag needs the type it groups", + ) + .with_help(format!( + "write `tag {}: Item {{ ... }}` (or `Block`, `Entity`)", + name.name + )), + ); + None + } + (_, Some(ty)) => { + self.error( + "syntax", + file, + ty.span, + format!("only tags declare a type; remove `: {}`", ty.name), + ); + None + } + (_, None) => None, + }; + let id = self.item_id(module, &name.name); + self.push_def(base( + kind, + DefInfo::Data { + kind: data.kind, + id, + tag_type, + }, + )) + } + ItemKind::Use(_) | ItemKind::Impl(_) | ItemKind::Error(_) => return, + }; + self.bind( + module, + &name, + file, + Binding { + def, + is_pub: item.is_pub, + }, + ); + } + + // ── Imports and path resolution ───────────────────────────────────────── + + fn resolve_imports(&mut self) { + struct Pending { + module: ModuleId, + file: FileId, + path: Path, + alias: Ident, + is_pub: bool, + } + let mut pending = Vec::new(); + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + for item in self.package.module(module).items.clone() { + if let ItemKind::Use(u) = &item.kind { + let mut flat = Vec::new(); + flatten_use(&u.tree, &[], &mut flat); + for (path, alias) in flat { + pending.push(Pending { + module, + file, + path, + alias, + is_pub: item.is_pub, + }); + } + } + } + } + // Type aliases resolve first; methods then join the same import fixpoint. + let mut implementations = false; + loop { + let mut progressed = false; + let mut remaining = Vec::new(); + for import in pending { + match self.resolve_path(import.module, &import.path) { + Ok((def, refs)) => { + self.references.extend(refs); + self.bind( + import.module, + &import.alias, + import.file, + Binding { + def, + is_pub: import.is_pub, + }, + ); + progressed = true; + } + Err(_) => remaining.push(import), + } + } + pending = remaining; + if !progressed || pending.is_empty() { + if !implementations { + self.collect_impls(); + implementations = true; + if !pending.is_empty() { + continue; + } + } + break; + } + } + for import in pending { + if let Err(diagnostic) = self.resolve_path(import.module, &import.path) { + let mut diagnostic = *diagnostic; + diagnostic.message = format!("unresolved import: {}", diagnostic.message); + self.diagnostics.push(diagnostic); + } + } + } + + fn visible(&self, from: ModuleId, owner: ModuleId, is_pub: bool) -> bool { + if is_pub { + return true; + } + let mut cursor = Some(from); + while let Some(module) = cursor { + if module == owner { + return true; + } + cursor = self.package.module(module).parent; + } + false + } + + fn resolve_path(&mut self, from: ModuleId, path: &Path) -> Resolved { + let file = self.package.module(from).file; + let fail = |span: Span, message: String| { + Err(Box::new(Diagnostic::error("resolve", file, span, message))) + }; + let mut refs = Vec::new(); + let mut cur = Cur::Module(from); + let mut segments = path.segments.iter().peekable(); + let first = segments.peek().expect("non-empty path"); + let method_target = self + .generics + .bindings + .get(&first.name) + .and_then(|(ty, parameter)| match ty { + Ty::Struct(def) | Ty::Enum(def) => Some((*def, *parameter)), + _ => None, + }) + .or_else(|| { + self.methods.iter().find_map(|(def, method)| { + let owner = &self.defs[def.0]; + (owner.module == from + && owner.span.contains(path.span.start) + && (first.name == "Self" + || (first.name == "self" + && path.segments.len() == 1 + && method.state_receiver))) + .then_some((method.target, method.target)) + }) + }); + if let Some((target, reference)) = method_target { + let segment = segments.next().expect("Self"); + refs.push(Reference { + file, + span: segment.span, + def: reference, + }); + cur = Cur::Def(target); + } else { + match first.name.as_str() { + "crate" => { + cur = Cur::Module(ModuleId(0)); + segments.next(); + } + "self" => { + segments.next(); + } + "super" => { + while segments.peek().is_some_and(|s| s.name == "super") { + let segment = segments.next().expect("peeked"); + let Cur::Module(module) = cur else { + unreachable!() + }; + match self.package.module(module).parent { + Some(parent) => cur = Cur::Module(parent), + None => { + return fail( + segment.span, + "there are too many leading `super` keywords".into(), + ); + } + } + } + } + _ => { + let segment = segments.next().expect("peeked"); + let Some(binding) = self.scopes[from.0].get(&segment.name) else { + let mut message = format!("cannot find `{}` in this scope", segment.name); + if self.package.module(from).parent.is_some() + && self.scopes[0].contains_key(&segment.name) + { + message.push_str(&format!( + "; it is defined at the crate root, so import it with `use crate::{};`", + segment.name + )); + } + return fail(segment.span, message); + }; + refs.push(Reference { + file, + span: segment.span, + def: binding.def, + }); + cur = self.enter(binding.def); + } + } + } + while let Some(segment) = segments.next() { + let index = path.segments.len() - segments.len() - 1; + if let Some(application) = path + .applications + .iter() + .find(|application| application.segment + 1 == index) + { + let Cur::Def(def) = cur else { + return fail(path.span, "type arguments require a generic struct".into()); + }; + let types = application + .arguments + .iter() + .map(|ty| self.resolve_type(from, ty)) + .collect(); + let Some(Ty::Struct(instance)) = + self.instantiate_record(def, types, file, path.span) + else { + return fail(path.span, "cannot instantiate this generic type".into()); + }; + cur = Cur::Def(instance); + } + match cur { + Cur::Module(module) => { + let Some(binding) = self.scopes[module.0].get(&segment.name) else { + return fail( + segment.span, + format!( + "cannot find `{}` in `{}`", + segment.name, + self.package.module(module).display_path() + ), + ); + }; + if !self.visible(from, module, binding.is_pub) { + return Err(Box::new( + Diagnostic::error( + "privacy", + file, + segment.span, + format!("`{}` is private", segment.name), + ) + .with_note( + self.defs[binding.def.0].file, + self.defs[binding.def.0].name_span, + "declared here; mark it `pub` to use it from other modules", + ), + )); + } + refs.push(Reference { + file, + span: segment.span, + def: binding.def, + }); + cur = self.enter(binding.def); + } + Cur::Def(def) => { + let parent = &self.defs[def.0]; + let member = self + .members + .get(&def) + .and_then(|members| members.get(&segment.name)) + .copied(); + match (parent.kind, member) { + (DefKind::Enum, Some(variant)) => { + refs.push(Reference { + file, + span: segment.span, + def: variant, + }); + cur = Cur::Def(variant); + } + (DefKind::Enum, None) => { + return fail( + segment.span, + format!( + "no variant named `{}` in enum `{}`", + segment.name, parent.name + ), + ); + } + (DefKind::State | DefKind::Struct, Some(method)) + if self.defs[method.0].kind == DefKind::Function => + { + if !self.visible( + from, + self.defs[method.0].module, + self.defs[method.0].is_pub, + ) { + return fail( + segment.span, + format!("method `{}` is private", segment.name), + ); + } + refs.push(Reference { + file, + span: segment.span, + def: method, + }); + cur = Cur::Def(method); + } + (DefKind::State | DefKind::Struct, _) => { + return fail( + segment.span, + format!( + "State fields are accessed with `.`: write `{}.{}`", + parent.name, segment.name + ), + ); + } + (kind, _) => { + return fail( + segment.span, + format!( + "`{}` is a {} and has no `::` members", + parent.name, + kind.describe() + ), + ); + } + } + } + } + } + match cur { + Cur::Def(def) => Ok((def, refs)), + Cur::Module(module) => { + // Paths ending in a module refer to its declaring `mod` item. + let def = self.defs.iter().position( + |d| matches!(d.info, DefInfo::Module { target: Some(t) } if t == module), + ); + match def { + Some(def) => Ok((DefId(def), refs)), + None => fail(path.span, "expected an item, found the crate root".into()), + } + } + } + } + + fn enter(&self, def: DefId) -> Cur { + match self.defs[def.0].info { + DefInfo::Module { + target: Some(module), + } => Cur::Module(module), + _ => Cur::Def(def), + } + } + + /// Resolve a path expecting particular definition kinds; records references. + fn expect_path( + &mut self, + module: ModuleId, + path: &Path, + kinds: &[DefKind], + what: &str, + ) -> Option { + match self.resolve_path(module, path) { + Ok((def, refs)) => { + self.references.extend(refs); + let found = &self.defs[def.0]; + if !path.arguments().is_empty() + && !matches!(found.kind, DefKind::Function | DefKind::Struct) + { + self.error( + "generic", + self.package.module(module).file, + path.span, + "type arguments require a generic function or struct", + ); + return None; + } + if kinds.contains(&found.kind) { + Some(def) + } else { + let message = format!( + "expected {what}, found {} `{}`", + found.kind.describe(), + found.name + ); + let note = (found.file, found.name_span); + let file = self.package.module(module).file; + self.diagnostics.push( + Diagnostic::error("kind", file, path.span, message).with_note( + note.0, + note.1, + "defined here", + ), + ); + None + } + } + Err(diagnostic) => { + self.diagnostics.push(*diagnostic); + None + } + } + } + + // ── Pack metadata ─────────────────────────────────────────────────────── + + fn pack_info(&mut self) { + let mut namespace = None; + let mut minecraft = None; + let mut description = None; + let mut pack_span = None; + for (index, source) in self.package.files.clone().iter().enumerate() { + let file = FileId(index); + for attr in &source.ast.inner_attrs { + if attr.name() != "pack" { + self.error( + "attribute", + file, + attr.path.span, + format!( + "unknown inner attribute `{}`; only `#![pack(...)]` is supported", + attr.name() + ), + ); + continue; + } + if index != 0 { + self.error( + "attribute", + file, + attr.span, + "`#![pack(...)]` belongs in the package root file", + ); + continue; + } + pack_span = Some(attr.span); + for arg in &attr.args { + let (Some(key), AttrValue::Str(value, _)) = (&arg.key, &arg.value) else { + self.error( + "attribute", + file, + arg.span, + "expected `key = \"value\"` in `#![pack(...)]`", + ); + continue; + }; + match key.name.as_str() { + "namespace" => namespace = Some((value.clone(), arg.span)), + "minecraft" => minecraft = Some(value.clone()), + "description" => description = Some(value.clone()), + other => self.error( + "attribute", + file, + key.span, + format!( + "unknown pack setting `{other}`; expected `namespace`, `minecraft`, or `description`" + ), + ), + } + } + } + } + let root = FileId(0); + let Some((namespace, ns_span)) = namespace else { + let span = pack_span.unwrap_or_default(); + self.diagnostics.push( + Diagnostic::error( + "pack", + root, + span, + "the package root must declare a namespace", + ) + .with_help("add `#![pack(namespace = \"my_pack\")]` at the top of the root file"), + ); + return; + }; + let valid = !namespace.is_empty() + && namespace + .bytes() + .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b"_-.".contains(&b)); + if !valid { + self.error( + "pack", + root, + ns_span, + "namespaces may only contain lowercase letters, digits, `_`, `-`, and `.`", + ); + return; + } + let minecraft = minecraft.unwrap_or_else(latest_target); + let minecraft = if minecraft == "latest" { + sand_version::LATEST_KNOWN.to_string() + } else { + minecraft + }; + if sand_version::registry::variants(&minecraft, "minecraft:item").is_none() { + self.error( + "target", + root, + pack_span.unwrap_or(ns_span), + format!("no verified vanilla catalog for Minecraft {minecraft}"), + ); + return; + } + + let description = description.unwrap_or_else(|| { + let docs = self.package.files[0].ast.docs.join(" "); + if docs.trim().is_empty() { + format!("{namespace} datapack") + } else { + docs.trim().to_string() + } + }); + self.pack = Some(PackInfo { + namespace, + minecraft, + description, + }); + // Identities depend on the namespace; refresh them now that it is known. + for index in 0..self.defs.len() { + let def = &self.defs[index]; + let mut fresh = self.item_id(def.module, &def.name); + if let Some(method) = self.methods.get(&DefId(index)) { + let target = &self.defs[method.target.0]; + fresh = format!( + "{}.method/{}", + self.item_id(target.module, &target.name), + def.name + ); + } else if def.kind == DefKind::Event { + fresh = event_id(&fresh); + } + match &mut self.defs[index].info { + DefInfo::State { id, .. } + | DefInfo::Flow { id } + | DefInfo::Function { id, .. } + | DefInfo::Data { id, .. } => *id = fresh, + _ => {} + } + } + } + + // ── Constants, enums, and State declarations ──────────────────────────── + + fn resolve_type(&mut self, module: ModuleId, annotation: &Type) -> Ty { + match &annotation.kind { + TypeKind::Function { + parameters, + returns, + } => { + let parameters = parameters + .iter() + .map(|ty| self.resolve_type(module, ty)) + .collect(); + let returns = returns.as_ref().map(|ty| self.resolve_type(module, ty)); + self.callable_type( + module, + callables::Signature { + parameters, + returns, + }, + ) + } + TypeKind::Named(path) => self.resolve_named_type(module, path), + TypeKind::Applied { path, arguments } => { + let file = self.package.module(module).file; + if !path.arguments().is_empty() { + self.error( + "generic", + file, + annotation.span, + "duplicate type application", + ); + return Ty::Unknown; + } + if path.segments.len() == 1 && path.last().name == "Vec" { + if arguments.len() != 1 { + self.error( + "type", + file, + annotation.span, + "expected `Vec` with one element type", + ); + return Ty::Unknown; + } + let element = self.resolve_type(module, &arguments[0]); + self.list_type(module, element) + } else { + let Some(def) = + self.expect_path(module, path, &[DefKind::Struct], "a generic struct") + else { + return Ty::Unknown; + }; + let types = arguments + .iter() + .map(|ty| self.resolve_type(module, ty)) + .collect(); + self.instantiate_record(def, types, file, annotation.span) + .unwrap_or(Ty::Unknown) + } + } + TypeKind::Array { element, length } => { + let element = self.resolve_type(module, element); + let file = self.package.module(module).file; + let Some(length) = self.eval_i32(module, file, length, Some(Ty::Number), None) + else { + return Ty::Unknown; + }; + if !(0..=1024).contains(&length) { + self.error( + "type", + file, + annotation.span, + "array length must be between 0 and 1024", + ); + return Ty::Unknown; + } + self.array_type(module, element, length as usize) + } + } + } + + fn resolve_named_type(&mut self, module: ModuleId, ty: &Path) -> Ty { + if let [segment] = ty.segments.as_slice() { + if !ty.arguments().is_empty() + && (self.generics.bindings.contains_key(&segment.name) + || matches!( + segment.name.as_str(), + "number" | "float" | "bool" | "string" | "EntityRef" + )) + { + self.error( + "generic", + self.package.module(module).file, + ty.span, + "this type does not take type arguments", + ); + return Ty::Unknown; + } + if let Some((resolved, parameter)) = self.generics.bindings.get(&segment.name).copied() + { + self.references.push(Reference { + file: self.package.module(module).file, + span: segment.span, + def: parameter, + }); + return resolved; + } + match segment.name.as_str() { + "number" => return Ty::Number, + "float" => return Ty::Float, + "bool" => return Ty::Bool, + "EntityRef" => return Ty::EntityRef, + "string" => return Ty::String, + "i32" => { + let file = self.package.module(module).file; + self.diagnostics.push( + Diagnostic::error( + "type", + file, + segment.span, + "`i32` is written `number` in Sand", + ) + .with_help("use `number` for whole numbers or `float` for decimals"), + ); + return Ty::Unknown; + } + "timer" => { + let file = self.package.module(module).file; + self.diagnostics.push( + Diagnostic::error( + "type", + file, + segment.span, + "`timer` is only for `state` fields", + ) + .with_help("use `number` to hold a duration here"), + ); + return Ty::Unknown; + } + _ => {} + } + } + match self.expect_path( + module, + ty, + &[DefKind::Enum, DefKind::Struct], + "a type (`number`, `float`, `bool`, `string`, `EntityRef`, enum, or struct)", + ) { + Some(def) if self.defs[def.0].kind == DefKind::Struct => { + if self.generics.records.contains_key(&def) || !ty.arguments().is_empty() { + let types = ty + .arguments() + .iter() + .map(|ty| self.resolve_type(module, ty)) + .collect(); + self.instantiate_record(def, types, self.package.module(module).file, ty.span) + .unwrap_or(Ty::Unknown) + } else { + Ty::Struct(def) + } + } + Some(def) => Ty::Enum(def), + None => Ty::Unknown, + } + } + + fn ty_name(&self, ty: Ty) -> String { + match ty { + Ty::Number => "number".into(), + Ty::Float => "float".into(), + Ty::Bool => "bool".into(), + Ty::Enum(def) | Ty::Struct(def) | Ty::Callable(def) => self.defs[def.0].name.clone(), + Ty::EntityRef => "EntityRef".into(), + Ty::String => "string".into(), + Ty::List(def) => self.defs[def.0].name.clone(), + Ty::Unknown => "{unknown}".into(), + } + } + + fn declare_constant_types(&mut self) { + // Scalar annotations precede composite lengths, including forward + // references, so a bool constant cannot silently become an array size. + for named in [true, false] { + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + for item in self.package.module(module).items.clone() { + let ItemKind::Const(c) = item.kind else { + continue; + }; + if matches!(c.ty.kind, TypeKind::Named(_)) != named { + continue; + } + let Some(def) = self.def_by_span(module, c.name.span) else { + continue; + }; + let ty = self.resolve_type(module, &c.ty); + if let Some(source) = self.const_src.get_mut(&def) { + source.ty = ty; + } + } + } + } + } + + fn evaluate_declarations(&mut self) { + let consts: Vec = self.const_src.keys().copied().collect(); + for def in consts { + let ty = self.const_src[&def].ty; + if ty == Ty::String { + let source = self.const_src[&def].clone(); + if let Some(value) = + self.constant_text(source.module, source.file, &source.expr, &mut vec![def]) + { + self.text_constants.insert(def, value); + } + self.defs[def.0].info = DefInfo::Const { ty, value: None }; + continue; + } + let value = self.eval_def(def); + self.defs[def.0].info = DefInfo::Const { ty, value }; + } + let variants: Vec = self.variant_src.keys().copied().collect(); + for def in variants { + let value = self.eval_def(def); + self.defs[def.0].info = DefInfo::Variant { value }; + } + // Enums must use distinct discriminants to be told apart in State. + let enums: Vec = (0..self.defs.len()) + .map(DefId) + .filter(|d| self.defs[d.0].kind == DefKind::Enum) + .collect(); + for def in enums { + let DefInfo::Enum { variants } = self.defs[def.0].info.clone() else { + continue; + }; + let mut seen: HashMap = HashMap::new(); + for variant in variants { + let DefInfo::Variant { value: Some(v) } = self.defs[variant.0].info else { + continue; + }; + if let Some(prior) = seen.insert(v, variant) { + let (pf, ps) = (self.defs[prior.0].file, self.defs[prior.0].name_span); + let d = &self.defs[variant.0]; + self.diagnostics.push( + Diagnostic::error( + "enum", + d.file, + d.name_span, + format!("discriminant {v} is already used"), + ) + .with_note(pf, ps, "first used here"), + ); + } + } + } + // State fields: types, defaults, and bounds. + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + for item in self.package.module(module).items.clone() { + let ItemKind::State(state) = &item.kind else { + continue; + }; + for attr in &item.attrs { + self.error( + "attribute", + file, + attr.path.span, + format!("unknown attribute `{}` on a state", attr.name()), + ); + } + let Some(state_def) = self.def_by_span(module, state.name.span) else { + continue; + }; + let field_defs = match &self.defs[state_def.0].info { + DefInfo::State { fields, .. } => fields.clone(), + _ => continue, + }; + for (field, def) in state.fields.iter().zip(field_defs) { + self.field(module, file, field, def); + } + } + } + } + + fn field(&mut self, module: ModuleId, file: FileId, field: &Field, def: DefId) { + let timer = matches!(&field.ty.kind, TypeKind::Named(path) if matches!(path.segments.as_slice(), [s] if s.name == "timer")); + let ty = if timer { + Ty::Number + } else { + self.resolve_type(module, &field.ty) + }; + if field.name.name.starts_with("__sand_record_") + || field.name.name.starts_with("__sand_data_") + { + self.error( + "field", + file, + field.name.span, + "`__sand_record_` is reserved for struct storage", + ); + } + let default = if matches!( + ty, + Ty::Struct(_) | Ty::String | Ty::List(_) | Ty::Callable(_) + ) { + if let Some(defaults) = self.record_constant(module, file, field.default.as_ref(), ty) { + self.record_defaults.insert(def, defaults); + } + None + } else { + match (&field.default, ty) { + (Some(expr), _) => self.eval_i32(module, file, expr, Some(ty), None), + (None, Ty::Enum(e)) => match &self.defs[e.0].info { + DefInfo::Enum { variants } => { + variants.first().and_then(|v| match self.defs[v.0].info { + DefInfo::Variant { value } => value, + _ => None, + }) + } + _ => None, + }, + (None, _) => Some(0), + } + }; + let mut bounds = None; + for attr in &field.attrs { + if attr.name() != "clamp" { + self.error( + "attribute", + file, + attr.path.span, + format!( + "unknown field attribute `{}`; expected `#[clamp(min..=max)]`", + attr.name() + ), + ); + continue; + } + if !matches!(ty, Ty::Number | Ty::Float) || timer { + self.error( + "attribute", + file, + attr.span, + "only `number` and `float` fields can be clamped", + ); + continue; + } + let [ + AttrArg { + key: None, + value: AttrValue::Range(range), + .. + }, + ] = attr.args.as_slice() + else { + self.error( + "attribute", + file, + attr.span, + "expected `#[clamp(min..=max)]`", + ); + continue; + }; + let (Some(start), Some(end)) = (&range.start, &range.end) else { + self.error( + "attribute", + file, + range.span, + "clamp needs both bounds, like `0..=100`", + ); + continue; + }; + let min = self.eval_i32(module, file, start, Some(ty), None); + let max = self.eval_i32(module, file, end, Some(ty), None); + let max = max.map(|m| if range.inclusive { m } else { m - 1 }); + if let (Some(min), Some(max)) = (min, max) { + if min > max { + self.error("range", file, range.span, "clamp range is empty"); + } else { + bounds = Some((min as i32, max as i32)); + if let Some(d) = default + && (d < min || d > max) + { + self.diagnostics.push(Diagnostic::warning( + "clamp", + file, + field.default.as_ref().map(Expr::span).unwrap_or(field.name.span), + format!( + "default {d} is outside the clamp range {min}..={max}; Sand keeps the declared default until the first write" + ), + )); + } + } + } + } + self.defs[def.0].info = DefInfo::Field { + ty, + default, + bounds, + timer, + }; + } + + fn def_by_span(&self, module: ModuleId, span: Span) -> Option { + let file = self.package.module(module).file; + self.defs + .iter() + .enumerate() + .find(|(index, d)| { + d.file == file + && d.name_span == span + && !self.generics.origins.contains_key(&DefId(*index)) + }) + .map(|(index, _)| DefId(index)) + } + + fn eval_def(&mut self, def: DefId) -> Option { + match self.memo.get(&def) { + Some(Memo::Done(value)) => return *value, + Some(Memo::Evaluating) => { + let d = &self.defs[def.0]; + let (file, span, name) = (d.file, d.name_span, d.name.clone()); + self.error( + "cycle", + file, + span, + format!("cycle detected while evaluating `{name}`"), + ); + self.memo.insert(def, Memo::Done(None)); + return None; + } + None => {} + } + self.memo.insert(def, Memo::Evaluating); + let value = if let Some(src) = self.const_src.get(&def) { + let (module, file, expr, ty) = (src.module, src.file, src.expr.clone(), src.ty); + self.eval_i32(module, file, &expr, Some(ty), None) + } else if let Some(src) = self.variant_src.get(&def) { + let (module, file, expr, prev) = (src.module, src.file, src.expr.clone(), src.prev); + match expr { + Some(expr) => self.eval_i32(module, file, &expr, Some(Ty::Number), None), + None => match prev { + None => Some(0), + Some(prev) => self.eval_def(prev).and_then(|v| { + let next = v + 1; + if next > i32::MAX as i64 { + let d = &self.defs[def.0]; + let (file, span) = (d.file, d.name_span); + self.error("range", file, span, "discriminant overflows i32"); + None + } else { + Some(next) + } + }), + }, + } + } else { + None + }; + self.memo.insert(def, Memo::Done(value)); + value + } + + /// Evaluate a constant expression and require it to fit in an i32. + fn eval_i32( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + expected: Option, + bare: Option, + ) -> Option { + let (value, ty) = self.eval(module, file, expr, bare)?; + if let Some(expected) = expected + && expected != Ty::Unknown + && ty != Ty::Unknown + && expected != ty + { + // A whole-number literal is a valid decimal: `speed: float = 1`. + if expected == Ty::Float && ty == Ty::Number && is_int_literal(expr) { + return Some(value * FLOAT_SCALE); + } + let message = format!( + "mismatched types: expected `{}`, found `{}`", + self.ty_name(expected), + self.ty_name(ty) + ); + let mut diagnostic = Diagnostic::error("type", file, expr.span(), message); + if let (Ty::Number, Ty::Enum(_)) = (expected, ty) { + diagnostic = diagnostic.with_help("convert the variant with `as number`"); + } + self.diagnostics.push(diagnostic); + return None; + } + if value < i32::MIN as i64 || value > i32::MAX as i64 { + self.error( + "range", + file, + expr.span(), + format!("{value} does not fit in an i32 score"), + ); + return None; + } + Some(value) + } + + fn eval( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + bare: Option, + ) -> Option<(i64, Ty)> { + match expr { + Expr::Int(value, _) => Some((*value, Ty::Number)), + Expr::Path(path) => { + // Inside a flow, bare variant names refer to the field's enum. + if let (Some(enum_def), [segment]) = (bare, path.segments.as_slice()) + && let Some(variant) = self + .members + .get(&enum_def) + .and_then(|m| m.get(&segment.name)) + .copied() + && !self.scopes[module.0].contains_key(&segment.name) + { + self.references.push(Reference { + file, + span: segment.span, + def: variant, + }); + let value = self.eval_def(variant)?; + return Some((value, Ty::Enum(enum_def))); + } + let def = self.expect_path( + module, + path, + &[DefKind::Const, DefKind::Variant], + "a constant or enum variant", + )?; + let value = self.eval_def(def)?; + let ty = match self.defs[def.0].kind { + DefKind::Variant => Ty::Enum(self.defs[def.0].parent.expect("variant owner")), + _ => self + .const_src + .get(&def) + .map(|s| s.ty) + .unwrap_or(Ty::Unknown), + }; + Some((value, ty)) + } + Expr::Float(value, _) => Some(((value * FLOAT_SCALE as f64).round() as i64, Ty::Float)), + Expr::Bool(value, _) => Some((i64::from(*value), Ty::Bool)), + Expr::Str { span, .. } => { + self.error("type", file, *span, "expected a constant value"); + None + } + Expr::Cond(_, span) => { + self.error("const", file, *span, "a condition is not a constant"); + None + } + Expr::Call { span, path, .. } => { + self.error( + "const", + file, + *span, + format!("`{}(...)` is not a constant", path.display()), + ); + None + } + Expr::Place(place) => { + self.diagnostics.push( + Diagnostic::error( + "const", + file, + place.span, + "expected a constant value, found a State field", + ) + .with_help( + "Sand currently writes constants into State; copying one field into another is not supported yet", + ), + ); + None + } + Expr::Neg(inner, span) => { + let (value, ty) = self.eval(module, file, inner, bare)?; + if let Ty::Enum(_) = ty { + self.error("type", file, *span, "cannot negate an enum variant"); + return None; + } + Some((-value, ty)) + } + Expr::Binary(lhs, op, rhs, span) => { + let (mut a, ta) = self.eval(module, file, lhs, bare)?; + let (mut b, tb) = self.eval(module, file, rhs, bare)?; + let bad = |t: Ty| matches!(t, Ty::Enum(_) | Ty::Bool); + if bad(ta) || bad(tb) { + self.diagnostics.push( + Diagnostic::error( + "type", + file, + *span, + "arithmetic needs `number` or `float` operands", + ) + .with_help("convert variants with `as number`"), + ); + return None; + } + // A whole-number literal joins a decimal calculation. + let float = match (ta, tb) { + (Ty::Float, Ty::Number) if is_int_literal(rhs) => { + b *= FLOAT_SCALE; + true + } + (Ty::Number, Ty::Float) if is_int_literal(lhs) => { + a *= FLOAT_SCALE; + true + } + (Ty::Float, Ty::Float) => true, + (Ty::Number, Ty::Number) => false, + (Ty::Unknown, _) | (_, Ty::Unknown) => false, + _ => { + self.diagnostics.push( + Diagnostic::error( + "type", + file, + *span, + "cannot mix `number` and `float` here", + ) + .with_help("convert one side with `as float` or `as number`"), + ); + return None; + } + }; + let result = match op { + BinOp::Add => a.checked_add(b), + BinOp::Sub => a.checked_sub(b), + BinOp::Mul if float => a.checked_mul(b).and_then(|v| floor_div(v, FLOAT_SCALE)), + BinOp::Mul => a.checked_mul(b), + BinOp::Div | BinOp::Rem if b == 0 => { + self.error("const", file, rhs.span(), "division by zero"); + return None; + } + BinOp::Div if float => a.checked_mul(FLOAT_SCALE).and_then(|v| floor_div(v, b)), + BinOp::Div => floor_div(a, b), + BinOp::Rem => floor_rem(a, b), + }; + match result { + Some(value) => Some((value, if float { Ty::Float } else { Ty::Number })), + None => { + self.error("range", file, *span, "constant arithmetic overflows"); + None + } + } + } + Expr::Closure(closure) => { + self.error("const", file, closure.span, "a closure is a runtime value"); + None + } + Expr::Struct { span, .. } + | Expr::Method { span, .. } + | Expr::Project(_, _, span) + | Expr::Array(_, span) + | Expr::Match { span, .. } + | Expr::Block { span, .. } + | Expr::ArrayRepeat { span, .. } + | Expr::Index(_, _, span) => { + self.error( + "const", + file, + *span, + "expected a scalar constant expression", + ); + None + } + Expr::Cast(inner, ty, span) => { + let (value, from) = self.eval(module, file, inner, bare)?; + let to = self.cast_target(module, file, ty)?; + let step = match self.cast_step(from, to) { + Ok(step) => step, + Err((message, help)) => { + self.diagnostics + .push(Diagnostic::error("type", file, *span, message).with_help(help)); + return None; + } + }; + let value = match step { + CastStep::Same => value, + CastStep::ToFloat => value * FLOAT_SCALE, + CastStep::ToNumber => value.div_euclid(FLOAT_SCALE), + CastStep::ToBool => i64::from(value != 0), + }; + if let Ty::Enum(def) = to + && from != to + { + let variants = match &self.defs[def.0].info { + DefInfo::Enum { variants } => variants.clone(), + _ => Vec::new(), + }; + if !variants.iter().any(|v| self.eval_def(*v) == Some(value)) { + let name = self.defs[def.0].name.clone(); + self.diagnostics.push( + Diagnostic::error( + "range", + file, + *span, + format!("no `{name}` variant has the value {value}"), + ) + .with_help(format!( + "`{name}` variants are numbered from 0 in declaration order unless given a value" + )), + ); + return None; + } + } + Some((value, to)) + } + } + } + + /// The type named after `as`, reporting unknown names. + pub(super) fn cast_target(&mut self, module: ModuleId, file: FileId, ty: &Type) -> Option { + let _ = file; + match self.resolve_type(module, ty) { + Ty::Unknown => None, + ty => Some(ty), + } + } + + /// The type named after `as`, resolved without diagnostics. + pub(super) fn cast_target_quiet(&mut self, module: ModuleId, annotation: &Type) -> Ty { + let TypeKind::Named(ty) = &annotation.kind else { + return Ty::Unknown; + }; + if let [segment] = ty.segments.as_slice() { + if let Some((ty, _)) = self.generics.bindings.get(&segment.name) { + return *ty; + } + match segment.name.as_str() { + "number" => return Ty::Number, + "float" => return Ty::Float, + "bool" => return Ty::Bool, + "EntityRef" => return Ty::EntityRef, + "string" => return Ty::String, + _ => {} + } + } + match self.resolve_path(module, ty) { + Ok((def, _)) if self.defs[def.0].kind == DefKind::Enum => Ty::Enum(def), + _ => Ty::Unknown, + } + } + + /// How `value as T` converts a `from` value into `to`, or why it cannot. + /// + /// | from \\ to | number | float | bool | enum | + /// |---|---|---|---|---| + /// | number | same | ×1000 | `!= 0` | same value | + /// | float | rounds down | same | `!= 0` | — | + /// | bool | 0 or 1 | 0.0 or 1.0 | same | — | + /// | enum | its value | its value | — | same enum only | + pub(super) fn cast_step(&self, from: Ty, to: Ty) -> Result { + if matches!( + from, + Ty::Struct(_) | Ty::EntityRef | Ty::String | Ty::List(_) | Ty::Callable(_) + ) || matches!( + to, + Ty::Struct(_) | Ty::EntityRef | Ty::String | Ty::List(_) | Ty::Callable(_) + ) { + return Err(( + "struct, string and entity-reference values cannot be cast".into(), + "format scalars with `.to_string()`, use scalar fields, or resolve the entity reference", + )); + } + Ok(match (from, to) { + (Ty::Unknown, _) | (_, Ty::Unknown) => CastStep::Same, + (a, b) if a == b => CastStep::Same, + (Ty::Number | Ty::Bool | Ty::Enum(_), Ty::Number) => CastStep::Same, + (Ty::Float, Ty::Number) => CastStep::ToNumber, + (Ty::Number | Ty::Bool | Ty::Enum(_), Ty::Float) => CastStep::ToFloat, + (Ty::Number | Ty::Float, Ty::Bool) => CastStep::ToBool, + (Ty::Number, Ty::Enum(_)) => CastStep::Same, + (Ty::Enum(_), Ty::Bool) => { + return Err(( + format!("cannot cast `{}` to `bool`", self.ty_name(from)), + "compare the variant instead, such as `phase == Phase::Busy`", + )); + } + (Ty::Bool, Ty::Enum(_)) => { + return Err(( + format!("cannot cast `bool` to `{}`", self.ty_name(to)), + "branch on the flag instead: `if flag { ... }`", + )); + } + (Ty::Float, Ty::Enum(_)) => { + return Err(( + format!("cannot cast `float` to `{}`", self.ty_name(to)), + "convert to a whole number first: `(value as number) as Phase`", + )); + } + (Ty::Enum(_), Ty::Enum(_)) => { + return Err(( + format!( + "cannot cast `{}` to `{}`", + self.ty_name(from), + self.ty_name(to) + ), + "go through its value: `value as number as Other`", + )); + } + _ => CastStep::Same, + }) + } + + // ── Lowering ──────────────────────────────────────────────────────────── + + fn lower(&mut self) -> Option { + let pack = self.pack.clone()?; + let mut lowerer = Lowering::default(); + self.declare_signatures(); + let mut modules = Vec::new(); + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + modules.push(self.lower_module(module, &mut lowerer)); + } + self.lower_generic_instances(&mut modules, &mut lowerer); + self.lower_callable_dispatchers(&mut lowerer); + self.infer_contexts(&mut lowerer); + self.validate_callable_contexts(); + self.discover_tests(&lowerer); + self.resolve_frames(&mut lowerer); + if (!self.local_fields.is_empty() || !self.local_data_fields.is_empty()) + && let Some(root) = modules.first_mut() + && let Ok(id) = self.locals_state_id().parse() + { + // One compiler-owned global State holds every local, parameter, + // return value, and temporary slot. + root.states.push(pc::State { + data_fields: self + .local_data_fields + .iter() + .map(|(name, default)| pc::DataField { + name: name.clone(), + default: default.clone(), + }) + .collect(), + id, + scope: "global".into(), + revision: 1, + fields: self + .local_fields + .iter() + .map(|name| pc::ScoreField { + name: name.clone(), + default: 0, + bounds: None, + timer: false, + }) + .collect(), + }); + } + // Contexts are known; finalise function declarations. + for (index, module) in modules.iter_mut().enumerate() { + for pending in lowerer.functions.iter().filter(|f| f.module.0 == index) { + if !self.test_mode + && pending + .def + .is_some_and(|def| self.test_functions.contains(&def)) + { + continue; + } + let context = match pending.def { + Some(def) => match &self.defs[def.0].info { + DefInfo::Function { context, .. } => *context, + _ => Context::Server, + }, + None => pending.fixed.unwrap_or(Context::Server), + }; + let ptr = format!("/functions/{}", module.functions.len()); + self.pointers + .push((module.id.to_string(), ptr, pending.file, pending.name_span)); + let Ok(id) = pending.id.parse() else { + self.error( + "id", + pending.file, + pending.name_span, + format!("`{}` is not a valid function identity", pending.id), + ); + continue; + }; + let mut function = pc::Function { + id, + context: match context { + Context::Server => pc::ExecutionContext::Server, + Context::Player => pc::ExecutionContext::Player, + Context::Entity => pc::ExecutionContext::Entity, + }, + body: pending.body.clone(), + }; + let joins = continuations::join_wait_paths(&mut function); + module.functions.push(function); + for join in joins { + let ptr = format!("/functions/{}", module.functions.len()); + self.pointers.push(( + module.id.to_string(), + ptr, + pending.file, + pending.name_span, + )); + module.functions.push(join); + } + } + } + if self.test_mode { + for (index, (def, test)) in self.tests.iter().enumerate() { + let module = self.defs[def.0].module.0; + if let Some(function) = self.test_wrapper(*def, test, index) { + let ptr = format!("/functions/{}", modules[module].functions.len()); + self.pointers + .push((modules[module].id.to_string(), ptr, test.file, test.span)); + modules[module].functions.push(function); + lowerer.raw = true; + } + } + } + let mut requires = Vec::new(); + if lowerer.raw { + requires.push("raw_commands".to_string()); + } + let structure_assets = modules + .iter() + .flat_map(|module| &module.structure_templates) + .map(|template| template.source_path()) + .collect::>() + .into_iter() + .filter_map(|path| { + let bytes = self.package.structure_assets.get(path)?.as_ref().ok()?; + Some((path.to_owned(), bytes.clone())) + }) + .collect(); + Some(pc::Program { + format: "sand.program".into(), + format_version: 1, + target: pc::ProgramTarget { + minecraft: pack.minecraft.clone(), + }, + pack: pc::Pack { + namespace: pack.namespace.clone(), + description: pack.description.clone(), + }, + requires, + modules, + structure_assets, + }) + } + + fn locals_state_id(&self) -> String { + format!("{}:sand.locals", self.namespace()) + } + + /// Resolve every function's parameters and return type before bodies are + /// lowered, so calls can target functions declared later. + fn declare_signatures(&mut self) { + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + for item in self.package.module(module).items.clone() { + match &item.kind { + ItemKind::Fn(function) if !function.generics.is_empty() => { + if let Some(def) = self.def_by_span(module, function.name.span) { + self.register_generic(def, &item, function); + } + } + ItemKind::Fn(function) => { + if let Some(receiver) = &function.receiver { + self.error( + "receiver", + file, + receiver.span, + "`self` parameters belong inside an impl block", + ); + } + if let Some(def) = self.def_by_span(module, function.name.span) { + self.declare_slots( + module, + file, + def, + &function.params, + function.ret.as_ref(), + ); + self.declare_test(def, &item, function); + } + } + ItemKind::Event(event) => { + if let Some(def) = self.def_by_span(module, event.name.span) { + self.declare_slots(module, file, def, &event.params, None); + } + } + _ => {} + } + } + } + self.collect_event_handlers(); + } + + /// Parameters and return slot of one declared function or event. + fn declare_slots( + &mut self, + module: ModuleId, + file: FileId, + owner: DefId, + declared: &[Param], + ret: Option<&Type>, + ) { + let mut params = Vec::new(); + let mut seen = HashSet::new(); + let mut rendered = Vec::new(); + for param in declared { + if !seen.insert(param.name.name.clone()) { + self.error( + "duplicate", + file, + param.name.span, + format!("parameter `{}` is declared more than once", param.name.name), + ); + } + let ty = self.resolve_type(module, ¶m.ty); + if param.name.name == "self" + && let Some(receiver) = self + .methods + .get(&owner) + .and_then(|method| method.receiver.as_ref()) + && receiver.borrowed + { + rendered.push(format!( + "&{}self", + if receiver.mutable { "mut " } else { "" } + )); + } else { + rendered.push(format!( + "{}{}: {}", + if param.mutable { "mut " } else { "" }, + param.name.name, + self.ty_name(ty) + )); + } + let local = self.push_def(Def { + kind: DefKind::Local, + name: param.name.name.clone(), + module, + file, + name_span: param.name.span, + span: param.span, + docs: Vec::new(), + is_pub: false, + parent: None, + info: DefInfo::Local { + ty, + mutable: param.mutable, + param: true, + owner: Some(owner), + }, + }); + if matches!(ty, Ty::Struct(_)) { + let base = self.local_ref(local); + self.value_slots(&base, ty); + } + params.push((format!("v{}_{}", local.0, param.name.name), local, ty)); + } + let ret = ret.map(|ret| { + let ty = self.resolve_type(module, ret); + let name = format!("f{}_ret", owner.0); + if matches!(ty, Ty::Struct(_)) { + let base = self.slot(name.clone()); + self.value_slots(&base, ty); + } + (name, ty) + }); + let mut signature = format!("({})", rendered.join(", ")); + if let Some((_, ty)) = &ret { + signature.push_str(&format!(" -> {}", self.ty_name(*ty))); + } + if let DefInfo::Function { signature: s, .. } = &mut self.defs[owner.0].info { + *s = signature; + } + let receiver_out = self + .methods + .get(&owner) + .filter(|method| { + !method.state_receiver + && method + .receiver + .as_ref() + .is_some_and(|r| r.borrowed && r.mutable) + }) + .and_then(|_| params.first()) + .map(|(_, _, ty)| (format!("f{}_receiver_out", owner.0), *ty)); + if let Some((field, ty)) = &receiver_out { + let base = self.slot(field.clone()); + self.value_slots(&base, *ty); + } + self.fn_slots.insert( + owner, + FnSlots { + params, + ret, + receiver_out, + }, + ); + } + + /// Bind `#[on(Event)]` functions to their custom events. + fn collect_event_handlers(&mut self) { + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + for item in self.package.module(module).items.clone() { + let ItemKind::Fn(function) = &item.kind else { + continue; + }; + if !function.generics.is_empty() { + continue; + } + let Some(def) = self.def_by_span(module, function.name.span) else { + continue; + }; + for attr in item.attrs.iter().filter(|a| a.name() == "on") { + let [ + AttrArg { + key: None, + value: AttrValue::Expr(Expr::Path(path)), + .. + }, + ] = attr.args.as_slice() + else { + continue; + }; + if path.segments.len() == 1 + && crate::builtins::EVENTS + .iter() + .any(|(name, _, _)| *name == path.segments[0].name) + { + continue; + } + let Ok((event, refs)) = self.resolve_path(module, path) else { + continue; + }; + if self.defs[event.0].kind != DefKind::Event { + continue; + } + self.references.extend(refs); + self.handler_attrs.insert((file, attr.span)); + let expected: Vec = + self.fn_slots[&event].params.iter().map(|p| p.2).collect(); + let found: Vec = self.fn_slots[&def].params.iter().map(|p| p.2).collect(); + // A handler takes the whole payload, or ignores it. + if expected != found && !found.is_empty() { + let name = self.defs[event.0].name.clone(); + let signature = match &self.defs[event.0].info { + DefInfo::Function { signature, .. } => signature.clone(), + _ => String::new(), + }; + let (event_file, event_span) = + (self.defs[event.0].file, self.defs[event.0].name_span); + self.diagnostics.push( + Diagnostic::error( + "params", + file, + function.name.span, + format!( + "`{}` handles `{name}`, so it must take {signature} or no parameters", + function.name.name + ), + ) + .with_note( + event_file, + event_span, + "event declared here", + ), + ); + continue; + } + self.event_handlers + .entry(event) + .or_default() + .push((def, function.name.span)); + } + } + } + } + + /// The dispatcher of a custom event: copy the payload into each handler's + /// parameters, then call it, in declaration order. + fn lower_event( + &mut self, + module: ModuleId, + file: FileId, + event: &crate::ast::EventItem, + def: DefId, + lowerer: &mut Lowering, + ) { + let DefInfo::Function { id, .. } = self.defs[def.0].info.clone() else { + return; + }; + let slots = self.fn_slots[&def].clone(); + let mut body = Vec::new(); + let mut calls = Vec::new(); + for (handler, span) in self.event_handlers.get(&def).cloned().unwrap_or_default() { + let handler_slots = self.fn_slots[&handler].clone(); + // A handler that emits this event again re-enters the dispatcher. + let marker = self.frame_marker(Some(def), handler); + body.push(op_at( + pc::Action::PushFrame { + fields: vec![marker.clone()], + }, + file, + span, + )); + for ((from, _, ty), (to, _, _)) in slots.params.iter().zip(&handler_slots.params) { + let from = self.slot(from.clone()); + let to = self.slot(to.clone()); + self.copy_value(&to, &from, *ty, file, span, &mut body); + } + if let Some(function) = self.function_reference(handler) { + body.push(op_at(pc::Action::Call { function }, file, span)); + } + body.push(op_at( + pc::Action::PopFrame { + fields: vec![marker], + }, + file, + span, + )); + calls.push((handler, span)); + } + lowerer.facts.insert( + def, + Facts { + entity_direct: None, + entity_loop_calls: Vec::new(), + all_calls: calls.clone(), + schedules: Vec::new(), + forced: None, + direct: None, + calls, + entry: Vec::new(), + file, + }, + ); + lowerer.functions.push(PendingFn { + module, + file, + def: Some(def), + fixed: None, + id, + name_span: event.name.span, + body, + }); + } + + /// Resolve every call's frame placeholder now that the call graph is + /// known. + /// + /// Locals live in shared slots, so a call that can lead back into its + /// caller (directly or through other functions) saves the caller's + /// locals, parameters, and temporaries on a storage stack and restores + /// them afterwards. Return slots are left out: they carry the callee's + /// result out across the restore. Calls that cannot re-enter their caller + /// drop the placeholders and cost nothing. + fn resolve_frames(&mut self, lowerer: &mut Lowering) { + let graph: BTreeMap> = lowerer + .facts + .iter() + .map(|(def, facts)| (*def, facts.all_calls.iter().map(|(d, _)| *d).collect())) + .collect(); + let reaches = |from: DefId, to: DefId| { + let mut stack = vec![from]; + let mut seen = HashSet::new(); + while let Some(next) = stack.pop() { + if next == to { + return true; + } + if seen.insert(next) + && let Some(calls) = graph.get(&next) + { + stack.extend(calls.iter().copied()); + } + } + false + }; + let mut frames: BTreeMap> = BTreeMap::new(); + let resolved: Vec>> = self + .call_frames + .clone() + .into_iter() + .map(|(caller, callee)| { + let caller = caller?; + if !reaches(callee, caller) { + return None; + } + let fields = frames + .entry(caller) + .or_insert_with(|| self.frame_fields(caller)) + .clone(); + (!fields.is_empty()).then(|| { + fields + .into_iter() + .map(|field| pc::FieldReference { + state: self.locals_state_id().parse().expect("namespace validated"), + field, + }) + .collect() + }) + }) + .collect(); + for function in &mut lowerer.functions { + resolve_frame_markers(&mut function.body, &resolved); + } + } + + /// The slots a function's own frame holds: its locals, parameters, and + /// temporaries, in allocation order. + fn frame_fields(&self, function: DefId) -> Vec { + let temps = format!("f{}_t", function.0); + self.local_fields + .iter() + .chain(self.local_data_fields.keys()) + .filter(|name| { + let name = name.strip_prefix("__sand_data_").unwrap_or(name); + if name.starts_with(&temps) { + return true; + } + let Some(local) = name + .strip_prefix('v') + .and_then(|rest| rest.split_once('_')) + .and_then(|(index, _)| index.parse::().ok()) + else { + return false; + }; + matches!( + self.defs.get(local).map(|d| &d.info), + Some(DefInfo::Local { owner: Some(owner), .. }) if *owner == function + ) + }) + .cloned() + .collect() + } + + fn module_identity(&self, module: ModuleId) -> String { + let data = self.package.module(module); + let mut path = vec!["crate".to_string()]; + path.extend(data.path.iter().cloned()); + format!("{}:{}", self.namespace(), path.join("/")) + } + + fn lower_module(&mut self, module: ModuleId, lowerer: &mut Lowering) -> pc::Module { + let file = self.package.module(module).file; + let id_text = self.module_identity(module); + let mut out = pc::Module { + id: id_text.parse().expect("module identities are valid"), + flows: Vec::new(), + states: Vec::new(), + functions: Vec::new(), + load: Vec::new(), + tick: Vec::new(), + tags: Vec::new(), + events: Vec::new(), + items: Vec::new(), + recipes: Vec::new(), + resource_tags: Vec::new(), + loot_tables: Vec::new(), + boss_bars: Vec::new(), + damage_types: Vec::new(), + predicates: Vec::new(), + advancements: Vec::new(), + dialogs: Vec::new(), + dimensions: Vec::new(), + biomes: Vec::new(), + structure_templates: Vec::new(), + inventory_transfers: Vec::new(), + huds: Vec::new(), + menus: Vec::new(), + }; + self.pointers + .push((id_text.clone(), String::new(), file, Span::default())); + for item in self.package.module(module).items.clone() { + let Some(name) = item.name().cloned() else { + continue; + }; + let Some(def) = self.def_by_span(module, name.span) else { + continue; + }; + match &item.kind { + ItemKind::Data(data) => self.lower_data(module, file, def, data, &item, &mut out), + ItemKind::State(state) => { + let DefInfo::State { id, fields, .. } = self.defs[def.0].info.clone() else { + continue; + }; + let ptr = format!("/states/{}", out.states.len()); + self.pointers + .push((id_text.clone(), ptr.clone(), file, name.span)); + let mut score_fields = Vec::new(); + let mut data_fields = Vec::new(); + for (index, field) in fields.iter().enumerate() { + let d = self.defs[field.0].clone(); + self.pointers.push(( + id_text.clone(), + format!("{ptr}/fields/{index}"), + file, + d.name_span, + )); + let DefInfo::Field { + default, + bounds, + timer, + .. + } = d.info + else { + continue; + }; + if matches!( + self.field_ty(*field), + Ty::Struct(_) | Ty::String | Ty::List(_) | Ty::Callable(_) + ) { + let value_ty = self.field_ty(*field); + let base = self.field_reference(def, *field).expect("State field"); + let defaults = + self.record_defaults.get(field).cloned().unwrap_or_default(); + for (index, (leaf, _)) in + self.value_slots(&base, value_ty).into_iter().enumerate() + { + self.pointers.push(( + id_text.clone(), + format!("{ptr}/fields/{}", score_fields.len()), + file, + d.name_span, + )); + match defaults + .get(index) + .cloned() + .unwrap_or(text::LeafDefault::Score(0)) + { + text::LeafDefault::Score(default) => { + score_fields.push(pc::ScoreField { + name: leaf.field, + default, + bounds: None, + timer: false, + }) + } + text::LeafDefault::Data(default) => { + data_fields.push(pc::DataField { + name: Self::data_field(&leaf).field, + default, + }) + } + } + } + continue; + } + score_fields.push(pc::ScoreField { + name: d.name.clone(), + default: default.unwrap_or(0) as i32, + bounds, + timer, + }); + } + let Ok(state_id) = id.parse() else { + self.error( + "id", + file, + name.span, + format!("`{id}` is not a valid State identity"), + ); + continue; + }; + out.states.push(pc::State { + data_fields, + id: state_id, + scope: match state.scope { + Scope::Player => "player".into(), + Scope::Global => "global".into(), + Scope::Entity => "entity".into(), + }, + revision: 1, + fields: score_fields, + }); + } + ItemKind::Fn(function) if function.generics.is_empty() => { + self.lower_fn(module, file, &item, function, def, &mut out, lowerer); + } + ItemKind::Fn(_) => {} + ItemKind::Event(event) => { + self.reject_attrs(file, &item); + self.lower_event(module, file, event, def, lowerer); + } + ItemKind::ExternFn(_) => { + for attr in &item.attrs { + if attr.name() != "player" { + self.error( + "attribute", + file, + attr.path.span, + format!( + "unknown attribute `{}` on an extern function; expected `#[player]`", + attr.name() + ), + ); + } + } + } + ItemKind::Flow(flow) => { + self.reject_attrs(file, &item); + if let Some(lowered) = self.lower_flow(module, file, flow, def, lowerer) { + let ptr = format!("/flows/{}", out.flows.len()); + self.pointers.push((id_text.clone(), ptr, file, name.span)); + out.flows.push(lowered); + } + } + ItemKind::Const(_) | ItemKind::Enum(_) | ItemKind::Mod(_) => { + self.reject_attrs(file, &item); + } + ItemKind::Use(_) + | ItemKind::Struct(_) + | ItemKind::Trait(_) + | ItemKind::Impl(_) + | ItemKind::Error(_) => {} + } + } + out + } + + /// Parse a bare player event, a vanilla filter, or an authored advancement. + fn event_attr( + &mut self, + module: ModuleId, + file: FileId, + attr: &Attr, + ) -> Option<(pc::PlayerEvent, String)> { + let usage = || { + crate::builtins::EVENTS + .iter() + .map(|(name, _, _)| format!("`{name}`")) + .collect::>() + .join(", ") + }; + let [arg] = attr.args.as_slice() else { + self.diagnostics.push( + Diagnostic::error( + "attribute", + file, + attr.span, + "expected one event: `#[on(death)]`", + ) + .with_help(format!("events: {}", usage())), + ); + return None; + }; + // Events that filter on a typed value: (key, value set, build). + type Filtered = (&'static str, &'static str, fn(String) -> pc::PlayerEvent); + const FILTERED: &[Filtered] = &[ + ("use_item", "Item", |item| pc::PlayerEvent::UseItem { item }), + ("craft_item", "Item", |item| pc::PlayerEvent::CraftItem { + item, + }), + ("pick_up_item", "Item", |item| pc::PlayerEvent::PickUpItem { + item, + }), + ("mine_block", "Block", |block| pc::PlayerEvent::MineBlock { + block, + }), + ("kill", "Entity", |entity| pc::PlayerEvent::KillEntityType { + entity, + }), + ("killed_by", "Entity", |entity| pc::PlayerEvent::KilledBy { + entity, + }), + ]; + match (&arg.key, &arg.value) { + (None, AttrValue::Expr(Expr::Path(path))) if path.segments.len() == 1 => { + let name = path.segments[0].name.as_str(); + let event = match name { + "join" => pc::PlayerEvent::Join, + "first_join" => pc::PlayerEvent::FirstJoin, + "death" => pc::PlayerEvent::Death, + "kill" => pc::PlayerEvent::KillEntity, + "kill_player" => pc::PlayerEvent::KillPlayer, + "jump" => pc::PlayerEvent::Jump, + "drop_item" => pc::PlayerEvent::DropItem, + "sleep" => pc::PlayerEvent::Sleep, + "take_damage" => pc::PlayerEvent::TakeDamage, + "deal_damage" => pc::PlayerEvent::DealDamage, + "advancement" => { + self.diagnostics.push( + Diagnostic::error( + "attribute", + file, + arg.span, + "expected an authored advancement", + ) + .with_help("write `#[on(advancement = Milestone)]`"), + ); + return None; + } + filtered => { + let diagnostic = match FILTERED.iter().find(|(key, _, _)| *key == filtered) + { + Some((key, set, _)) => Diagnostic::error( + "attribute", + file, + arg.span, + format!("`{key}` needs {} `{set}`", article(set)), + ) + .with_help(format!("write `#[on({key} = {set}::...)]`")), + None => Diagnostic::error( + "attribute", + file, + path.span, + format!("unknown event `{name}`"), + ) + .with_help(format!("events: {}", usage())), + }; + self.diagnostics.push(diagnostic); + return None; + } + }; + Some((event, name.to_string())) + } + (Some(key), value) if key.name == "advancement" => { + let AttrValue::Expr(expr @ Expr::Path(path)) = value else { + self.error( + "attribute", + file, + arg.span, + "expected an authored advancement", + ); + return None; + }; + let advancement = self.native_data_id(module, file, expr, DefKind::Advancement)?; + let label = format!("advancement = {}", path.display()); + Some((pc::PlayerEvent::AdvancementCompleted { advancement }, label)) + } + (Some(key), value) if FILTERED.iter().any(|(k, _, _)| *k == key.name) => { + let (_, set, build) = FILTERED + .iter() + .find(|(k, _, _)| *k == key.name) + .expect("checked above"); + let expr = match value { + AttrValue::Expr(expr) => expr.clone(), + AttrValue::Str(text, span) => Expr::Str { + value: text.clone(), + raw: text.clone(), + span: *span, + }, + _ => { + self.error( + "attribute", + file, + arg.span, + format!("expected {} `{set}` such as `{set}::...`", article(set)), + ); + return None; + } + }; + if self + .declared(module, file, &expr, DefKind::CustomItem) + .is_some() + { + self.diagnostics.push( + Diagnostic::error( + "attribute", + file, + expr.span(), + format!("`{}` observes vanilla items", key.name), + ) + .with_help("Minecraft counts statistics by base item; use the custom item's base item here"), + ); + return None; + } + let id = self.vanilla_value(module, file, &expr, set)?; + let label = match &expr { + Expr::Path(path) => format!("{} = {}", key.name, path.display()), + _ => format!("{} = \"{id}\"", key.name), + }; + Some((build(id), label)) + } + _ => { + self.diagnostics.push( + Diagnostic::error("attribute", file, arg.span, "expected an event name") + .with_help(format!("events: {}", usage())), + ); + None + } + } + } + + /// Warn about unused variables and needless `mut`. + fn local_lints(&mut self, body: &BodyCx) { + for local in &body.locals { + let d = &self.defs[local.0]; + let (file, span, name) = (d.file, d.name_span, d.name.clone()); + let (mutable, param) = match d.info { + DefInfo::Local { mutable, param, .. } => (mutable, param), + _ => continue, + }; + if name.starts_with('_') || span == Span::default() { + continue; + } + if !body.used.contains(local) { + let what = if param { "parameter" } else { "variable" }; + self.diagnostics.push( + Diagnostic::warning("unused", file, span, format!("unused {what} `{name}`")) + .with_help(format!("remove it, or name it `_{name}` to silence this")), + ); + } else if mutable && !body.assigned.contains(local) { + self.diagnostics.push( + Diagnostic::warning( + "mutability", + file, + span, + format!("variable `{name}` does not need to be mutable"), + ) + .with_help("remove `mut`"), + ); + } + } + } + + /// Resolve a typed vanilla value (`Item::Diamond`) or an identity string + /// to a namespaced identity for `registry`. + pub(crate) fn vanilla_value( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + registry: &'static str, + ) -> Option { + let target = self + .pack + .as_ref() + .map(|pack| pack.minecraft.clone()) + .unwrap_or_else(|| sand_version::LATEST_KNOWN.into()); + let table = crate::vanilla::for_target(&target, registry); + let noun = table.map(|t| t.noun).unwrap_or("value"); + let declaration = match registry { + "Item" => Some(DefKind::CustomItem), + "DamageType" => Some(DefKind::DamageType), + "Dimension" => Some(DefKind::Dimension), + "Biome" => Some(DefKind::Biome), + _ => None, + }; + if let Some(declaration) = declaration + && let Some((_, id)) = self.declared(module, file, expr, declaration) + { + return Some(id); + } + match expr { + Expr::Path(path) + if path.segments.len() == 2 + && crate::vanilla::registry(&path.segments[0].name).is_some() + && !self.scopes[module.0].contains_key(&path.segments[0].name) => + { + let (given, variant) = (&path.segments[0], &path.segments[1]); + if given.name != registry { + self.diagnostics.push( + Diagnostic::error( + "type", + file, + given.span, + format!( + "expected {} `{registry}`, found {} `{}`", + article(registry), + article(&given.name), + given.name + ), + ) + .with_help(format!("write `{registry}::...`")), + ); + return None; + } + let table = table?; + let Some(id) = table.id(&variant.name) else { + let suggestions = table.suggest(&variant.name); + let mut diagnostic = Diagnostic::error( + "resolve", + file, + variant.span, + if crate::vanilla::registry(registry) + .is_some_and(|table| table.id(&variant.name).is_some()) + { + format!( + "`{registry}::{}` is not available in Minecraft {target}", + variant.name + ) + } else { + format!("no {noun} named `{}` in `{registry}`", variant.name) + }, + ); + if let Some(best) = suggestions.first() { + diagnostic = + diagnostic.with_help(format!("did you mean `{registry}::{best}`?")); + } + self.diagnostics.push(diagnostic); + return None; + }; + let span = Span::new(given.span.start, variant.span.end); + self.vanilla_uses.push(VanillaUse { + file, + span, + registry: table.name, + variant: variant.name.clone(), + id: id.to_string(), + }); + Some(id.to_string()) + } + Expr::Str { value, span, .. } => { + let valid = value.split_once(':').is_some_and(|(ns, path)| { + !ns.is_empty() + && !path.is_empty() + && ns.bytes().all(|b| { + b.is_ascii_lowercase() || b.is_ascii_digit() || b"_-.".contains(&b) + }) + && path.bytes().all(|b| { + b.is_ascii_lowercase() || b.is_ascii_digit() || b"_-./".contains(&b) + }) + }); + if !valid { + self.diagnostics.push( + Diagnostic::error("id", file, *span, format!("`{value}` is not a valid {noun} identity")) + .with_help(format!("use a typed value such as `{registry}::...`, or a namespaced id like `\"mymod:name\"`")), + ); + return None; + } + if let Some(table) = table + && value.starts_with("minecraft:") + { + match table.by_id.get(value.as_str()) { + Some(variant) => self.diagnostics.push( + Diagnostic::warning( + "typed", + file, + *span, + format!("use `{registry}::{variant}` instead of a string"), + ) + .with_help( + "typed values are checked, completed, and explained by the editor", + ), + ), + None => { + let path = value.trim_start_matches("minecraft:"); + let guess: String = path + .split(['_', '.', '/']) + .map(|w| { + let mut c = w.chars(); + c.next() + .map(|f| f.to_ascii_uppercase().to_string() + c.as_str()) + .unwrap_or_default() + }) + .collect(); + let mut diagnostic = Diagnostic::error( + "resolve", + file, + *span, + if crate::vanilla::registry(registry) + .is_some_and(|table| table.by_id.contains_key(value)) + { + format!("Minecraft {target} has no {noun} `{value}`") + } else { + format!("Minecraft has no {noun} `{value}`") + }, + ); + if let Some(best) = table.suggest(&guess).first() { + diagnostic = diagnostic + .with_help(format!("did you mean `{registry}::{best}`?")); + } + self.diagnostics.push(diagnostic); + return None; + } + } + } + Some(value.clone()) + } + other => { + self.diagnostics.push( + Diagnostic::error("type", file, other.span(), format!("expected {} `{registry}` value", article(registry))) + .with_help(format!("for example `{registry}::...`; the editor lists every {noun} after `{registry}::`")), + ); + None + } + } + } + + fn reject_attrs(&mut self, file: FileId, item: &Item) { + for attr in &item.attrs { + self.error( + "attribute", + file, + attr.path.span, + format!("unknown attribute `{}`", attr.name()), + ); + } + } + + #[allow(clippy::too_many_arguments)] + fn lower_fn( + &mut self, + module: ModuleId, + file: FileId, + item: &Item, + function: &FnItem, + def: DefId, + out: &mut pc::Module, + lowerer: &mut Lowering, + ) { + let DefInfo::Function { id, .. } = self.defs[def.0].info.clone() else { + return; + }; + if self.generics.origins.contains_key(&def) && item.attr("test").is_some() { + self.error( + "test", + file, + function.name.span, + "a test cannot be a specialized method", + ); + } + let id_text = out.id.to_string(); + let reference = || pc::FunctionReference::Internal { + id: id.parse().expect("validated below"), + }; + let valid_id = id.parse::().is_ok(); + let mut forced = None; + let mut entry = Vec::new(); + for attr in &item.attrs { + match attr.name() { + "test" => {} + "player" => forced = Some(attr.span), + "tick" | "load" => { + if !attr.args.is_empty() { + self.error( + "attribute", + file, + attr.span, + format!("`#[{}]` takes no arguments", attr.name()), + ); + } + if !valid_id { + continue; + } + let call = pc::Operation { + action: pc::Action::Call { + function: reference(), + }, + origin: Some(origin(file, function.name.span)), + }; + let (list, label) = if attr.name() == "tick" { + (&mut out.tick, "tick") + } else { + (&mut out.load, "load") + }; + self.pointers.push(( + id_text.clone(), + format!("/{label}/{}", list.len()), + file, + attr.span, + )); + list.push(call); + entry.push((format!("#[{label}]"), attr.span)); + } + "tag" => { + let [AttrArg { + key: None, + value: AttrValue::Str(tag, tag_span), + .. + }] = attr.args.as_slice() + else { + self.error( + "attribute", + file, + attr.span, + "expected `#[tag(\"namespace:name\")]`", + ); + continue; + }; + let Ok(tag_id) = tag.parse() else { + self.error( + "attribute", + file, + *tag_span, + format!("`{tag}` is not a valid function tag identity"), + ); + continue; + }; + if !valid_id { + continue; + } + self.pointers.push(( + id_text.clone(), + format!("/tags/{}", out.tags.len()), + file, + attr.span, + )); + out.tags.push(pc::TagMembership { + tag: tag_id, + function: reference(), + }); + entry.push((format!("#[tag(\"{tag}\")]"), attr.span)); + } + "on" if self.handler_attrs.contains(&(file, attr.span)) => {} + "on" => { + let Some((event, label)) = self.event_attr(module, file, attr) else { + continue; + }; + if !valid_id { + continue; + } + self.pointers.push(( + id_text.clone(), + format!("/events/{}", out.events.len()), + file, + attr.span, + )); + out.events.push(pc::EventHook { + event, + function: reference(), + }); + entry.push((format!("#[on({label})]"), attr.span)); + } + other => self.error( + "attribute", + file, + attr.path.span, + format!( + "unknown function attribute `{other}`; expected `tick`, `load`, `tag`, `on`, `player`, or `test`" + ), + ), + } + } + let slots = self.fn_slots.get(&def).cloned(); + if !function.params.is_empty() + && let Some((label, span)) = entry.first() + { + self.diagnostics.push( + Diagnostic::error( + "params", + file, + *span, + format!("`{}` takes parameters, so {label} cannot call it", function.name.name), + ) + .with_help("entry points run without arguments; call a parameterised function from inside them"), + ); + } + let mut body = BodyCx::new(module, file, false); + body.slot = format!("f{}", def.0); + body.owner = Some(def); + if let Some(method) = self.methods.get(&def) + && let Some(receiver) = &method.receiver + && method.state_receiver + { + let reason = format!( + "uses a receiver for State `{}`", + self.defs[method.target.0].name + ); + match self.defs[method.target.0].info { + DefInfo::State { + scope: Scope::Player, + .. + } => body.note_player(receiver.span, reason), + DefInfo::State { + scope: Scope::Entity, + .. + } => body.note_executor(receiver.span, reason), + _ => {} + } + } + if let Some(slots) = &slots { + if let Some((field, ty)) = &slots.ret { + body.ret = Some((self.slot(field.clone()), *ty)); + } + for (field, param, _) in &slots.params { + let name = self.defs[param.0].name.clone(); + body.scopes[0].push((name, *param)); + body.locals.push(*param); + self.local_scopes.push((file, function.body.span, *param)); + let _ = field; + } + } + if let Some(slots) = &slots + && let Some((output, ty)) = &slots.receiver_out + && let Some((_, receiver, _)) = slots.params.first() + { + body.receiver_out = Some((self.local_ref(*receiver), self.slot(output.clone()), *ty)); + } + let mut ops = self.lower_block(&mut body, &function.body); + self.finish_receiver(&body, function.body.span, &mut ops); + if let Some((_, ty)) = slots.as_ref().and_then(|s| s.ret.as_ref()) + && !block_returns(&function.body) + { + let ty = self.ty_name(*ty); + self.diagnostics.push( + Diagnostic::error( + "return", + file, + function.name.span, + format!( + "`{}` must return a `{ty}` on every path", + function.name.name + ), + ) + .with_help("end the function with `return ;`"), + ); + } + self.local_lints(&body); + lowerer.raw |= body.raw && (self.test_mode || !self.test_functions.contains(&def)); + lowerer.facts.insert( + def, + Facts { + entity_direct: body.entity_use.clone(), + entity_loop_calls: body.entity_loop_calls.clone(), + all_calls: body.all_calls.clone(), + schedules: body.schedules.clone(), + forced, + direct: body.player_use, + calls: body.calls, + entry, + file, + }, + ); + lowerer.functions.push(PendingFn { + module, + file, + def: Some(def), + fixed: None, + id, + name_span: function.name.span, + body: ops, + }); + } + + fn lower_flow( + &mut self, + module: ModuleId, + file: FileId, + flow: &FlowItem, + def: DefId, + lowerer: &mut Lowering, + ) -> Option { + let DefInfo::Flow { id } = self.defs[def.0].info.clone() else { + return None; + }; + let (state_def, field_def, field_ty) = self.resolve_place(module, file, &flow.on)?; + let scope = match self.defs[state_def.0].info { + DefInfo::State { scope, .. } => scope, + _ => return None, + }; + let hook_context = match scope { + Scope::Player => Context::Player, + Scope::Global => Context::Server, + Scope::Entity => { + self.diagnostics.push( + Diagnostic::error( + "flow", + file, + flow.on.span, + "flows run over player or global State, not entity State", + ) + .with_help( + "drive entity behaviour from a `#[tick]` loop over `entities(with = ...)`", + ), + ); + return None; + } + }; + let bare = match field_ty { + Ty::Enum(e) => Some(e), + _ => None, + }; + let field_ref = self.field_reference(state_def, field_def)?; + let phase = |cx: &mut Cx, expr: &Expr| -> Option { + cx.eval_i32(module, file, expr, Some(field_ty), bare) + .map(|v| v as i32) + }; + let mut transitions = Vec::new(); + for transition in &flow.transitions { + let from = phase(self, &transition.from); + let to = phase(self, &transition.to); + let when = match &transition.guard { + None => Some(None), + Some(cond) => self.flow_guard(module, file, cond, scope).map(Some), + }; + let priority = match &transition.priority { + None => Some(0), + Some(expr) => self + .eval_i32(module, file, expr, Some(Ty::Number), None) + .map(|v| v as i32), + }; + if let (Some(from), Some(to), Some(when), Some(priority)) = (from, to, when, priority) { + if from == to { + self.error( + "flow", + file, + transition.span, + "a transition must move to a different phase", + ); + } + transitions.push(pc::FlowTransition { + from, + to, + when, + priority, + }); + } + } + let mut hooks = Vec::new(); + let mut generated: HashMap = HashMap::new(); + for hook in &flow.hooks { + let state = phase(self, &hook.state); + let cadence = match &hook.every { + None => Some(1), + Some(expr) => { + if hook.phase != HookPhase::Tick { + self.error( + "flow", + file, + expr.span(), + "only `tick` hooks can run `every` n cycles", + ); + None + } else { + match self.eval_i32(module, file, expr, Some(Ty::Number), None) { + Some(v) if v >= 1 => Some(v as u32), + Some(_) => { + self.error("flow", file, expr.span(), "cadence must be at least 1"); + None + } + None => None, + } + } + } + }; + let phase_name = match hook.phase { + HookPhase::Enter => "enter", + HookPhase::Exit => "exit", + HookPhase::Tick => "tick", + }; + let function = match &hook.target { + HookTarget::Function(path) => { + let target = self.expect_path( + module, + path, + &[DefKind::Function, DefKind::ExternFunction], + "a function", + ); + target.and_then(|target| { + if self + .fn_slots + .get(&target) + .is_some_and(|s| !s.params.is_empty()) + { + self.error( + "params", + file, + path.span, + format!( + "`{}` takes parameters, so a flow hook cannot call it", + path.display() + ), + ); + return None; + } + if self.test_functions.contains(&target) { + self.error( + "test", + file, + path.span, + "a test function cannot be a flow hook", + ); + return None; + } + if scope == Scope::Global { + lowerer.global_hooks.push((target, file, path.span)); + } + self.function_reference(target) + }) + } + HookTarget::Block(block) => { + let label = match &hook.state { + Expr::Path(path) => snake_case(&path.last().name), + _ => state + .map(|v| v.to_string().replace('-', "neg")) + .unwrap_or_default(), + }; + let base = format!("{id}.flow/{phase_name}_{label}"); + let count = generated.entry(base.clone()).or_default(); + *count += 1; + let fn_id = if *count == 1 { + base + } else { + format!("{base}_{count}") + }; + let mut body = BodyCx::new(module, file, scope == Scope::Player); + body.slot = format!("h{}_{}", def.0, hooks.len() + generated.len()); + let ops = self.lower_block(&mut body, block); + for (target, span) in body.all_calls.iter().chain(&body.schedules) { + if self.test_functions.contains(target) { + self.error("test", file, *span, "a flow cannot call a test function"); + } + } + self.local_lints(&body); + lowerer.raw |= body.raw; + if let Some((span, reason)) = &body.player_use { + self.diagnostics.push( + Diagnostic::error( + "context", + file, + *span, + format!("this global flow hook has no player, but it {reason}"), + ) + .with_help("wrap it in `for player in players() { ... }`"), + ); + } + for (callee, span) in &body.calls { + lowerer + .global_hooks_calls + .push((*callee, file, *span, scope)); + } + for (target, span) in &body.schedules { + lowerer.hook_schedules.push((*target, file, *span)); + } + let parsed = fn_id.parse().ok(); + lowerer.functions.push(PendingFn { + module, + file, + def: None, + fixed: Some(hook_context), + id: fn_id, + name_span: hook.span, + body: ops, + }); + parsed.map(|id| pc::FunctionReference::Internal { id }) + } + }; + if let (Some(state), Some(cadence), Some(function)) = (state, cadence, function) { + hooks.push(pc::FlowHook { + phase: match hook.phase { + HookPhase::Enter => pc::FlowHookPhase::Enter, + HookPhase::Exit => pc::FlowHookPhase::Exit, + HookPhase::Tick => pc::FlowHookPhase::Tick, + }, + state, + function, + cadence, + }); + } + } + if transitions.is_empty() && hooks.is_empty() && flow.errors.is_empty() { + self.error( + "flow", + file, + flow.name.span, + "a flow needs at least one transition or hook", + ); + } + Some(pc::Flow { + id: id.parse().ok()?, + state: field_ref, + transitions, + hooks, + }) + } + + fn flow_guard( + &mut self, + module: ModuleId, + file: FileId, + cond: &Cond, + scope: Scope, + ) -> Option { + let simple = matches!(cond, Cond::Compare { op, .. } if *op != CmpOp::Ne) + || matches!(cond, Cond::InRange { .. }); + if !simple { + self.diagnostics.push( + Diagnostic::error( + "flow", + file, + cond.span(), + "a transition guard must be a single comparison or `in` range", + ) + .with_help("split the transition, or use priorities to order alternatives"), + ); + return None; + } + let mut body = BodyCx::new(module, file, scope == Scope::Player); + body.slot = "guard".into(); + let mut pre = Vec::new(); + let (condition, negated) = self.atom(&mut body, cond, &mut pre)?; + let (pc::Condition::Range(comparison), true) = (condition, pre.is_empty()) else { + self.diagnostics.push( + Diagnostic::error( + "flow", + file, + cond.span(), + "a transition guard compares a field with constants", + ) + .with_help("compare fields inside a hook and write the phase instead"), + ); + return None; + }; + debug_assert!(!negated); + if let Some((span, reason)) = body.player_use { + self.error( + "context", + file, + span, + format!("this global flow guard has no player, but it {reason}"), + ); + return None; + } + Some(comparison) + } + + fn field_reference(&self, state: DefId, field: DefId) -> Option { + let DefInfo::State { id, .. } = &self.defs[state.0].info else { + return None; + }; + Some(pc::FieldReference { + state: id.parse().ok()?, + field: if matches!( + self.defs[field.0].info, + DefInfo::Field { + ty: Ty::Struct(_), + .. + } + ) { + format!( + "__sand_record_{}_{}", + self.defs[field.0].name.len(), + self.defs[field.0].name + ) + } else { + self.defs[field.0].name.clone() + }, + }) + } + + fn function_reference(&self, def: DefId) -> Option { + match &self.defs[def.0].info { + DefInfo::Function { id, .. } => Some(pc::FunctionReference::Internal { + id: id.parse().ok()?, + }), + DefInfo::ExternFunction { id, context } => Some(pc::FunctionReference::External { + id: id.parse().ok()?, + context: match context { + Context::Server => pc::ExecutionContext::Server, + Context::Player => pc::ExecutionContext::Player, + Context::Entity => pc::ExecutionContext::Entity, + }, + }), + _ => None, + } + } + + fn resolve_place( + &mut self, + module: ModuleId, + file: FileId, + place: &Place, + ) -> Option<(DefId, DefId, Ty)> { + let state = self.expect_path(module, &place.state, &[DefKind::State], "a state")?; + let Some(field) = self + .members + .get(&state) + .and_then(|m| m.get(&place.field.name)) + .copied() + else { + let d = &self.defs[state.0]; + let available = self.members[&state] + .keys() + .map(|k| format!("`{k}`")) + .collect::>() + .join(", "); + let message = format!("state `{}` has no field `{}`", d.name, place.field.name); + let (df, ds) = (d.file, d.name_span); + self.diagnostics.push( + Diagnostic::error("resolve", file, place.field.span, message) + .with_note(df, ds, "state declared here") + .with_help(format!("available fields: {available}")), + ); + return None; + }; + self.references.push(Reference { + file, + span: place.field.span, + def: field, + }); + let ty = match self.defs[field.0].info { + DefInfo::Field { ty, .. } => ty, + _ => Ty::Unknown, + }; + Some((state, field, ty)) + } + + fn lower_block(&mut self, body: &mut BodyCx, block: &Block) -> Vec { + self.lower_block_with_tail(body, block, None) + } + + fn lower_block_with_tail( + &mut self, + body: &mut BodyCx, + block: &Block, + tail: Option<(&pc::FieldReference, Ty, &Expr)>, + ) -> Vec { + enum Segment { + Actions(Vec, Option), + Wait(continuations::WaitSite), + } + let mut segments = Vec::new(); + body.scopes.push(Vec::new()); + body.block_ends.push(block.span.end); + let mut exited = false; + for stmt in &block.stmts { + if exited && !matches!(stmt, Stmt::Error(_)) { + self.diagnostics.push( + Diagnostic::warning( + "unreachable", + body.file, + stmt_span(stmt), + "unreachable statement", + ) + .with_help("the previous statement always returns or continues"), + ); + break; + } + if let Stmt::Call { path, args, span } = stmt + && self.is_wait(body, path) + { + if let Some(wait) = self.lower_wait(body, path, args, *span) { + segments.push(Segment::Wait(wait)); + } + continue; + } + let mut lowered = Vec::new(); + self.lower_stmt(body, stmt, &mut lowered); + exited = stmt_exits(stmt); + // After a nested `break` or `continue`, the rest of this pass + // runs only while the jump flag is clear. + let flag = body + .jumps + .last() + .filter(|jump| jump.executor_loops == body.loops.len()) + .and_then(|jump| jump.flag.clone()); + let guard = (!exited + && (statements::jumps_here(stmt, true) || statements::jumps_here(stmt, false))) + .then_some(flag) + .flatten(); + segments.push(Segment::Actions(lowered, guard)); + } + let mut ops = Vec::new(); + if let Some((dest, ty, tail)) = tail { + self.emit(body, dest, ty, tail, &mut ops); + } + for segment in segments.into_iter().rev() { + let (lowered, guard) = match segment { + Segment::Actions(lowered, guard) => (lowered, guard), + Segment::Wait(wait) => { + ops = wait.suspend(body.file, ops); + continue; + } + }; + if let Some(flag) = guard + && !ops.is_empty() + { + let origin = ops.first().and_then(|op: &pc::Operation| op.origin.clone()); + let rest = std::mem::take(&mut ops); + ops.push(pc::Operation { + action: pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: flag, + min: Some(0), + max: Some(0), + }), + then: rest, + otherwise: Vec::new(), + }, + origin, + }); + } + let mut segment = lowered; + segment.append(&mut ops); + ops = segment; + } + body.block_ends.pop(); + body.scopes.pop(); + self.diagnostics.append(&mut body.pending); + ops + } + + fn lower_stmt(&mut self, body: &mut BodyCx, stmt: &Stmt, ops: &mut Vec) { + let file = body.file; + match stmt { + Stmt::Expr(value, span) => self.lower_value_statement(body, value, *span, ops), + Stmt::Assign { + target, + op, + value, + span, + } => match target { + AssignTarget::Place(place) if self.is_handle(body, place) => { + self.lower_property_assign(body, place, *op, value, *span, ops) + } + _ => self.lower_assign(body, target, *op, value, *span, ops), + }, + Stmt::Let { + mutable, + name, + ty, + value, + span, + } => self.lower_let( + body, + *mutable, + name, + ty.as_ref(), + value.as_ref(), + *span, + ops, + ), + Stmt::Destructure { + pattern, + ty, + value, + span, + } => self.lower_destructure(body, pattern, ty.as_ref(), value, *span, ops), + Stmt::Return { value, span } => self.lower_return(body, value.as_ref(), *span, ops), + Stmt::Match { value, arms, span } => self.lower_match(body, value, arms, *span, ops), + Stmt::Continue(span) => self.lower_jump(body, false, *span, ops), + Stmt::Break(span) => self.lower_jump(body, true, *span, ops), + Stmt::Emit { event, args, span } => self.lower_emit(body, event, args, *span, ops), + Stmt::While { + cond, + body: block, + span, + } => self.lower_repeat(body, statements::Repeat::While(cond), block, *span, ops), + Stmt::Loop { body: block, span } => { + self.lower_repeat(body, statements::Repeat::Forever, block, *span, ops) + } + Stmt::ForValues { + binding, + value, + body: block, + span, + } => { + let ty = self.type_of(body, value); + let length = if let Some((_, length)) = self.array_shape(ty) { + length + } else if matches!(ty, Ty::List(_) | Ty::String) { + 0 + } else { + self.error( + "for", + file, + value.span(), + "iterate an array, vector, string, player query, or entity query", + ); + return; + }; + let range = Range { + start: Some(Expr::Int(0, value.span())), + end: Some(Expr::Int(length as i64, value.span())), + inclusive: false, + span: value.span(), + }; + self.lower_repeat( + body, + statements::Repeat::Count { + binding, + range: &range, + reverse: false, + step: None, + collection: Some(value), + }, + block, + *span, + ops, + ); + } + Stmt::ForRange { + binding, + range, + reverse, + step, + body: block, + span, + } => self.lower_repeat( + body, + statements::Repeat::Count { + binding, + range, + reverse: *reverse, + step: step.as_ref(), + collection: None, + }, + block, + *span, + ops, + ), + Stmt::Call { path, args, span } => self.lower_call(body, path, args, *span, ops), + Stmt::Macro { name, args, span } => self.lower_macro(body, name, args, *span, ops), + Stmt::If(if_stmt) => { + let lowered = self.lower_if(body, if_stmt); + ops.extend(lowered); + } + Stmt::For { + binding, + source, + args, + body: block, + span, + } => { + let name = (source.segments.len() == 1).then(|| source.segments[0].name.as_str()); + if matches!(name, Some("resolve_entity" | "resolve_player")) { + self.lower_reference_loop(body, stmt, ops); + return; + } + let kind = match name { + Some("players") => LoopKind::Players, + Some("entities") => LoopKind::Entities, + _ => { + self.diagnostics.push( + Diagnostic::error( + "for", + file, + source.span, + format!("cannot iterate `{}()`", source.display()), + ) + .with_help( + "iterate `players()` to run as each player, or `entities(..)` to run as each matching entity", + ), + ); + return; + } + }; + let query = match kind { + LoopKind::Players => { + if let Some(first) = args.first() { + self.error("for", file, first.span, "`players()` takes no arguments; use `entities(type = Entity::Player, ..)` to filter"); + return; + } + None + } + LoopKind::Entities => { + let builtin = crate::builtins::find( + "entities", + crate::builtins::BuiltinKind::Expression, + ) + .expect("entities builtin"); + self.builtin_uses + .push((file, source.span, builtin.name, builtin.kind)); + let Some(query) = self.entity_query(body, builtin, args, source.span) + else { + return; + }; + Some(query) + } + }; + let was = body.in_players; + body.in_players = true; + body.loops.push(kind); + body.loop_bindings.push(binding.name.clone()); + self.handle_scopes.push(( + file, + block.span, + binding.name.clone(), + kind == LoopKind::Players, + )); + if kind == LoopKind::Players { + body.player_loops += 1; + } + let inner = self.lower_block(body, block); + if kind == LoopKind::Players { + body.player_loops -= 1; + } + body.loops.pop(); + body.loop_bindings.pop(); + body.in_players = was; + let action = match query { + None => pc::Action::Players { body: inner }, + Some(query) => pc::Action::Entities { query, body: inner }, + }; + ops.push(op_at(action, file, *span)); + } + Stmt::Error(_) => {} + } + } + + fn lower_if(&mut self, body: &mut BodyCx, stmt: &IfStmt) -> Vec { + let then = self.lower_if_block(body, &stmt.then); + let otherwise = match &stmt.otherwise { + None => Vec::new(), + Some(Else::Block(block)) => self.lower_if_block(body, block), + Some(Else::If(nested)) => self.lower_if(body, nested), + }; + if !continuations::may_suspend(&then) && !continuations::may_suspend(&otherwise) { + return self + .lower_cond(body, &stmt.cond, then, otherwise) + .unwrap_or_default(); + } + // Evaluate short-circuit conditions once and put each suspending arm + // in a single branch, keeping the number of wait sites linear. + let depth = body.temp_depth; + let selected = self.temp(body); + let test = |value| { + vec![op_at( + pc::Action::ScoreSet { + score: selected.clone(), + value, + }, + body.file, + stmt.span, + )] + }; + let yes = test(1); + let no = test(0); + let evaluated = self.lower_cond(body, &stmt.cond, yes, no); + body.temp_depth = depth; + let Some(mut operations) = evaluated else { + return Vec::new(); + }; + operations.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: selected, + min: Some(1), + max: Some(1), + }), + then, + otherwise, + }, + body.file, + stmt.span, + )); + operations + } + + fn lower_if_block(&mut self, body: &mut BodyCx, block: &Block) -> Vec { + let saved = body.wait_block_depth; + let depth = body.block_ends.len(); + if saved == depth { + body.wait_block_depth = depth + 1; + } + let operations = self.lower_block(body, block); + body.wait_block_depth = saved; + operations + } + + /// Lower a boolean condition into nested single-comparison branches. + /// + /// `a && b` becomes `if a { if b {T} else {E} } else {E}` and `a || b` + /// becomes `if a {T} else { if b {T} else {E} }`. Each comparison is + /// evaluated at most once and exactly one body runs. + fn lower_cond( + &mut self, + body: &mut BodyCx, + cond: &Cond, + then: Vec, + otherwise: Vec, + ) -> Option> { + match cond { + Cond::Not(inner, _) => self.lower_cond(body, inner, otherwise, then), + Cond::And(a, b) => { + let inner = self.lower_cond(body, b, then, otherwise.clone())?; + self.lower_cond(body, a, inner, otherwise) + } + Cond::Or(a, b) => { + let inner = self.lower_cond(body, b, then.clone(), otherwise)?; + self.lower_cond(body, a, then, inner) + } + Cond::Value(expr) => { + let span = expr.span(); + let mut ops = Vec::new(); + let (condition, _) = self.atom(body, cond, &mut ops)?; + if then.is_empty() && otherwise.is_empty() { + return Some(ops); + } + ops.push(op_at( + pc::Action::Branch { + condition, + then, + otherwise, + }, + body.file, + span, + )); + Some(ops) + } + Cond::Compare { span, .. } | Cond::InRange { span, .. } | Cond::Call { span, .. } => { + let mut ops = Vec::new(); + let (condition, negated) = self.atom(body, cond, &mut ops)?; + let (then, otherwise) = if negated { + (otherwise, then) + } else { + (then, otherwise) + }; + if then.is_empty() && otherwise.is_empty() { + return Some(ops); + } + ops.push(op_at( + pc::Action::Branch { + condition, + then, + otherwise, + }, + body.file, + *span, + )); + Some(ops) + } + } + } + + /// Lower one comparison to a score test, plus whether the branches must + /// be swapped (for `!=`). Sides that need computation are evaluated into + /// temporaries by operations appended to `pre`, which run before the test. + fn atom( + &mut self, + body: &mut BodyCx, + cond: &Cond, + pre: &mut Vec, + ) -> Option<(pc::Condition, bool)> { + let file = body.file; + let depth = body.temp_depth; + let result = self.atom_inner(body, cond, pre); + body.temp_depth = depth; + let _ = file; + result + } + + fn cond_value( + &mut self, + body: &mut BodyCx, + expr: &Expr, + ty: Ty, + pre: &mut Vec, + ) -> Option { + match self.simple(body, expr, ty) { + Ok(Some(value)) => Some(value), + Ok(None) => { + let temp = self.temp(body); + self.emit(body, &temp, ty, expr, pre)?; + Some(statements::Value::Read(temp)) + } + Err(()) => None, + } + } + + fn atom_inner( + &mut self, + body: &mut BodyCx, + cond: &Cond, + pre: &mut Vec, + ) -> Option<(pc::Condition, bool)> { + use statements::Value; + let (module, file) = (body.module, body.file); + let out_of_range = + |v: Option| v.is_some_and(|v| v < i32::MIN as i64 || v > i32::MAX as i64); + let range_condition = |cx: &mut Cx, + score: pc::FieldReference, + min: Option, + max: Option, + span: Span| + -> Option { + if out_of_range(min) || out_of_range(max) || min.zip(max).is_some_and(|(a, b)| a > b) { + cx.error("condition", file, span, "this condition can never be true"); + return None; + } + Some(pc::Condition::Range(pc::ScoreComparison { + score, + min: min.map(|v| v as i32), + max: max.map(|v| v as i32), + })) + }; + match cond { + Cond::Call { path, args, span } => { + let name = &path.last().name; + let builtin = path.segments.len() == 1 + && !self.scopes[body.module.0].contains_key(name) + && Self::lookup_local(body, name).is_none() + && crate::builtins::find(name, crate::builtins::BuiltinKind::Condition) + .is_some(); + if !builtin { + // A function returning `bool`, tested like a variable. + let call = Expr::Call { + path: path.clone(), + args: args.clone(), + span: *span, + }; + return self.atom_inner(body, &Cond::Value(call), pre); + } + self.predicate(body, path, args, *span).map(|c| (c, false)) + } + Cond::Value(expr) => { + let ty = self.type_of(body, expr); + if !matches!(ty, Ty::Bool | Ty::Unknown) { + let found = self.ty_name(ty); + self.diagnostics.push( + Diagnostic::error( + "type", + file, + expr.span(), + format!("expected a `bool` condition, found `{found}`"), + ) + .with_help("compare it, like `value > 0`"), + ); + return None; + } + let Value::Read(score) = self.cond_value(body, expr, Ty::Bool, pre)? else { + self.diagnostics.push( + Diagnostic::error( + "condition", + file, + expr.span(), + "this condition is always the same", + ) + .with_help("test a `bool` field or variable"), + ); + return None; + }; + Some(( + range_condition(self, score, Some(1), Some(1), expr.span())?, + false, + )) + } + Cond::InRange { value, range, span } => { + let ty = self.type_of(body, value); + if !matches!(ty, Ty::Number | Ty::Float | Ty::Unknown) { + self.error( + "type", + file, + range.span, + "only `number` and `float` values can be tested against ranges", + ); + return None; + } + let Value::Read(score) = self.cond_value(body, value, ty, pre)? else { + self.error( + "condition", + file, + value.span(), + "`in` tests a field or variable, like `Hero.energy in 0..=10`", + ); + return None; + }; + let start = match &range.start { + Some(e) => Some(self.eval_i32(module, file, e, Some(ty), None)?), + None => None, + }; + let end = match &range.end { + Some(e) => Some( + self.eval_i32(module, file, e, Some(ty), None)? + - if range.inclusive { 0 } else { 1 }, + ), + None => None, + }; + Some((range_condition(self, score, start, end, *span)?, false)) + } + Cond::Compare { lhs, op, rhs, span } => { + let left_value_ty = self.type_of(body, lhs); + let right_value_ty = self.type_of(body, rhs); + if matches!(left_value_ty, Ty::Callable(_)) + || matches!(right_value_ty, Ty::Callable(_)) + { + self.error( + "callable", + file, + *span, + "function values cannot be compared directly", + ); + return None; + } + if matches!(left_value_ty, Ty::String | Ty::List(_) | Ty::Struct(_)) + || matches!(right_value_ty, Ty::String | Ty::List(_) | Ty::Struct(_)) + { + let value_ty = if matches!(left_value_ty, Ty::List(_)) { + left_value_ty + } else if matches!(right_value_ty, Ty::List(_)) { + right_value_ty + } else if matches!(left_value_ty, Ty::Struct(_)) { + left_value_ty + } else if matches!(right_value_ty, Ty::Struct(_)) { + right_value_ty + } else { + Ty::String + }; + if !matches!(op, CmpOp::Eq | CmpOp::Ne) { + self.error( + "type", + file, + *span, + "stored values support equality comparisons with `==` or `!=`", + ); + return None; + } + let left = self.temp(body); + self.emit(body, &left, value_ty, lhs, pre)?; + let right = self.temp(body); + self.emit(body, &right, value_ty, rhs, pre)?; + let (left, right) = if matches!(value_ty, Ty::Struct(_)) { + let packed_left = self.temp(body); + let packed_right = self.temp(body); + self.register_data_slot( + &packed_left, + sand::data::NbtValue::List(Vec::new()), + ); + self.register_data_slot( + &packed_right, + sand::data::NbtValue::List(Vec::new()), + ); + self.pack_value( + body, + Self::data_reference(&packed_left), + &left, + value_ty, + *span, + pre, + ); + self.pack_value( + body, + Self::data_reference(&packed_right), + &right, + value_ty, + *span, + pre, + ); + (packed_left, packed_right) + } else { + (left, right) + }; + let score = self.temp(body); + pre.push(op_at( + pc::Action::DataEqual { + score: score.clone(), + left: Self::data_reference(&left), + right: Self::data_reference(&right), + }, + file, + *span, + )); + return Some(( + pc::Condition::Range(pc::ScoreComparison { + score, + min: Some(1), + max: Some(1), + }), + *op == CmpOp::Ne, + )); + } + let left_ty = self.type_of(body, lhs); + let ty = if Self::is_const_in(body, lhs) && !matches!(left_ty, Ty::Enum(_)) { + self.type_of(body, rhs) + } else { + left_ty + }; + if matches!(ty, Ty::Enum(_) | Ty::Bool | Ty::EntityRef | Ty::Callable(_)) + && !matches!(op, CmpOp::Eq | CmpOp::Ne) + { + let what = if ty == Ty::Bool { "bool" } else { "enum" }; + self.error( + "type", + file, + *span, + format!("{what} values can only be compared with `==` or `!=`"), + ); + return None; + } + let left = self.cond_value(body, lhs, ty, pre)?; + let right = self.cond_value(body, rhs, ty, pre)?; + let (score, op, value) = match (left, right) { + (Value::Read(a), Value::Read(b)) => { + let (relation, negated) = match op { + CmpOp::Eq => (pc::Relation::Eq, false), + CmpOp::Ne => (pc::Relation::Eq, true), + CmpOp::Lt => (pc::Relation::Lt, false), + CmpOp::Le => (pc::Relation::Le, false), + CmpOp::Gt => (pc::Relation::Gt, false), + CmpOp::Ge => (pc::Relation::Ge, false), + }; + return Some(( + pc::Condition::Relation(pc::ScoreRelation { + left: a, + relation, + right: b, + }), + negated, + )); + } + (Value::Read(a), Value::Const(c)) => (a, *op, c), + (Value::Const(c), Value::Read(b)) => (b, op.flipped(), c), + (Value::Const(_), Value::Const(_)) => { + self.diagnostics.push( + Diagnostic::error( + "condition", + file, + *span, + "this condition compares two constants", + ) + .with_help("compare a field or variable, like `Hero.energy >= 30`"), + ); + return None; + } + }; + let (min, max, negated) = match op { + CmpOp::Eq => (Some(value), Some(value), false), + CmpOp::Ne => (Some(value), Some(value), true), + CmpOp::Lt => (None, Some(value - 1), false), + CmpOp::Le => (None, Some(value), false), + CmpOp::Gt => (Some(value + 1), None, false), + CmpOp::Ge => (Some(value), None, false), + }; + Some((range_condition(self, score, min, max, *span)?, negated)) + } + _ => unreachable!("atoms are comparisons"), + } + } + + // ── Execution context inference ───────────────────────────────────────── + + fn infer_contexts(&mut self, lowerer: &mut Lowering) { + let mut player: HashMap = HashMap::new(); + for (def, facts) in &lowerer.facts { + if facts.forced.is_some() { + player.insert(*def, "is marked `#[player]`".into()); + } else if let Some((_, reason)) = &facts.direct { + player.insert(*def, reason.clone()); + } + } + loop { + let mut changed = false; + for (def, facts) in &lowerer.facts { + if player.contains_key(def) { + continue; + } + for (callee, _) in &facts.calls { + let needs = match &self.defs[callee.0].info { + DefInfo::ExternFunction { context, .. } => *context == Context::Player, + _ => player.contains_key(callee), + }; + if needs { + let name = &self.defs[callee.0].name; + player.insert(*def, format!("calls `{name}`, which needs a player")); + changed = true; + break; + } + } + } + if !changed { + break; + } + } + // Functions that need some entity as `@s`, but not a player. + let mut entity: HashMap = HashMap::new(); + for (def, facts) in &lowerer.facts { + if !player.contains_key(def) + && let Some((_, reason)) = &facts.entity_direct + { + entity.insert(*def, reason.clone()); + } + } + loop { + let mut changed = false; + for (def, facts) in &lowerer.facts { + if player.contains_key(def) || entity.contains_key(def) { + continue; + } + if let Some((callee, _)) = facts.calls.iter().find(|(c, _)| entity.contains_key(c)) + { + let name = &self.defs[callee.0].name; + entity.insert(*def, format!("calls `{name}`, which runs as an entity")); + changed = true; + } + } + if !changed { + break; + } + } + for (def, facts) in &lowerer.facts { + let (ctx, reason) = match (player.get(def), entity.get(def)) { + (Some(reason), _) => (Context::Player, Some(reason.clone())), + (None, Some(reason)) => (Context::Entity, Some(reason.clone())), + (None, None) => (Context::Server, None), + }; + if let DefInfo::Function { + context, + player_reason, + entry, + .. + } = &mut self.defs[def.0].info + { + *context = ctx; + *player_reason = reason.clone(); + *entry = facts.entry.iter().map(|(label, _)| label.clone()).collect(); + } + let Some(reason) = reason else { continue }; + if ctx == Context::Entity { + for (label, attr_span) in &facts.entry { + if label.starts_with("#[on(") { + continue; + } + let d = &self.defs[def.0]; + self.diagnostics.push( + Diagnostic::error( + "context", + d.file, + d.name_span, + format!( + "`{}` runs from {label} on the server, but it {reason}", + d.name + ), + ) + .with_note(facts.file, *attr_span, "runs on the server here") + .with_help("loop over entities with `for entity in entities(..) { ... }`"), + ); + } + continue; + } + // Entry points run without a player executor. + for (label, attr_span) in &facts.entry { + let server_only = label == "#[tick]" + || label == "#[load]" + || label.contains("\"minecraft:tick\"") + || label.contains("\"minecraft:load\""); + if !server_only { + continue; + } + let d = &self.defs[def.0]; + let mut diagnostic = Diagnostic::error( + "context", + d.file, + d.name_span, + format!( + "`{}` runs from {label} without a player, but it {reason}", + d.name + ), + ) + .with_note(facts.file, *attr_span, "runs on the server here") + .with_help("move player work into `for player in players() { ... }`"); + if let Some((span, _)) = &facts.direct { + diagnostic = diagnostic.with_note(facts.file, *span, "player state used here"); + } else if let Some((_, span)) = facts + .calls + .iter() + .find(|(callee, _)| player.contains_key(callee)) + { + diagnostic = + diagnostic.with_note(facts.file, *span, "player function called here"); + } + self.diagnostics.push(diagnostic); + } + } + for facts in lowerer.facts.values() { + for (callee, span) in &facts.entity_loop_calls { + let needs_player = match &self.defs[callee.0].info { + DefInfo::Function { context, .. } | DefInfo::ExternFunction { context, .. } => { + *context == Context::Player + } + _ => false, + }; + if needs_player { + let name = self.defs[callee.0].name.clone(); + self.diagnostics.push( + Diagnostic::error( + "context", + facts.file, + *span, + format!("`{name}` needs a player, but `entities(..)` loops run as entities that may not be players"), + ) + .with_help("call it from `for player in players()` instead"), + ); + } + } + } + let schedules: Vec<(DefId, FileId, Span)> = lowerer + .facts + .values() + .flat_map(|facts| facts.schedules.iter().map(|(d, s)| (*d, facts.file, *s))) + .chain(std::mem::take(&mut lowerer.hook_schedules)) + .collect(); + for (target, file, span) in schedules { + let reason = match &self.defs[target.0].info { + DefInfo::Function { + context: Context::Player | Context::Entity, + player_reason, + .. + } => player_reason + .clone() + .unwrap_or_else(|| "needs a player".into()), + DefInfo::ExternFunction { + context: Context::Player, + .. + } => "is declared `#[player]`".into(), + _ => continue, + }; + let name = self.defs[target.0].name.clone(); + self.diagnostics.push( + Diagnostic::error( + "context", + file, + span, + format!("`{name}` runs later on the server without a player or entity, but it {reason}"), + ) + .with_help( + "schedule a server function that loops `for player in players() { ... }`", + ), + ); + } + for (target, file, span) in std::mem::take(&mut lowerer.global_hooks) { + let needs = match &self.defs[target.0].info { + DefInfo::Function { context, .. } | DefInfo::ExternFunction { context, .. } => { + *context != Context::Server + } + _ => false, + }; + if needs { + self.error( + "context", + file, + span, + format!( + "`{}` needs a player or entity, but hooks of a global flow run on the server", + self.defs[target.0].name + ), + ); + } + } + for (callee, file, span, scope) in std::mem::take(&mut lowerer.global_hooks_calls) { + let needs = match &self.defs[callee.0].info { + DefInfo::Function { context, .. } | DefInfo::ExternFunction { context, .. } => { + *context != Context::Server + } + _ => false, + }; + if needs && scope == Scope::Global { + self.error( + "context", + file, + span, + format!( + "`{}` needs a player or entity, but this global flow hook runs on the server", + self.defs[callee.0].name + ), + ); + } + } + } +} + +/// The dispatcher function of an event, given the event's item identity. +fn event_id(item: &str) -> String { + item.replacen(':', ":sand_event/", 1) +} + +/// "a" or "an" before a name. +pub(crate) fn article(name: &str) -> &'static str { + if name.starts_with(['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u']) { + "an" + } else { + "a" + } +} + +fn stmt_span(stmt: &Stmt) -> Span { + match stmt { + Stmt::Destructure { span, .. } + | Stmt::Let { span, .. } + | Stmt::Return { span, .. } + | Stmt::Continue(span) + | Stmt::Break(span) + | Stmt::Emit { span, .. } + | Stmt::Match { span, .. } + | Stmt::While { span, .. } + | Stmt::Loop { span, .. } + | Stmt::ForRange { span, .. } + | Stmt::ForValues { span, .. } + | Stmt::Assign { span, .. } + | Stmt::Call { span, .. } + | Stmt::Macro { span, .. } + | Stmt::For { span, .. } => *span, + Stmt::If(if_stmt) => if_stmt.span, + Stmt::Expr(_, span) => *span, + Stmt::Error(error) => error.span, + } +} + +/// Whether control never continues past this statement. +fn stmt_exits(stmt: &Stmt) -> bool { + match stmt { + Stmt::Return { .. } | Stmt::Continue(_) | Stmt::Break(_) => true, + Stmt::If(if_stmt) => if_exits(if_stmt), + Stmt::Match { arms, .. } => { + !arms.is_empty() && arms.iter().all(|arm| arm.body.stmts.iter().any(stmt_exits)) + } + _ => false, + } +} + +fn if_exits(if_stmt: &IfStmt) -> bool { + let then = if_stmt.then.stmts.iter().any(stmt_exits); + let otherwise = match &if_stmt.otherwise { + None => false, + Some(Else::Block(block)) => block.stmts.iter().any(stmt_exits), + Some(Else::If(nested)) => if_exits(nested), + }; + then && otherwise +} + +/// Whether every path through the block ends in `return`. +pub(crate) fn block_returns(block: &Block) -> bool { + block.stmts.iter().any(|stmt| match stmt { + Stmt::Return { .. } => true, + Stmt::If(if_stmt) => if_returns(if_stmt), + Stmt::Match { arms, .. } => { + !arms.is_empty() && arms.iter().all(|arm| block_returns(&arm.body)) + } + _ => false, + }) +} + +fn if_returns(if_stmt: &IfStmt) -> bool { + let otherwise = match &if_stmt.otherwise { + None => false, + Some(Else::Block(block)) => block_returns(block), + Some(Else::If(nested)) => if_returns(nested), + }; + block_returns(&if_stmt.then) && otherwise +} + +fn latest_target() -> String { + pc::Compiler::capabilities()["targets"] + .as_array() + .and_then(|targets| targets.last()) + .and_then(|target| target.as_str()) + .unwrap_or("26.2") + .to_string() +} + +fn origin(file: FileId, span: Span) -> serde_json::Value { + serde_json::json!({ "file": file.0, "start": span.start, "end": span.end }) +} + +fn op_at(action: pc::Action, file: FileId, span: Span) -> pc::Operation { + pc::Operation { + action, + origin: Some(origin(file, span)), + } +} + +fn flatten_use(tree: &UseTree, prefix: &[Ident], out: &mut Vec<(Path, Ident)>) { + let mut segments: Vec = prefix.to_vec(); + segments.extend(tree.path.segments.iter().cloned()); + match &tree.group { + Some(group) => { + for child in group { + flatten_use(child, &segments, out); + } + } + None => { + // `use a::{self}` imports `a` itself. + if segments.len() > 1 && segments.last().is_some_and(|s| s.name == "self") { + segments.pop(); + } + let alias = tree + .alias + .clone() + .unwrap_or_else(|| segments.last().expect("non-empty").clone()); + let span = segments + .first() + .expect("non-empty") + .span + .to(segments.last().expect("non-empty").span); + out.push(( + Path { + segments, + applications: Vec::new(), + span, + }, + alias, + )); + } + } +} + +/// Replace frame placeholders with their resolved fields, or drop them. +fn resolve_frame_markers( + ops: &mut Vec, + resolved: &[Option>], +) { + let index_of = |fields: &[pc::FieldReference]| { + fields + .first() + .and_then(|field| field.field.strip_prefix(statements::FRAME_MARKER)) + .and_then(|index| index.parse::().ok()) + }; + ops.retain_mut(|op| match &mut op.action { + pc::Action::PushFrame { fields } | pc::Action::PopFrame { fields } => { + match index_of(fields).and_then(|index| resolved.get(index).cloned().flatten()) { + Some(frame) => { + *fields = frame; + true + } + None => index_of(fields).is_none(), + } + } + pc::Action::Branch { + then, otherwise, .. + } => { + resolve_frame_markers(then, resolved); + resolve_frame_markers(otherwise, resolved); + true + } + pc::Action::Players { body } + | pc::Action::Entities { body, .. } + | pc::Action::WithEntity { body, .. } + | pc::Action::While { body, .. } + | pc::Action::InDimension { body, .. } + | pc::Action::Suspend { body, .. } => { + resolve_frame_markers(body, resolved); + true + } + _ => true, + }); +} + +#[derive(Default)] +struct Lowering { + /// Schedules made from generated flow hook bodies. + hook_schedules: Vec<(DefId, FileId, Span)>, + functions: Vec, + facts: BTreeMap, + raw: bool, + global_hooks: Vec<(DefId, FileId, Span)>, + global_hooks_calls: Vec<(DefId, FileId, Span, Scope)>, +} + +struct PendingFn { + module: ModuleId, + file: FileId, + def: Option, + fixed: Option, + id: String, + name_span: Span, + body: Vec, +} + +struct Facts { + entity_direct: Option<(Span, String)>, + entity_loop_calls: Vec<(DefId, Span)>, + all_calls: Vec<(DefId, Span)>, + schedules: Vec<(DefId, Span)>, + forced: Option, + direct: Option<(Span, String)>, + calls: Vec<(DefId, Span)>, + entry: Vec<(String, Span)>, + file: FileId, +} + +/// A `while`, `loop`, or counting `for` that `break` and `continue` target. +#[derive(Clone)] +struct Jump { + /// 0 during a pass, 1 after `continue`, 2 after `break`; present when + /// the body jumps. + flag: Option, + /// Executor loops already open when this loop started; a jump inside a + /// deeper `players()` or `entities(..)` loop targets that loop instead. + executor_loops: usize, +} + +/// The kind of an executor-changing loop. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum LoopKind { + Players, + Entities, +} + +#[derive(Clone)] +struct BodyCx { + module: ModuleId, + file: FileId, + /// Slot prefix of the function being lowered, such as `f12`. + slot: String, + /// The function that owns locals declared in this body. + owner: Option, + /// Locals declared in this body, for lints. + locals: Vec, + /// Visible locals, innermost scope last. + scopes: Vec>, + /// Current temporary nesting depth. + temp_depth: usize, + /// The return slot, when the function returns a value. + ret: Option<(pc::FieldReference, Ty)>, + /// Mutable borrowed receiver output, separate from recursive frame slots. + receiver_out: Option<(pc::FieldReference, pc::FieldReference, Ty)>, + /// Nesting depth of `for player in players()` loops. + player_loops: usize, + /// Locals read and reassigned, for lints. + used: HashSet, + assigned: HashSet, + /// Every call, including those inside player loops. + all_calls: Vec<(DefId, Span)>, + /// Enclosing executor loops, innermost last. + loops: Vec, + /// The binding of each executor loop, parallel to `loops`. + loop_bindings: Vec, + /// Enclosing `while`, `loop`, and counting `for` loops, innermost last. + jumps: Vec, + /// Where a block expression prevents jumps into surrounding loops. + value_blocks: Vec<(usize, usize)>, + /// Calls made as entities inside `entities(..)` loops. + entity_loop_calls: Vec<(DefId, Span)>, + /// First use that needs an entity executor outside any loop. + entity_use: Option<(Span, String)>, + /// Errors found while noting uses, emitted by the enclosing block. + pending: Vec, + /// End offsets of enclosing blocks, for local visibility ranges. + block_ends: Vec, + /// The innermost block where a wait may suspend this function frame. + wait_block_depth: usize, + in_players: bool, + player_use: Option<(Span, String)>, + calls: Vec<(DefId, Span)>, + schedules: Vec<(DefId, Span)>, + raw: bool, +} + +impl BodyCx { + fn new(module: ModuleId, file: FileId, in_players: bool) -> Self { + Self { + module, + file, + in_players, + slot: "body".into(), + owner: None, + locals: Vec::new(), + scopes: vec![Vec::new()], + temp_depth: 0, + ret: None, + receiver_out: None, + player_loops: 0, + used: HashSet::new(), + assigned: HashSet::new(), + all_calls: Vec::new(), + loops: Vec::new(), + loop_bindings: Vec::new(), + jumps: Vec::new(), + value_blocks: Vec::new(), + entity_loop_calls: Vec::new(), + entity_use: None, + pending: Vec::new(), + block_ends: Vec::new(), + wait_block_depth: 1, + player_use: None, + calls: Vec::new(), + schedules: Vec::new(), + raw: false, + } + } + + fn note_player(&mut self, span: Span, reason: String) { + if self.loops.last() == Some(&LoopKind::Entities) { + self.entity_violation(span, &reason); + return; + } + if !self.in_players && self.player_use.is_none() { + self.player_use = Some((span, reason)); + } + } + + /// A use that needs `@s` to be some entity, such as `kill()`. + fn note_executor(&mut self, span: Span, reason: String) { + if self.loops.is_empty() && self.entity_use.is_none() { + self.entity_use = Some((span, reason)); + } + } + + fn entity_violation(&mut self, span: Span, reason: &str) { + self.pending.push( + Diagnostic::error( + "context", + self.file, + span, + format!("this {reason}, but `entities(..)` loops run as entities that may not be players"), + ) + .with_help("do player work in `for player in players()` instead"), + ); + } + + fn note_state(&mut self, cx: &Cx, state: DefId, place: &Place, verb: &str) { + if let DefInfo::State { + scope: Scope::Entity, + .. + } = cx.defs[state.0].info + { + self.note_executor( + place.span, + format!( + "{verb} entity state `{}.{}`", + place.state.display(), + place.field.name + ), + ); + return; + } + if self.loops.last() == Some(&LoopKind::Entities) + && let DefInfo::State { + scope: Scope::Player, + .. + } = cx.defs[state.0].info + { + let reason = format!( + "{verb} player state `{}.{}`", + place.state.display(), + place.field.name + ); + self.entity_violation(place.span, &reason); + return; + } + if self.in_players || self.player_use.is_some() { + return; + } + if let DefInfo::State { + scope: Scope::Player, + .. + } = cx.defs[state.0].info + { + self.player_use = Some(( + place.span, + format!( + "{verb} player state `{}.{}`", + place.state.display(), + place.field.name + ), + )); + } + } +} + +/// Collect the names of every identifier a set of definitions shadows; used +/// by completion to avoid offering both an import and its target. +pub(crate) fn scope_names(analysis: &Analysis, module: ModuleId) -> Vec<(String, DefId)> { + let mut names: Vec<(String, DefId)> = Vec::new(); + let mut seen = HashSet::new(); + // Items declared in the module. + for (index, def) in analysis.defs.iter().enumerate() { + if def.module == module + && !analysis.origins.contains_key(&DefId(index)) + && def.parent.is_none() + && def.kind != DefKind::Local + && seen.insert(def.name.clone()) + { + names.push((def.name.clone(), DefId(index))); + } + } + // Imports, recovered from references inside `use` items. + let data = analysis.package.module(module); + for item in &data.items { + if let ItemKind::Use(u) = &item.kind { + let mut flat = Vec::new(); + flatten_use(&u.tree, &[], &mut flat); + for (path, alias) in flat { + let target = analysis + .references + .iter() + .find(|r| r.file == data.file && r.span == path.last().span) + .map(|r| r.def); + if let Some(def) = target + && seen.insert(alias.name.clone()) + { + names.push((alias.name, def)); + } + } + } + } + names +} diff --git a/sand-lang/src/analysis/resources.rs b/sand-lang/src/analysis/resources.rs new file mode 100644 index 00000000..559f09bb --- /dev/null +++ b/sand-lang/src/analysis/resources.rs @@ -0,0 +1,2393 @@ +//! Lowering for data declarations: custom items, recipes, and registry tags. + +use super::*; +use crate::ast::{DataField, DataItem, DataKind, DataValue}; +use crate::builtins; +use std::collections::BTreeSet; + +impl Cx { + pub(super) fn lower_data( + &mut self, + module: ModuleId, + file: FileId, + def: DefId, + data: &DataItem, + item: &Item, + out: &mut pc::Module, + ) { + let DefInfo::Data { id, tag_type, .. } = self.defs[def.0].info.clone() else { + return; + }; + if let Some(attr) = item.attrs.first() { + self.error( + "attribute", + file, + attr.span, + format!("`{}` declarations take no attributes", data.kind.keyword()), + ); + } + let Ok(location) = id.parse::() else { + self.error( + "id", + file, + data.name.span, + format!("`{id}` is not a valid resource identity"), + ); + return; + }; + let fields = self.check_fields(file, data); + let module_id = self.module_identity(module); + let get = |name: &str| fields.get(name).copied(); + match data.kind { + DataKind::Item => { + let base = + get("base").and_then(|f| self.data_item_ref(module, file, &f.value, false)); + let name = get("name").map(|f| self.data_text(module, file, &f.value)); + let lore = get("lore").map(|f| match &f.value { + DataValue::Array(lines, _) => lines + .iter() + .map(|line| self.data_text(module, file, line)) + .collect::>>(), + other => { + self.error( + "type", + file, + other.span(), + "expected a list of lines: `[\"...\"]`", + ); + None + } + }); + let rarity = get("rarity").map(|f| { + let expr = self.data_expr(file, &f.value, "a rarity such as `Rarity::Epic`")?; + self.vanilla_value(module, file, expr, "Rarity") + .map(|value| match value.as_str() { + "common" => pc::Rarity::Common, + "uncommon" => pc::Rarity::Uncommon, + "rare" => pc::Rarity::Rare, + _ => pc::Rarity::Epic, + }) + }); + let glint = get("glint").map(|f| self.data_bool(file, &f.value)); + let unbreakable = get("unbreakable").map(|f| self.data_bool(file, &f.value)); + let max_stack = + get("max_stack").map(|f| self.data_int(module, file, &f.value, 1, 99)); + let model = get("custom_model_data").map(|f| { + self.data_int(module, file, &f.value, i32::MIN as i64, i32::MAX as i64) + }); + let enchantments = + get("enchantments").map(|f| self.data_enchantments(module, file, &f.value)); + let ( + Some(base), + Some(name), + Some(lore), + Some(rarity), + Some(glint), + Some(unbreakable), + Some(max_stack), + Some(model), + Some(enchantments), + ) = ( + base, + name.map(|n| n.map(Some)).unwrap_or(Some(None)), + lore.map(|l| l.map(Some)).unwrap_or(Some(None)), + rarity.map(|r| r.map(Some)).unwrap_or(Some(None)), + glint.map(|g| g.map(Some)).unwrap_or(Some(None)), + unbreakable.unwrap_or(Some(false)), + max_stack.map(|m| m.map(Some)).unwrap_or(Some(None)), + model.map(|m| m.map(Some)).unwrap_or(Some(None)), + enchantments.unwrap_or_else(|| Some(BTreeMap::new())), + ) + else { + return; + }; + let book = match get("book") { + Some(field) => { + if base != "minecraft:written_book" { + self.error( + "item", + file, + field.key.span, + "`book` requires `base: Item::WrittenBook`", + ); + return; + } + let Some(content) = self.data_book(module, file, &field.value) else { + return; + }; + Some(content) + } + None => None, + }; + self.pointers.push(( + module_id, + format!("/items/{}", out.items.len()), + file, + data.name.span, + )); + out.items.push(pc::CustomItem { + id: location, + base, + name: name.unwrap_or_default(), + lore: lore.unwrap_or_default(), + glint, + unbreakable, + max_stack: max_stack.map(|m| m as u32), + rarity, + enchantments, + custom_model_data: model.map(|m| m as i32), + book, + }); + } + DataKind::Recipe => { + let chosen: Vec<&str> = builtins::RECIPE_TYPES + .iter() + .copied() + .filter(|name| fields.contains_key(name)) + .collect(); + let kind = match chosen.as_slice() { + [kind] => *kind, + [] => { + self.diagnostics.push( + Diagnostic::error("recipe", file, data.name.span, "a recipe needs a type") + .with_help("add one of `shaped`, `shapeless`, `smelting`, `blasting`, `smoking`, `campfire`, `stonecutting`, `smithing`, or `smithing_trim`"), + ); + return; + } + [_, second, ..] => { + let span = fields[second].key.span; + self.error("recipe", file, span, "a recipe has exactly one type"); + return; + } + }; + for field in [ + "key", + "base", + "addition", + "experience", + "time", + "trim_pattern", + "result", + "count", + ] { + if let Some(f) = get(field) + && !builtins::recipe_accepts_field(Some(kind), field) + { + self.error( + "recipe", + file, + f.key.span, + format!("`{field}` does not apply to a `{kind}` recipe"), + ); + } + } + let register_recipe = |this: &mut Self, recipe| { + this.pointers.push(( + module_id, + format!("/recipes/{}", out.recipes.len()), + file, + data.name.span, + )); + out.recipes.push(recipe); + }; + if kind == "smithing_trim" { + let Some((template, base, addition)) = self.data_smithing_ingredients( + module, + file, + fields[kind], + get("base"), + get("addition"), + ) else { + return; + }; + let Some(pattern) = get("trim_pattern") else { + self.error( + "recipe", + file, + data.name.span, + "a smithing trim recipe needs `trim_pattern`", + ); + return; + }; + let parsed = match &pattern.value { + DataValue::Expr(Expr::Str { value, .. }) => value.parse().ok(), + _ => None, + }; + let Some(pattern_id) = parsed else { + self.error( + "recipe", + file, + pattern.value.span(), + "expected a quoted trim pattern id such as `\"minecraft:sentry\"`", + ); + return; + }; + let recipe = pc::Recipe::SmithingTrim { + id: location, + template, + base, + addition, + pattern: pattern_id, + }; + register_recipe(self, recipe); + return; + } + let Some(result_field) = get("result") else { + self.error("field", file, data.name.span, "`recipe` needs `result`"); + return; + }; + let result_item = self.data_item_ref(module, file, &result_field.value, true); + let count = get("count") + .map(|f| self.data_int(module, file, &f.value, 1, 99)) + .unwrap_or(Some(1)); + let (Some(item), Some(count)) = (result_item, count) else { + return; + }; + let result = pc::RecipeOutput { + item, + count: count as u32, + }; + let type_field = fields[kind]; + let recipe = match kind { + "shaped" => { + let Some(pattern) = self.data_pattern(file, &type_field.value) else { + return; + }; + let Some(key_field) = get("key") else { + self.error( + "recipe", + file, + type_field.key.span, + "a shaped recipe needs a `key`", + ); + return; + }; + let DataValue::Object(entries, _) = &key_field.value else { + self.error( + "type", + file, + key_field.value.span(), + "expected `{ A: Item::..., ... }`", + ); + return; + }; + let mut key = BTreeMap::new(); + let used: std::collections::BTreeSet = pattern + .iter() + .flat_map(|row| row.chars()) + .filter(|c| *c != ' ') + .collect(); + for entry in entries { + let mut chars = entry.key.name.chars(); + match (chars.next(), chars.next()) { + (Some(c), None) if used.contains(&c) => {} + (Some(_), None) => { + self.error( + "recipe", + file, + entry.key.span, + format!("`{}` is not used in the pattern", entry.key.name), + ); + continue; + } + _ => { + self.error( + "recipe", + file, + entry.key.span, + "pattern keys are single characters", + ); + continue; + } + } + if let Some(ingredient) = + self.data_ingredient(module, file, &entry.value) + { + key.insert(entry.key.name.clone(), ingredient); + } + } + for c in &used { + if !entries.iter().any(|e| e.key.name == c.to_string()) { + self.error( + "recipe", + file, + type_field.value.span(), + format!("pattern character `{c}` has no `key` entry"), + ); + return; + } + } + pc::Recipe::Shaped { + id: location, + pattern, + key, + result, + } + } + "shapeless" => { + let DataValue::Array(values, span) = &type_field.value else { + self.error( + "type", + file, + type_field.value.span(), + "expected a list of ingredients", + ); + return; + }; + if values.is_empty() || values.len() > 9 { + self.error( + "recipe", + file, + *span, + "a shapeless recipe has one to nine ingredients", + ); + return; + } + let ingredients: Option> = values + .iter() + .map(|v| self.data_ingredient(module, file, v)) + .collect(); + pc::Recipe::Shapeless { + id: location, + ingredients: ingredients.unwrap_or_default(), + result, + } + } + "smithing" => { + let Some((template, base, addition)) = self.data_smithing_ingredients( + module, + file, + fields[kind], + get("base"), + get("addition"), + ) else { + return; + }; + pc::Recipe::Smithing { + id: location, + template, + base, + addition, + result, + } + } + "stonecutting" => { + let Some(ingredient) = + self.data_ingredient(module, file, &type_field.value) + else { + return; + }; + pc::Recipe::Stonecutting { + id: location, + ingredient, + result, + } + } + cooking => { + let Some(ingredient) = + self.data_ingredient(module, file, &type_field.value) + else { + return; + }; + let experience = get("experience") + .map(|f| self.data_number(module, file, &f.value)) + .unwrap_or(Some(0.0)); + let time = get("time") + .map(|f| { + self.data_int(module, file, &f.value, 1, i32::MAX as i64) + .map(Some) + }) + .unwrap_or(Some(None)); + let (Some(experience), Some(time)) = (experience, time) else { + return; + }; + pc::Recipe::Cooking { + id: location, + method: match cooking { + "smelting" => pc::CookingMethod::Smelting, + "blasting" => pc::CookingMethod::Blasting, + "smoking" => pc::CookingMethod::Smoking, + _ => pc::CookingMethod::Campfire, + }, + ingredient, + result, + experience: experience as f32, + time: time.map(|t| t as u32), + } + } + }; + register_recipe(self, recipe); + } + DataKind::BossBar => { + let Some(title) = get("title").and_then(|f| self.data_text(module, file, &f.value)) + else { + return; + }; + let color = match get("color") { + Some(f) => { + let Some(expr) = self.data_expr(file, &f.value, "a `BossBarColor`") else { + return; + }; + let Some(value) = self.vanilla_value(module, file, expr, "BossBarColor") + else { + return; + }; + match value.as_str() { + "blue" => pc::BossBarColor::Blue, + "green" => pc::BossBarColor::Green, + "pink" => pc::BossBarColor::Pink, + "purple" => pc::BossBarColor::Purple, + "red" => pc::BossBarColor::Red, + "yellow" => pc::BossBarColor::Yellow, + _ => pc::BossBarColor::White, + } + } + None => pc::BossBarColor::White, + }; + let style = match get("style") { + Some(f) => { + let Some(expr) = self.data_expr(file, &f.value, "a `BossBarStyle`") else { + return; + }; + let Some(value) = self.vanilla_value(module, file, expr, "BossBarStyle") + else { + return; + }; + match value.as_str() { + "notched_6" => pc::BossBarStyle::Notched6, + "notched_10" => pc::BossBarStyle::Notched10, + "notched_12" => pc::BossBarStyle::Notched12, + "notched_20" => pc::BossBarStyle::Notched20, + _ => pc::BossBarStyle::Progress, + } + } + None => pc::BossBarStyle::Progress, + }; + let max = get("max") + .map(|f| self.data_int(module, file, &f.value, 1, i32::MAX as i64)) + .unwrap_or(Some(100)); + let Some(max) = max else { + return; + }; + self.pointers.push(( + module_id, + format!("/boss_bars/{}", out.boss_bars.len()), + file, + data.name.span, + )); + out.boss_bars.push(pc::BossBar { + id: location, + title, + color, + style, + max: max as u32, + }); + } + DataKind::Menu => { + let Some(title) = + get("title").and_then(|field| self.data_text(module, file, &field.value)) + else { + return; + }; + let Some(ticks) = get("ticks").and_then(|field| { + self.data_int(module, file, &field.value, 1, i64::from(i32::MAX)) + }) else { + return; + }; + let page_size = get("page_size") + .and_then(|field| self.data_int(module, file, &field.value, 1, 64)) + .map(|value| value as u32); + let Some(choices) = get("choices") + .and_then(|field| self.data_menu_choices(module, file, &field.value)) + else { + return; + }; + let views = match get("views") { + Some(field) => { + let Some(views) = self.data_menu_views(module, file, &field.value) else { + return; + }; + views + } + None => Vec::new(), + }; + let start = get("start").and_then(|field| self.data_menu_name(file, &field.value)); + let while_open = get("while_open") + .and_then(|field| self.data_menu_guard(module, file, &field.value)); + self.pointers.push(( + module_id, + format!("/menus/{}", out.menus.len()), + file, + data.name.span, + )); + out.menus.push(pc::MenuDefinition { + id: location, + title, + ticks: ticks as u32, + page_size, + choices, + views, + start, + while_open, + }); + } + DataKind::Hud => { + let Some(ticks) = get("ticks").and_then(|field| { + self.data_int(module, file, &field.value, 1, i64::from(i32::MAX)) + }) else { + return; + }; + if get("actionbar").is_none() && get("bossbar").is_none() { + self.error( + "hud", + file, + data.name.span, + "a HUD needs an actionbar or a boss bar", + ); + return; + } + let every = get("every") + .and_then(|field| { + self.data_int(module, file, &field.value, 1, i64::from(i32::MAX)) + }) + .map(|value| value as u32); + let actionbar = get("actionbar") + .and_then(|field| self.data_text(module, file, &field.value)) + .unwrap_or_default(); + let bossbar = get("bossbar") + .and_then(|field| self.data_hud_bossbar(module, file, &field.value)); + self.pointers.push(( + module_id, + format!("/huds/{}", out.huds.len()), + file, + data.name.span, + )); + out.huds.push(pc::HudDefinition { + id: location, + ticks: ticks as u32, + every, + actionbar, + bossbar, + }); + } + DataKind::InventoryTransfer => { + use sand::inventory::InventoryIndex; + let max = i64::from(InventoryIndex::MAX); + let Some(from) = + get("from").and_then(|field| self.data_int(module, file, &field.value, 0, max)) + else { + return; + }; + let Some(to) = + get("to").and_then(|field| self.data_int(module, file, &field.value, 0, max)) + else { + return; + }; + if from == to { + self.error( + "inventory transfer", + file, + get("to").expect("checked").value.span(), + "source and destination must be distinct numbered player slots", + ); + return; + } + let amount = get("amount") + .and_then(|field| self.data_int(module, file, &field.value, 1, 99)) + .map(|value| value as u32); + let success = + get("success").and_then(|field| self.data_callback(module, file, &field.value)); + let rejected = get("rejected") + .and_then(|field| self.data_callback(module, file, &field.value)); + self.pointers.push(( + module_id, + format!("/inventory_transfers/{}", out.inventory_transfers.len()), + file, + data.name.span, + )); + out.inventory_transfers + .push(pc::InventoryTransferDefinition { + id: location, + from: InventoryIndex::new(from as u8).expect("checked slot index"), + to: InventoryIndex::new(to as u8).expect("checked slot index"), + amount, + success, + rejected, + }); + } + DataKind::StructureTemplate => { + use sand::registration::DatapackComponent; + let Some(field) = get("source") else { + return; + }; + let Some(Expr::Str { + value: source, + span, + .. + }) = self.data_expr(file, &field.value, "a quoted relative .nbt path") + else { + self.error( + "type", + file, + field.value.span(), + "expected a quoted relative .nbt path", + ); + return; + }; + let template = sand::component::StructureTemplate::new(location, source); + if let Err(error) = template.validate() { + self.error("structure", file, *span, error.to_string()); + return; + } + if let Some(Err(error)) = self.package.structure_assets.get(source) { + self.error( + "io", + file, + *span, + format!("cannot read structure asset `{source}`: {error}"), + ); + return; + } + self.pointers.push(( + module_id, + format!("/structure_templates/{}", out.structure_templates.len()), + file, + *span, + )); + out.structure_templates.push(template); + } + DataKind::Biome => { + let precipitation = + get("precipitation").and_then(|field| self.data_bool(file, &field.value)); + let temperature = get("temperature") + .and_then(|field| self.data_biome_number(module, file, &field.value)); + let downfall = get("downfall").and_then(|field| { + let value = self.data_biome_number(module, file, &field.value)?; + if !(0.0..=1.0).contains(&value) { + self.error( + "range", + file, + field.value.span(), + "downfall must be between zero and one", + ); + return None; + } + Some(value) + }); + let mut color = + |name| get(name).and_then(|field| self.data_biome_color(file, &field.value)); + let biome = pc::CustomBiome { + id: location, + precipitation, + temperature, + downfall, + fog_color: color("fog_color"), + water_color: color("water_color"), + water_fog_color: color("water_fog_color"), + sky_color: color("sky_color"), + grass_color: color("grass_color"), + foliage_color: color("foliage_color"), + spawners: get("spawners") + .and_then(|field| self.data_biome_spawners(module, file, &field.value)) + .unwrap_or_default(), + spawn_costs: get("spawn_costs") + .and_then(|field| self.data_biome_spawn_costs(module, file, &field.value)) + .unwrap_or_default(), + }; + self.pointers.push(( + module_id, + format!("/biomes/{}", out.biomes.len()), + file, + data.name.span, + )); + out.biomes.push(biome); + } + DataKind::Dimension => { + let Some(layers) = get("layers") + .and_then(|field| self.data_flat_layers(module, file, &field.value)) + else { + return; + }; + let mut flat = sand::component::FlatGenerator::new(layers); + if let Some(field) = get("biome") { + let Some(biome) = self + .data_expr(file, &field.value, "a biome") + .and_then(|expr| self.vanilla_value(module, file, expr, "Biome")) + .and_then(|id| id.parse::().ok()) + else { + return; + }; + flat = flat.biome(biome); + } + if let Some(field) = get("structures") { + let Some(structures) = self.data_bool(file, &field.value) else { + return; + }; + flat = flat.with_structures(structures); + } + let dimension_type = if let Some(field) = get("type") { + let Some(id) = self + .data_expr(file, &field.value, "a dimension type") + .and_then(|expr| self.vanilla_value(module, file, expr, "DimensionType")) + .and_then(|id| id.parse::().ok()) + else { + return; + }; + id.into() + } else { + sand::registry::DimensionTypeId::minecraft("overworld") + .expect("valid built-in id") + }; + self.pointers.push(( + module_id, + format!("/dimensions/{}", out.dimensions.len()), + file, + data.name.span, + )); + out.dimensions.push(pc::FlatDimension { + id: location, + dimension_type, + flat, + }); + } + DataKind::Dialog => { + let Some(title) = + get("title").and_then(|field| self.data_text(module, file, &field.value)) + else { + return; + }; + let body = match get("body").map(|field| &field.value) { + Some(DataValue::Array(lines, _)) => { + let Some(lines) = lines + .iter() + .map(|line| self.data_text(module, file, line)) + .collect::>>() + else { + return; + }; + lines + } + Some(other) => { + self.error( + "dialog", + file, + other.span(), + "dialog body must be a list of text blocks", + ); + return; + } + None => Vec::new(), + }; + let Some(button) = get("button") + .map(|field| self.data_text(module, file, &field.value)) + .unwrap_or_else(|| Some(Vec::new())) + else { + return; + }; + self.pointers.push(( + module_id, + format!("/dialogs/{}", out.dialogs.len()), + file, + data.name.span, + )); + out.dialogs.push(pc::NoticeDialog { + id: location, + title, + body, + button, + }); + } + DataKind::Advancement => { + let Some(criteria) = get("criteria") + .and_then(|field| self.data_advancement_criteria(module, file, &field.value)) + else { + return; + }; + let display = match get("display") { + Some(field) => { + let Some(display) = + self.data_advancement_display(module, file, &field.value) + else { + return; + }; + Some(display) + } + None => None, + }; + let require_any = get("require_any") + .map(|field| self.data_bool(file, &field.value)) + .unwrap_or(Some(false)); + let experience = get("experience") + .map(|field| self.data_int(module, file, &field.value, 0, i32::MAX as i64)) + .unwrap_or(Some(0)); + let (Some(require_any), Some(experience)) = (require_any, experience) else { + return; + }; + self.pointers.push(( + module_id, + format!("/advancements/{}", out.advancements.len()), + file, + data.name.span, + )); + out.advancements.push(pc::Advancement { + id: location, + display, + criteria, + require_any, + experience: experience as i32, + }); + } + DataKind::Predicate => { + let option = |cx: &mut Cx, field, registry| match get(field) { + Some(field) => { + let expr = cx.data_expr(file, &field.value, "a typed predicate value")?; + cx.vanilla_value(module, file, expr, registry).map(Some) + } + None => Some(None), + }; + let (Some(block), Some(biome), Some(dimension)) = ( + option(self, "block", "Block"), + option(self, "biome", "Biome"), + option(self, "dimension", "Dimension"), + ) else { + return; + }; + let weather = match get("weather") { + Some(field) => { + let Some(weather) = self.data_weather(module, file, &field.value) else { + return; + }; + Some(weather) + } + None => None, + }; + let chance = match get("chance") { + Some(field) => { + let Some(chance) = + self.data_probability(module, file, &field.value, "predicate") + else { + return; + }; + Some(chance) + } + None => None, + }; + if block.is_none() + && biome.is_none() + && dimension.is_none() + && weather.is_none() + && chance.is_none() + { + self.error( + "predicate", + file, + data.name.span, + "a world predicate needs at least one condition", + ); + return; + } + self.pointers.push(( + module_id, + format!("/predicates/{}", out.predicates.len()), + file, + data.name.span, + )); + out.predicates.push(pc::WorldPredicate { + id: location, + biome, + block, + dimension: dimension.and_then(|id| id.parse().ok()), + weather, + chance, + }); + } + DataKind::DamageType => { + let Some(message) = get("message_id") else { + return; + }; + let DataValue::Expr(Expr::Str { + value: message_id, + span, + .. + }) = &message.value + else { + self.error( + "type", + file, + message.value.span(), + "expected a literal death message id", + ); + return; + }; + if message_id.trim().is_empty() || message_id.chars().any(char::is_control) { + self.error( + "value", + file, + *span, + "a death message id must contain text without control characters", + ); + return; + } + let exhaustion = match get("exhaustion") { + Some(field) => match self.data_number(module, file, &field.value) { + Some(value) if value >= 0.0 && (value as f32).is_finite() => value as f32, + Some(_) => { + self.error( + "range", + file, + field.value.span(), + "exhaustion must be finite and non-negative", + ); + return; + } + None => return, + }, + None => 0.0, + }; + let option = |cx: &mut Cx, field, registry| { + let Some(field) = get(field) else { + return Some(serde_json::Value::Null); + }; + let value = cx.data_expr(file, &field.value, "a typed damage option")?; + if !matches!(value, Expr::Path(_)) { + cx.error( + "type", + file, + value.span(), + format!("expected a `{registry}::...` value"), + ); + return None; + } + cx.vanilla_value(module, file, value, registry) + .map(serde_json::Value::String) + }; + let (Some(scaling), Some(effects), Some(death_message_type)) = ( + option(self, "scaling", "DamageScaling"), + option(self, "effects", "DamageEffects"), + option(self, "death_message_type", "DeathMessageType"), + ) else { + return; + }; + self.pointers.push(( + module_id, + format!("/damage_types/{}", out.damage_types.len()), + file, + data.name.span, + )); + let mut damage_type = sand::component::DamageType::new(location) + .message_id(message_id) + .exhaustion(exhaustion); + if let Some(scaling) = + serde_json::from_value(scaling).expect("damage scaling option") + { + damage_type = damage_type.scaling(scaling); + } + if let Some(effects) = + serde_json::from_value(effects).expect("damage effect option") + { + damage_type = damage_type.effects(effects); + } + if let Some(death_message_type) = + serde_json::from_value(death_message_type).expect("death message option") + { + damage_type = damage_type.death_message_type(death_message_type); + } + out.damage_types.push(damage_type); + } + DataKind::Loot => { + let Some(pools) = self.data_loot_pools(module, file, data, &fields) else { + return; + }; + self.pointers.push(( + module_id, + format!("/loot_tables/{}", out.loot_tables.len()), + file, + data.name.span, + )); + out.loot_tables.push(pc::LootTable { + id: location, + pools, + }); + } + DataKind::Tag => { + // A missing or unknown type was reported at the declaration. + let Some(registry) = tag_type else { + return; + }; + let kind = match registry { + "Item" => pc::TagKind::Item, + "Block" => pc::TagKind::Block, + _ => pc::TagKind::EntityType, + }; + let Some(values_field) = get("values") else { + return; + }; + let DataValue::Array(values, _) = &values_field.value else { + self.error( + "type", + file, + values_field.value.span(), + "expected a list of values", + ); + return; + }; + let values: Option> = values + .iter() + .map(|v| self.data_tag_value(module, file, v, registry)) + .collect(); + let replace = get("replace") + .map(|f| self.data_bool(file, &f.value)) + .unwrap_or(Some(false)); + let (Some(values), Some(replace)) = (values, replace) else { + return; + }; + self.pointers.push(( + module_id, + format!("/resource_tags/{}", out.resource_tags.len()), + file, + data.name.span, + )); + out.resource_tags.push(pc::ResourceTag { + kind, + id: location, + values, + replace, + }); + } + } + } + + pub(super) fn native_data_id( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + kind: DefKind, + ) -> Option { + let label = kind.describe(); + if let Expr::Str { value, span, .. } = expr { + if value.contains(':') + && let Ok(id) = value.parse() + { + return Some(id); + } + self.error( + "id", + file, + *span, + format!("expected a namespaced {label} identity"), + ); + return None; + } + let Expr::Path(path) = expr else { + self.error( + "type", + file, + expr.span(), + format!("expected a declared {label}"), + ); + return None; + }; + let def = self.expect_path( + module, + path, + &[kind], + &format!("{} {label}", super::article(label)), + )?; + let DefInfo::Data { id, .. } = &self.defs[def.0].info else { + return None; + }; + id.parse().ok() + } + + fn data_weather( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let expr = self.data_expr(file, value, "a Weather value")?; + let value = self.vanilla_value(module, file, expr, "Weather")?; + let Ok(weather) = serde_json::from_value(serde_json::Value::String(value)) else { + self.error("type", file, expr.span(), "expected a `Weather::...` value"); + return None; + }; + Some(weather) + } + + fn data_probability( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + owner: &str, + ) -> Option { + let chance = self.data_number(module, file, value)?; + if !(0.0..=1.0).contains(&chance) { + self.error( + "range", + file, + value.span(), + format!("{owner} chance must be between zero and one"), + ); + return None; + } + Some(chance) + } + + fn data_loot_pools( + &mut self, + module: ModuleId, + file: FileId, + data: &DataItem, + fields: &BTreeMap<&str, &DataField>, + ) -> Option> { + if let Some(pools) = fields.get("pools") { + if fields.len() > 1 { + self.error( + "loot", + file, + pools.span, + "use either pools or top-level items and rolls", + ); + return None; + } + let DataValue::Array(values, span) = &pools.value else { + self.error( + "type", + file, + pools.value.span(), + "expected a list of loot pools", + ); + return None; + }; + if values.is_empty() { + self.error("loot", file, *span, "a loot table needs at least one pool"); + return None; + } + return values + .iter() + .map(|value| { + let DataValue::Object(fields, span) = value else { + self.error("type", file, value.span(), "expected a loot pool object"); + return None; + }; + self.data_loot_pool(module, file, fields, *span) + }) + .collect(); + } + self.data_loot_pool(module, file, &data.fields, data.name.span) + .map(|pool| vec![pool]) + } + + fn data_loot_pool( + &mut self, + module: ModuleId, + file: FileId, + fields: &[DataField], + span: Span, + ) -> Option { + let mut pool = pc::LootPool { + items: Vec::new(), + rolls: 1, + chance: None, + weather: None, + predicate: None, + }; + let mut seen = BTreeSet::new(); + for field in fields { + if !seen.insert(&field.key.name) { + self.error( + "loot", + file, + field.key.span, + format!("duplicate loot pool field `{}`", field.key.name), + ); + return None; + } + match field.key.name.as_str() { + "items" => { + let DataValue::Array(values, _) = &field.value else { + self.error("type", file, field.value.span(), "expected a list of items"); + return None; + }; + pool.items = values + .iter() + .map(|item| self.data_loot_item(module, file, item)) + .collect::>()?; + } + "rolls" => pool.rolls = self.data_int(module, file, &field.value, 1, 1000)? as u32, + "chance" => { + pool.chance = + Some(self.data_probability(module, file, &field.value, "loot pool")?) + } + "weather" => pool.weather = Some(self.data_weather(module, file, &field.value)?), + "when" => { + let expr = self.data_expr(file, &field.value, "a native predicate")?; + pool.predicate = + Some(self.native_data_id(module, file, expr, DefKind::Predicate)?); + } + _ => { + self.error( + "field", + file, + field.key.span, + format!("unknown loot pool field `{}`", field.key.name), + ); + return None; + } + } + } + if pool.items.is_empty() { + self.error("loot", file, span, "a loot table needs at least one item"); + return None; + } + Some(pool) + } + + /// A vanilla item, or `{ item: ..., weight: ..., count: ... }`. + fn data_loot_item( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let (item, mut weight, mut count) = match value { + DataValue::Object(entries, span) => { + let mut item = None; + let mut weight = Some(1); + let mut count = Some(1); + for entry in entries { + match entry.key.name.as_str() { + "item" => { + item = Some(self.data_item_ref(module, file, &entry.value, false)?); + } + "weight" => { + weight = self.data_int(module, file, &entry.value, 1, i32::MAX as i64) + } + "count" => count = self.data_int(module, file, &entry.value, 1, 99), + other => { + self.diagnostics.push( + Diagnostic::error( + "field", + file, + entry.key.span, + format!("a loot item has no field `{other}`"), + ) + .with_help("fields: item, weight, count"), + ); + return None; + } + } + } + if item.is_none() { + self.error("field", file, *span, "a loot item needs `item`"); + return None; + } + (item?, weight, count) + } + other => ( + self.data_item_ref(module, file, other, false)?, + Some(1), + Some(1), + ), + }; + Some(pc::LootItem { + item, + weight: weight.take()? as u32, + count: count.take()? as u32, + }) + } + + /// Index fields by name, reporting unknown, duplicate, and missing ones. + fn check_fields<'a>( + &mut self, + file: FileId, + data: &'a DataItem, + ) -> BTreeMap<&'a str, &'a DataField> { + let keyword = data.kind.keyword(); + let mut fields = BTreeMap::new(); + for field in &data.fields { + let name = field.key.name.as_str(); + if builtins::data_fields(keyword).all(|doc| doc.name != name) { + let known: Vec<&str> = builtins::data_fields(keyword).map(|doc| doc.name).collect(); + let best = known + .iter() + .min_by_key(|candidate| crate::vanilla::distance(name, candidate)) + .filter(|candidate| crate::vanilla::distance(name, candidate) <= 2); + let mut diagnostic = Diagnostic::error( + "field", + file, + field.key.span, + format!("`{keyword}` has no field `{name}`"), + ); + diagnostic = match best { + Some(best) => diagnostic.with_help(format!("did you mean `{best}`?")), + None => diagnostic.with_help(format!("fields: {}", known.join(", "))), + }; + self.diagnostics.push(diagnostic); + continue; + } + if fields.insert(name, field).is_some() { + self.error( + "field", + file, + field.key.span, + format!("field `{name}` is given more than once"), + ); + } + } + for doc in builtins::data_fields(keyword).filter(|doc| doc.required) { + if !fields.contains_key(doc.name) { + self.diagnostics.push( + Diagnostic::error( + "field", + file, + data.name.span, + format!("`{keyword}` needs `{}`", doc.name), + ) + .with_help(doc.doc), + ); + } + } + fields + } + + fn data_expr<'a>( + &mut self, + file: FileId, + value: &'a DataValue, + what: &str, + ) -> Option<&'a Expr> { + match value { + DataValue::Expr(expr) => Some(expr), + other => { + self.error("type", file, other.span(), format!("expected {what}")); + None + } + } + } + + /// A vanilla item or a declared custom item (only where `allow_custom`). + fn data_item_ref( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + allow_custom: bool, + ) -> Option { + let expr = self.data_expr(file, value, "an item such as `Item::Diamond`")?; + if let Some((def, id)) = self.declared(module, file, expr, DefKind::CustomItem) { + if !allow_custom { + self.error( + "type", + file, + expr.span(), + format!( + "`{}` is a custom item; the base must be a vanilla item", + self.defs[def.0].name + ), + ); + return None; + } + return Some(id); + } + self.vanilla_value(module, file, expr, "Item") + } + + /// Resolve a path to a declaration of `kind`, recording the reference. + pub(super) fn declared( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + kind: DefKind, + ) -> Option<(DefId, String)> { + let Expr::Path(path) = expr else { + return None; + }; + let Ok((def, _)) = self.resolve_path(module, path) else { + return None; + }; + if self.defs[def.0].kind != kind { + return None; + } + let DefInfo::Data { id, .. } = &self.defs[def.0].info else { + return None; + }; + let id = id.clone(); + self.references.push(Reference { + file, + span: path.last().span, + def, + }); + Some((def, id)) + } + + fn data_smithing_ingredients( + &mut self, + module: ModuleId, + file: FileId, + template: &DataField, + base: Option<&DataField>, + addition: Option<&DataField>, + ) -> Option<(String, String, String)> { + let (Some(base), Some(addition)) = (base, addition) else { + self.error( + "recipe", + file, + template.key.span, + "a smithing recipe needs `base` and `addition`", + ); + return None; + }; + let template = self.data_ingredient(module, file, &template.value); + let base = self.data_ingredient(module, file, &base.value); + let addition = self.data_ingredient(module, file, &addition.value); + Some((template?, base?, addition?)) + } + + fn data_ingredient( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let expr = self.data_expr(file, value, "an ingredient such as `Item::Stick`")?; + if let Some((def, id)) = self.declared(module, file, expr, DefKind::Tag) { + if !matches!( + self.defs[def.0].info, + DefInfo::Data { + tag_type: Some("Item"), + .. + } + ) { + self.error( + "type", + file, + expr.span(), + "recipe ingredients use `Item` tags", + ); + return None; + } + return Some(format!("#{id}")); + } + if let Some((def, _)) = self.declared(module, file, expr, DefKind::CustomItem) { + let name = self.defs[def.0].name.clone(); + self.diagnostics.push( + Diagnostic::error("recipe", file, expr.span(), format!("custom item `{name}` cannot be a recipe ingredient")) + .with_help("vanilla recipes match ingredients only by item id or tag; use its base item or an item tag"), + ); + return None; + } + self.data_tag_or(module, file, expr, "Item") + } + + fn data_tag_value( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + registry: &'static str, + ) -> Option { + let expr = self.data_expr(file, value, "a value")?; + if let Some((def, id)) = self.declared(module, file, expr, DefKind::Tag) { + if !matches!(&self.defs[def.0].info, DefInfo::Data { tag_type: Some(t), .. } if *t == registry) + { + self.error( + "type", + file, + expr.span(), + format!("expected a `{registry}` tag"), + ); + return None; + } + return Some(format!("#{id}")); + } + self.data_tag_or(module, file, expr, registry) + } + + /// `"#ns:tag"` strings, or a typed vanilla value. + fn data_tag_or( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + registry: &'static str, + ) -> Option { + if let Expr::Str { value, span, .. } = expr + && let Some(tag) = value.strip_prefix('#') + { + if tag.parse::().is_err() || !tag.contains(':') { + self.error( + "id", + file, + *span, + format!("`{value}` is not a tag reference such as `\"#minecraft:logs\"`"), + ); + return None; + } + return Some(value.clone()); + } + self.vanilla_value(module, file, expr, registry) + } + + fn data_object_fields<'a>( + &mut self, + file: FileId, + value: &'a DataValue, + kind: &str, + required: &[&str], + optional: &[&str], + ) -> Option> { + let DataValue::Object(entries, span) = value else { + self.error( + "field", + file, + value.span(), + format!("expected fields in braces for `{kind}`"), + ); + return None; + }; + let mut fields = BTreeMap::new(); + for field in entries { + let name = field.key.name.as_str(); + if !required.contains(&name) && !optional.contains(&name) { + self.error( + "field", + file, + field.key.span, + format!("`{kind}` has no field `{name}`"), + ); + } else if fields.insert(name, &field.value).is_some() { + self.error( + "field", + file, + field.key.span, + format!("duplicate `{kind}` field `{name}`"), + ); + } + } + for name in required { + if !fields.contains_key(name) { + self.error("field", file, *span, format!("`{kind}` needs `{name}`")); + } + } + Some(fields) + } + + fn data_menu_choices( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + let DataValue::Array(entries, _) = value else { + self.error( + "menu", + file, + value.span(), + "expected a list of menu choices", + ); + return None; + }; + if !(1..=256).contains(&entries.len()) { + self.error( + "menu", + file, + value.span(), + "a menu needs between 1 and 256 choices", + ); + return None; + } + entries + .iter() + .map(|choice| { + let fields = self.data_object_fields( + file, + choice, + "menu choice", + &["label"], + &["action", "next", "when"], + )?; + if !fields.contains_key("action") && !fields.contains_key("next") { + self.error( + "menu", + file, + choice.span(), + "a menu choice needs an action or destination", + ); + return None; + } + Some(pc::MenuChoice { + label: self.data_text(module, file, fields.get("label")?)?, + action: fields + .get("action") + .and_then(|value| self.data_callback(module, file, value)), + next: fields + .get("next") + .and_then(|value| self.data_menu_name(file, value)), + when: fields + .get("when") + .and_then(|value| self.data_menu_guard(module, file, value)), + }) + }) + .collect() + } + + fn data_menu_views( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + let DataValue::Array(views, _) = value else { + self.error("menu", file, value.span(), "expected a list of menu views"); + return None; + }; + views + .iter() + .map(|view| { + let fields = self.data_object_fields( + file, + view, + "menu view", + &["name", "title", "choices"], + &[], + )?; + Some(pc::MenuView { + name: self.data_menu_name(file, fields.get("name")?)?, + title: self.data_text(module, file, fields.get("title")?)?, + choices: self.data_menu_choices(module, file, fields.get("choices")?)?, + }) + }) + .collect() + } + + fn data_menu_name(&mut self, file: FileId, value: &DataValue) -> Option { + if let Expr::Str { value, .. } = self.data_expr(file, value, "a quoted menu view name")? { + return Some(value.clone()); + } + self.error( + "menu", + file, + value.span(), + "expected a quoted menu view name", + ); + None + } + + fn data_menu_guard( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let expr = self.data_expr(file, value, "a boolean State field")?; + let Expr::Place(place) = expr else { + self.error("menu", file, value.span(), "expected a boolean State field"); + return None; + }; + let (state, field, ty) = self.resolve_place(module, file, place)?; + if !self.types_agree(file, value.span(), Ty::Bool, ty) { + return None; + } + self.field_reference(state, field) + } + + fn data_hud_bossbar( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let fields = + self.data_object_fields(file, value, "HUD boss bar", &["title", "value", "max"], &[])?; + let title = self.data_text(module, file, fields.get("title")?)?; + let max = self.data_int(module, file, fields.get("max")?, 1, i64::from(i32::MAX))? as u32; + let value = self.data_expr( + file, + fields.get("value")?, + "a constant or State number field", + )?; + let value = match value { + Expr::Place(place) => { + let (state, field, ty) = self.resolve_place(module, file, place)?; + if !self.types_agree(file, value.span(), Ty::Number, ty) { + return None; + } + pc::ScoreOperand::Field(self.field_reference(state, field)?) + } + _ => pc::ScoreOperand::Value(self.eval_i32( + module, + file, + value, + Some(Ty::Number), + None, + )? as i32), + }; + Some(pc::HudBossBar { title, value, max }) + } + + fn data_callback( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let expr = self.data_expr(file, value, "a callback function name")?; + let Expr::Path(path) = expr else { + self.error( + "type", + file, + value.span(), + "expected a callback function name", + ); + return None; + }; + let def = self.expect_path( + module, + path, + &[DefKind::Function, DefKind::ExternFunction], + "a function", + )?; + if self.defs[def.0].kind == DefKind::Function + && !self + .fn_slots + .get(&def) + .is_some_and(|slots| slots.params.is_empty() && slots.ret.is_none()) + { + self.error( + "type", + file, + path.span, + "expected a parameterless function with no return value", + ); + return None; + } + self.function_reference(def) + } + + fn data_biome_spawners( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option>> { + let DataValue::Object(categories, _) = value else { + self.error( + "biome", + file, + value.span(), + "expected spawn categories such as `{ creature: [...] }`", + ); + return None; + }; + let mut table = BTreeMap::new(); + for category in categories { + let Ok(kind) = + serde_json::from_value(serde_json::Value::String(category.key.name.clone())) + else { + self.error( + "biome", + file, + category.key.span, + format!("unknown mob spawn category `{}`", category.key.name), + ); + continue; + }; + let DataValue::Array(entries, _) = &category.value else { + self.error( + "biome", + file, + category.value.span(), + "expected a list of weighted spawn entries", + ); + continue; + }; + let entries = entries + .iter() + .map(|entry| { + let fields = self.data_object_fields( + file, + entry, + "spawn entry", + &["entity"], + &["weight", "min_count", "max_count"], + )?; + let entity = self.data_spawn_entity(module, file, fields.get("entity")?)?; + let mut number = |key, default, min| { + fields.get(key).map_or(Some(default), |value| { + self.data_int(module, file, value, min, i64::from(i32::MAX)) + }) + }; + let weight = number("weight", 1, 1)?; + let min = number("min_count", 1, 1)?; + let max = number("max_count", min, min)?; + Some(sand::component::SpawnEntry::new( + entity, + weight as u32, + min as u32, + max as u32, + )) + }) + .collect::>>()?; + if table.insert(kind, entries).is_some() { + self.error( + "biome", + file, + category.key.span, + format!("duplicate mob spawn category `{}`", category.key.name), + ); + } + } + Some(table) + } + + fn data_biome_spawn_costs( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + let DataValue::Array(entries, _) = value else { + self.error( + "biome", + file, + value.span(), + "expected a list of entity spawn costs", + ); + return None; + }; + let mut costs = BTreeMap::new(); + for entry in entries { + let fields = self.data_object_fields( + file, + entry, + "spawn cost", + &["entity", "energy_budget", "charge"], + &[], + )?; + let entity = self.data_spawn_entity(module, file, fields.get("entity")?)?; + let budget = self.data_number(module, file, fields.get("energy_budget")?)?; + let charge = self.data_number(module, file, fields.get("charge")?)?; + if costs + .insert( + entity.to_string(), + sand::component::SpawnCost::new(budget, charge), + ) + .is_some() + { + self.error( + "biome", + file, + entry.span(), + "duplicate spawn cost for this entity type", + ); + } + } + Some(costs) + } + + fn data_spawn_entity( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let expr = self.data_expr(file, value, "an entity type")?; + self.vanilla_value(module, file, expr, "Entity")? + .parse::() + .ok() + .map(Into::into) + } + + fn data_biome_number( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let expr = self.data_expr(file, value, "a constant number")?; + match self.eval(module, file, expr, None)? { + (value, Ty::Number) => Some(value as f32), + (value, Ty::Float) => Some((value as f64 / FLOAT_SCALE as f64) as f32), + _ => { + self.error("type", file, expr.span(), "expected a constant number"); + None + } + } + } + + fn data_biome_color(&mut self, file: FileId, value: &DataValue) -> Option { + let expr = self.data_expr(file, value, "an RGB color")?; + if let Expr::Str { value, .. } = expr + && let Some(hex) = value.strip_prefix('#') + && hex.len() == 6 + && hex.bytes().all(|byte| byte.is_ascii_hexdigit()) + { + return u32::from_str_radix(hex, 16).ok(); + } + self.error( + "color", + file, + expr.span(), + "expected an RGB color such as `\"#3f76e4\"`", + ); + None + } + + fn data_flat_layers( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + let DataValue::Array(entries, _) = value else { + self.error( + "dimension", + file, + value.span(), + "expected a list of terrain layers", + ); + return None; + }; + entries + .iter() + .map(|entry| { + let fields = + self.data_object_fields(file, entry, "flat layer", &["block", "height"], &[])?; + let block = self.data_expr(file, fields.get("block")?, "a block")?; + let block = self + .vanilla_value(module, file, block, "Block")? + .parse::() + .ok()?; + let height = + self.data_int(module, file, fields.get("height")?, 1, i64::from(u32::MAX))?; + Some(sand::component::FlatLayer::new(block, height as u32)) + }) + .collect() + } + + fn data_advancement_criteria( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + let DataValue::Object(entries, span) = value else { + self.error( + "advancement", + file, + value.span(), + "expected a map of named advancement criteria", + ); + return None; + }; + if entries.is_empty() { + self.error( + "advancement", + file, + *span, + "an advancement needs at least one criterion", + ); + return None; + } + let mut criteria = BTreeMap::new(); + for field in entries { + let DataValue::Object(triggers, _) = &field.value else { + self.error( + "advancement", + file, + field.value.span(), + "expected one typed trigger in braces", + ); + continue; + }; + let [trigger] = triggers.as_slice() else { + self.error( + "advancement", + file, + field.value.span(), + "an advancement criterion has exactly one trigger", + ); + continue; + }; + let criterion = match trigger.key.name.as_str() { + "inventory_item" => self + .data_item_ref(module, file, &trigger.value, false) + .map(|item| pc::AdvancementCriterion::InventoryItem { item }), + "place_block" => self + .data_expr(file, &trigger.value, "a Block value") + .and_then(|expr| self.vanilla_value(module, file, expr, "Block")) + .map(|block| pc::AdvancementCriterion::PlaceBlock { block }), + "kill_entity" => self + .data_expr(file, &trigger.value, "an Entity value") + .and_then(|expr| self.vanilla_value(module, file, expr, "Entity")) + .map(|entity| pc::AdvancementCriterion::KillEntity { entity }), + _ => { + self.error( + "advancement", + file, + trigger.key.span, + "use `inventory_item`, `place_block`, or `kill_entity`", + ); + None + } + }; + if let Some(criterion) = criterion + && criteria.insert(field.key.name.clone(), criterion).is_some() + { + self.error( + "advancement", + file, + field.key.span, + format!("duplicate criterion `{}`", field.key.name), + ); + } + } + Some(criteria) + } + + fn data_advancement_display( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let fields = self.data_object_fields( + file, + value, + "display", + &["icon", "title", "description"], + &["background"], + )?; + let icon = self.data_item_ref(module, file, fields.get("icon")?, false)?; + let title = self.data_text(module, file, fields.get("title")?)?; + let description = self.data_text(module, file, fields.get("description")?)?; + let background = match fields.get("background") { + Some(background) => { + let id = match background { + DataValue::Expr(Expr::Str { value, .. }) => value.parse().ok(), + _ => None, + }; + let Some(id) = id else { + self.error( + "advancement", + file, + background.span(), + "expected a quoted namespaced background texture id", + ); + return None; + }; + Some(id) + } + None => None, + }; + Some(pc::AdvancementDisplay { + icon, + title, + description, + background, + }) + } + + fn data_book( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option { + let fields = + self.data_object_fields(file, value, "book", &["title", "author", "pages"], &[])?; + let plain = |this: &mut Self, key: &str| match fields.get(key)? { + DataValue::Expr(Expr::Str { value, .. }) => Some(value.clone()), + other => { + this.error( + "book", + file, + other.span(), + format!("book {key} must be a quoted string"), + ); + None + } + }; + let title = plain(self, "title")?; + let author = plain(self, "author")?; + let DataValue::Array(pages, _) = fields.get("pages")? else { + self.error( + "book", + file, + fields["pages"].span(), + "book pages must be a list of text values", + ); + return None; + }; + let count = pages.len(); + let pages = pages + .iter() + .map(|page| self.data_static_text(module, file, page, Some(count))) + .collect::>>()?; + Some(pc::WrittenBookContent { + title, + author, + pages, + }) + } + + fn data_text( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + self.data_static_text(module, file, value, None) + } + + fn data_static_text( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + book_pages: Option, + ) -> Option> { + let expr = self.data_expr(file, value, "text in quotes")?.clone(); + let span = expr.span(); + let mut body = BodyCx::new(module, file, false); + let arg = Arg { + name: None, + value: ArgValue::Expr(expr), + span, + }; + let parts = + self.presentation_text(&mut body, &arg, None, book_pages.is_some(), book_pages, 0)?; + self.diagnostics.append(&mut body.pending); + if parts.iter().any(|part| !part.is_static()) || body.player_use.is_some() { + self.diagnostics.push( + Diagnostic::error( + "text", + file, + span, + "resource text cannot read runtime values", + ) + .with_help( + "use literals, styles or translations with fixed arguments; scores and `{player}` are not available", + ), + ); + return None; + } + Some(parts) + } + + fn data_bool(&mut self, file: FileId, value: &DataValue) -> Option { + match value { + DataValue::Expr(Expr::Bool(b, _)) => Some(*b), + other => { + self.error("type", file, other.span(), "expected `true` or `false`"); + None + } + } + } + + fn data_int( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + min: i64, + max: i64, + ) -> Option { + let expr = self.data_expr(file, value, "an integer")?; + let v = self.eval_i32(module, file, expr, Some(Ty::Number), None)?; + if v < min || v > max { + self.error( + "range", + file, + expr.span(), + format!("expected a value from {min} to {max}, found {v}"), + ); + return None; + } + Some(v) + } + + fn data_number(&mut self, module: ModuleId, file: FileId, value: &DataValue) -> Option { + let expr = self.data_expr(file, value, "a number")?; + match expr { + Expr::Float(v, _) => Some(*v), + other => self + .eval_i32(module, file, other, Some(Ty::Number), None) + .map(|v| v as f64), + } + } + + fn data_pattern(&mut self, file: FileId, value: &DataValue) -> Option> { + let DataValue::Array(rows, span) = value else { + self.error( + "type", + file, + value.span(), + "expected rows such as `[\"AAA\", \" B \"]`", + ); + return None; + }; + let mut pattern = Vec::new(); + for row in rows { + match row { + DataValue::Expr(Expr::Str { value, .. }) => pattern.push(value.clone()), + other => { + self.error("type", file, other.span(), "pattern rows are strings"); + return None; + } + } + } + let width = pattern.first().map(|r| r.chars().count()).unwrap_or(0); + if pattern.is_empty() + || pattern.len() > 3 + || width == 0 + || width > 3 + || pattern.iter().any(|r| r.chars().count() != width) + { + self.diagnostics.push( + Diagnostic::error( + "recipe", + file, + *span, + "a pattern has one to three rows of the same width, at most three wide", + ) + .with_help("spaces are empty slots: `[\" D \", \" D \", \" S \"]`"), + ); + return None; + } + Some(pattern) + } + + fn data_enchantments( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option> { + let mut out = BTreeMap::new(); + match value { + DataValue::Array(entries, _) => { + for entry in entries { + let (id, level, span) = self.data_enchantment_entry(module, file, entry)?; + if out.insert(id.clone(), level).is_some() { + self.error( + "duplicate", + file, + span, + format!("enchantment `{id}` is listed twice"), + ); + return None; + } + } + } + DataValue::Object(entries, _) => { + let target = self + .pack + .as_ref() + .map_or(sand_version::LATEST_KNOWN, |pack| &pack.minecraft) + .to_owned(); + for entry in entries { + let id = &entry.key.name; + if !id.contains(':') || id.parse::().is_err() { + self.error( + "id", + file, + entry.key.span, + format!("invalid enchantment identity `{id}`"), + ); + return None; + } + if id.starts_with("minecraft:") + && sand_version::registry::contains(&target, "minecraft:enchantment", id) + == Some(false) + { + self.error( + "id", + file, + entry.key.span, + format!("no enchantment `{id}` in Minecraft {target}"), + ); + return None; + } + let level = self.data_int(module, file, &entry.value, 1, 255)?; + if out.insert(id.clone(), level as u32).is_some() { + self.error( + "duplicate", + file, + entry.key.span, + format!("enchantment `{id}` is listed twice"), + ); + return None; + } + } + } + _ => { + self.error("type", file, value.span(), "expected a list of `{ enchantment: Enchantment::Sharpness, level: 5 }` entries"); + return None; + } + } + Some(out) + } + + fn data_enchantment_entry( + &mut self, + module: ModuleId, + file: FileId, + value: &DataValue, + ) -> Option<(String, u32, Span)> { + let DataValue::Object(fields, span) = value else { + self.error( + "type", + file, + value.span(), + "expected an enchantment and level pair", + ); + return None; + }; + let mut enchantment = None; + let mut level = None; + for field in fields { + match field.key.name.as_str() { + "enchantment" if enchantment.is_none() => { + let expr = self.data_expr(file, &field.value, "a typed enchantment")?; + enchantment = Some(self.vanilla_value(module, file, expr, "Enchantment")?); + } + "level" if level.is_none() => { + level = Some(self.data_int(module, file, &field.value, 1, 255)? as u32); + } + "enchantment" | "level" => { + self.error( + "duplicate", + file, + field.key.span, + format!("duplicate enchantment entry field `{}`", field.key.name), + ); + return None; + } + _ => { + self.error( + "field", + file, + field.key.span, + "an enchantment entry has only enchantment and level fields", + ); + return None; + } + } + } + let (Some(id), Some(level)) = (enchantment, level) else { + self.error( + "field", + file, + *span, + "an enchantment entry needs both enchantment and level", + ); + return None; + }; + Some((id, level, *span)) + } +} diff --git a/sand-lang/src/analysis/sequence_methods.rs b/sand-lang/src/analysis/sequence_methods.rs new file mode 100644 index 00000000..4b54fe98 --- /dev/null +++ b/sand-lang/src/analysis/sequence_methods.rs @@ -0,0 +1,484 @@ +//! Vector intrinsics operate on ordinary typed values and writable addresses. +use super::*; +use pc::DataModifyOperation; +use sand::data::NbtValue; + +impl Cx { + pub(super) fn emit_list_method( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + self.list_method(body, Some((dest, ty)), expr, ops) + } + + pub(super) fn lower_list_statement( + &mut self, + body: &mut BodyCx, + expr: &Expr, + ops: &mut Vec, + ) { + let _ = self.list_method(body, None, expr, ops); + } + + fn list_method( + &mut self, + body: &mut BodyCx, + result: Option<(&pc::FieldReference, Ty)>, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Method { + receiver, + name, + args, + span, + .. + } = expr + else { + unreachable!() + }; + let list_ty = self.type_of(body, receiver); + let element = self.list_element(list_ty)?; + let Some(builtin) = crate::builtins::list_method(&name.name) else { + self.error( + "method", + body.file, + name.span, + format!("vectors have no method `{}`", name.name), + ); + return None; + }; + self.references_builtin(body.file, name.span, builtin); + let bound = self.bind_args(body, builtin, args, *span)?; + let result_ty = match name.name.as_str() { + "len" | "extend" => Ty::Number, + "is_empty" | "contains" | "push" | "insert" => Ty::Bool, + "get_or" | "pop_or" | "remove_or" => element, + _ => Ty::Unknown, + }; + if let Some((_, expected)) = result { + if builtin.kind == crate::builtins::BuiltinKind::Statement { + self.error( + "type", + body.file, + *span, + "this vector method does not return a value", + ); + return None; + } + if !self.types_agree(body.file, *span, expected, result_ty) { + return None; + } + } + let depth = body.temp_depth; + let mutable = matches!( + name.name.as_str(), + "push" | "pop_or" | "remove_or" | "insert" | "extend" | "clear" | "truncate" + ); + let address = if mutable { + Some(self.value_address(body, receiver, ops)?) + } else { + None + }; + let source = self.temp(body); + if let Some(address) = &address { + self.read_address(body, &source, address, *span, ops)?; + } else { + self.emit(body, &source, list_ty, receiver, ops)?; + } + let mut values = BTreeMap::new(); + for argument in args { + let (¶meter, _) = bound + .iter() + .find(|(_, value)| std::ptr::eq(**value, argument))?; + let ArgValue::Expr(value) = &argument.value else { + self.error( + "argument", + body.file, + argument.span, + "this method argument needs a value expression", + ); + return None; + }; + let slot = self.temp(body); + let ty = match parameter { + "index" | "length" => Ty::Number, + "values" => list_ty, + _ => element, + }; + self.emit(body, &slot, ty, value, ops)?; + values.insert(parameter, slot); + } + let ignored = self.temp(body); + let dest = result.map_or(&ignored, |(dest, _)| dest); + let file = body.file; + let at = |action| op_at(action, file, *span); + if result_ty != Ty::Unknown { + let defaults = self.record_constant(body.module, file, None, result_ty)?; + for ((score, _), value) in self.value_slots(dest, result_ty).into_iter().zip(defaults) { + ops.push(at(Self::initialize_leaf(score, value))); + } + } + let invocation_start = ops.len(); + let length = self.temp(body); + ops.push(at(pc::Action::DataRead { + score: length.clone(), + source: Self::data_reference(&source), + })); + match name.name.as_str() { + "len" => self.copy_value(dest, &length, Ty::Number, file, *span, ops), + "is_empty" => ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: length, + min: Some(0), + max: Some(0), + }), + then: vec![at(pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + })], + otherwise: Vec::new(), + })), + "get_or" | "pop_or" | "remove_or" => { + self.copy_value(dest, &values["fallback"], element, file, *span, ops); + let selected = if name.name == "pop_or" { + let selected = self.temp(body); + self.copy_value(&selected, &length, Ty::Number, file, *span, ops); + ops.push(at(pc::Action::ScoreAdd { + score: selected.clone(), + value: -1, + })); + selected + } else { + values["index"].clone() + }; + let valid = self.storage_index_valid( + body, + Self::data_reference(&source), + &selected, + *span, + ops, + ); + let selected_value = Self::stored_element(&source, &selected); + let mut then = Vec::new(); + self.unpack_value( + body, + dest, + selected_value.clone(), + element, + *span, + &mut then, + ); + if mutable { + then.push(at(pc::Action::DataRemove { + target: selected_value, + })); + } + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: valid, + min: Some(1), + max: Some(1), + }), + then, + otherwise: Vec::new(), + })); + if let Some(address) = &address { + self.write_address(body, address, &source, *span, ops); + } + } + "contains" => { + let needle = self.temp(body); + self.register_data_slot(&needle, NbtValue::List(Vec::new())); + self.pack_value( + body, + Self::data_reference(&needle), + &values["value"], + element, + *span, + ops, + ); + let counter = self.temp(body); + let equal = self.temp(body); + ops.push(at(pc::Action::ScoreSet { + score: counter.clone(), + value: 0, + })); + ops.push(at(pc::Action::While { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: counter.clone(), + relation: pc::Relation::Lt, + right: length.clone(), + }), + body: vec![ + at(pc::Action::DataEqual { + score: equal.clone(), + left: Self::stored_element(&source, &counter), + right: Self::data_reference(&needle), + }), + at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: equal, + min: Some(1), + max: Some(1), + }), + then: vec![ + at(pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + }), + at(pc::Action::ScoreOperation { + score: counter.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length), + }), + ], + otherwise: vec![at(pc::Action::ScoreAdd { + score: counter, + value: 1, + })], + }), + ], + })); + } + "push" => { + let packed = self.temp(body); + self.register_data_slot(&packed, NbtValue::List(Vec::new())); + let mut then = Vec::new(); + self.pack_value( + body, + Self::data_reference(&packed), + &values["value"], + element, + *span, + &mut then, + ); + then.push(at(pc::Action::DataModify { + target: Self::data_reference(&source), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::data_reference(&packed), + }, + })); + self.write_address(body, address.as_ref()?, &source, *span, &mut then); + then.push(at(pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + })); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: length, + min: Some(0), + max: Some(super::sequences::LIST_LIMIT as i32 - 1), + }), + then, + otherwise: Vec::new(), + })); + } + "clear" => { + ops.push(at(Self::initialize_leaf( + source.clone(), + text::LeafDefault::Data(NbtValue::List(Vec::new())), + ))); + self.write_address(body, address.as_ref()?, &source, *span, ops); + } + "truncate" => { + let limit = &values["length"]; + ops.push(at(pc::Action::ScoreOperation { + score: limit.clone(), + operator: pc::ScoreOperator::Max, + operand: pc::ScoreOperand::Value(0), + })); + let last = self.temp(body); + ops.push(at(pc::Action::While { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: length.clone(), + relation: pc::Relation::Gt, + right: limit.clone(), + }), + body: vec![ + at(pc::Action::ScoreOperation { + score: last.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length.clone()), + }), + at(pc::Action::ScoreAdd { + score: last.clone(), + value: -1, + }), + at(pc::Action::DataRemove { + target: Self::stored_element(&source, &last), + }), + at(pc::Action::ScoreAdd { + score: length, + value: -1, + }), + ], + })); + self.write_address(body, address.as_ref()?, &source, *span, ops); + } + "extend" => { + let other = &values["values"]; + let limit = self.temp(body); + ops.push(at(pc::Action::ScoreSet { + score: limit.clone(), + value: super::sequences::LIST_LIMIT as i32, + })); + ops.push(at(pc::Action::ScoreOperation { + score: limit.clone(), + operator: pc::ScoreOperator::Sub, + operand: pc::ScoreOperand::Field(length), + })); + let other_length = self.temp(body); + ops.push(at(pc::Action::DataRead { + score: other_length.clone(), + source: Self::data_reference(other), + })); + ops.push(at(pc::Action::ScoreOperation { + score: limit.clone(), + operator: pc::ScoreOperator::Min, + operand: pc::ScoreOperand::Field(other_length), + })); + ops.push(at(pc::Action::ScoreSet { + score: dest.clone(), + value: 0, + })); + ops.push(at(pc::Action::While { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: dest.clone(), + relation: pc::Relation::Lt, + right: limit, + }), + body: vec![ + at(pc::Action::DataModify { + target: Self::data_reference(&source), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::stored_element(other, dest), + }, + }), + at(pc::Action::ScoreAdd { + score: dest.clone(), + value: 1, + }), + ], + })); + self.write_address(body, address.as_ref()?, &source, *span, ops); + } + "insert" => { + let packed = self.temp(body); + self.register_data_slot(&packed, NbtValue::List(Vec::new())); + let output = self.temp(body); + self.register_data_slot(&output, NbtValue::List(Vec::new())); + let counter = self.temp(body); + let index = &values["index"]; + let mut then = Vec::new(); + self.pack_value( + body, + Self::data_reference(&packed), + &values["value"], + element, + *span, + &mut then, + ); + then.push(at(Self::initialize_leaf( + output.clone(), + text::LeafDefault::Data(NbtValue::List(Vec::new())), + ))); + then.push(at(pc::Action::ScoreSet { + score: counter.clone(), + value: 0, + })); + then.push(at(pc::Action::While { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: counter.clone(), + relation: pc::Relation::Le, + right: length.clone(), + }), + body: vec![ + at(pc::Action::Branch { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: counter.clone(), + relation: pc::Relation::Eq, + right: index.clone(), + }), + then: vec![at(pc::Action::DataModify { + target: Self::data_reference(&output), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::data_reference(&packed), + }, + })], + otherwise: Vec::new(), + }), + at(pc::Action::Branch { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: counter.clone(), + relation: pc::Relation::Lt, + right: length.clone(), + }), + then: vec![at(pc::Action::DataModify { + target: Self::data_reference(&output), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::stored_element(&source, &counter), + }, + })], + otherwise: Vec::new(), + }), + at(pc::Action::ScoreAdd { + score: counter, + value: 1, + }), + ], + })); + self.write_address(body, address.as_ref()?, &output, *span, &mut then); + then.push(at(pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + })); + let room = pc::Condition::Range(pc::ScoreComparison { + score: length.clone(), + min: Some(0), + max: Some(super::sequences::LIST_LIMIT as i32 - 1), + }); + let nonnegative = pc::Condition::Range(pc::ScoreComparison { + score: index.clone(), + min: Some(0), + max: None, + }); + let within = pc::Condition::Relation(pc::ScoreRelation { + left: index.clone(), + relation: pc::Relation::Le, + right: length, + }); + ops.push(at(pc::Action::Branch { + condition: room, + then: vec![at(pc::Action::Branch { + condition: nonnegative, + then: vec![at(pc::Action::Branch { + condition: within, + then, + otherwise: Vec::new(), + })], + otherwise: Vec::new(), + })], + otherwise: Vec::new(), + })); + } + _ => unreachable!("documented vector methods have lowering"), + } + if let Some(address) = &address + && self.address_is_guarded(address) + { + let invocation = ops.split_off(invocation_start); + ops.extend(self.guard_address(body, address, *span, invocation)); + } + body.temp_depth = depth; + Some(()) + } +} diff --git a/sand-lang/src/analysis/sequences.rs b/sand-lang/src/analysis/sequences.rs new file mode 100644 index 00000000..ab2a33bb --- /dev/null +++ b/sand-lang/src/analysis/sequences.rs @@ -0,0 +1,585 @@ +//! Growable collections use the same owned NBT leaves as runtime text. +use super::*; +use pc::DataModifyOperation; +use sand::data::{NbtCompound, NbtValue}; + +pub(super) const LIST_LIMIT: usize = 1024; + +impl Cx { + pub(super) fn storage_index_valid( + &mut self, + body: &mut BodyCx, + source: pc::DataReference, + index: &pc::FieldReference, + span: Span, + ops: &mut Vec, + ) -> pc::FieldReference { + let file = body.file; + let at = |action| op_at(action, file, span); + let length = self.temp(body); + let valid = self.temp(body); + ops.push(at(pc::Action::DataRead { + score: length.clone(), + source, + })); + ops.push(at(pc::Action::ScoreSet { + score: valid.clone(), + value: 0, + })); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: index.clone(), + min: Some(0), + max: None, + }), + then: vec![at(pc::Action::Branch { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: index.clone(), + relation: pc::Relation::Lt, + right: length, + }), + then: vec![at(pc::Action::ScoreSet { + score: valid.clone(), + value: 1, + })], + otherwise: Vec::new(), + })], + otherwise: Vec::new(), + })); + valid + } + + pub(super) fn emit_list_index( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Index(value, index, span) = expr else { + unreachable!() + }; + let list_ty = self.type_of(body, value); + let element = self.list_element(list_ty)?; + if !self.types_agree(body.file, *span, ty, element) { + return None; + } + let depth = body.temp_depth; + let list = self.temp(body); + self.emit(body, &list, list_ty, value, ops)?; + if Self::is_const_in(body, index) + && self.eval_i32(body.module, body.file, index, Some(Ty::Number), None)? < 0 + { + self.error( + "index", + body.file, + index.span(), + "vector indices must be nonnegative", + ); + return None; + } + let selected = self.temp(body); + self.emit(body, &selected, Ty::Number, index, ops)?; + let defaults = self.record_constant(body.module, body.file, None, element)?; + for ((score, _), value) in self.value_slots(dest, element).into_iter().zip(defaults) { + ops.push(op_at(Self::initialize_leaf(score, value), body.file, *span)); + } + let mut source = Self::data_reference(&list); + let valid = self.storage_index_valid(body, source.clone(), &selected, *span, ops); + source.path.push(pc::DataProjection::Index { + index: pc::ScoreOperand::Field(selected), + }); + let mut then = Vec::new(); + self.unpack_value(body, dest, source, element, *span, &mut then); + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: valid, + min: Some(1), + max: Some(1), + }), + then, + otherwise: Vec::new(), + }, + body.file, + *span, + )); + body.temp_depth = depth; + Some(()) + } + + pub(super) fn list_type(&mut self, module: ModuleId, element: Ty) -> Ty { + if let Some(def) = self.list_types.get(&element) { + return Ty::List(*def); + } + let index = self.defs.len(); + let def = self.push_def(Def { + kind: DefKind::Struct, + name: format!("Vec<{}>", self.ty_name(element)), + module, + file: self.package.module(module).file, + name_span: Span::default(), + span: Span::default(), + docs: Vec::new(), + is_pub: false, + parent: Some(DefId(index)), + info: DefInfo::List { element }, + }); + self.list_types.insert(element, def); + Ty::List(def) + } + + pub(super) fn list_element(&self, ty: Ty) -> Option { + let Ty::List(def) = ty else { + return None; + }; + let DefInfo::List { element } = self.defs[def.0].info else { + return None; + }; + Some(element) + } + + pub(super) fn list_constant( + &mut self, + module: ModuleId, + file: FileId, + def: DefId, + value: Option<&Expr>, + ) -> Option { + let DefInfo::List { element } = self.defs[def.0].info else { + unreachable!() + }; + match value { + None => Some(NbtValue::List(Vec::new())), + Some(Expr::Array(values, span)) => { + if values.len() > LIST_LIMIT { + self.error( + "const", + file, + *span, + "vectors support at most 1024 elements", + ); + return None; + } + let mut result = Vec::new(); + let mut bytes = 2usize; + for value in values { + let value = self.constant_nbt(module, file, element, Some(value))?; + bytes = bytes.saturating_add(value.to_string().len().saturating_add(1)); + if !self.default_size(file, *span, bytes) { + return None; + } + result.push(value); + } + Some(NbtValue::List(result)) + } + Some(Expr::ArrayRepeat { + value, + length, + span, + }) => { + let count = self.eval_i32(module, file, length, Some(Ty::Number), None)?; + if !(0..=LIST_LIMIT as i64).contains(&count) { + self.error( + "const", + file, + *span, + "vectors support at most 1024 elements", + ); + return None; + } + let value = self.constant_nbt(module, file, element, Some(value))?; + let bytes = value + .to_string() + .len() + .saturating_add(1) + .saturating_mul(count as usize) + .saturating_add(2); + if !self.default_size(file, *span, bytes) { + return None; + } + Some(NbtValue::List(vec![value; count as usize])) + } + Some(value) => { + self.error( + "const", + file, + value.span(), + "expected a constant vector literal", + ); + None + } + } + } + + fn constant_nbt( + &mut self, + module: ModuleId, + file: FileId, + ty: Ty, + value: Option<&Expr>, + ) -> Option { + let defaults = self.record_constant(module, file, value, ty)?; + let result = self.nested_default(ty, &mut defaults.into_iter()); + if !self.default_size( + file, + value.map(Expr::span).unwrap_or_default(), + result.to_string().len(), + ) { + return None; + } + Some(result) + } + + fn nested_default( + &self, + ty: Ty, + leaves: &mut impl Iterator, + ) -> NbtValue { + if let Some((element, length)) = self.array_shape(ty) { + return NbtValue::List( + (0..length) + .map(|_| self.nested_default(element, leaves)) + .collect(), + ); + } + if let Ty::Struct(def) = ty { + let mut result = NbtCompound::new(); + for field in self.struct_fields(def) { + result = result.field( + &self.defs[field.0].name, + self.nested_default(self.field_ty(field), leaves), + ); + } + return NbtValue::Compound(result); + } + match leaves.next().expect("validated value layout") { + text::LeafDefault::Score(value) => NbtValue::Int(value), + text::LeafDefault::Data(value) => value, + } + } + + /// Pack a typed score/aggregate value into its canonical nested NBT shape. + pub(super) fn pack_value( + &mut self, + body: &mut BodyCx, + target: pc::DataReference, + source: &pc::FieldReference, + ty: Ty, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + let at = |action| op_at(action, file, span); + self.value_slots(source, ty); + if let Some((element, length)) = self.array_shape(ty) { + ops.push(at(pc::Action::DataModify { + target: target.clone(), + operator: DataModifyOperation::Set, + source: pc::DataOperand::Value { + value: NbtValue::List(Vec::new()), + }, + })); + for index in 0..length { + let depth = body.temp_depth; + let packed = self.temp(body); + self.register_data_slot(&packed, NbtValue::List(Vec::new())); + self.pack_value( + body, + Self::data_reference(&packed), + &super::values::child(source, &format!("i{index}")), + element, + span, + ops, + ); + ops.push(at(pc::Action::DataModify { + target: target.clone(), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::data_reference(&packed), + }, + })); + body.temp_depth = depth; + } + } else if let Ty::Struct(def) = ty { + ops.push(at(pc::Action::DataModify { + target: target.clone(), + operator: DataModifyOperation::Set, + source: pc::DataOperand::Value { + value: NbtValue::Compound(NbtCompound::new()), + }, + })); + for field in self.struct_fields(def) { + let name = self.defs[field.0].name.clone(); + let mut target = target.clone(); + target + .path + .push(pc::DataProjection::Member { name: name.clone() }); + self.pack_value( + body, + target, + &super::values::child(source, &name), + self.field_ty(field), + span, + ops, + ); + } + } else { + let source = if matches!(ty, Ty::String | Ty::List(_) | Ty::Callable(_)) { + pc::DataOperand::Reference { + value: Self::data_reference(source), + } + } else { + pc::DataOperand::Score { + value: pc::ScoreOperand::Field(source.clone()), + } + }; + ops.push(at(pc::Action::DataModify { + target, + operator: DataModifyOperation::Set, + source, + })); + } + } + + /// Restore the typed leaf layout from a stored element. + pub(super) fn unpack_value( + &mut self, + body: &mut BodyCx, + target: &pc::FieldReference, + source: pc::DataReference, + ty: Ty, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + self.value_slots(target, ty); + if let Some((element, length)) = self.array_shape(ty) { + for index in 0..length { + let mut source = source.clone(); + source.path.push(pc::DataProjection::Index { + index: pc::ScoreOperand::Value(index as i32), + }); + self.unpack_value( + body, + &super::values::child(target, &format!("i{index}")), + source, + element, + span, + ops, + ); + } + } else if let Ty::Struct(def) = ty { + for field in self.struct_fields(def) { + let name = self.defs[field.0].name.clone(); + let mut source = source.clone(); + source + .path + .push(pc::DataProjection::Member { name: name.clone() }); + self.unpack_value( + body, + &super::values::child(target, &name), + source, + self.field_ty(field), + span, + ops, + ); + } + } else { + let action = if matches!(ty, Ty::String | Ty::List(_) | Ty::Callable(_)) { + pc::Action::DataModify { + target: Self::data_reference(target), + operator: DataModifyOperation::Set, + source: pc::DataOperand::Reference { value: source }, + } + } else { + pc::Action::DataRead { + score: target.clone(), + source, + } + }; + ops.push(op_at(action, file, span)); + } + } + + pub(super) fn emit_list( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let element = self.list_element(ty)?; + self.value_slots(dest, ty); + let file = body.file; + let span = expr.span(); + let at = |action| op_at(action, file, span); + match expr { + Expr::Array(values, _) => { + if values.len() > LIST_LIMIT { + self.error("type", file, span, "vectors support at most 1024 elements"); + return None; + } + // Stage the full literal before committing the destination. + let depth = body.temp_depth; + let output = self.temp(body); + self.register_data_slot(&output, NbtValue::List(Vec::new())); + ops.push(at(Self::initialize_leaf( + output.clone(), + text::LeafDefault::Data(NbtValue::List(Vec::new())), + ))); + for value in values { + let element_depth = body.temp_depth; + let logical = self.temp(body); + self.emit(body, &logical, element, value, ops)?; + let packed = self.temp(body); + self.register_data_slot(&packed, NbtValue::List(Vec::new())); + self.pack_value( + body, + Self::data_reference(&packed), + &logical, + element, + span, + ops, + ); + ops.push(at(pc::Action::DataModify { + target: Self::data_reference(&output), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::data_reference(&packed), + }, + })); + body.temp_depth = element_depth; + } + self.copy_value(dest, &output, ty, file, span, ops); + body.temp_depth = depth; + } + Expr::ArrayRepeat { value, length, .. } => { + let count = self.eval_i32(body.module, file, length, Some(Ty::Number), None)?; + if !(0..=LIST_LIMIT as i64).contains(&count) { + self.error("type", file, span, "vectors support at most 1024 elements"); + return None; + } + let depth = body.temp_depth; + let logical = self.temp(body); + self.emit(body, &logical, element, value, ops)?; + let packed = self.temp(body); + self.register_data_slot(&packed, NbtValue::List(Vec::new())); + self.pack_value( + body, + Self::data_reference(&packed), + &logical, + element, + span, + ops, + ); + ops.push(at(Self::initialize_leaf( + dest.clone(), + text::LeafDefault::Data(NbtValue::List(Vec::new())), + ))); + for _ in 0..count { + ops.push(at(pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::data_reference(&packed), + }, + })); + } + body.temp_depth = depth; + } + Expr::Path(path) => { + let local = Self::local_of(body, expr).or_else(|| { + self.error("resolve", file, span, "expected a vector value"); + None + })?; + if !self.types_agree(file, span, ty, self.local_ty(local)) { + return None; + } + body.used.insert(local); + self.references.push(Reference { + file, + span: path.last().span, + def: local, + }); + let source = self.local_ref(local); + self.copy_value(dest, &source, ty, file, span, ops); + } + Expr::Place(place) => { + let source = self.place_value(body, place, false)?; + if !self.types_agree(file, span, ty, source.ty) { + return None; + } + self.copy_value(dest, &source.reference, ty, file, span, ops); + } + Expr::Call { path, args, .. } => { + return self.emit_call(body, dest, ty, path, args, span, ops); + } + Expr::Project(value, field, _) => { + return self.emit_projection(body, dest, ty, value, field, ops); + } + Expr::Method { + receiver, + name, + type_arguments, + args, + .. + } if name.name == "to_vec" + && matches!(self.type_of(body, receiver), Ty::Struct(def) if matches!(self.defs[def.0].info, DefInfo::Array { .. })) => + { + let builtin = crate::builtins::array_method("to_vec")?; + self.references_builtin(file, name.span, builtin); + self.bind_args(body, builtin, args, span)?; + let array_ty = self.type_of(body, receiver); + let (actual, _) = self.array_shape(array_ty)?; + if !self.types_agree(file, span, element, actual) { + return None; + } + let depth = body.temp_depth; + let source = self.temp(body); + self.emit(body, &source, array_ty, receiver, ops)?; + self.pack_value( + body, + Self::data_reference(dest), + &source, + array_ty, + span, + ops, + ); + body.temp_depth = depth; + } + Expr::Method { receiver, .. } + if matches!(self.type_of(body, receiver), Ty::List(_)) => + { + return self.emit_list_method(body, dest, ty, expr, ops); + } + Expr::Method { + receiver, + name, + type_arguments, + args, + .. + } => { + return self.emit_method( + body, + dest, + ty, + receiver, + name, + type_arguments, + args, + span, + ops, + ); + } + Expr::Index(..) => return self.emit_index(body, dest, ty, expr, ops), + _ => { + self.error("type", file, span, "expected a vector value"); + return None; + } + } + Some(()) + } +} diff --git a/sand-lang/src/analysis/source_map.rs b/sand-lang/src/analysis/source_map.rs new file mode 100644 index 00000000..83e4428f --- /dev/null +++ b/sand-lang/src/analysis/source_map.rs @@ -0,0 +1,148 @@ +//! Map emitted commands and portable locations to authored source. +use super::*; +use serde_json::{Value, json}; + +impl Analysis { + /// A versioned source map for the lowered program. + /// + /// Entries identify portable module pointers and emitted command ranges. + /// Source offsets are UTF-8 bytes. Generated line numbers are one-based. + /// Build failures report ordinary source diagnostics. + pub fn source_map(&self) -> Result> { + let Some(program) = &self.program else { + return Err(self.diagnostics.clone()); + }; + let (_, commands) = + pc::Compiler::compile_with_command_sources(program).map_err(|errors| { + errors + .iter() + .map(|error| self.map_backend(error)) + .collect::>() + })?; + let directory = self + .package + .root + .parent() + .unwrap_or_else(|| std::path::Path::new("")); + let files: Vec<_> = self + .package + .files + .iter() + .map(|file| { + file.path + .strip_prefix(directory) + .unwrap_or(&file.path) + .to_string_lossy() + .replace('\\', "/") + }) + .collect(); + let locations: BTreeMap<_, _> = self + .pointers + .iter() + .map(|(module, pointer, file, span)| { + ((module.as_str(), pointer.as_str()), (*file, *span)) + }) + .collect(); + let mut entries = Vec::new(); + for (module, pointer, file, span) in &self.pointers { + entries.push(json!({ + "module": module, + "pointer": pointer, + "source": origin(*file, *span), + })); + } + let mut functions = Vec::new(); + for module in &program.modules { + let id = module.id.to_string(); + map_body(&mut entries, &id, "/load", &module.load); + map_body(&mut entries, &id, "/tick", &module.tick); + for (index, function) in module.functions.iter().enumerate() { + let pointer = format!("/functions/{index}"); + let source = locations + .get(&(id.as_str(), pointer.as_str())) + .map(|(file, span)| origin(*file, *span)); + functions.push(json!({ + "id": function.id, + "module": id, + "pointer": pointer, + "resource": format!("data/{}/function/{}.mcfunction", function.id.namespace(), function.id.path()), + "source": source, + })); + map_body( + &mut entries, + &id, + &format!("{pointer}/body"), + &function.body, + ); + } + } + let source_by_pointer: BTreeMap<_, _> = entries + .iter() + .filter_map(|entry| { + Some(( + (entry["module"].as_str()?, entry["pointer"].as_str()?), + &entry["source"], + )) + }) + .collect(); + let commands: BTreeMap<_, _> = commands + .functions + .into_iter() + .filter_map(|(resource, locations)| { + let ranges: Vec<_> = locations + .into_iter() + .filter_map(|location| { + let source = source_by_pointer + .get(&(location.module.as_str(), location.pointer.as_str()))?; + Some(json!({ + "lines": location.lines, + "module": location.module, + "pointer": location.pointer, + "source": source, + })) + }) + .collect(); + (!ranges.is_empty()).then_some((resource, ranges)) + }) + .collect(); + Ok(json!({ + "format": "sand.source_map", + "format_version": 2, + "files": files, + "functions": functions, + "entries": entries, + "commands": commands, + })) + } +} + +fn map_body(entries: &mut Vec, module: &str, parent: &str, body: &[pc::Operation]) { + for (index, operation) in body.iter().enumerate() { + let pointer = format!("{parent}/{index}"); + if let Some(source) = &operation.origin { + entries.push(json!({ "module": module, "pointer": pointer, "source": source })); + } + match &operation.action { + pc::Action::Branch { + then, otherwise, .. + } => { + map_body(entries, module, &format!("{pointer}/action/then"), then); + map_body( + entries, + module, + &format!("{pointer}/action/otherwise"), + otherwise, + ); + } + pc::Action::Players { body } + | pc::Action::Entities { body, .. } + | pc::Action::WithEntity { body, .. } + | pc::Action::While { body, .. } + | pc::Action::InDimension { body, .. } + | pc::Action::Suspend { body, .. } => { + map_body(entries, module, &format!("{pointer}/action/body"), body); + } + _ => {} + } + } +} diff --git a/sand-lang/src/analysis/statements.rs b/sand-lang/src/analysis/statements.rs new file mode 100644 index 00000000..2f99db30 --- /dev/null +++ b/sand-lang/src/analysis/statements.rs @@ -0,0 +1,5565 @@ +//! Lowering for assignments, builtin statements, and text macros. + +use super::*; +use crate::builtins::{self, Builtin, BuiltinKind}; +use crate::properties::{Property, PropertyKind, PropertyType}; +use std::collections::BTreeSet; + +/// A value that needs no computation: a constant or one score read. +#[derive(Debug, Clone)] +pub(super) enum Value { + /// A folded constant. + Const(i64), + /// A State field or local slot. + Read(pc::FieldReference), +} + +/// Where an assignment writes. +struct Dest { + reference: pc::FieldReference, + ty: Ty, + bounds: Option<(i32, i32)>, + name: String, +} + +struct LoweredMatchArm { + values: Vec, + catch_all: bool, + body: Vec, + span: Span, +} + +/// One local and its path inside an already evaluated pattern subject. +#[derive(Clone)] +pub(super) struct PatternLocal { + name: Ident, + def: DefId, + ty: Ty, + projection: Vec, +} + +/// What a `while`-shaped loop repeats on. +pub(super) enum Repeat<'a> { + /// `while cond { }`. + While(&'a Cond), + /// `loop { }`. + Forever, + /// `for binding in range { }`. + Count { + binding: &'a Ident, + range: &'a Range, + reverse: bool, + step: Option<&'a Expr>, + /// Array snapshot supplying the loop binding instead of the counter. + collection: Option<&'a Expr>, + }, +} + +/// Whether the statement can `break` (or `continue`, when `is_break` is +/// false) out of the innermost enclosing loop, without entering a nested one. +pub(super) fn jumps_here(stmt: &Stmt, is_break: bool) -> bool { + match stmt { + Stmt::Break(_) => is_break, + Stmt::Continue(_) => !is_break, + Stmt::If(if_stmt) => if_jumps(if_stmt, is_break), + Stmt::Match { arms, .. } => arms + .iter() + .any(|arm| arm.body.stmts.iter().any(|s| jumps_here(s, is_break))), + _ => false, + } +} + +fn if_jumps(if_stmt: &IfStmt, is_break: bool) -> bool { + if_stmt.then.stmts.iter().any(|s| jumps_here(s, is_break)) + || match &if_stmt.otherwise { + None => false, + Some(Else::Block(block)) => block.stmts.iter().any(|s| jumps_here(s, is_break)), + Some(Else::If(nested)) => if_jumps(nested, is_break), + } +} + +/// Whether a `return` appears anywhere in the block. +fn block_mentions_return(block: &Block) -> bool { + block.stmts.iter().any(|stmt| match stmt { + Stmt::Return { .. } => true, + Stmt::If(if_stmt) => if_mentions_return(if_stmt), + Stmt::Match { arms, .. } => arms.iter().any(|arm| block_mentions_return(&arm.body)), + Stmt::While { body, .. } + | Stmt::Loop { body, .. } + | Stmt::ForRange { body, .. } + | Stmt::ForValues { body, .. } => block_mentions_return(body), + _ => false, + }) +} + +fn if_mentions_return(if_stmt: &IfStmt) -> bool { + block_mentions_return(&if_stmt.then) + || match &if_stmt.otherwise { + None => false, + Some(Else::Block(block)) => block_mentions_return(block), + Some(Else::If(nested)) => if_mentions_return(nested), + } +} + +/// Placeholder flag for loop tests built before the flag is allocated. +fn keep_marker() -> pc::FieldReference { + pc::FieldReference { + state: "sand:keep".parse().expect("valid placeholder"), + field: "__keep".into(), + } +} + +/// Point every placeholder flag write at `keep`. +fn retarget_marker(mut ops: Vec, keep: &pc::FieldReference) -> Vec { + for op in &mut ops { + match &mut op.action { + pc::Action::ScoreSet { score, .. } if score.field == "__keep" => *score = keep.clone(), + pc::Action::Branch { + then, otherwise, .. + } => { + *then = retarget_marker(std::mem::take(then), keep); + *otherwise = retarget_marker(std::mem::take(otherwise), keep); + } + _ => {} + } + } + ops +} + +/// Field-name prefix of an unresolved frame placeholder; `__` cannot start a +/// slot name, so it never collides with a real slot. +pub(super) const FRAME_MARKER: &str = "__frame"; + +/// Whether evaluating the expression calls a function. +pub(super) fn contains_call(expr: &Expr) -> bool { + match expr { + Expr::Match { value, arms, .. } => { + contains_call(value) + || arms.iter().any(|arm| { + contains_call(&arm.value) || arm.guard.as_ref().is_some_and(cond_contains_call) + }) + } + // A value block can contain arbitrary statements before its tail. + Expr::Block { .. } => true, + Expr::Call { .. } => true, + Expr::Neg(inner, _) | Expr::Cast(inner, _, _) => contains_call(inner), + Expr::Binary(lhs, _, rhs, _) => contains_call(lhs) || contains_call(rhs), + Expr::Cond(cond, _) => cond_contains_call(cond), + Expr::Struct { fields, .. } => fields.iter().any(|(_, value)| contains_call(value)), + Expr::Method { .. } => true, + Expr::Project(value, ..) => contains_call(value), + Expr::Array(values, _) => values.iter().any(contains_call), + Expr::ArrayRepeat { value, .. } => contains_call(value), + Expr::Index(value, index, _) => contains_call(value) || contains_call(index), + _ => false, + } +} + +fn cond_contains_call(cond: &Cond) -> bool { + match cond { + Cond::Or(a, b) | Cond::And(a, b) => cond_contains_call(a) || cond_contains_call(b), + Cond::Not(inner, _) => cond_contains_call(inner), + Cond::Compare { lhs, rhs, .. } => contains_call(lhs) || contains_call(rhs), + Cond::Value(value) | Cond::InRange { value, .. } => contains_call(value), + // Builtin predicates call nothing, but a `bool` function does. + Cond::Call { .. } => true, + } +} + +impl Cx { + fn locals_state(&self) -> String { + format!("{}:sand.locals", self.namespace()) + } + + /// The slot reference for a compiler-owned locals field. + pub(super) fn slot(&mut self, field: String) -> pc::FieldReference { + if !self.local_fields.contains(&field) { + self.local_fields.push(field.clone()); + } + pc::FieldReference { + state: self.locals_state().parse().expect("namespace validated"), + field, + } + } + + fn local_slot_name(&self, def: DefId) -> String { + format!("v{}_{}", def.0, self.defs[def.0].name) + } + + pub(super) fn local_ref(&mut self, def: DefId) -> pc::FieldReference { + let name = self.local_slot_name(def); + self.slot(name) + } + + pub(super) fn lookup_local(body: &BodyCx, name: &str) -> Option { + body.scopes + .iter() + .rev() + .find_map(|scope| scope.iter().rev().find(|(n, _)| n == name).map(|(_, d)| *d)) + } + + pub(super) fn local_of(body: &BodyCx, expr: &Expr) -> Option { + match expr { + Expr::Path(path) if path.segments.len() == 1 && path.arguments().is_empty() => { + Self::lookup_local(body, &path.segments[0].name) + } + _ => None, + } + } + + pub(super) fn local_ty(&self, def: DefId) -> Ty { + match self.defs[def.0].info { + DefInfo::Local { ty, .. } => ty, + _ => Ty::Unknown, + } + } + + pub(super) fn is_const_in(body: &BodyCx, expr: &Expr) -> bool { + match expr { + Expr::Int(..) => true, + Expr::Path(_) => Self::local_of(body, expr).is_none(), + Expr::Neg(inner, _) | Expr::Cast(inner, _, _) => Self::is_const_in(body, inner), + Expr::Binary(a, _, b, _) => Self::is_const_in(body, a) && Self::is_const_in(body, b), + Expr::Place(_) + | Expr::Call { .. } + | Expr::Cond(..) + | Expr::Str { .. } + | Expr::Struct { .. } + | Expr::Method { .. } + | Expr::Project(..) + | Expr::Array(..) + | Expr::ArrayRepeat { .. } + | Expr::Index(..) + | Expr::Match { .. } + | Expr::Block { .. } + | Expr::Closure(_) => false, + Expr::Float(..) | Expr::Bool(..) => true, + } + } + + /// The type an expression produces, without reporting errors. + pub(super) fn type_of(&mut self, body: &BodyCx, expr: &Expr) -> Ty { + match expr { + Expr::Closure(closure) => self.closure_type(body.module, closure), + Expr::Block { + body: block, value, .. + } => self.block_tail_type(body, block, value), + Expr::Match { value, arms, .. } => { + let Some(arm) = arms.first() else { + return Ty::Unknown; + }; + let MatchPattern::Binding(pattern) = &arm.pattern else { + return self.type_of(body, &arm.value); + }; + let ty = self.type_of(body, value); + let bindings = self.pattern_locals(body, pattern, ty, arm.span); + let mut scoped = body.clone(); + scoped.scopes.push( + bindings + .iter() + .map(|binding| (binding.name.name.clone(), binding.def)) + .collect(), + ); + self.type_of(&scoped, &arm.value) + } + Expr::Path(path) => { + if let Some(local) = Self::local_of(body, expr) { + return self.local_ty(local); + } + match self.resolve_path(body.module, path) { + Ok((def, _)) => match self.defs[def.0].kind { + DefKind::Variant => { + self.defs[def.0].parent.map(Ty::Enum).unwrap_or(Ty::Number) + } + DefKind::Function => self.named_function_type(body.module, def), + DefKind::Const => { + self.const_src.get(&def).map(|s| s.ty).unwrap_or(Ty::Number) + } + _ => Ty::Number, + }, + Err(_) => Ty::Unknown, + } + } + Expr::Place(place) if self.is_handle(body, place) => { + match crate::properties::find(&place.field.name).map(|p| p.ty) { + Some(PropertyType::Number) => Ty::Number, + Some(PropertyType::Float) => Ty::Float, + Some(PropertyType::Bool) => Ty::Bool, + None => Ty::Unknown, + } + } + Expr::ArrayRepeat { value, length, .. } => { + let element = self.type_of(body, value); + let Some(length) = + self.eval_i32(body.module, body.file, length, Some(Ty::Number), None) + else { + return Ty::Unknown; + }; + if !(0..=1024).contains(&length) { + self.error( + "type", + body.file, + expr.span(), + "array length must be between 0 and 1024", + ); + return Ty::Unknown; + } + self.array_type(body.module, element, length as usize) + } + Expr::Array(values, _) => { + let Some(first) = values.first() else { + return Ty::Unknown; + }; + let element = self.type_of(body, first); + self.array_type(body.module, element, values.len()) + } + Expr::Index(value, _, _) => { + let ty = self.type_of(body, value); + if ty == Ty::String { + return Ty::String; + } + if let Some(element) = self.list_element(ty) { + return element; + } + self.array_shape(ty) + .map_or(Ty::Unknown, |(element, _)| element) + } + Expr::Place(place) => self.place_ty(body, place), + Expr::Struct { path, fields, .. } => self + .record_literal_type( + Some(body), + body.module, + body.file, + path, + fields, + None, + false, + ) + .unwrap_or(Ty::Unknown), + Expr::Project(value, field, _) => { + let ty = self.type_of(body, value); + self.record_member(ty, &field.name) + .map_or(Ty::Unknown, |field| self.field_ty(field)) + } + Expr::Method { + receiver, + name, + type_arguments, + args, + .. + } => { + let receiver_ty = self.type_of(body, receiver); + if name.name == "to_string" + && matches!(receiver_ty, Ty::Number | Ty::Float | Ty::Bool | Ty::Enum(_)) + { + return Ty::String; + } + if let Some(element) = self.list_element(receiver_ty) { + return match name.name.as_str() { + "len" | "extend" => Ty::Number, + "is_empty" | "contains" | "push" | "insert" => Ty::Bool, + "get_or" | "pop_or" | "remove_or" => element, + _ => Ty::Unknown, + }; + } + if receiver_ty == Ty::String { + return match name.name.as_str() { + "len" => Ty::Number, + "slice" => Ty::String, + "is_empty" | "contains" | "starts_with" | "ends_with" => Ty::Bool, + _ => Ty::Unknown, + }; + } + if let Some((element, _)) = self.array_shape(receiver_ty) { + if name.name == "to_vec" { + return self.list_type(body.module, element); + } + return match name.name.as_str() { + "len" => Ty::Number, + "is_empty" | "contains" => Ty::Bool, + "get_or" => element, + _ => Ty::Unknown, + }; + } + let target = self.method_target(body, receiver).or_else(|| { + match self.type_of(body, receiver) { + Ty::Struct(def) => Some(def), + _ => None, + } + }); + let Some(def) = target + .and_then(|target| self.members.get(&target)?.get(&name.name)) + .copied() + else { + return Ty::Unknown; + }; + let mut arguments = args.clone(); + if matches!(receiver_ty, Ty::Struct(_)) { + arguments.insert( + 0, + Arg { + name: None, + value: ArgValue::Expr((**receiver).clone()), + span: receiver.span(), + }, + ); + } + let path = Path { + segments: vec![name.clone()], + applications: if type_arguments.is_empty() { + Vec::new() + } else { + vec![PathApplication { + segment: 0, + arguments: type_arguments.clone(), + }] + }, + span: name.span, + }; + self.specialize_call(body, def, &path, &arguments, None, false) + .and_then(|def| self.fn_slots.get(&def)?.ret.as_ref()) + .map_or(Ty::Unknown, |(_, ty)| *ty) + } + Expr::Float(..) => Ty::Float, + Expr::Bool(..) | Expr::Cond(..) => Ty::Bool, + Expr::Str { .. } => Ty::String, + Expr::Neg(inner, _) => self.type_of(body, inner), + Expr::Cast(_, ty, _) => self.cast_target_quiet(body.module, ty), + Expr::Binary(lhs, _, rhs, _) => { + let (left, right) = (self.type_of(body, lhs), self.type_of(body, rhs)); + if left == Ty::Float || right == Ty::Float { + Ty::Float + } else { + left + } + } + Expr::Call { path, .. } + if path.segments.len() == 1 + && let Some(local) = Self::lookup_local(body, &path.last().name) => + { + self.callable_signature(self.local_ty(local)) + .and_then(|signature| signature.returns) + .unwrap_or(Ty::Unknown) + } + Expr::Call { path, .. } + if path.segments.len() == 1 + && Self::lookup_local(body, &path.last().name).is_none() + && !self.scopes[body.module.0].contains_key(&path.last().name) + && builtins::find(&path.last().name, BuiltinKind::Condition).is_some() => + { + Ty::Bool + } + Expr::Call { path, .. } + if path.segments.len() == 1 + && path.last().name == "entity_ref" + && !self.scopes[body.module.0].contains_key("entity_ref") => + { + Ty::EntityRef + } + Expr::Call { path, .. } + if path.segments.len() == 1 + && path.last().name == "block_data_number" + && !self.scopes[body.module.0].contains_key("block_data_number") => + { + Ty::Number + } + Expr::Call { path, args, .. } => self + .resolve_call(body, path, args, None, false) + .and_then(|def| self.fn_slots.get(&def)) + .and_then(|slots| slots.ret.as_ref().map(|(_, ty)| *ty)) + .unwrap_or(Ty::Unknown), + _ => Ty::Number, + } + } + + /// A constant or single read, or `None` when the expression needs work. + pub(super) fn simple( + &mut self, + body: &mut BodyCx, + expr: &Expr, + ty: Ty, + ) -> Result, ()> { + if matches!( + ty, + Ty::Struct(_) | Ty::String | Ty::List(_) | Ty::Callable(_) + ) { + return Ok(None); + } + let (module, file) = (body.module, body.file); + if Self::is_const_in(body, expr) { + return self + .eval_i32(module, file, expr, Some(ty), None) + .map(|v| Some(Value::Const(v))) + .ok_or(()); + } + if let Some(local) = Self::local_of(body, expr) { + body.used.insert(local); + if let Expr::Path(path) = expr { + // The identifier's own span: path spans can include trailing whitespace. + self.references.push(Reference { + file, + span: path.segments[0].span, + def: local, + }); + } + let local_ty = self.local_ty(local); + if !self.types_agree(file, expr.span(), ty, local_ty) { + return Err(()); + } + return Ok(Some(Value::Read(self.local_ref(local)))); + } + if let Expr::Place(place) = expr { + if self.is_handle(body, place) || self.entity_place(body, place) { + return Ok(None); + } + let value = self.place_value(body, place, false).ok_or(())?; + if !self.types_agree(file, place.span, ty, value.ty) { + return Err(()); + } + return Ok(Some(Value::Read(value.reference))); + } + Ok(None) + } + + pub(super) fn types_agree( + &mut self, + file: FileId, + span: Span, + expected: Ty, + found: Ty, + ) -> bool { + if expected == Ty::Unknown || found == Ty::Unknown || expected == found { + return true; + } + let message = format!( + "mismatched types: expected `{}`, found `{}`", + self.ty_name(expected), + self.ty_name(found) + ); + let mut diagnostic = Diagnostic::error("type", file, span, message); + match (expected, found) { + (Ty::Float, Ty::Number) => { + diagnostic = diagnostic.with_help("convert it with `as float`") + } + (Ty::Number, Ty::Float) => { + diagnostic = diagnostic.with_help("convert it with `as number`") + } + (Ty::Number, Ty::Enum(_)) => { + diagnostic = diagnostic.with_help("convert the enum with `as number`") + } + _ => {} + } + self.diagnostics.push(diagnostic); + false + } + + pub(super) fn temp(&mut self, body: &mut BodyCx) -> pc::FieldReference { + let name = format!("{}_t{}", body.slot, body.temp_depth); + body.temp_depth += 1; + self.slot(name) + } + + fn arithmetic( + &mut self, + file: FileId, + dest: &pc::FieldReference, + op: BinOp, + value: Value, + span: Span, + ) -> Option { + Some(match (op, value) { + (BinOp::Add, Value::Const(v)) => pc::Action::ScoreAdd { + score: dest.clone(), + value: v as i32, + }, + (BinOp::Sub, Value::Const(v)) => { + let Some(value) = (v as i32).checked_neg() else { + self.error("range", file, span, "subtracting this overflows i32"); + return None; + }; + pc::Action::ScoreAdd { + score: dest.clone(), + value, + } + } + (BinOp::Div | BinOp::Rem, Value::Const(0)) => { + self.error("const", file, span, "division by zero"); + return None; + } + (op, value) => pc::Action::ScoreOperation { + score: dest.clone(), + operator: match op { + BinOp::Add => pc::ScoreOperator::Add, + BinOp::Sub => pc::ScoreOperator::Sub, + BinOp::Mul => pc::ScoreOperator::Mul, + BinOp::Div => pc::ScoreOperator::Div, + BinOp::Rem => pc::ScoreOperator::Mod, + }, + operand: match value { + Value::Const(v) => pc::ScoreOperand::Value(v as i32), + Value::Read(reference) => pc::ScoreOperand::Field(reference), + }, + }, + }) + } + + pub(super) fn set_from(dest: &pc::FieldReference, value: Value) -> Option { + match value { + Value::Const(v) => Some(pc::Action::ScoreSet { + score: dest.clone(), + value: v as i32, + }), + Value::Read(source) if source.state == dest.state && source.field == dest.field => None, + Value::Read(source) => Some(pc::Action::ScoreOperation { + score: dest.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(source), + }), + } + } + + /// Compute `expr` into `dest`, using temporaries for nested parts. + pub(super) fn emit( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + if !self.validate_method_type_arguments(body, expr) { + return None; + } + let file = body.file; + let span = expr.span(); + self.value_slots(dest, ty); + if let Expr::Block { + body: block, value, .. + } = expr + { + let depth = body.temp_depth; + body.value_blocks.push((body.loops.len(), body.jumps.len())); + ops.extend(self.lower_block_with_tail(body, block, Some((dest, ty, value)))); + body.value_blocks.pop(); + body.temp_depth = depth; + return Some(()); + } + if let Expr::Match { value, arms, span } = expr { + return self.emit_match(body, dest, ty, value, arms, *span, ops); + } + if let Ty::List(_) = ty { + return self.emit_list(body, dest, ty, expr, ops); + } + if ty == Ty::String { + return self.emit_text(body, dest, expr, ops); + } + if matches!(ty, Ty::Struct(_)) { + return self.emit_record(body, dest, ty, expr, ops); + } + if matches!(ty, Ty::Callable(_)) { + return self.emit_callable(body, dest, ty, expr, ops); + } + if let Some(value) = self.simple(body, expr, ty).ok()? { + if let Some(action) = Self::set_from(dest, value) { + ops.push(op_at(action, file, span)); + } + return Some(()); + } + match expr { + Expr::Index(..) => self.emit_index(body, dest, ty, expr, ops), + Expr::Method { + receiver, + name, + type_arguments, + args, + span, + } => { + let receiver_ty = self.type_of(body, receiver); + if self.list_element(receiver_ty).is_some() { + return self.emit_list_method(body, dest, ty, expr, ops); + } + if receiver_ty == Ty::String { + return self.emit_text_method(body, dest, ty, expr, ops); + } + if self.array_shape(receiver_ty).is_some() { + return self.emit_array_method(body, dest, ty, expr, ops); + } + self.emit_method( + body, + dest, + ty, + receiver, + name, + type_arguments, + args, + *span, + ops, + ) + } + Expr::Project(value, field, _) => { + self.emit_projection(body, dest, ty, value, field, ops) + } + Expr::Call { path, args, span } => { + self.emit_call(body, dest, ty, path, args, *span, ops) + } + Expr::Cast(inner, cast_ty, cast_span) => { + let to = self.cast_target(body.module, file, cast_ty)?; + if !self.types_agree(file, *cast_span, ty, to) { + return None; + } + let from = self.type_of(body, inner); + let step = match self.cast_step(from, to) { + Ok(step) => step, + Err((message, help)) => { + self.diagnostics.push( + Diagnostic::error("type", file, *cast_span, message).with_help(help), + ); + return None; + } + }; + self.emit(body, dest, from, inner, ops)?; + match step { + super::CastStep::Same => {} + super::CastStep::ToFloat | super::CastStep::ToNumber => { + let op = if step == super::CastStep::ToFloat { + BinOp::Mul + } else { + BinOp::Div + }; + let action = + self.arithmetic(file, dest, op, Value::Const(FLOAT_SCALE), *cast_span)?; + ops.push(op_at(action, file, *cast_span)); + } + super::CastStep::ToBool => ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: dest.clone(), + min: Some(0), + max: Some(0), + }), + then: Vec::new(), + otherwise: vec![op_at( + pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + }, + file, + *cast_span, + )], + }, + file, + *cast_span, + )), + } + Some(()) + } + Expr::Cond(cond, cond_span) => { + if !self.types_agree(file, *cond_span, ty, Ty::Bool) { + return None; + } + // A temporary, so `flag = !flag` reads the old value. + let depth = body.temp_depth; + let temp = self.temp(body); + let set = |value| pc::Action::ScoreSet { + score: temp.clone(), + value, + }; + ops.push(op_at(set(0), file, *cond_span)); + let then = vec![op_at(set(1), file, *cond_span)]; + let branch = self.lower_cond(body, cond, then, Vec::new())?; + ops.extend(branch); + body.temp_depth = depth; + if let Some(action) = Self::set_from(dest, Value::Read(temp.clone())) { + ops.push(op_at(action, file, *cond_span)); + } + Some(()) + } + Expr::Neg(inner, neg_span) => { + self.expect_numeric(file, *neg_span, ty)?; + let inner_ty = if ty == Ty::Unknown { + self.type_of(body, inner) + } else { + ty + }; + self.emit(body, dest, inner_ty, inner, ops)?; + let action = + self.arithmetic(file, dest, BinOp::Mul, Value::Const(-1), *neg_span)?; + ops.push(op_at(action, file, *neg_span)); + Some(()) + } + Expr::Binary(lhs, op, rhs, bin_span) => { + self.expect_numeric(file, *bin_span, ty)?; + let ty = if ty == Ty::Unknown { + self.type_of(body, expr) + } else { + ty + }; + self.emit(body, dest, ty, lhs, ops)?; + let value = match self.simple(body, rhs, ty).ok()? { + Some(value) => value, + None => { + let depth = body.temp_depth; + let temp = self.temp(body); + self.emit(body, &temp, ty, rhs, ops)?; + body.temp_depth = depth; + Value::Read(temp) + } + }; + self.apply(file, dest, ty, *op, value, rhs.span(), ops) + } + Expr::Place(place) if !self.is_handle(body, place) => { + let value = self.place_value(body, place, false)?; + if !self.types_agree(file, place.span, ty, value.ty) { + return None; + } + self.copy_value(dest, &value.reference, ty, file, place.span, ops); + Some(()) + } + Expr::Place(place) => { + let property = self.entity_property(body, place)?; + let found = match property.ty { + PropertyType::Number => Ty::Number, + PropertyType::Float => Ty::Float, + PropertyType::Bool => Ty::Bool, + }; + if !self.types_agree(file, place.span, ty, found) { + return None; + } + let scale = if found == Ty::Float { + FLOAT_SCALE as f64 + } else { + 1.0 + }; + let action = match property.kind { + PropertyKind::Attribute(attribute) => pc::Action::AttributeGet { + score: dest.clone(), + attribute, + scale, + }, + PropertyKind::Data(value) => pc::Action::DataGet { + score: dest.clone(), + value, + scale, + }, + }; + ops.push(op_at(action, file, place.span)); + Some(()) + } + Expr::Str { span: s, .. } => { + self.error("type", file, *s, "expected a value, found text"); + None + } + _ => { + self.error("type", file, span, "expected a value"); + None + } + } + } + + /// One arithmetic step. Decimal multiply and divide rescale, because a + /// `float` score already holds `value * 1000`. + #[allow(clippy::too_many_arguments)] + pub(super) fn apply( + &mut self, + file: FileId, + dest: &pc::FieldReference, + ty: Ty, + op: BinOp, + value: Value, + span: Span, + ops: &mut Vec, + ) -> Option<()> { + let mut step = |cx: &mut Self, op: BinOp, value: Value| -> Option<()> { + let action = cx.arithmetic(file, dest, op, value, span)?; + ops.push(op_at(action, file, span)); + Some(()) + }; + if ty != Ty::Float || !matches!(op, BinOp::Mul | BinOp::Div) { + return step(self, op, value); + } + let (mul, div) = match (op, value) { + (_, Value::Const(0)) if op == BinOp::Div => { + self.error("const", file, span, "division by zero"); + return None; + } + // Reduce the fraction so constant factors overflow later. + (BinOp::Mul, Value::Const(c)) => { + let g = gcd(c.unsigned_abs(), FLOAT_SCALE as u64) as i64; + (Value::Const(c / g), Value::Const(FLOAT_SCALE / g)) + } + (_, Value::Const(c)) => { + let g = gcd(c.unsigned_abs(), FLOAT_SCALE as u64) as i64; + (Value::Const(FLOAT_SCALE / g), Value::Const(c / g)) + } + (BinOp::Mul, read) => (read, Value::Const(FLOAT_SCALE)), + (_, read) => (Value::Const(FLOAT_SCALE), read), + }; + if !matches!(mul, Value::Const(1)) { + step(self, BinOp::Mul, mul)?; + } + if !matches!(div, Value::Const(1)) { + step(self, BinOp::Div, div)?; + } + Some(()) + } + + fn expect_numeric(&mut self, file: FileId, span: Span, ty: Ty) -> Option<()> { + if matches!( + ty, + Ty::Enum(_) | Ty::Bool | Ty::Struct(_) | Ty::EntityRef | Ty::Callable(_) + ) { + self.diagnostics.push( + Diagnostic::error( + "type", + file, + span, + "arithmetic needs `number` or `float` values", + ) + .with_help("`bool` and enum values can only be assigned and compared"), + ); + return None; + } + Some(()) + } + + /// A call used as a value: `random(..)`, `count_entities(..)`, or a function + /// with a return type. + #[allow(clippy::too_many_arguments)] + pub(super) fn emit_call( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + path: &Path, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) -> Option<()> { + let (module, file) = (body.module, body.file); + if path.segments.len() == 1 + && let Some(local) = Self::lookup_local(body, &path.last().name) + { + let (def, actual) = self.indirect_call(body, path, local, args)?; + return self.emit_user_result(body, dest, ty, def, path, &actual, span, ops); + } + let name = &path.last().name; + if !path.arguments().is_empty() + && path.segments.len() == 1 + && !self.scopes[module.0].contains_key(name) + { + self.error( + "generic", + file, + path.span, + "builtins do not take type arguments", + ); + return None; + } + + if path.segments.len() == 1 + && !self.scopes[module.0].contains_key(name) + && Self::lookup_local(body, name).is_none() + && builtins::find(name, BuiltinKind::Condition).is_some() + { + let value = Expr::Cond( + Box::new(Cond::Call { + path: path.clone(), + args: args.to_vec(), + span, + }), + span, + ); + return self.emit(body, dest, ty, &value, ops); + } + let builtin = (path.segments.len() == 1 + && !self.scopes[module.0].contains_key(name) + && Self::lookup_local(body, name).is_none()) + .then(|| builtins::find(name, BuiltinKind::Expression)) + .flatten(); + if let Some(builtin) = builtin { + self.references_builtin(file, path.span, builtin); + if builtin.name != "entity_ref" { + self.expect_numeric(file, span, ty)?; + } + let result_ty = if builtin.name == "entity_ref" { + Ty::EntityRef + } else { + Ty::Number + }; + if !self.types_agree(file, span, ty, result_ty) { + return None; + } + let bound = self.bind_args(body, builtin, args, span)?; + let action = match builtin.name { + "random" => { + let range = match &bound["range"].value { + ArgValue::Range(range) => range.clone(), + ArgValue::Expr(expr) => { + self.error( + "call", + file, + expr.span(), + "expected a range such as `1..=6`", + ); + return None; + } + }; + let (Some(start), Some(end)) = (&range.start, &range.end) else { + self.error( + "call", + file, + range.span, + "`random` needs both ends, like `1..=6`", + ); + return None; + }; + let min = self.eval_i32(module, file, start, Some(Ty::Number), None)?; + let max = self.eval_i32(module, file, end, Some(Ty::Number), None)?; + let max = if range.inclusive { max } else { max - 1 }; + if min > max { + self.error("range", file, range.span, "random range is empty"); + return None; + } + pc::Action::ScoreRandom { + score: dest.clone(), + min: min as i32, + max: max as i32, + } + } + "entity_ref" => { + let relation = if let Some(arg) = bound.get("relation") { + let keyword = self.arg_id(body, arg, "Relation")?; + match serde_json::from_value(serde_json::Value::String(keyword)) { + Ok(relation) => Some(relation), + Err(_) => { + self.error( + "type", + file, + arg.span, + "expected a `Relation::...` value", + ); + return None; + } + } + } else { + None + }; + body.note_executor(span, "retains an entity identity".into()); + pc::Action::CaptureEntity { + score: dest.clone(), + relation, + } + } + "inventory_count" => { + body.note_player(span, "counts the executing player's inventory".into()); + pc::Action::CountItems { + item: self.arg_id(body, bound["item"], "Item")?, + score: dest.clone(), + } + } + "entity_data_number" => { + body.note_executor(span, "reads data from the executing entity".into()); + let (path, _, _) = self.arg_string(file, bound["path"], "an NBT path")?; + pc::Action::ReadEntityData { + path, + score: dest.clone(), + } + } + "block_data_number" => pc::Action::ReadBlockData { + target: self.arg_block_data(body, bound["at"], bound["path"])?, + score: dest.clone(), + }, + "count_entities" => pc::Action::CountEntities { + score: dest.clone(), + query: self.query_from(body, &bound)?, + }, + "entities" => { + self.diagnostics.push( + Diagnostic::error("call", file, span, "`entities(..)` is the source of a `for` loop") + .with_help("write `for entity in entities(..) { ... }`, or count them with `count_entities(..)`"), + ); + return None; + } + other => unreachable!("expression builtin `{other}`"), + }; + ops.push(op_at(action, file, span)); + return Some(()); + } + let def = self.resolve_call(body, path, args, Some(ty), true)?; + self.emit_user_result(body, dest, ty, def, path, args, span, ops) + } + + #[allow(clippy::too_many_arguments)] + pub(super) fn emit_user_result( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + def: DefId, + path: &Path, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) -> Option<()> { + let file = body.file; + let Some(slots) = self.fn_slots.get(&def).cloned() else { + self.error( + "call", + file, + path.span, + "this function does not return a value", + ); + return None; + }; + let Some((ret_field, ret_ty)) = slots.ret.clone() else { + let d = &self.defs[def.0]; + let (df, ds, dname) = (d.file, d.name_span, d.name.clone()); + self.diagnostics.push( + Diagnostic::error( + "call", + file, + path.span, + format!("`{dname}` does not return a value"), + ) + .with_note(df, ds, "declared without a return type") + .with_help(format!("declare one: `fn {dname}(...) -> number`")), + ); + return None; + }; + if !self.types_agree(file, span, ty, ret_ty) { + return None; + } + self.call_user(body, def, &slots, path, args, span, ops)?; + let ret = self.slot(ret_field); + self.copy_value(dest, &ret, ty, file, span, ops); + Some(()) + } + + /// Pass arguments into the callee's parameter slots, then call it. + #[allow(clippy::too_many_arguments)] + pub(super) fn call_user( + &mut self, + body: &mut BodyCx, + def: DefId, + slots: &FnSlots, + path: &Path, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) -> Option<()> { + let file = body.file; + if let Some(caller) = body.owner.and_then(|owner| self.methods.get(&owner)) + && let Some(callee) = self.methods.get(&def) + && caller.state_receiver + && caller.target == callee.target + && caller.receiver.as_ref().is_some_and(|r| !r.mutable) + && callee.receiver.as_ref().is_some_and(|r| r.mutable) + { + self.error( + "mutability", + file, + span, + "this State receiver is read-only; calling a mutable method requires `&mut self`", + ); + return None; + } + if args.len() != slots.params.len() || args.iter().any(|a| a.name.is_some()) { + let name = self.defs[def.0].name.clone(); + let expected = slots.params.len(); + let message = if args.iter().any(|a| a.name.is_some()) { + "named arguments are only for builtins; pass arguments in order".to_string() + } else { + format!( + "`{name}` takes {expected} argument{}, but {} {} given", + if expected == 1 { "" } else { "s" }, + args.len(), + if args.len() == 1 { "was" } else { "were" } + ) + }; + let signature = match &self.defs[def.0].info { + DefInfo::Function { signature, .. } => signature.clone(), + _ => String::new(), + }; + self.diagnostics + .push( + Diagnostic::error("call", file, span, message).with_help(format!( + "signature: {} {name}{signature}", + if self.defs[def.0].kind == DefKind::Event { + "event" + } else { + "fn" + } + )), + ); + return None; + } + let mut exprs = Vec::with_capacity(args.len()); + for arg in args { + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", file, arg.span, "expected a value, found a range"); + return None; + }; + exprs.push(expr); + } + let depth = body.temp_depth; + let receiver_dest = if slots.receiver_out.is_some() { + Some(self.value_address(body, exprs.first().copied()?, ops)?) + } else { + None + }; + // A self-call reads the parameters it is about to overwrite, and a + // nested call may overwrite parameters already passed, so those + // arguments are computed into temporaries before any is passed. + let staged = body.owner == Some(def) + || slots + .params + .iter() + .any(|(_, _, ty)| matches!(ty, Ty::Struct(_))) + || exprs.iter().any(|expr| contains_call(expr)); + let mut values = Vec::with_capacity(exprs.len()); + if staged { + for (index, ((_, _, param_ty), expr)) in slots.params.iter().zip(&exprs).enumerate() { + if index == 0 + && let Some(address) = &receiver_dest + { + let temp = self.temp(body); + self.read_address(body, &temp, address, span, ops)?; + values.push(Value::Read(temp)); + continue; + } + let value = match self.simple(body, expr, *param_ty).ok()? { + Some(Value::Const(value)) => Value::Const(value), + _ => { + let temp = self.temp(body); + self.emit(body, &temp, *param_ty, expr, ops)?; + Value::Read(temp) + } + }; + values.push(value); + } + } + let invocation_start = ops.len(); + let marker = self.frame_marker(body.owner, def); + ops.push(op_at( + pc::Action::PushFrame { + fields: vec![marker.clone()], + }, + file, + span, + )); + for (index, ((field, _, param_ty), expr)) in slots.params.iter().zip(&exprs).enumerate() { + let slot = self.slot(field.clone()); + if staged { + match values[index].clone() { + Value::Read(source) => { + self.copy_value(&slot, &source, *param_ty, file, expr.span(), ops) + } + value => { + if let Some(action) = Self::set_from(&slot, value) { + ops.push(op_at(action, file, expr.span())); + } + } + } + } else { + self.emit(body, &slot, *param_ty, expr, ops)?; + } + } + body.temp_depth = depth; + body.all_calls.push((def, path.span)); + if !body.in_players { + body.calls.push((def, path.span)); + } + if body.loops.last() == Some(&super::LoopKind::Entities) { + body.entity_loop_calls.push((def, path.span)); + } + let function = self.function_reference(def)?; + ops.push(op_at(pc::Action::Call { function }, file, span)); + ops.push(op_at( + pc::Action::PopFrame { + fields: vec![marker], + }, + file, + span, + )); + if let (Some(dest), Some((field, _))) = (&receiver_dest, &slots.receiver_out) { + let output = self.slot(field.clone()); + self.write_address(body, dest, &output, span, ops); + } + if let Some(address) = &receiver_dest + && self.address_is_guarded(address) + { + let invocation = ops.split_off(invocation_start); + if let Some((field, ty)) = &slots.ret { + let reference = self.slot(field.clone()); + let defaults = self.record_constant(body.module, file, None, *ty)?; + for ((score, _), value) in + self.value_slots(&reference, *ty).into_iter().zip(defaults) + { + ops.push(op_at(Self::initialize_leaf(score, value), file, span)); + } + } + ops.extend(self.guard_address(body, address, span, invocation)); + } + Some(()) + } + + /// A placeholder frame field for one call, resolved once the whole call + /// graph is known: a call that can re-enter its caller saves the caller's + /// variables around it, and every other call drops the placeholder. + pub(super) fn frame_marker( + &mut self, + caller: Option, + callee: DefId, + ) -> pc::FieldReference { + let index = self.call_frames.len(); + self.call_frames.push((caller, callee)); + pc::FieldReference { + state: self.locals_state().parse().expect("namespace validated"), + field: format!("{FRAME_MARKER}{index}"), + } + } + + fn resolve_target(&mut self, body: &mut BodyCx, target: &AssignTarget) -> Option { + let (module, file) = (body.module, body.file); + match target { + AssignTarget::Value(_) => None, + AssignTarget::Place(place) => { + let value = self.place_value(body, place, true)?; + let bounds = match self.defs[value.field.0].info { + DefInfo::Field { bounds, .. } => bounds, + _ => None, + }; + Some(Dest { + reference: value.reference, + ty: value.ty, + bounds, + name: self.defs[value.field.0].name.clone(), + }) + } + AssignTarget::Local(ident) => { + let Some(local) = Self::lookup_local(body, &ident.name) else { + let mut diagnostic = Diagnostic::error( + "resolve", + file, + ident.span, + format!("cannot find variable `{}` in this scope", ident.name), + ); + if self.scopes[module.0].contains_key(&ident.name) { + diagnostic = diagnostic.with_help( + "only `let` variables and State fields (`State.field`) can be assigned", + ); + } else { + diagnostic = diagnostic + .with_help(format!("declare it first: `let mut {} = 0;`", ident.name)); + } + self.diagnostics.push(diagnostic); + return None; + }; + self.references.push(Reference { + file, + span: ident.span, + def: local, + }); + let DefInfo::Local { + mutable, ty, param, .. + } = self.defs[local.0].info + else { + return None; + }; + if !mutable { + let d = &self.defs[local.0]; + let (df, ds) = (d.file, d.name_span); + let help = if param { + format!("make the parameter mutable: `mut {0}: ...`", ident.name) + } else { + format!("make it mutable: `let mut {}`", ident.name) + }; + self.diagnostics.push( + Diagnostic::error( + "mutability", + file, + ident.span, + format!("cannot assign twice to immutable variable `{}`", ident.name), + ) + .with_note(df, ds, "first assigned here") + .with_help(help), + ); + return None; + } + body.assigned.insert(local); + Some(Dest { + reference: self.local_ref(local), + ty, + bounds: None, + name: ident.name.clone(), + }) + } + } + } + + pub(super) fn lower_assign( + &mut self, + body: &mut BodyCx, + target: &AssignTarget, + op: AssignOp, + value: &Expr, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + if let AssignTarget::Value(target) = target { + self.lower_value_assignment(body, target, op, value, ops); + return; + } + let Some(dest) = self.resolve_target(body, target) else { + return; + }; + let compound = match op { + AssignOp::Set => None, + AssignOp::Add => Some(BinOp::Add), + AssignOp::Sub => Some(BinOp::Sub), + AssignOp::Mul => Some(BinOp::Mul), + AssignOp::Div => Some(BinOp::Div), + AssignOp::Rem => Some(BinOp::Rem), + }; + if dest.ty == Ty::String && compound.is_some() { + if op != AssignOp::Add { + self.error( + "type", + file, + span, + "strings support `=` and `+=` assignments", + ); + return; + } + let depth = body.temp_depth; + let rhs = self.temp(body); + if self.emit(body, &rhs, Ty::String, value, ops).is_some() { + ops.push(op_at(Self::append_text(&dest.reference, &rhs), file, span)); + } + body.temp_depth = depth; + return; + } + if compound.is_some() && matches!(dest.ty, Ty::List(_)) { + self.error( + "type", + file, + span, + "vectors use `=` for assignment; use collection methods to change their contents", + ); + return; + } + if let Some(bin) = compound { + if matches!(dest.ty, Ty::Struct(_)) { + self.error( + "type", + file, + span, + "compound arithmetic needs scalar fields, not a struct value", + ); + return; + } + if matches!( + dest.ty, + Ty::Enum(_) | Ty::Bool | Ty::EntityRef | Ty::Callable(_) + ) { + self.error( + "type", + file, + span, + "`bool` and enum values can only be assigned with `=`", + ); + return; + } + let depth = body.temp_depth; + let value_ = match self.simple(body, value, dest.ty) { + Ok(Some(v)) => v, + Ok(None) => { + let temp = self.temp(body); + if self.emit(body, &temp, dest.ty, value, ops).is_none() { + return; + } + Value::Read(temp) + } + Err(()) => return, + }; + // Evaluate the RHS first, then snapshot the compound-assignment + // value. Rescaling must not clamp intermediate score writes. + let rescale = dest.bounds.is_some() + && dest.ty == Ty::Float + && matches!(bin, BinOp::Mul | BinOp::Div); + let target = if rescale { + let temp = self.temp(body); + if let Some(action) = Self::set_from(&temp, Value::Read(dest.reference.clone())) { + ops.push(op_at(action, file, span)); + } + temp + } else { + dest.reference.clone() + }; + let applied = self.apply(file, &target, dest.ty, bin, value_, value.span(), ops); + if applied.is_some() + && rescale + && let Some(action) = Self::set_from(&dest.reference, Value::Read(target)) + { + ops.push(op_at(action, file, span)); + } + body.temp_depth = depth; + return; + } + // Constant writes outside a clamp range are worth flagging. + if Self::is_const_in(body, value) + && let Some((min, max)) = dest.bounds + && let Some(v) = self.eval_i32(body.module, file, value, Some(dest.ty), None) + { + if v < min as i64 || v > max as i64 { + self.diagnostics.push(Diagnostic::warning( + "clamp", + file, + value.span(), + format!( + "{v} is outside `{}`'s clamp range {min}..={max} and will be clamped", + dest.name + ), + )); + } + ops.push(op_at( + pc::Action::ScoreSet { + score: dest.reference, + value: v as i32, + }, + file, + span, + )); + return; + } + // Calls and entity-property reads already write their result once. + if dest.bounds.is_none() + && !matches!(dest.ty, Ty::Struct(_)) + && (matches!(value, Expr::Call { .. } | Expr::Method { .. }) + || matches!(value, Expr::Place(place) if self.is_handle(body, place))) + { + let _ = self.emit(body, &dest.reference, dest.ty, value, ops); + return; + } + // A simple read/constant commits once. Every computed value uses + // scratch storage: calls and conditions may read or mutate the target, + // and casts must finish in their source units before bounds apply. + match self.simple(body, value, dest.ty) { + Ok(Some(value)) => { + if let Some(action) = Self::set_from(&dest.reference, value) { + ops.push(op_at(action, file, span)); + } + } + Ok(None) => { + let depth = body.temp_depth; + let temp = self.temp(body); + let computed = self.emit(body, &temp, dest.ty, value, ops); + body.temp_depth = depth; + if computed.is_some() { + self.copy_value(&dest.reference, &temp, dest.ty, file, span, ops); + } + } + Err(()) => {} + } + } + + #[allow(clippy::too_many_arguments)] + pub(super) fn lower_let( + &mut self, + body: &mut BodyCx, + mutable: bool, + name: &Ident, + ty: Option<&Type>, + value: Option<&Expr>, + span: Span, + ops: &mut Vec, + ) { + let (module, file) = (body.module, body.file); + let key = (body.file, name.span, body.slot.clone()); + let local = match self.inferred_block_locals.get(&key) { + Some(local) => *local, + None => { + let ty = self.local_declaration_type(body, ty, value); + self.new_local(body, name, ty, mutable, span) + } + }; + let ty = self.local_ty(local); + let reference = self.local_ref(local); + match value { + Some(value) => { + let _ = self.emit(body, &reference, ty, value, ops); + } + None => { + let defaults = self + .record_constant(module, file, None, ty) + .unwrap_or_default(); + for ((score, _), default) in + self.value_slots(&reference, ty).into_iter().zip(defaults) + { + ops.push(op_at(Self::initialize_leaf(score, default), file, span)); + } + } + } + // Visible from after the statement to the end of the block. + let end = body.block_ends.last().copied().unwrap_or(span.end); + self.bring_into_scope(body, name, local, Span::new(span.end, end)); + } + + pub(super) fn lower_destructure( + &mut self, + body: &mut BodyCx, + pattern: &Pattern, + annotation: Option<&Type>, + value: &Expr, + span: Span, + ops: &mut Vec, + ) { + let depth = body.temp_depth; + let ty = match annotation { + Some(ty) => self.resolve_type(body.module, ty), + None => self.type_of(body, value), + }; + let snapshot = self.temp(body); + if self.emit(body, &snapshot, ty, value, ops).is_some() { + let bindings = self.pattern_locals(body, pattern, ty, span); + let end = body.block_ends.last().copied().unwrap_or(span.end); + self.apply_pattern(body, &bindings, &snapshot, Span::new(span.end, end), ops); + } + body.temp_depth = depth; + } + + #[allow(clippy::too_many_arguments)] + fn plan_pattern( + &mut self, + body: &BodyCx, + pattern: &Pattern, + ty: Ty, + span: Span, + projection: &mut Vec, + bindings: &mut Vec, + ) { + match pattern { + Pattern::Ignore(_) => {} + Pattern::Bind { name, mutable } => { + if bindings + .iter() + .any(|binding| binding.name.name == name.name) + { + self.error( + "pattern", + body.file, + name.span, + format!("duplicate binding `{}` in pattern", name.name), + ); + return; + } + bindings.push(PatternLocal { + name: name.clone(), + def: self.new_local(body, name, ty, *mutable, span), + ty, + projection: projection.clone(), + }); + } + Pattern::Array(patterns, location) => { + let Some((element, length)) = self.array_shape(ty) else { + self.error( + "pattern", + body.file, + *location, + "an array pattern requires a fixed array value", + ); + return; + }; + if patterns.len() != length { + self.error( + "pattern", + body.file, + *location, + format!("expected {length} array patterns, found {}", patterns.len()), + ); + return; + } + for (index, pattern) in patterns.iter().enumerate() { + projection.push(format!("i{index}")); + self.plan_pattern(body, pattern, element, span, projection, bindings); + projection.pop(); + } + } + Pattern::Record { + path, + fields, + rest, + span: location, + } => { + let Some(def) = self.expect_path(body.module, path, &[DefKind::Struct], "a struct") + else { + return; + }; + let expected = if self.generics.records.contains_key(&def) + && path.arguments().is_empty() + && matches!(ty, Ty::Struct(instance) if self.generics.record_arguments.get(&instance).is_some_and(|(template, _)| *template == def)) + { + ty + } else if !path.arguments().is_empty() { + let types = path + .arguments() + .iter() + .map(|ty| self.resolve_type(body.module, ty)) + .collect(); + self.instantiate_record(def, types, body.file, *location) + .unwrap_or(Ty::Unknown) + } else { + Ty::Struct(def) + }; + if !self.types_agree(body.file, *location, expected, ty) { + return; + } + let Ty::Struct(def) = ty else { + return; + }; + let mut seen = HashSet::new(); + for (name, pattern) in fields { + if !seen.insert(name.name.clone()) { + self.error( + "pattern", + body.file, + name.span, + "duplicate field in record pattern", + ); + continue; + } + let Some(field) = self.record_member(ty, &name.name) else { + self.error( + "pattern", + body.file, + name.span, + format!("unknown field `{}`", name.name), + ); + continue; + }; + if !self.visible( + body.module, + self.defs[field.0].module, + self.defs[field.0].is_pub, + ) { + self.error( + "privacy", + body.file, + name.span, + format!("field `{}` is private", name.name), + ); + continue; + } + self.references.push(Reference { + file: body.file, + span: name.span, + def: field, + }); + projection.push(name.name.clone()); + self.plan_pattern( + body, + pattern, + self.field_ty(field), + span, + projection, + bindings, + ); + projection.pop(); + } + if !rest { + for field in self.struct_fields(def) { + let name = self.defs[field.0].name.clone(); + if !seen.contains(&name) { + self.error("pattern", body.file, *location, format!("missing record field `{name}`; add `..` to ignore remaining fields")); + } + } + } + } + } + } + + fn apply_pattern( + &mut self, + body: &mut BodyCx, + bindings: &[PatternLocal], + snapshot: &pc::FieldReference, + visibility: Span, + ops: &mut Vec, + ) { + for binding in bindings { + let source = binding + .projection + .iter() + .fold(snapshot.clone(), |part, field| { + super::values::child(&part, field) + }); + let dest = self.local_ref(binding.def); + self.copy_value( + &dest, + &source, + binding.ty, + body.file, + binding.name.span, + ops, + ); + self.bring_into_scope(body, &binding.name, binding.def, visibility); + } + } + + fn pattern_locals( + &mut self, + body: &BodyCx, + pattern: &Pattern, + ty: Ty, + statement_span: Span, + ) -> Vec { + let key = (body.file, pattern.span(), body.slot.clone()); + if let Some(bindings) = self.pattern_bindings.get(&key) { + return bindings.clone(); + } + let mut bindings = Vec::new(); + // Keep definitions allocated during type inference so lowering and + // editor references resolve each name to the same binding. + self.plan_pattern( + body, + pattern, + ty, + statement_span, + &mut Vec::new(), + &mut bindings, + ); + self.pattern_bindings.insert(key, bindings.clone()); + bindings + } + + fn local_declaration_type( + &mut self, + body: &BodyCx, + ty: Option<&Type>, + value: Option<&Expr>, + ) -> Ty { + match (ty, value) { + (Some(ty), _) => self.resolve_type(body.module, ty), + (None, Some(value)) => self.type_of(body, value), + (None, None) => Ty::Number, + } + } + + /// Infer the value with the declarations in its lexical scope. Other + /// statements can change values and control flow but cannot declare locals + /// visible to the tail. + fn block_tail_type(&mut self, body: &BodyCx, block: &Block, tail: &Expr) -> Ty { + let mut scoped = body.clone(); + scoped.scopes.push(Vec::new()); + for statement in &block.stmts { + match statement { + Stmt::Let { + mutable, + name, + ty, + value, + span, + } => { + let key = (scoped.file, name.span, scoped.slot.clone()); + let local = match self.inferred_block_locals.get(&key) { + Some(local) => *local, + None => { + let ty = + self.local_declaration_type(&scoped, ty.as_ref(), value.as_ref()); + let local = self.new_local(&scoped, name, ty, *mutable, *span); + self.inferred_block_locals.insert(key, local); + local + } + }; + scoped + .scopes + .last_mut() + .expect("value block scope") + .push((name.name.clone(), local)); + } + Stmt::Destructure { + pattern, + ty, + value, + span, + } => { + let ty = self.local_declaration_type(&scoped, ty.as_ref(), Some(value)); + let bindings = self.pattern_locals(&scoped, pattern, ty, *span); + scoped.scopes.last_mut().expect("value block scope").extend( + bindings + .into_iter() + .map(|binding| (binding.name.name, binding.def)), + ); + } + _ => {} + } + } + self.type_of(&scoped, tail) + } + + /// A new local owned by the function being lowered; not yet visible. + fn new_local( + &mut self, + body: &BodyCx, + name: &Ident, + ty: Ty, + mutable: bool, + span: Span, + ) -> DefId { + self.push_def(Def { + kind: DefKind::Local, + name: name.name.clone(), + module: body.module, + file: body.file, + name_span: name.span, + span, + docs: Vec::new(), + is_pub: false, + parent: None, + info: DefInfo::Local { + ty, + mutable, + param: false, + owner: body.owner, + }, + }) + } + + /// Make a local visible by name in the innermost scope, over `visible`. + fn bring_into_scope(&mut self, body: &mut BodyCx, name: &Ident, local: DefId, visible: Span) { + self.local_scopes.push((body.file, visible, local)); + body.scopes + .last_mut() + .expect("block scope") + .push((name.name.clone(), local)); + body.locals.push(local); + } + + pub(super) fn lower_return( + &mut self, + body: &mut BodyCx, + value: Option<&Expr>, + span: Span, + ops: &mut Vec, + ) { + if !body.value_blocks.is_empty() { + self.error("control", body.file, span, "use a tail expression for the value of a block; `return` cannot leave a value block"); + return; + } + let file = body.file; + if !body.loops.is_empty() { + self.diagnostics.push( + Diagnostic::error( + "control", + file, + span, + "`return` inside a `for` loop would only end this iteration", + ) + .with_help("use `continue` to skip to the next one, or return after the loop"), + ); + return; + } + match (&body.ret.clone(), value) { + (Some((slot, ty)), Some(value)) => { + // A recursive call would overwrite a partly computed return + // slot, so such a value is computed in a saved temporary. + if contains_call(value) && !matches!(value, Expr::Call { .. }) { + let depth = body.temp_depth; + let temp = self.temp(body); + if self.emit(body, &temp, *ty, value, ops).is_none() { + return; + } + body.temp_depth = depth; + self.copy_value(slot, &temp, *ty, file, value.span(), ops); + } else if self.emit(body, slot, *ty, value, ops).is_none() { + return; + } + } + (Some((_, ty)), None) => { + let ty = self.ty_name(*ty); + self.error( + "return", + file, + span, + format!("this function returns `{ty}`; write `return ;`"), + ); + return; + } + (None, Some(value)) => { + self.diagnostics.push( + Diagnostic::error( + "return", + file, + value.span(), + "this function does not return a value", + ) + .with_help("declare a return type: `fn name() -> number`"), + ); + return; + } + (None, None) => {} + } + self.finish_receiver(body, span, ops); + ops.push(op_at(pc::Action::Return, file, span)); + } + + /// Match a snapshot of a value against typed constant alternatives. + pub(super) fn lower_match( + &mut self, + body: &mut BodyCx, + value: &Expr, + arms: &[MatchArm], + span: Span, + ops: &mut Vec, + ) { + let depth = body.temp_depth; + let ty = self.type_of(body, value); + let snapshot = self.temp(body); + if self.emit(body, &snapshot, ty, value, ops).is_none() { + body.temp_depth = depth; + return; + } + // Reserve the dispatch flag before lowering arm scratch storage. + let matched = self.temp(body); + let patterns: Vec<_> = arms + .iter() + .map(|arm| (&arm.pattern, arm.guard.is_some(), arm.span)) + .collect(); + let values = self.match_patterns(body, ty, &patterns, span); + let lowered = arms + .iter() + .zip(values) + .filter_map(|(arm, values)| { + let branch = self.lower_match_arm( + body, + &snapshot, + ty, + &matched, + &arm.pattern, + arm.guard.as_ref(), + arm.span, + |this, body| Some(this.lower_block(body, &arm.body)), + )?; + Some(LoweredMatchArm { + values, + catch_all: !matches!(&arm.pattern, MatchPattern::Constants(_)), + body: branch, + span: arm.span, + }) + }) + .collect(); + self.match_dispatch(body, &snapshot, &matched, lowered, span, ops); + body.temp_depth = depth; + } + + #[allow(clippy::too_many_arguments)] + fn lower_match_arm( + &mut self, + body: &mut BodyCx, + snapshot: &pc::FieldReference, + ty: Ty, + matched: &pc::FieldReference, + pattern: &MatchPattern, + guard: Option<&Cond>, + span: Span, + lower: impl FnOnce(&mut Self, &mut BodyCx) -> Option>, + ) -> Option> { + body.scopes.push(Vec::new()); + let mut prelude = Vec::new(); + if let MatchPattern::Binding(pattern) = pattern { + let bindings = self.pattern_locals(body, pattern, ty, span); + self.apply_pattern( + body, + &bindings, + snapshot, + Span::new(pattern.span().end, span.end), + &mut prelude, + ); + } + + let branch = lower(self, body).and_then(|mut branch| { + branch.insert( + 0, + op_at( + pc::Action::ScoreSet { + score: matched.clone(), + value: 1, + }, + body.file, + span, + ), + ); + match guard { + Some(guard) => self.lower_cond(body, guard, branch, Vec::new()), + None => Some(branch), + } + }); + body.scopes.pop(); + prelude.extend(branch?); + Some(prelude) + } + + /// Validate shared statement/value-match patterns and exhaustiveness. + fn match_patterns( + &mut self, + body: &BodyCx, + ty: Ty, + arms: &[(&MatchPattern, bool, Span)], + span: Span, + ) -> Vec> { + let file = body.file; + let mut covered = BTreeSet::new(); + let mut catch_all = None; + let mut lowered = Vec::new(); + for (pattern, guarded, arm_span) in arms { + if let Some(message) = catch_all { + self.error("match", file, *arm_span, message); + } + let mut values = Vec::new(); + let mut alternatives = BTreeSet::new(); + let patterns: &[Expr] = match pattern { + MatchPattern::Constants(patterns) => patterns, + MatchPattern::Wildcard | MatchPattern::Binding(_) => { + if !guarded && catch_all.is_none() { + catch_all = Some(if matches!(pattern, MatchPattern::Wildcard) { + "unreachable match arm after `_`" + } else { + "unreachable match arm after an unguarded binding pattern" + }); + } + &[] + } + }; + for pattern in patterns { + if !Self::is_const_in(body, pattern) { + self.error( + "match", + file, + pattern.span(), + "match patterns must be constants or enum variants", + ); + continue; + } + if let Some(value) = self.eval_i32(body.module, file, pattern, Some(ty), None) { + let value = value as i32; + if covered.contains(&value) || !alternatives.insert(value) { + self.error( + "match", + file, + pattern.span(), + "this value is already covered by a previous pattern", + ); + } + if !guarded { + covered.insert(value); + } + values.push(value); + } + } + lowered.push(values); + } + let exhaustive = catch_all.is_some() + || match ty { + Ty::Bool => covered.contains(&0) && covered.contains(&1), + Ty::Enum(def) => match &self.defs[def.0].info { + DefInfo::Enum { variants } => { + variants + .iter() + .all(|variant| match self.defs[variant.0].info { + DefInfo::Variant { value: Some(value) } => { + covered.contains(&(value as i32)) + } + _ => false, + }) + } + _ => false, + }, + _ => false, + }; + if !exhaustive && ty != Ty::Unknown { + self.diagnostics.push( + Diagnostic::error( + "match", + file, + span, + "non-exhaustive match: some values are not covered", + ) + .with_help("cover every variant, both boolean values, or add `_ => { ... }`"), + ); + } + lowered + } + + /// Flat dispatch keeps the operation depth independent of the number of arms. + #[allow(clippy::too_many_arguments)] + fn match_dispatch( + &mut self, + body: &mut BodyCx, + snapshot: &pc::FieldReference, + matched: &pc::FieldReference, + arms: Vec, + span: Span, + ops: &mut Vec, + ) { + ops.push(op_at( + pc::Action::ScoreSet { + score: matched.clone(), + value: 0, + }, + body.file, + span, + )); + for arm in arms { + let arm_span = arm.span; + let branch = arm.body; + let selected = if arm.catch_all { + branch + } else { + arm.values + .into_iter() + .map(|value| { + op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: snapshot.clone(), + min: Some(value), + max: Some(value), + }), + then: branch.clone(), + otherwise: Vec::new(), + }, + body.file, + arm_span, + ) + }) + .collect() + }; + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: matched.clone(), + min: Some(0), + max: Some(0), + }), + then: selected, + otherwise: Vec::new(), + }, + body.file, + arm_span, + )); + } + } + + #[allow(clippy::too_many_arguments)] + fn emit_match( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + value: &Expr, + arms: &[MatchValueArm], + span: Span, + ops: &mut Vec, + ) -> Option<()> { + let depth = body.temp_depth; + let scrutinee_ty = self.type_of(body, value); + let snapshot = self.temp(body); + self.emit(body, &snapshot, scrutinee_ty, value, ops)?; + // Reserve the dispatch flag before lowering arm scratch storage. + let matched = self.temp(body); + let patterns: Vec<_> = arms + .iter() + .map(|arm| (&arm.pattern, arm.guard.is_some(), arm.span)) + .collect(); + let values = self.match_patterns(body, scrutinee_ty, &patterns, span); + let mut lowered = Vec::new(); + for (arm, values) in arms.iter().zip(values) { + let branch = self.lower_match_arm( + body, + &snapshot, + scrutinee_ty, + &matched, + &arm.pattern, + arm.guard.as_ref(), + arm.span, + |this, body| { + let mut branch = Vec::new(); + this.emit(body, dest, ty, &arm.value, &mut branch)?; + Some(branch) + }, + )?; + lowered.push(LoweredMatchArm { + values, + catch_all: !matches!(&arm.pattern, MatchPattern::Constants(_)), + body: branch, + span: arm.span, + }); + } + self.match_dispatch(body, &snapshot, &matched, lowered, span, ops); + body.temp_depth = depth; + Some(()) + } + + /// Lower `while`, `loop`, and counting `for` loops. + /// + /// Each becomes one backend `While` whose helper re-checks the test after + /// every pass. A test that is a single plain comparison is checked + /// directly; any other test (`!=`, `!`, `&&`, `||`, calculations, calls) + /// is computed into a saved flag before the first pass and again at the + /// end of each. `break` and `continue` set a jump flag that skips the rest + /// of the pass; `break` also clears the loop flag. + pub(super) fn lower_repeat( + &mut self, + body: &mut BodyCx, + kind: Repeat<'_>, + block: &Block, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + let depth = body.temp_depth; + let count_guard = match &kind { + Repeat::Count { + reverse: false, + step: None, + range, + .. + } => !matches!(range.end, Some(Expr::Int(n, _)) if n < i64::from(i32::MAX)), + Repeat::Count { .. } => true, + _ => false, + }; + let has_break = count_guard || block.stmts.iter().any(|stmt| jumps_here(stmt, true)); + let has_jump = has_break || block.stmts.iter().any(|stmt| jumps_here(stmt, false)); + if matches!(kind, Repeat::Forever) && !has_break && !block_mentions_return(block) { + self.diagnostics.push( + Diagnostic::warning("loop", file, span, "this `loop` never ends").with_help( + "leave it with `break;` or `return`; Minecraft stops runaway command chains", + ), + ); + } + let jump = has_jump.then(|| self.temp(body)); + // Reserve the loop flag's temporary before the test uses any. + let keep_index = body.temp_depth; + body.temp_depth += 1; + let mut setup = Vec::new(); + let mut step = Vec::new(); + let mut pre_body = Vec::new(); + body.scopes.push(Vec::new()); + // The plain condition, when the test is a single comparison. + let mut direct = None; + // Operations that compute the test into `keep`. + let mut test = Vec::new(); + let keep_needed; + match kind { + Repeat::While(cond) => { + let mut pre = Vec::new(); + let simple_shape = matches!( + cond, + Cond::Compare { .. } + | Cond::InRange { .. } + | Cond::Call { .. } + | Cond::Value(_) + ); + let atom = if simple_shape { + let Some(atom) = self.atom(body, cond, &mut pre) else { + body.scopes.pop(); + body.temp_depth = depth; + return; + }; + Some(atom) + } else { + None + }; + match atom { + Some((condition, false)) if pre.is_empty() => direct = Some(condition), + Some((condition, negated)) => { + test = pre; + test.push(Self::flag_branch(condition, negated, file, cond.span())); + } + None => { + let Some(lowered) = self.lower_cond( + body, + cond, + vec![Self::marker_set(1, file, span)], + Vec::new(), + ) else { + body.scopes.pop(); + body.temp_depth = depth; + return; + }; + test.push(Self::marker_set(0, file, span)); + test.extend(lowered); + } + } + keep_needed = direct.is_none() || has_break; + } + Repeat::Forever => { + test.push(Self::marker_set(1, file, span)); + keep_needed = true; + } + Repeat::Count { + binding, + range, + reverse, + step: increment, + collection, + } => { + let (Some(start), Some(end)) = (&range.start, &range.end) else { + self.diagnostics.push( + Diagnostic::error( + "for", + file, + range.span, + "a counting `for` needs both ends", + ) + .with_help("write `for i in 0..10 { ... }`; `..=` includes the end"), + ); + body.scopes.pop(); + return; + }; + for bound in [start, end] { + let ty = self.type_of(body, bound); + if !matches!(ty, Ty::Number | Ty::Unknown) { + let found = self.ty_name(ty); + self.diagnostics.push( + Diagnostic::error( + "type", + file, + bound.span(), + format!("a counting `for` counts `number`s, but this is `{found}`"), + ) + .with_help(if ty == Ty::Float { + "convert it with `as number`" + } else { + "use whole numbers for the range ends" + }), + ); + body.scopes.pop(); + return; + } + } + let magnitude = if let Some(increment) = increment { + if !Self::is_const_in(body, increment) { + self.error( + "for", + file, + increment.span(), + "`step_by` needs a positive constant number", + ); + body.scopes.pop(); + body.temp_depth = depth; + return; + } + let Some(value) = + self.eval_i32(body.module, file, increment, Some(Ty::Number), None) + else { + body.scopes.pop(); + body.temp_depth = depth; + return; + }; + if value <= 0 { + self.error( + "for", + file, + increment.span(), + "`step_by` needs a positive constant number", + ); + body.scopes.pop(); + body.temp_depth = depth; + return; + } + value as i32 + } else { + 1 + }; + let snapshot = if let Some(value) = collection { + let ty = self.type_of(body, value); + let (element, length) = if let Some((element, length)) = self.array_shape(ty) { + (element, Some(length)) + } else if let Some(element) = self.list_element(ty) { + (element, None) + } else if ty == Ty::String { + (Ty::String, None) + } else { + self.error( + "for", + file, + value.span(), + "this loop needs an array, vector or string value", + ); + body.scopes.pop(); + body.temp_depth = depth; + return; + }; + let array = self.temp(body); + if self.emit(body, &array, ty, value, &mut setup).is_none() { + body.scopes.pop(); + body.temp_depth = depth; + return; + } + Some((array, element, length, ty == Ty::String)) + } else { + None + }; + // Save the first bound before evaluating the second one: either + // expression may call a function that changes the other's State. + let first = self.temp(body); + if self + .emit(body, &first, Ty::Number, start, &mut setup) + .is_none() + { + body.scopes.pop(); + body.temp_depth = depth; + return; + } + let binding_ty = snapshot + .as_ref() + .map_or(Ty::Number, |(_, element, _, _)| *element); + let local = self.new_local(body, binding, binding_ty, false, binding.span); + let binding_slot = self.local_ref(local); + self.value_slots(&binding_slot, binding_ty); + let counter = if snapshot.is_some() { + self.temp(body) + } else { + binding_slot.clone() + }; + let mut dynamic_length = None; + if let Some((array, element, length, characters)) = snapshot { + if let Some(length) = length { + for offset in 0..length { + let mut then = Vec::new(); + self.copy_value( + &binding_slot, + &super::values::child(&array, &format!("i{offset}")), + element, + file, + span, + &mut then, + ); + pre_body.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: counter.clone(), + min: Some(offset as i32), + max: Some(offset as i32), + }), + then, + otherwise: Vec::new(), + }, + file, + span, + )); + } + } else { + let length = self.temp(body); + setup.push(op_at( + pc::Action::DataRead { + score: length.clone(), + source: Self::data_reference(&array), + }, + file, + span, + )); + dynamic_length = Some(length); + let source = Self::stored_element(&array, &counter); + if characters { + pre_body.push(op_at( + Self::initialize_leaf( + binding_slot.clone(), + super::text::LeafDefault::Data(super::text::text_value("")), + ), + file, + span, + )); + pre_body.push(op_at( + pc::Action::DataModify { + target: Self::data_reference(&binding_slot), + operator: pc::DataModifyOperation::Append, + source: pc::DataOperand::Reference { value: source }, + }, + file, + span, + )); + } else { + self.unpack_value( + body, + &binding_slot, + source, + element, + span, + &mut pre_body, + ); + } + } + } + let limit = if reverse { + if self + .emit(body, &counter, Ty::Number, end, &mut setup) + .is_none() + { + body.scopes.pop(); + body.temp_depth = depth; + return; + } + Value::Read(first) + } else { + setup.push(op_at( + Self::set_from(&counter, Value::Read(first)).expect("score copy"), + file, + start.span(), + )); + if let Some(length) = dynamic_length { + Value::Read(length) + } else { + match self.simple(body, end, Ty::Number) { + Ok(Some(Value::Const(value))) + if range.inclusive || value > i64::from(i32::MIN) => + { + Value::Const(value) + } + Ok(_) => { + let temp = self.temp(body); + if self + .emit(body, &temp, Ty::Number, end, &mut setup) + .is_none() + { + body.scopes.pop(); + body.temp_depth = depth; + return; + } + Value::Read(temp) + } + Err(()) => { + body.scopes.pop(); + body.temp_depth = depth; + return; + } + } + } + }; + self.bring_into_scope( + body, + binding, + local, + Span::new(block.span.start, block.span.end), + ); + let condition = match limit { + Value::Const(value) => { + let max = if range.inclusive { value } else { value - 1 }; + let Ok(max) = i32::try_from(max) else { + self.error( + "range", + file, + end.span(), + "this range end overflows `number`", + ); + body.scopes.pop(); + body.temp_depth = depth; + return; + }; + pc::Condition::Range(pc::ScoreComparison { + score: counter.clone(), + min: None, + max: Some(max), + }) + } + Value::Read(limit) => pc::Condition::Relation(pc::ScoreRelation { + left: counter.clone(), + relation: match (reverse, range.inclusive) { + (true, true) => pc::Relation::Ge, + (true, false) => pc::Relation::Gt, + (false, true) => pc::Relation::Le, + (false, false) => pc::Relation::Lt, + }, + right: limit, + }), + }; + // A reversed exclusive range decrements before the body; + // its strict lower-bound test proves this cannot underflow. + if reverse && !range.inclusive { + pre_body.push(op_at( + pc::Action::ScoreAdd { + score: counter.clone(), + value: -1, + }, + file, + range.span, + )); + } + let delta = if reverse { + -magnitude + i32::from(!range.inclusive) + } else { + magnitude + }; + if delta != 0 { + let advance = op_at( + pc::Action::ScoreAdd { + score: counter.clone(), + value: delta, + }, + file, + range.span, + ); + if count_guard { + // Do not wrap at the scoreboard's endpoints and loop + // forever. A synthetic break shares the normal jump flag. + let jump = jump.as_ref().expect("guarded counting loop"); + step.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: counter, + min: (delta < 0).then(|| i32::MIN - delta), + max: (delta > 0).then(|| i32::MAX - delta), + }), + then: vec![advance], + otherwise: vec![op_at( + pc::Action::ScoreSet { + score: jump.clone(), + value: 2, + }, + file, + span, + )], + }, + file, + span, + )); + } else { + step.push(advance); + } + } + direct = Some(condition); + keep_needed = has_break; + } + } + let keep = keep_needed.then(|| self.slot(format!("{}_t{keep_index}", body.slot))); + // `test` was built against a placeholder flag; point it at `keep`. + let test: Vec = match (&keep, &direct) { + (Some(keep), Some(condition)) => vec![ + op_at( + pc::Action::ScoreSet { + score: keep.clone(), + value: 0, + }, + file, + span, + ), + op_at( + pc::Action::Branch { + condition: condition.clone(), + then: vec![op_at( + pc::Action::ScoreSet { + score: keep.clone(), + value: 1, + }, + file, + span, + )], + otherwise: Vec::new(), + }, + file, + span, + ), + ], + (Some(keep), None) => retarget_marker(test, keep), + (None, _) => Vec::new(), + }; + body.jumps.push(super::Jump { + flag: jump.clone(), + executor_loops: body.loops.len(), + }); + let lowered = self.lower_block(body, block); + body.jumps.pop(); + body.scopes.pop(); + let mut inner = Vec::new(); + if let Some(jump) = &jump { + inner.push(op_at( + pc::Action::ScoreSet { + score: jump.clone(), + value: 0, + }, + file, + span, + )); + } + inner.extend(pre_body); + inner.extend(lowered); + inner.extend(step); + if let Some(keep) = &keep { + match (&jump, has_break) { + (Some(jump), true) => inner.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: jump.clone(), + min: Some(2), + max: Some(2), + }), + then: vec![op_at( + pc::Action::ScoreSet { + score: keep.clone(), + value: 0, + }, + file, + span, + )], + otherwise: test.clone(), + }, + file, + span, + )), + _ => inner.extend(test.clone()), + } + } + body.temp_depth = depth; + ops.extend(setup); + let condition = match (keep, direct) { + (Some(keep), _) => { + ops.extend(test); + pc::Condition::Range(pc::ScoreComparison { + score: keep, + min: Some(1), + max: Some(1), + }) + } + (None, Some(condition)) => condition, + (None, None) => unreachable!("a loop without a direct test keeps a flag"), + }; + ops.push(op_at( + pc::Action::While { + condition, + body: inner, + }, + file, + span, + )); + } + + /// `keep = 1` (or 0) against the placeholder flag, retargeted later. + fn marker_set(value: i32, file: FileId, span: Span) -> pc::Operation { + op_at( + pc::Action::ScoreSet { + score: keep_marker(), + value, + }, + file, + span, + ) + } + + /// Set the placeholder flag to whether `condition` holds (or fails). + fn flag_branch( + condition: pc::Condition, + negated: bool, + file: FileId, + span: Span, + ) -> pc::Operation { + op_at( + pc::Action::Branch { + condition, + then: vec![Self::marker_set(i32::from(!negated), file, span)], + otherwise: vec![Self::marker_set(i32::from(negated), file, span)], + }, + file, + span, + ) + } + + /// `break;` and `continue;`. + pub(super) fn lower_jump( + &mut self, + body: &mut BodyCx, + is_break: bool, + span: Span, + ops: &mut Vec, + ) { + if body.value_blocks.last() == Some(&(body.loops.len(), body.jumps.len())) { + self.error( + "control", + body.file, + span, + "a loop jump cannot leave a value block", + ); + return; + } + let file = body.file; + let word = if is_break { "break" } else { "continue" }; + let repeat = body + .jumps + .last() + .filter(|jump| jump.executor_loops == body.loops.len()); + if let Some(jump) = repeat { + let flag = jump + .flag + .clone() + .expect("a loop with jumps keeps a jump flag"); + ops.push(op_at( + pc::Action::ScoreSet { + score: flag, + value: if is_break { 2 } else { 1 }, + }, + file, + span, + )); + } else if !body.loops.is_empty() { + if is_break { + self.diagnostics.push( + Diagnostic::error( + "control", + file, + span, + "`break` cannot stop a `players()` or `entities(..)` loop", + ) + .with_help( + "every match runs once; `continue` skips the rest of this one's turn", + ), + ); + } else { + ops.push(op_at(pc::Action::Return, file, span)); + } + } else { + self.diagnostics.push( + Diagnostic::error("control", file, span, format!("`{word}` only works inside a loop")) + .with_help("loops are `while`, `loop`, `for i in a..b`, `for player in players()`, and `for entity in entities(..)`"), + ); + } + } + + /// Bind call arguments to a builtin's parameters by position and name. + pub(super) fn bind_args<'a>( + &mut self, + body: &BodyCx, + builtin: &Builtin, + args: &'a [Arg], + span: Span, + ) -> Option> { + let file = body.file; + let mut bound = BTreeMap::new(); + let mut ok = true; + let mut position = 0; + for arg in args { + let param = match &arg.name { + Some(name) => builtin.params.iter().find(|p| p.name == name.name), + None => { + let param = builtin.params.get(position); + position += 1; + param + } + }; + let Some(param) = param else { + let message = match &arg.name { + Some(name) => format!( + "`{}` has no argument named `{}`; expected {}", + builtin.name, + name.name, + param_list(builtin) + ), + None => format!( + "too many arguments: `{}` takes {}", + builtin.name, + param_list(builtin) + ), + }; + self.diagnostics.push( + Diagnostic::error("call", file, arg.span, message) + .with_help(format!("usage: {}", builtin.signature)), + ); + ok = false; + continue; + }; + if bound.insert(param.name, arg).is_some() { + self.error( + "call", + file, + arg.span, + format!("argument `{}` is given more than once", param.name), + ); + ok = false; + } + } + for param in builtin.params.iter().filter(|p| p.required) { + if !bound.contains_key(param.name) { + self.diagnostics.push( + Diagnostic::error( + "call", + file, + span, + format!("`{}` needs `{}`: {}", builtin.name, param.name, param.doc), + ) + .with_help(format!("usage: {}", builtin.signature)), + ); + ok = false; + } + } + ok.then_some(bound) + } + + fn arg_string( + &mut self, + file: FileId, + arg: &Arg, + what: &str, + ) -> Option<(String, String, Span)> { + match &arg.value { + ArgValue::Expr(Expr::Str { value, raw, span }) => { + Some((value.clone(), raw.clone(), *span)) + } + other => { + self.error( + "type", + file, + other.span(), + format!("expected {what} in quotes"), + ); + None + } + } + } + + fn arg_id(&mut self, body: &BodyCx, arg: &Arg, registry: &'static str) -> Option { + let ArgValue::Expr(expr) = &arg.value else { + self.error( + "type", + body.file, + arg.value.span(), + format!("expected {} `{registry}` value", super::article(registry)), + ); + return None; + }; + self.vanilla_value(body.module, body.file, expr, registry) + } + + fn arg_equipment_slot( + &mut self, + body: &BodyCx, + arg: &Arg, + ) -> Option { + let value = self.arg_id(body, arg, "EquipmentSlot")?; + match serde_json::from_value(serde_json::Value::String(value)) { + Ok(slot) => Some(slot), + Err(_) => { + self.error( + "type", + body.file, + arg.span, + "expected an `EquipmentSlot::...` value", + ); + None + } + } + } + + pub(super) fn arg_int(&mut self, body: &BodyCx, arg: &Arg, min: i64, max: i64) -> Option { + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", body.file, arg.value.span(), "expected an integer"); + return None; + }; + if !Self::is_const_in(body, expr) { + self.diagnostics.push( + Diagnostic::error("type", body.file, expr.span(), "expected a constant number") + .with_help("this argument is written into the command when the pack is built"), + ); + return None; + } + let value = self.eval_i32(body.module, body.file, expr, Some(Ty::Number), None)?; + if value < min || value > max { + self.error( + "range", + body.file, + expr.span(), + format!("expected a value from {min} to {max}, found {value}"), + ); + return None; + } + Some(value) + } + + fn arg_bool(&mut self, file: FileId, arg: &Arg) -> Option { + match &arg.value { + ArgValue::Expr(Expr::Bool(value, _)) => Some(*value), + other => { + self.error("type", file, other.span(), "expected `true` or `false`"); + None + } + } + } + + pub(super) fn lower_call( + &mut self, + body: &mut BodyCx, + path: &Path, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) { + let (module, file) = (body.module, body.file); + if path.segments.len() == 1 + && let Some(local) = Self::lookup_local(body, &path.last().name) + { + if let Some((def, actual)) = self.indirect_call(body, path, local, args) { + let slots = self.fn_slots[&def].clone(); + self.call_user(body, def, &slots, path, &actual, span, ops); + } + return; + } + let name = &path.last().name; + if !path.arguments().is_empty() + && path.segments.len() == 1 + && !self.scopes[module.0].contains_key(name) + { + self.error( + "generic", + file, + path.span, + "builtins do not take type arguments", + ); + return; + } + + let is_builtin_name = path.segments.len() == 1 && !self.scopes[module.0].contains_key(name); + if is_builtin_name && let Some(builtin) = builtins::find(name, BuiltinKind::Statement) { + self.lower_builtin(body, builtin, path, args, span, ops); + return; + } + if is_builtin_name && builtins::find(name, BuiltinKind::Macro).is_some() { + self.diagnostics.push( + Diagnostic::error("call", file, path.span, format!("`{name}` is a macro")) + .with_help(format!("write `{name}!(...)`")), + ); + return; + } + let Some(def) = self.resolve_call(body, path, args, None, true) else { + return; + }; + if let Some(slots) = self.fn_slots.get(&def).cloned() { + let _ = self.call_user(body, def, &slots, path, args, span, ops); + return; + } + if let Some(first) = args.first() { + self.error( + "call", + file, + first.span.to(args.last().expect("non-empty").span), + "external functions take no arguments", + ); + } + body.all_calls.push((def, path.span)); + if !body.in_players { + body.calls.push((def, path.span)); + } + if body.loops.last() == Some(&super::LoopKind::Entities) { + body.entity_loop_calls.push((def, path.span)); + } + if let Some(function) = self.function_reference(def) { + ops.push(op_at(pc::Action::Call { function }, file, span)); + } + } + + /// `emit(Event, args...)`: pass the payload to the event's dispatcher. + /// `emit Event(args);`: evaluate the payload once into the event's + /// parameters and run its dispatcher. + pub(super) fn lower_emit( + &mut self, + body: &mut BodyCx, + event: &Path, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) { + let (module, file) = (body.module, body.file); + let Some(def) = self.expect_path(module, event, &[DefKind::Event], "an event") else { + return; + }; + if !self.event_handlers.contains_key(&def) { + let name = self.defs[def.0].name.clone(); + self.diagnostics.push( + Diagnostic::warning( + "event", + file, + event.span, + format!("`{name}` has no handlers, so this does nothing"), + ) + .with_help(format!("mark a function with `#[on({name})]`")), + ); + } + let Some(slots) = self.fn_slots.get(&def).cloned() else { + return; + }; + let _ = self.call_user(body, def, &slots, event, args, span, ops); + } + + fn lower_builtin( + &mut self, + body: &mut BodyCx, + builtin: &'static Builtin, + path: &Path, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + self.references_builtin(file, path.span, builtin); + let Some(bound) = self.bind_args(body, builtin, args, span) else { + return; + }; + if builtin.needs_player { + body.note_player( + path.span, + format!("uses `{}`, which needs a player", builtin.name), + ); + } + if builtins::EXECUTOR_BUILTINS.contains(&builtin.name) { + body.note_executor( + path.span, + format!( + "uses `{}`, which acts on the executing entity", + builtin.name + ), + ); + } + if builtin.name == "start_timer" { + self.lower_start_timer(body, &bound, span, ops); + return; + } + if builtin.name == "in_dimension" { + let Some(dimension) = self + .arg_id(body, bound["dimension"], "Dimension") + .and_then(|id| id.parse().ok()) + else { + return; + }; + let ArgValue::Expr(Expr::Path(function)) = &bound["function"].value else { + self.error( + "type", + file, + bound["function"].span, + "expected a parameterless function name", + ); + return; + }; + if !self + .resolve_path(body.module, function) + .is_ok_and(|(def, _)| { + matches!( + self.defs[def.0].kind, + DefKind::Function | DefKind::ExternFunction + ) + }) + { + self.error( + "resolve", + file, + function.span, + "expected a parameterless function name", + ); + return; + } + let mut nested = Vec::new(); + self.lower_call(body, function, &[], function.span, &mut nested); + if !nested.is_empty() { + ops.push(op_at( + pc::Action::InDimension { + dimension, + body: nested, + }, + file, + span, + )); + } + return; + } + if matches!(builtin.name, "set_bossbar" | "set_bossbar_max") { + self.lower_set_bossbar(body, builtin, &bound, span, ops); + return; + } + if matches!( + builtin.name, + "give_item" + | "clear_item" + | "damage" + | "mount" + | "set_block_data" + | "teleport" + | "teleport_by" + | "set_velocity" + | "play_sound" + | "spawn_particle" + | "add_experience" + ) { + let depth = body.temp_depth; + let action = self.numeric_builtin_action(body, builtin.name, args, &bound, span, ops); + body.temp_depth = depth; + if let Some(action) = action { + ops.push(op_at(action, file, span)); + } + return; + } + if let Some(action) = self.builtin_action(body, builtin, &bound, span) { + ops.push(op_at(action, file, span)); + } + } + + fn runtime_whole( + &mut self, + body: &mut BodyCx, + arg: &Arg, + min: i64, + max: i64, + ops: &mut Vec, + ) -> Option { + let ArgValue::Expr(expr) = &arg.value else { + self.error( + "type", + body.file, + arg.span, + "expected a number value, found a range", + ); + return None; + }; + if Self::is_const_in(body, expr) { + return Some(pc::ScoreOperand::Value( + self.arg_int(body, arg, min, max)? as i32 + )); + } + let found = self.type_of(body, expr); + if !self.types_agree(body.file, expr.span(), Ty::Number, found) { + return None; + } + let score = self.temp(body); + self.emit(body, &score, Ty::Number, expr, ops)?; + Some(pc::ScoreOperand::Field(score)) + } + + // Numeric command arguments are frozen in authored argument order. A later + // argument may call a function that changes the State read by an earlier one. + fn numeric_builtin_action( + &mut self, + body: &mut BodyCx, + name: &str, + args: &[Arg], + bound: &BTreeMap<&str, &Arg>, + span: Span, + ops: &mut Vec, + ) -> Option { + match name { + "give_item" => { + let item = self.arg_id(body, bound["item"], "Item")?; + let count = match bound.get("count") { + None => pc::ScoreOperand::Value(1), + Some(arg) => self.runtime_whole(body, arg, 1, 6400, ops)?, + }; + Some(pc::Action::GiveItem { item, count }) + } + "clear_item" => { + let item = self.arg_id(body, bound["item"], "Item")?; + let count = match bound.get("count") { + Some(arg) => { + Some(self.runtime_whole(body, arg, 0, i64::from(i32::MAX), ops)?) + } + None => None, + }; + Some(pc::Action::ClearItem { + item: Some(item), + count, + }) + } + "play_sound" => { + let sound = self.arg_id(body, bound["sound"], "Sound")?; + let mut volume = pc::Amount::Value(1.0); + let mut pitch = pc::Amount::Value(1.0); + for arg in args { + let (key, _) = bound.iter().find(|(_, value)| std::ptr::eq(**value, arg))?; + match *key { + "volume" => volume = self.runtime_amount(body, arg, ops)?, + "pitch" => pitch = self.runtime_amount(body, arg, ops)?, + _ => {} + } + } + for (key, amount, max) in + [("volume", &volume, f32::MAX as f64), ("pitch", &pitch, 2.0)] + { + if matches!(amount, pc::Amount::Value(value) if !(0.0..=max).contains(value)) { + self.error( + "range", + body.file, + bound.get(key).map_or(span, |arg| arg.span), + format!("sound {key} must be from 0 to {max}"), + ); + return None; + } + } + Some(pc::Action::Sound { + sound, + volume, + pitch, + }) + } + "spawn_particle" => { + let particle = self.arg_id(body, bound["particle"], "Particle")?; + let mut count = pc::ScoreOperand::Value(1); + let mut spread = pc::Amount::Value(0.0); + let mut speed = pc::Amount::Value(0.0); + for arg in args { + let (key, _) = bound.iter().find(|(_, value)| std::ptr::eq(**value, arg))?; + match *key { + "count" => count = self.runtime_whole(body, arg, 0, 100_000, ops)?, + "spread" => spread = self.runtime_amount(body, arg, ops)?, + "speed" => speed = self.runtime_amount(body, arg, ops)?, + _ => {} + } + } + for (key, amount) in [("spread", &spread), ("speed", &speed)] { + if matches!(amount, pc::Amount::Value(value) if !(0.0..=1000.0).contains(value)) + { + self.error( + "range", + body.file, + bound.get(key).map_or(span, |arg| arg.span), + format!("particle {key} must be from 0 to 1000"), + ); + return None; + } + } + Some(pc::Action::Particle { + particle, + count, + spread, + speed, + }) + } + "add_experience" => { + let (arg, levels) = match (bound.get("points"), bound.get("levels")) { + (Some(arg), None) => (*arg, false), + (None, Some(arg)) => (*arg, true), + _ => { + self.error( + "call", + body.file, + span, + "`add_experience` needs exactly one of `points` or `levels`", + ); + return None; + } + }; + let ArgValue::Expr(expr) = &arg.value else { + self.error( + "type", + body.file, + arg.span, + "expected a number value, found a range", + ); + return None; + }; + let found = self.type_of(body, expr); + if !self.types_agree(body.file, expr.span(), Ty::Number, found) { + return None; + } + let amount = if Self::is_const_in(body, expr) { + pc::ScoreOperand::Value(self.arg_int( + body, + arg, + i32::MIN as i64, + i32::MAX as i64, + )? as i32) + } else { + let score = self.temp(body); + self.emit(body, &score, Ty::Number, expr, ops)?; + pc::ScoreOperand::Field(score) + }; + Some(pc::Action::AddExperience { amount, levels }) + } + "damage" => { + let mut amount = None; + let mut by = None; + for arg in args { + if std::ptr::eq(arg, bound["amount"]) { + amount = Some(self.runtime_amount(body, arg, ops)?); + } else if bound.get("by").is_some_and(|by| std::ptr::eq(arg, *by)) { + let ArgValue::Expr(expr) = &arg.value else { + return None; + }; + let score = self.temp(body); + self.emit(body, &score, Ty::EntityRef, expr, ops)?; + by = Some(score); + } + } + let amount = amount?; + if let pc::Amount::Value(value) = amount + && !(0.01..=1_000_000.0).contains(&value) + { + self.error( + "range", + body.file, + bound["amount"].span, + "damage must be from 0.01 to 1000000", + ); + return None; + } + let damage_type = match bound.get("type") { + Some(arg) => Some(self.arg_id(body, arg, "DamageType")?.parse().ok()?), + None => None, + }; + Some(pc::Action::Damage { + amount, + by, + damage_type, + }) + } + "set_block_data" => { + let target = self.arg_block_data(body, bound["at"], bound["path"])?; + let arg = bound["value"]; + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", body.file, arg.span, "expected an integer value"); + return None; + }; + let value = if matches!( + expr, + Expr::Struct { .. } | Expr::Array(..) | Expr::Str { .. } + ) || Self::is_const_in(body, expr) + { + pc::DataOperand::Value { + value: self.const_nbt_value(body, expr, 0)?, + } + } else { + let value = match self.simple(body, expr, Ty::Number).ok()? { + Some(Value::Const(value)) => pc::ScoreOperand::Value(value as i32), + Some(Value::Read(score)) => pc::ScoreOperand::Field(score), + None => { + let score = self.temp(body); + self.emit(body, &score, Ty::Number, expr, ops)?; + pc::ScoreOperand::Field(score) + } + }; + pc::DataOperand::Score { value } + }; + Some(pc::Action::WriteBlockData { + target, + value: Some(value), + }) + } + "mount" => { + let arg = bound["vehicle"]; + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", body.file, arg.span, "expected an `EntityRef` value"); + return None; + }; + let vehicle = self.temp(body); + self.emit(body, &vehicle, Ty::EntityRef, expr, ops)?; + Some(pc::Action::Ride { + vehicle: Some(vehicle), + }) + } + "teleport" | "teleport_by" | "set_velocity" => { + let keys = if name == "teleport_by" { + ["dx", "dy", "dz"] + } else { + ["x", "y", "z"] + }; + let mut values = BTreeMap::new(); + for arg in args { + let (key, _) = bound.iter().find(|(_, value)| std::ptr::eq(**value, arg))?; + if keys.contains(key) { + let amount = self.runtime_amount(body, arg, ops)?; + if name == "set_velocity" + && matches!(amount, pc::Amount::Value(value) if !(-10.0..=10.0).contains(&value)) + { + self.error( + "range", + body.file, + arg.span, + "velocity must be from -10 to 10 blocks per tick", + ); + return None; + } + values.insert(*key, amount); + } + } + let x = values.remove(keys[0])?; + let y = values.remove(keys[1])?; + let z = values.remove(keys[2])?; + Some(match name { + "set_velocity" => pc::Action::SetVelocity { x, y, z }, + "teleport" => pc::Action::Teleport { + destination: pc::TeleportDestination::Position { x, y, z }, + }, + _ => pc::Action::Teleport { + destination: pc::TeleportDestination::Offset { x, y, z }, + }, + }) + } + _ => unreachable!("numeric builtin"), + } + } + + fn lower_start_timer( + &mut self, + body: &mut BodyCx, + bound: &BTreeMap<&str, &Arg>, + span: Span, + ops: &mut Vec, + ) { + let Some(timer) = self.arg_timer(body, bound["timer"], "starts") else { + return; + }; + let (arg, scale) = match (bound.get("ticks"), bound.get("seconds")) { + (Some(arg), None) => (*arg, 1), + (None, Some(arg)) => (*arg, 20), + _ => { + self.error( + "call", + body.file, + span, + "`start_timer` needs exactly one of `ticks` or `seconds`", + ); + return; + } + }; + let max = i32::MAX / scale; + let ArgValue::Expr(expr) = &arg.value else { + self.error( + "type", + body.file, + arg.span, + "expected a number duration, found a range", + ); + return; + }; + if Self::is_const_in(body, expr) { + if let Some(value) = self.arg_int(body, arg, 1, max as i64) { + ops.push(op_at( + pc::Action::ScoreSet { + score: timer, + value: value as i32 * scale, + }, + body.file, + span, + )); + } + return; + } + let found = self.type_of(body, expr); + if !self.types_agree(body.file, expr.span(), Ty::Number, found) { + return; + } + let depth = body.temp_depth; + let temp = self.temp(body); + let computed = self.emit(body, &temp, Ty::Number, expr, ops); + body.temp_depth = depth; + if computed.is_none() { + return; + } + let mut then = Vec::new(); + if scale != 1 { + then.push(op_at( + pc::Action::ScoreOperation { + score: temp.clone(), + operator: pc::ScoreOperator::Mul, + operand: pc::ScoreOperand::Value(scale), + }, + body.file, + span, + )); + } + if let Some(action) = Self::set_from(&timer, Value::Read(temp.clone())) { + then.push(op_at(action, body.file, span)); + } + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: temp, + min: Some(1), + max: Some(max), + }), + then, + otherwise: Vec::new(), + }, + body.file, + span, + )); + } + + fn runtime_amount( + &mut self, + body: &mut BodyCx, + arg: &Arg, + ops: &mut Vec, + ) -> Option { + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", body.file, arg.span, "expected a numeric value"); + return None; + }; + let ty = self.type_of(body, expr); + self.expect_numeric(body.file, expr.span(), ty)?; + if Self::is_const_in(body, expr) { + let value = if matches!(expr, Expr::Float(..)) + || matches!(expr, Expr::Neg(inner, _) if matches!(**inner, Expr::Float(..))) + { + self.arg_coordinate(body, arg)? + } else { + self.eval_i32(body.module, body.file, expr, Some(ty), None)? as f64 + / if ty == Ty::Float { + FLOAT_SCALE as f64 + } else { + 1.0 + } + }; + return Some(pc::Amount::Value(value)); + } + let score = self.temp(body); + self.emit(body, &score, ty, expr, ops)?; + Some(pc::Amount::Field(pc::ScaledField { + score, + scale: if ty == Ty::Float { + FLOAT_SCALE as f64 + } else { + 1.0 + }, + })) + } + + /// A constant coordinate, in full double precision. + fn arg_coordinate(&mut self, body: &BodyCx, arg: &Arg) -> Option { + let file = body.file; + let value = match &arg.value { + ArgValue::Expr(Expr::Float(value, _)) => *value, + ArgValue::Expr(Expr::Neg(inner, _)) if matches!(**inner, Expr::Float(..)) => { + let Expr::Float(value, _) = **inner else { + unreachable!() + }; + -value + } + ArgValue::Expr(expr) if Self::is_const_in(body, expr) => { + self.eval_i32(body.module, file, expr, Some(Ty::Number), None)? as f64 + } + other => { + self.diagnostics.push( + Diagnostic::error("type", file, other.span(), "coordinates must be constants") + .with_help("use `teleport_by` to move relative to the entity"), + ); + return None; + } + }; + Some(value) + } + + /// An argument naming a declared `entity state`. + fn arg_attachable_state(&mut self, body: &BodyCx, arg: &Arg) -> Option<(DefId, String)> { + let (module, file) = (body.module, body.file); + let ArgValue::Expr(Expr::Path(path)) = &arg.value else { + self.error( + "type", + file, + arg.value.span(), + "expected an entity state name", + ); + return None; + }; + let def = self.expect_path(module, path, &[DefKind::State], "an entity state")?; + let DefInfo::State { scope, id, .. } = &self.defs[def.0].info else { + return None; + }; + if *scope != Scope::Entity { + let name = self.defs[def.0].name.clone(); + self.diagnostics.push( + Diagnostic::error( + "type", + file, + path.span, + format!("`{name}` is not an entity state"), + ) + .with_help("only `entity state` declarations are attached to entities"), + ); + return None; + } + Some((def, id.clone())) + } + + /// A `State.field` argument naming a `timer` field. + fn arg_timer( + &mut self, + body: &mut BodyCx, + arg: &Arg, + verb: &str, + ) -> Option { + let (module, file) = (body.module, body.file); + let ArgValue::Expr(Expr::Place(place)) = &arg.value else { + self.diagnostics.push( + Diagnostic::error("type", file, arg.value.span(), "expected a `timer` field") + .with_help("write it as `State.field`"), + ); + return None; + }; + let (state, field, _) = self.resolve_place(module, file, place)?; + if verb != "tests" && !self.check_state_write(body, state, place.span) { + return None; + } + if !matches!(self.defs[field.0].info, DefInfo::Field { timer: true, .. }) { + self.diagnostics.push( + Diagnostic::error( + "type", + file, + place.field.span, + format!("`{}` is not a `timer` field", place.field.name), + ) + .with_help("declare it as `name: timer`"), + ); + return None; + } + body.note_state(self, state, place, verb); + self.field_reference(state, field) + } + + /// `pos(x, y, z)` or `offset(dx, dy, dz)`. + fn arg_position(&mut self, body: &mut BodyCx, arg: &Arg) -> Option { + let file = body.file; + let call = match &arg.value { + ArgValue::Expr(Expr::Call { path, args, .. }) if path.segments.len() == 1 => { + Some((path, args)) + } + _ => None, + }; + let Some((path, args)) = call.filter(|(path, args)| { + matches!(path.segments[0].name.as_str(), "pos" | "offset") && args.len() == 3 + }) else { + self.diagnostics.push( + Diagnostic::error("type", file, arg.value.span(), "expected a block position") + .with_help("write `pos(x, y, z)` or `offset(dx, dy, dz)`"), + ); + return None; + }; + let min = i32::MIN as i64; + let max = i32::MAX as i64; + if let Some(arg) = args.iter().find( + |arg| !matches!(&arg.value, ArgValue::Expr(expr) if Self::is_const_in(body, expr)), + ) { + self.diagnostics.push( + Diagnostic::error("type", file, arg.span, "block positions must be constants") + .with_help("positions are written into the command when the pack is built"), + ); + return None; + } + let x = self.arg_int(body, &args[0], min, max); + let y = self.arg_int(body, &args[1], min, max); + let z = self.arg_int(body, &args[2], min, max); + let (x, y, z) = (x? as i32, y? as i32, z? as i32); + Some(if path.segments[0].name == "offset" { + body.note_executor( + path.span, + "uses `offset`, which is relative to the executing entity".into(), + ); + pc::BlockPosition::Relative { x, y, z } + } else { + pc::BlockPosition::Absolute { x, y, z } + }) + } + + /// An argument naming a declared boss bar or loot table. + fn arg_declared( + &mut self, + body: &BodyCx, + arg: &Arg, + kind: DefKind, + what: &str, + ) -> Option { + let ArgValue::Expr(Expr::Path(path)) = &arg.value else { + self.error( + "type", + body.file, + arg.value.span(), + format!("expected {what}"), + ); + return None; + }; + let def = self.expect_path(body.module, path, &[kind], what)?; + let DefInfo::Data { id, .. } = &self.defs[def.0].info else { + return None; + }; + id.parse().ok() + } + + fn arg_block_data( + &mut self, + body: &mut BodyCx, + position: &Arg, + path: &Arg, + ) -> Option { + let at = self.arg_position(body, position)?; + let (path, _, _) = self.arg_string(body.file, path, "an NBT path")?; + Some(pc::BlockDataAddress { at, path }) + } + + /// A vanilla block, or `#tag` for a declared `Block` tag. + fn arg_block_test(&mut self, body: &BodyCx, arg: &Arg) -> Option { + if let ArgValue::Expr(expr) = &arg.value + && let Some((def, id)) = self.declared(body.module, body.file, expr, DefKind::Tag) + { + if matches!( + self.defs[def.0].info, + DefInfo::Data { + tag_type: Some("Block"), + .. + } + ) { + return Some(format!("#{id}")); + } + self.error( + "type", + body.file, + expr.span(), + format!("`{}` is not a `Block` tag", self.defs[def.0].name), + ); + return None; + } + self.arg_id(body, arg, "Block") + } + + fn lower_set_bossbar( + &mut self, + body: &mut BodyCx, + builtin: &'static Builtin, + bound: &BTreeMap<&'static str, &Arg>, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + let Some(bar) = self.arg_declared(body, bound["bar"], DefKind::BossBar, "a boss bar") + else { + return; + }; + let max = builtin.name == "set_bossbar_max"; + let value_arg = bound[if max { "max" } else { "value" }]; + let ArgValue::Expr(expr) = &value_arg.value else { + self.error("type", file, value_arg.span, "expected a value"); + return; + }; + let ty = self.type_of(body, expr); + if !self.types_agree(file, expr.span(), Ty::Number, ty) { + return; + } + let value = if Self::is_const_in(body, expr) { + let Some(value) = + self.arg_int(body, value_arg, if max { 1 } else { 0 }, i32::MAX as i64) + else { + return; + }; + pc::ScoreOperand::Value(value as i32) + } else { + match self.simple(body, expr, ty) { + Ok(Some(Value::Read(reference))) => pc::ScoreOperand::Field(reference), + Ok(_) => { + let depth = body.temp_depth; + let temp = self.temp(body); + if self.emit(body, &temp, ty, expr, ops).is_none() { + return; + } + body.temp_depth = depth; + pc::ScoreOperand::Field(temp) + } + Err(()) => return, + } + }; + ops.push(op_at( + pc::Action::SetBossBar { bar, value, max }, + file, + span, + )); + } + + /// A predicate call in a condition, such as `has_state(Mana)`. + pub(super) fn predicate( + &mut self, + body: &mut BodyCx, + path: &Path, + args: &[Arg], + span: Span, + ) -> Option { + if !path.arguments().is_empty() { + self.error( + "generic", + body.file, + path.span, + "builtins do not take type arguments", + ); + return None; + } + let file = body.file; + let name = &path.last().name; + let Some(builtin) = (path.segments.len() == 1) + .then(|| builtins::find(name, BuiltinKind::Condition)) + .flatten() + else { + self.diagnostics.push( + Diagnostic::error("condition", file, path.span, format!("`{}` is not a condition", path.display())) + .with_help("compare a value, like `price(2) > 5`, or use a predicate such as `has_state(...)`"), + ); + return None; + }; + self.references_builtin(file, path.span, builtin); + let bound = self.bind_args(body, builtin, args, span)?; + if matches!(builtin.name, "has_state") + || builtins::EXECUTOR_BUILTINS.contains(&builtin.name) + { + body.note_executor( + path.span, + format!("uses `{name}`, which tests the executing entity"), + ); + } + let flag = |flag| Some(pc::Condition::Flag(pc::FlagSet { flag })); + match builtin.name { + "has_state" => { + let (_, id) = self.arg_attachable_state(body, bound["state"])?; + Some(pc::Condition::Attached(pc::StateAttached { + attached: id.parse().ok()?, + })) + } + "any_entities" => Some(pc::Condition::Exists(pc::EntitiesExist { + exists: self.query_from(body, &bound)?, + })), + "block_is" => { + let block = self.arg_block_test(body, bound["block"]); + let at = self.arg_position(body, bound["at"]); + Some(pc::Condition::Block(pc::BlockMatches { + block: block?, + at: at?, + })) + } + "biome_is" => Some(pc::Condition::Biome(pc::BiomeMatches { + biome: self.arg_id(body, bound["biome"], "Biome")?, + at: self.arg_position(body, bound["at"])?, + })), + "advancement_done" => { + body.note_player( + path.span, + "`advancement_done` reads the executing player's progress".into(), + ); + let arg = bound["advancement"]; + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", file, arg.span, "expected an advancement resource"); + return None; + }; + let advancement = + self.native_data_id(body.module, file, expr, DefKind::Advancement)?; + let criterion = match bound.get("criterion") { + Some(arg) => Some(self.arg_string(file, arg, "a criterion name")?.0), + None => None, + }; + Some(pc::Condition::Advancement { + advancement, + criterion, + }) + } + "predicate_matches" => { + let arg = bound["predicate"]; + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", file, arg.span, "expected a predicate resource"); + return None; + }; + Some(pc::Condition::Predicate { + predicate: self.native_data_id(body.module, file, expr, DefKind::Predicate)?, + }) + } + "dimension_is" => Some(pc::Condition::Dimension(pc::DimensionMatches { + dimension: self + .arg_id(body, bound["dimension"], "Dimension")? + .parse() + .ok()?, + })), + "holding" => { + let holding = self.arg_id(body, bound["item"], "Item")?; + let offhand = match bound.get("offhand") { + Some(arg) => self.arg_bool(file, arg)?, + None => false, + }; + let slot = match bound.get("slot") { + Some(arg) if bound.contains_key("offhand") => { + self.error("type", file, arg.span, "choose either slot or offhand"); + return None; + } + Some(arg) => Some(self.arg_equipment_slot(body, arg)?), + None => None, + }; + Some(pc::Condition::Holding(pc::ItemHeld { + holding, + offhand, + slot, + })) + } + "is_sneaking" => flag(pc::EntityFlag::Sneaking), + "is_sprinting" => flag(pc::EntityFlag::Sprinting), + "is_swimming" => flag(pc::EntityFlag::Swimming), + "is_on_fire" => flag(pc::EntityFlag::OnFire), + "timer_running" | "timer_done" => { + let score = self.arg_timer(body, bound["timer"], "tests")?; + let (min, max) = if builtin.name == "timer_running" { + (Some(1), None) + } else { + (Some(0), Some(0)) + }; + Some(pc::Condition::Range(pc::ScoreComparison { + score, + min, + max, + })) + } + other => unreachable!("condition builtin `{other}` is not lowered"), + } + } + + /// Parse the filters of `entities(..)` in a `for` loop. + pub(super) fn entity_query( + &mut self, + body: &mut BodyCx, + builtin: &'static Builtin, + args: &[Arg], + span: Span, + ) -> Option { + let bound = self.bind_args(body, builtin, args, span)?; + self.query_from(body, &bound) + } + + fn query_from( + &mut self, + body: &mut BodyCx, + bound: &BTreeMap<&'static str, &Arg>, + ) -> Option { + let file = body.file; + let mut query = pc::EntityQuery::default(); + let mut ok = true; + if let Some(arg) = bound.get("type") { + match self.arg_id(body, arg, "Entity") { + Some(id) => query.entity_type = Some(id), + None => ok = false, + } + } + if let Some(arg) = bound.get("tag") { + match self.arg_string(file, arg, "a tag name") { + Some((tag, _, _)) if valid_tag(&tag) => query.tag = Some(tag), + Some((tag, _, tag_span)) => { + self.error( + "id", + file, + tag_span, + format!("`{tag}` is not a valid tag; use letters, digits, and `_ . + -`"), + ); + ok = false; + } + None => ok = false, + } + } + if let Some(arg) = bound.get("distance") { + match &arg.value { + ArgValue::Range(range) => { + let mut bound_of = |expr: &Option| -> Option> { + match expr { + None => Some(None), + Some(Expr::Float(v, _)) => Some(Some(*v)), + Some(e) => self + .eval_i32(body.module, file, e, Some(Ty::Number), None) + .map(|v| Some(v as f64)), + } + }; + match (bound_of(&range.start), bound_of(&range.end)) { + (Some(min), Some(max)) => { + query.min_distance = min; + query.max_distance = max; + } + _ => ok = false, + } + } + ArgValue::Expr(expr) => { + self.diagnostics.push( + Diagnostic::error("type", file, expr.span(), "expected a distance range") + .with_help("for example `distance = ..=16` or `distance = 4..=10`"), + ); + ok = false; + } + } + } + if let Some(arg) = bound.get("with") { + match self + .arg_attachable_state(body, arg) + .and_then(|(_, id)| id.parse().ok()) + { + Some(state) => query.with_state = Some(state), + None => ok = false, + } + } + if let Some(arg) = bound.get("limit") { + match self.arg_int(body, arg, 1, i32::MAX as i64) { + Some(limit) => query.limit = Some(limit as u32), + None => ok = false, + } + } + if let Some(arg) = bound.get("sort") { + match self.arg_id(body, arg, "Sort").as_deref() { + Some("nearest") => query.sort = Some(pc::EntitySort::Nearest), + Some("furthest") => query.sort = Some(pc::EntitySort::Furthest), + Some("random") => query.sort = Some(pc::EntitySort::Random), + Some(_) => query.sort = Some(pc::EntitySort::Arbitrary), + None => ok = false, + } + } + query.score = match (bound.get("score"), bound.get("score_range")) { + (Some(field), Some(range)) => match self.query_score(body, field, range) { + Some(filter) => Some(filter), + None => { + ok = false; + None + } + }, + (Some(arg), None) | (None, Some(arg)) => { + self.error("type", file, arg.span, "supply both score and score_range"); + ok = false; + None + } + (None, None) => None, + }; + if let Some(arg) = bound.get("nbt") { + if let ArgValue::Expr(Expr::Struct { path, fields, .. }) = &arg.value + && path.segments.len() == 1 + && path.applications.is_empty() + && path.last().name == "Nbt" + { + query.nbt = self.const_nbt_compound(body, fields, 0); + ok &= query.nbt.is_some(); + } else { + self.error( + "type", + file, + arg.span, + "expected a typed compound such as `Nbt { Silent: true }`", + ); + ok = false; + } + } + ok.then_some(query) + } + + fn query_score( + &mut self, + body: &BodyCx, + field: &Arg, + range: &Arg, + ) -> Option { + let file = body.file; + let ArgValue::Expr(Expr::Place(place)) = &field.value else { + self.error( + "type", + file, + field.span, + "expected a player or entity `State.field`", + ); + return None; + }; + let (state, field, ty) = self.resolve_place(body.module, file, place)?; + if ty != Ty::Number + || !matches!( + self.defs[state.0].info, + DefInfo::State { + scope: Scope::Entity | Scope::Player, + .. + } + ) + { + self.error( + "type", + file, + place.span, + "query scores require a number field on player or entity State", + ); + return None; + } + let mut evaluate = |expr: &Expr| { + self.eval_i32(body.module, file, expr, Some(Ty::Number), None) + .map(|number| number as i32) + }; + let (min, max) = match &range.value { + ArgValue::Expr(expr) => { + let exact = evaluate(expr)?; + (Some(exact), Some(exact)) + } + ArgValue::Range(range) => { + let min = match &range.start { + Some(expr) => Some(evaluate(expr)?), + None => None, + }; + let max = match &range.end { + Some(expr) => { + let end = evaluate(expr)?; + if range.inclusive { + Some(end) + } else { + match end.checked_sub(1) { + Some(end) => Some(end), + None => { + self.error( + "range", + file, + expr.span(), + "exclusive score bound leaves no possible value", + ); + return None; + } + } + } + } + None => None, + }; + (min, max) + } + }; + if (min.is_none() && max.is_none()) || min.zip(max).is_some_and(|(min, max)| min > max) { + self.error( + "range", + file, + range.span, + "query score bounds must be ordered with at least one bound", + ); + return None; + } + Some(pc::ScoreComparison { + score: self.field_reference(state, field)?, + min, + max, + }) + } + + fn const_nbt_compound( + &mut self, + body: &BodyCx, + fields: &[(Ident, Expr)], + depth: usize, + ) -> Option { + let mut nbt = sand::data::NbtCompound::new(); + let mut seen = std::collections::BTreeSet::new(); + for (field, expr) in fields { + if !seen.insert(&field.name) { + self.error( + "duplicate", + body.file, + field.span, + format!("duplicate NBT field `{}`", field.name), + ); + return None; + } + nbt = nbt.field(&field.name, self.const_nbt_value(body, expr, depth + 1)?); + } + Some(nbt) + } + + fn const_nbt_value( + &mut self, + body: &BodyCx, + expr: &Expr, + depth: usize, + ) -> Option { + use sand::data::NbtValue; + let file = body.file; + if depth > 32 { + self.error( + "limit", + file, + expr.span(), + "typed NBT values may be nested at most 32 levels", + ); + return None; + } + Some(match expr { + Expr::Str { value, .. } => NbtValue::String(value.clone()), + Expr::Float(value, _) => NbtValue::Double(*value), + Expr::Neg(inner, _) if matches!(inner.as_ref(), Expr::Float(_, _)) => { + let Expr::Float(value, _) = inner.as_ref() else { + unreachable!() + }; + NbtValue::Double(-value) + } + Expr::Array(values, _) => NbtValue::List( + values + .iter() + .map(|element| self.const_nbt_value(body, element, depth + 1)) + .collect::>()?, + ), + Expr::Struct { path, fields, .. } + if path.segments.len() == 1 + && path.applications.is_empty() + && path.last().name == "Nbt" => + { + NbtValue::Compound(self.const_nbt_compound(body, fields, depth)?) + } + _ => { + let (value, ty) = self.eval(body.module, file, expr, None)?; + match ty { + Ty::Bool => NbtValue::Bool(value != 0), + Ty::Float => NbtValue::Double(value as f64 / super::FLOAT_SCALE as f64), + Ty::Number => match i32::try_from(value) { + Ok(value) => NbtValue::Int(value), + Err(_) => { + self.error( + "range", + file, + expr.span(), + "NBT integer must fit in a number", + ); + return None; + } + }, + _ => { + self.error( + "type", + file, + expr.span(), + "expected a constant NBT scalar, list, or compound", + ); + return None; + } + } + } + }) + } + + /// Whether `Handle.field` names an entity handle rather than a State: + /// `Player` (when no item of that name is in scope) or the binding of an + /// enclosing `players()` or `entities(..)` loop. + pub(super) fn is_handle(&self, body: &BodyCx, place: &Place) -> bool { + if !place.state.applications.is_empty() { + return false; + } + let [segment] = place.state.segments.as_slice() else { + return false; + }; + let name = segment.name.as_str(); + body.loop_bindings.iter().any(|b| b == name) + || (name == "Player" && !self.scopes[body.module.0].contains_key(name)) + } + + /// Resolve a property of a handle, checking that the handle is the + /// executor and that the property exists on it. + fn entity_property(&mut self, body: &mut BodyCx, place: &Place) -> Option { + let file = body.file; + let handle = place.state.segments[0].name.clone(); + let name = &place.field.name; + let Some(property) = crate::properties::find(name) else { + let suggestions = crate::properties::suggest(name); + let mut diagnostic = Diagnostic::error( + "resolve", + file, + place.field.span, + format!("`{handle}` has no property `{name}`"), + ); + diagnostic = if suggestions.is_empty() { + diagnostic.with_help("properties are entity data such as `health`, `food`, and `on_ground`, and every attribute, such as `max_health` or `step_height`") + } else { + diagnostic.with_help(format!( + "did you mean {}?", + suggestions + .iter() + .map(|s| format!("`{s}`")) + .collect::>() + .join(", ") + )) + }; + self.diagnostics.push(diagnostic); + return None; + }; + self.property_uses.push(super::PropertyUse { + file, + span: place.field.span, + handle: handle.clone(), + property: property.clone(), + }); + if handle == "Player" && !body.loop_bindings.iter().any(|b| b == "Player") { + body.note_player( + place.span, + format!("reads `Player.{name}`, which needs a player"), + ); + return Some(property); + } + let innermost = body.loop_bindings.last().map(String::as_str); + if innermost != Some(handle.as_str()) { + let current = innermost.unwrap_or_default().to_string(); + self.diagnostics.push( + Diagnostic::error( + "context", + file, + place.state.span, + format!("`{handle}` is not the executing entity here"), + ) + .with_help(format!( + "only the innermost loop's `{current}` can be read or changed; copy `{handle}.{name}` into a `let` before the inner loop" + )), + ); + return None; + } + if property.player_only && body.loops.last() == Some(&super::LoopKind::Entities) { + self.diagnostics.push( + Diagnostic::error( + "context", + file, + place.field.span, + format!("only players have `{name}`, but `entities(..)` may match other entities"), + ) + .with_help("read it in `for player in players()`, or as `Player.{name}` in a player function"), + ); + return None; + } + Some(property) + } + + /// `Player.max_health = 40.0;`, `zombie.scale *= 2;`, and the other + /// assignments to a handle's attribute. + pub(super) fn lower_property_assign( + &mut self, + body: &mut BodyCx, + place: &Place, + op: AssignOp, + value: &Expr, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + let Some(property) = self.entity_property(body, place) else { + return; + }; + let PropertyKind::Attribute(attribute) = property.kind.clone() else { + let help = match property.name.as_str() { + "health" => { + "change health with `damage(...)` or a healing effect such as `add_effect(Effect::InstantHealth, ...)`" + } + "food" | "saturation" => { + "feed the player with an effect such as `add_effect(Effect::Saturation, ...)`" + } + "xp_level" | "xp_total" | "xp_progress" => { + "give experience with `add_experience(...)`" + } + "x" | "y" | "z" => "move it with `teleport(...)` or `teleport_by(...)`", + _ => "entity data can be read but not written", + }; + self.diagnostics.push( + Diagnostic::error( + "assign", + file, + place.field.span, + format!("`{}.{}` is read-only", place.state.display(), property.name), + ) + .with_help(help), + ); + return; + }; + let compound = match op { + AssignOp::Set => None, + AssignOp::Add => Some(BinOp::Add), + AssignOp::Sub => Some(BinOp::Sub), + AssignOp::Mul => Some(BinOp::Mul), + AssignOp::Div => Some(BinOp::Div), + AssignOp::Rem => Some(BinOp::Rem), + }; + let amount = match compound { + None if Self::is_const_in(body, value) => { + let Some(v) = self.eval_i32(body.module, file, value, Some(Ty::Float), None) else { + return; + }; + pc::Amount::Value(v as f64 / FLOAT_SCALE as f64) + } + None => { + let depth = body.temp_depth; + let temp = self.temp(body); + if self.emit(body, &temp, Ty::Float, value, ops).is_none() { + return; + } + body.temp_depth = depth; + pc::Amount::Field(pc::ScaledField { + score: temp, + scale: FLOAT_SCALE as f64, + }) + } + Some(bin) => { + // Read the current base value, combine, and write it back. + let depth = body.temp_depth; + let temp = self.temp(body); + ops.push(op_at( + pc::Action::AttributeGet { + score: temp.clone(), + attribute: attribute.clone(), + scale: FLOAT_SCALE as f64, + }, + file, + place.span, + )); + let operand = match self.simple(body, value, Ty::Float) { + Ok(Some(operand)) => operand, + Ok(None) => { + let rhs = self.temp(body); + if self.emit(body, &rhs, Ty::Float, value, ops).is_none() { + return; + } + Value::Read(rhs) + } + Err(()) => return, + }; + if self + .apply(file, &temp, Ty::Float, bin, operand, value.span(), ops) + .is_none() + { + return; + } + body.temp_depth = depth; + pc::Amount::Field(pc::ScaledField { + score: temp, + scale: FLOAT_SCALE as f64, + }) + } + }; + ops.push(op_at( + pc::Action::AttributeSet { + attribute, + value: amount, + }, + file, + span, + )); + } + + fn builtin_action( + &mut self, + body: &mut BodyCx, + builtin: &'static Builtin, + bound: &BTreeMap<&'static str, &Arg>, + span: Span, + ) -> Option { + let file = body.file; + Some(match builtin.name { + "equip" | "clear_equipment" => { + let slot = self.arg_equipment_slot(body, bound["slot"])?; + let item = match bound.get("item") { + Some(arg) => Some(self.arg_id(body, arg, "Item")?), + None => None, + }; + let count = match bound.get("count") { + Some(arg) => Some(self.arg_int(body, arg, 1, 99)? as u32), + None => None, + }; + pc::Action::SetEquipment { slot, item, count } + } + "show_dialog" => { + let arg = bound["dialog"]; + let ArgValue::Expr(expr) = &arg.value else { + self.error("type", body.file, arg.span, "expected a dialog resource"); + return None; + }; + pc::Action::Dialog { + dialog: Some(self.native_data_id( + body.module, + body.file, + expr, + DefKind::Dialog, + )?), + } + } + "clear_dialog" => pc::Action::Dialog { dialog: None }, + "add_effect" => { + let effect = self.arg_id(body, bound["effect"], "Effect"); + let seconds = match bound.get("seconds") { + Some(arg) => self.arg_int(body, arg, 1, 1_000_000).map(Some), + None => Some(None), + }; + let level = match bound.get("level") { + Some(arg) => self.arg_int(body, arg, 1, 256), + None => Some(1), + }; + let hide = match bound.get("hide_particles") { + Some(arg) => self.arg_bool(file, arg), + None => Some(false), + }; + pc::Action::Effect { + effect: effect?, + seconds: seconds?.map(|s| s as u32), + amplifier: (level? - 1) as u8, + hide_particles: hide?, + } + } + "clear_effect" => { + let effect = match bound.get("effect") { + Some(arg) => Some(self.arg_id(body, arg, "Effect")?), + None => None, + }; + pc::Action::ClearEffect { effect } + } + "clear_inventory" => pc::Action::ClearItem { + item: None, + count: None, + }, + "schedule" => { + let target = match &bound["function"].value { + ArgValue::Expr(Expr::Path(target)) => self.expect_path( + body.module, + target, + &[DefKind::Function, DefKind::ExternFunction], + "a function", + ), + other => { + self.error("type", file, other.span(), "expected a function name"); + None + } + }; + let delay = match (bound.get("ticks"), bound.get("seconds")) { + (Some(arg), None) => self.arg_int(body, arg, 1, i32::MAX as i64), + (None, Some(arg)) => self + .arg_int(body, arg, 1, i32::MAX as i64 / 20) + .map(|s| s * 20), + _ => { + self.diagnostics.push( + Diagnostic::error( + "call", + file, + span, + "`schedule` needs exactly one of `ticks` or `seconds`", + ) + .with_help("for example `schedule(reset, seconds = 5);`"), + ); + None + } + }; + let target = target?; + if self + .fn_slots + .get(&target) + .is_some_and(|s| !s.params.is_empty()) + { + self.error( + "params", + file, + bound["function"].value.span(), + "scheduled functions run later without arguments; remove the parameters", + ); + return None; + } + let function = self.function_reference(target)?; + body.schedules + .push((target, bound["function"].value.span())); + pc::Action::Schedule { + function, + ticks: delay? as u32, + } + } + "attach_state" | "detach_state" => { + let (def, id) = self.arg_attachable_state(body, bound["state"])?; + if !self.check_state_write(body, def, bound["state"].span) { + return None; + } + let state: sand::ResourceLocation = id.parse().ok()?; + if builtin.name == "attach_state" { + pc::Action::AttachState { state } + } else { + pc::Action::DetachState { state } + } + } + "teleport_to" => pc::Action::Teleport { + destination: pc::TeleportDestination::Entity { + query: self.query_from(body, bound)?, + }, + }, + "kill" => pc::Action::Kill, + "dismount" => pc::Action::Ride { vehicle: None }, + "cancel_waits" => pc::Action::CancelWaits, + "add_tag" | "remove_tag" => { + let (tag, _, tag_span) = self.arg_string(file, bound["tag"], "a tag name")?; + if !valid_tag(&tag) { + self.error( + "id", + file, + tag_span, + format!("`{tag}` is not a valid tag; use letters, digits, and `_ . + -`"), + ); + return None; + } + pc::Action::EntityTag { + tag, + add: builtin.name == "add_tag", + } + } + "summon" => { + let entity_type = self.arg_id(body, bound["entity"], "Entity"); + let tag = match bound.get("tag") { + Some(arg) => { + let (tag, _, tag_span) = self.arg_string(file, arg, "a tag name")?; + if !valid_tag(&tag) { + self.error( + "id", + file, + tag_span, + format!( + "`{tag}` is not a valid tag; use letters, digits, and `_ . + -`" + ), + ); + return None; + } + Some(tag) + } + None => None, + }; + pc::Action::Summon { + entity_type: entity_type?, + tag, + } + } + "stop_timer" => pc::Action::ScoreSet { + score: self.arg_timer(body, bound["timer"], "stops")?, + value: 0, + }, + "open_menu" | "close_menu" => pc::Action::Menu { + menu: self.arg_declared(body, bound["menu"], DefKind::Menu, "a menu")?, + open: builtin.name == "open_menu", + }, + "start_hud" | "cancel_hud" => pc::Action::Hud { + hud: self.arg_declared(body, bound["hud"], DefKind::Hud, "a HUD")?, + show: builtin.name == "start_hud", + }, + "transfer_inventory" => pc::Action::TransferInventory { + transfer: self.arg_declared( + body, + bound["transfer"], + DefKind::InventoryTransfer, + "an inventory transfer", + )?, + }, + "place_template" => { + let template = bound["template"]; + let ArgValue::Expr(expr) = &template.value else { + self.error( + "type", + file, + template.span, + "expected a structure template resource", + ); + return None; + }; + pc::Action::PlaceTemplate { + template: self.native_data_id( + body.module, + file, + expr, + DefKind::StructureTemplate, + )?, + at: self.arg_position(body, bound["at"])?, + } + } + "set_block" => { + let block = self.arg_id(body, bound["block"], "Block"); + let at = self.arg_position(body, bound["at"]); + pc::Action::SetBlock { + block: block?, + at: at?, + } + } + "copy_block_data" => pc::Action::WriteBlockData { + target: self.arg_block_data(body, bound["to"], bound["destination_path"])?, + value: Some(pc::DataOperand::Block { + value: self.arg_block_data(body, bound["from"], bound["source_path"])?, + }), + }, + "remove_block_data" => pc::Action::WriteBlockData { + target: self.arg_block_data(body, bound["at"], bound["path"])?, + value: None, + }, + "clone_blocks" => { + let masked = match bound.get("masked") { + Some(arg) => self.arg_bool(file, arg)?, + None => false, + }; + let filter = match bound.get("filter") { + Some(arg) => Some(self.arg_block_test(body, arg)?), + None => None, + }; + if masked && filter.is_some() { + self.error( + "call", + file, + span, + "choose either a clone filter or a masked clone", + ); + return None; + } + let mode = match bound.get("mode") { + Some(arg) => { + let value = self.arg_id(body, arg, "CloneMode")?; + match serde_json::from_value(serde_json::Value::String(value)) { + Ok(mode) => mode, + Err(_) => { + self.error( + "type", + file, + arg.span, + "expected a `CloneMode::...` value", + ); + return None; + } + } + } + None => sand::command::CloneMode::Normal, + }; + pc::Action::CloneBlocks { + from: self.arg_position(body, bound["from"])?, + to: self.arg_position(body, bound["to"])?, + destination: self.arg_position(body, bound["destination"])?, + masked, + filter, + mode, + } + } + "fill_blocks" => { + let block = self.arg_id(body, bound["block"], "Block"); + let from = self.arg_position(body, bound["from"]); + let to = self.arg_position(body, bound["to"]); + pc::Action::FillBlocks { + block: block?, + from: from?, + to: to?, + } + } + "set_gamemode" => pc::Action::SetGameMode { + mode: match self.arg_id(body, bound["mode"], "GameMode")?.as_str() { + "survival" => pc::PlayerGameMode::Survival, + "creative" => pc::PlayerGameMode::Creative, + "adventure" => pc::PlayerGameMode::Adventure, + _ => pc::PlayerGameMode::Spectator, + }, + }, + "set_time" => pc::Action::SetTime { + ticks: self.arg_int(body, bound["ticks"], 0, i32::MAX as i64)? as u32, + }, + "set_weather" => { + let weather = self.arg_id(body, bound["weather"], "Weather"); + let seconds = match bound.get("seconds") { + Some(arg) => self.arg_int(body, arg, 1, 1_000_000).map(Some), + None => Some(None), + }; + pc::Action::SetWeather { + weather: match weather?.as_str() { + "clear" => pc::Weather::Clear, + "rain" => pc::Weather::Rain, + _ => pc::Weather::Thunder, + }, + seconds: seconds?.map(|s| s as u32), + } + } + "show_bossbar" | "hide_bossbar" | "show_bossbar_all" | "hide_bossbar_all" => { + pc::Action::BossBarAudience { + bar: self.arg_declared(body, bound["bar"], DefKind::BossBar, "a boss bar")?, + audience: if builtin.name.ends_with("_all") { + pc::Audience::Everyone + } else { + pc::Audience::Player + }, + visible: builtin.name.starts_with("show"), + } + } + "give_loot" | "drop_loot" => { + let table = + self.arg_declared(body, bound["table"], DefKind::Loot, "a loot table")?; + if builtin.name == "give_loot" { + pc::Action::GiveLoot { table } + } else { + pc::Action::DropLoot { table } + } + } + other => unreachable!("statement builtin `{other}` is not lowered"), + }) + } + + pub(super) fn lower_macro( + &mut self, + body: &mut BodyCx, + name: &Ident, + args: &[Arg], + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + let Some(builtin) = builtins::find(&name.name, BuiltinKind::Macro) else { + let known = builtins::BUILTINS + .iter() + .filter(|b| b.kind == BuiltinKind::Macro) + .map(|b| format!("`{}!`", b.name)) + .collect::>() + .join(", "); + self.diagnostics.push( + Diagnostic::error( + "macro", + file, + name.span, + format!("unknown macro `{}!`", name.name), + ) + .with_help(format!("available macros: {known}")), + ); + return; + }; + self.references_builtin(file, name.span, builtin); + let Some(bound) = self.bind_args(body, builtin, args, span) else { + return; + }; + if builtin.name == "assert" { + let Some(owner) = body.owner else { + self.error( + "test", + file, + span, + "`assert!` is only available inside a Sand test", + ); + return; + }; + if !self.test_functions.contains(&owner) { + self.error( + "test", + file, + span, + "`assert!` is only available inside a Sand test", + ); + return; + } + let ArgValue::Expr(condition) = &bound["condition"].value else { + self.error("test", file, span, "`assert!` needs a boolean condition"); + return; + }; + let depth = body.temp_depth; + let score = self.temp(body); + if self.emit(body, &score, Ty::Bool, condition, ops).is_some() { + let mut fail = vec![op_at( + pc::Action::Raw { + command: format!("say __SAND_ASSERT_{}_{}__", file.0, span.start), + }, + file, + span, + )]; + self.lower_return(body, Some(&Expr::Bool(false, span)), span, &mut fail); + body.raw = true; + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score, + min: Some(1), + max: Some(1), + }), + then: Vec::new(), + otherwise: fail, + }, + file, + span, + )); + } + body.temp_depth = depth; + return; + } + if builtin.name == "raw" { + let Some((command, _, string_span)) = + self.arg_string(file, bound["command"], "a command") + else { + return; + }; + if command.trim().is_empty() { + self.error("raw", file, string_span, "raw command is empty"); + return; + } + body.raw = true; + ops.push(op_at(pc::Action::Raw { command }, file, span)); + return; + } + if builtin.needs_player { + body.note_player( + name.span, + format!( + "uses `{}!`, which shows text to the executing player", + builtin.name + ), + ); + } + let interactive = matches!(builtin.name, "chat" | "broadcast"); + let Some(text) = + self.presentation_text(body, bound["text"], Some(ops), interactive, None, 0) + else { + return; + }; + let (audience, channel) = match builtin.name { + "chat" => (pc::Audience::Player, pc::MessageChannel::Chat), + "broadcast" => (pc::Audience::Everyone, pc::MessageChannel::Chat), + "actionbar" => (pc::Audience::Player, pc::MessageChannel::Actionbar), + "title" => (pc::Audience::Player, pc::MessageChannel::Title), + _ => (pc::Audience::Player, pc::MessageChannel::Subtitle), + }; + ops.push(op_at( + pc::Action::Message { + audience, + channel, + text, + }, + file, + span, + )); + } + + fn float_in_text(&mut self, file: FileId, span: Span) { + self.diagnostics.push( + Diagnostic::error("text", file, span, "text can only show whole numbers").with_help( + "store a copy first: `let shown = value as number;`, then write `{shown}`", + ), + ); + } + + pub(super) fn references_builtin( + &mut self, + file: FileId, + span: Span, + builtin: &'static Builtin, + ) { + self.builtin_uses + .push((file, span, builtin.name, builtin.kind)); + } + + /// Build a runtime message or a static resource's component text. + pub(super) fn presentation_text( + &mut self, + body: &mut BodyCx, + arg: &Arg, + mut ops: Option<&mut Vec>, + interactive: bool, + book_pages: Option, + depth: usize, + ) -> Option> { + use sand::text::ClickEvent; + if let ArgValue::Expr(Expr::Call { path, args, span }) = &arg.value + && path.applications.is_empty() + && path.segments.len() == 2 + && path.segments[0].name == "Text" + && matches!( + path.last().name.as_str(), + "translate" | "hover" | "link" | "suggest" | "copy" | "page" + ) + { + let action = path.last().name.as_str(); + if depth >= pc::TextPart::MAX_NESTING_DEPTH { + self.error( + "text", + body.file, + *span, + "text exceeds the component nesting limit", + ); + return None; + } + if let Some(named) = args.iter().find_map(|arg| arg.name.as_ref()) { + let message = if action == "translate" { + "translation arguments are positional" + } else { + "interactive text arguments are positional" + }; + self.error("text", body.file, named.span, message); + return None; + } + if action == "translate" { + let Some((key, arguments)) = args.split_first() else { + self.error( + "text", + body.file, + *span, + "`Text::translate` needs a quoted translation key", + ); + return None; + }; + let (key, _, key_span) = self.arg_string(body.file, key, "a translation key")?; + if key.trim().is_empty() || key.chars().any(char::is_control) { + self.error( + "text", + body.file, + key_span, + "translation keys must be nonblank and contain no control characters", + ); + return None; + } + let mut rendered = Vec::with_capacity(arguments.len()); + for argument in arguments { + rendered.push(self.presentation_text( + body, + argument, + ops.as_deref_mut(), + interactive, + book_pages, + depth + 1, + )?); + } + return Some(vec![pc::TextPart::Translation { + key, + arguments: rendered, + style: pc::TextStyle::default(), + }]); + } + if !interactive { + self.error( + "text", + body.file, + *span, + "interactive text is supported in chat messages and written-book pages", + ); + return None; + } + let [content, payload] = args.as_slice() else { + self.error( + "text", + body.file, + *span, + format!("`Text::{action}` takes a label and one other argument"), + ); + return None; + }; + let content = self.presentation_text( + body, + content, + ops.as_deref_mut(), + interactive, + book_pages, + depth + 1, + )?; + let (tooltip, click) = if action == "hover" { + ( + self.presentation_text(body, payload, ops, interactive, book_pages, depth + 1)?, + None, + ) + } else if action == "page" { + let Some(pages) = book_pages else { + self.error( + "text", + body.file, + *span, + "`Text::page` is for written-book pages", + ); + return None; + }; + let page = self.arg_int(body, payload, 1, pages as i64)?; + (Vec::new(), Some(ClickEvent::ChangePage(page as u32))) + } else { + let (payload, _, payload_span) = + self.arg_string(body.file, payload, "a click payload")?; + let click = match action { + "link" => ClickEvent::OpenUrl(payload), + "suggest" => ClickEvent::SuggestCommand(payload), + _ => ClickEvent::CopyToClipboard(payload), + }; + if let Err(error) = click.validate() { + self.error("text", body.file, payload_span, error.to_string()); + return None; + } + (Vec::new(), Some(click)) + }; + return Some(vec![pc::TextPart::Interactive { + content, + tooltip, + click, + }]); + } + if let ArgValue::Expr(value) = &arg.value + && !matches!(value, Expr::Str { .. }) + && let Some(ops) = ops + { + let slot = self.temp(body); + self.emit(body, &slot, Ty::String, value, ops)?; + return Some(vec![pc::TextPart::Stored { + value: Self::data_field(&slot), + style: pc::TextStyle::default(), + }]); + } + self.format_text(body, arg) + } + + /// Parse a format string into styled text parts, resolving `{State.field}`. + pub(super) fn format_text( + &mut self, + body: &mut BodyCx, + arg: &Arg, + ) -> Option> { + let file = body.file; + let (_, raw, string_span) = self.arg_string(file, arg, "text")?; + let base = string_span.start + 1; + let bytes = raw.as_bytes(); + let mut parts = Vec::new(); + let mut style = pc::TextStyle::default(); + let mut literal = String::new(); + let mut ok = true; + let mut i = 0; + let flush = |literal: &mut String, style: &pc::TextStyle, parts: &mut Vec| { + if !literal.is_empty() { + parts.push(pc::TextPart::Text { + text: crate::parser::unescape(literal), + style: style.clone(), + }); + literal.clear(); + } + }; + while i < bytes.len() { + match bytes[i] { + b'\\' => { + let start = i; + i += 1; + if bytes.get(i) == Some(&b'u') && bytes.get(i + 1) == Some(&b'{') { + i = raw[i..].find('}').map_or(raw.len(), |end| i + end + 1); + } else if let Some(character) = raw[i..].chars().next() { + i += character.len_utf8(); + } + literal.push_str(&raw[start..i]); + } + b'{' if bytes.get(i + 1) == Some(&b'{') => { + literal.push('{'); + i += 2; + } + b'}' if bytes.get(i + 1) == Some(&b'}') => { + literal.push('}'); + i += 2; + } + b'}' => { + self.diagnostics.push( + Diagnostic::error( + "text", + file, + Span::new(base + i, base + i + 1), + "unmatched `}` in text", + ) + .with_help("write `}}` for a literal brace"), + ); + ok = false; + i += 1; + } + b'{' => { + let Some(close) = raw[i + 1..].find('}') else { + self.diagnostics.push( + Diagnostic::error( + "text", + file, + Span::new(base + i, base + raw.len()), + "unclosed `{` in text", + ) + .with_help("close it with `}`, or write `{{` for a literal brace"), + ); + ok = false; + break; + }; + let inner = &raw[i + 1..i + 1 + close]; + let token = inner.trim(); + let token_start = base + i + 1 + (inner.len() - inner.trim_start().len()); + let token_span = Span::new(token_start, token_start + token.len()); + flush(&mut literal, &style, &mut parts); + if !self.text_token(body, token, token_span, &mut style, &mut parts) { + ok = false; + } + i += close + 2; + } + _ => { + let ch = raw[i..].chars().next().expect("in bounds"); + literal.push(ch); + i += ch.len_utf8(); + } + } + } + flush(&mut literal, &style, &mut parts); + if ok && parts.is_empty() { + self.error("text", file, string_span, "message text is empty"); + return None; + } + ok.then_some(parts) + } + + fn text_token( + &mut self, + body: &mut BodyCx, + token: &str, + span: Span, + style: &mut pc::TextStyle, + parts: &mut Vec, + ) -> bool { + let file = body.file; + let color = |name: &str| { + Some(match name { + "black" => pc::TextColor::Black, + "dark_blue" => pc::TextColor::DarkBlue, + "dark_green" => pc::TextColor::DarkGreen, + "dark_aqua" => pc::TextColor::DarkAqua, + "dark_red" => pc::TextColor::DarkRed, + "dark_purple" => pc::TextColor::DarkPurple, + "gold" => pc::TextColor::Gold, + "gray" => pc::TextColor::Gray, + "dark_gray" => pc::TextColor::DarkGray, + "blue" => pc::TextColor::Blue, + "green" => pc::TextColor::Green, + "aqua" => pc::TextColor::Aqua, + "red" => pc::TextColor::Red, + "light_purple" => pc::TextColor::LightPurple, + "yellow" => pc::TextColor::Yellow, + "white" => pc::TextColor::White, + _ => return None, + }) + }; + if let Some(local) = Self::lookup_local(body, token) { + if self.local_ty(local) == Ty::Float { + self.float_in_text(file, span); + return false; + } + body.used.insert(local); + self.references.push(Reference { + file, + span, + def: local, + }); + let score = self.local_ref(local); + parts.push(if self.local_ty(local) == Ty::String { + pc::TextPart::Stored { + value: Self::data_field(&score), + style: style.clone(), + } + } else { + pc::TextPart::Score { + score, + style: style.clone(), + } + }); + return true; + } + match token { + "player" => { + body.note_player(span, "shows `{player}`, the executing player's name".into()); + parts.push(pc::TextPart::PlayerName { + style: style.clone(), + }); + true + } + "bold" => { + style.bold = true; + true + } + "italic" => { + style.italic = true; + true + } + "underlined" => { + style.underlined = true; + true + } + "reset" => { + *style = pc::TextStyle::default(); + true + } + name if color(name).is_some() => { + style.color = color(name); + true + } + path_text if path_text.contains('.') => { + let (state_text, rest) = path_text.split_once('.').expect("contains a dot"); + let mut offset = span.start; + let segments: Vec<_> = state_text + .split("::") + .map(|name| { + let ident = Ident { + name: name.into(), + span: Span::new(offset, offset + name.len()), + }; + offset += name.len() + 2; + ident + }) + .collect(); + offset = span.start + state_text.len() + 1; + let mut projections: Vec<_> = rest + .split('.') + .map(|name| { + let ident = Ident { + name: name.into(), + span: Span::new(offset, offset + name.len()), + }; + offset += name.len() + 1; + ident + }) + .collect(); + if !segments.iter().chain(&projections).all(|part| { + part.name.chars().next().is_some_and(|character| { + character.is_ascii_alphabetic() || character == '_' + }) && part + .name + .bytes() + .all(|character| character.is_ascii_alphanumeric() || character == b'_') + }) { + self.error( + "text", + file, + span, + "expected a local or State field path in text", + ); + return false; + } + let field = projections.remove(0); + let place = Place { + state: Path { + applications: Vec::new(), + segments, + span: Span::new(span.start, span.start + state_text.len()), + }, + field, + projections, + span, + }; + let Some(value) = self.place_value(body, &place, false) else { + return false; + }; + if value.ty == Ty::Float { + self.float_in_text(file, span); + return false; + } + if matches!(value.ty, Ty::Struct(_) | Ty::EntityRef) { + self.error( + "text", + file, + span, + "text interpolation needs a scalar or string value", + ); + return false; + } + parts.push(if value.ty == Ty::String { + pc::TextPart::Stored { + value: Self::data_field(&value.reference), + style: style.clone(), + } + } else { + pc::TextPart::Score { + score: value.reference, + style: style.clone(), + } + }); + true + } + other => { + self.diagnostics.push( + Diagnostic::error("text", file, span, format!("unknown `{{{other}}}` in text")) + .with_help( + "use a variable such as `{price}`, `{State.field}` for a live score, `{player}` for the player's name, or a style such as `{gold}`, `{bold}`, `{reset}`", + ), + ); + false + } + } + } +} + +fn gcd(a: u64, b: u64) -> u64 { + if b == 0 { a } else { gcd(b, a % b) } +} + +fn valid_tag(tag: &str) -> bool { + !tag.is_empty() + && tag + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b"_.+-".contains(&b)) +} + +fn param_list(builtin: &Builtin) -> String { + if builtin.params.is_empty() { + return "no arguments".into(); + } + builtin + .params + .iter() + .map(|p| format!("`{}`", p.name)) + .collect::>() + .join(", ") +} diff --git a/sand-lang/src/analysis/testing.rs b/sand-lang/src/analysis/testing.rs new file mode 100644 index 00000000..c77c30e5 --- /dev/null +++ b/sand-lang/src/analysis/testing.rs @@ -0,0 +1,142 @@ +//! Test entry points share normal function lowering and typed return slots. +use super::*; + +/// A discovered Sand test and its command entry point in a test build. +#[derive(Debug, Clone)] +pub struct TestCase { + /// Source-qualified test name. + pub name: String, + /// Generated server-context wrapper, present in test builds only. + pub runner: String, + /// Declaration file. + pub file: FileId, + /// Declaration name span. + pub span: Span, +} + +impl Cx { + pub(super) fn declare_test(&mut self, def: DefId, item: &Item, function: &FnItem) { + let Some(attribute) = item.attr("test") else { + return; + }; + let file = self.defs[def.0].file; + if item.attrs.len() != 1 || !attribute.args.is_empty() { + self.error( + "test", + file, + attribute.span, + "`#[test]` takes no arguments or other function attributes", + ); + } + if !function.params.is_empty() + || self.methods.contains_key(&def) + || !function.generics.is_empty() + || self + .fn_slots + .get(&def) + .and_then(|slots| slots.ret.as_ref()) + .is_none_or(|(_, ty)| *ty != Ty::Bool) + { + self.error( + "test", + file, + function.name.span, + "a test must be a plain function with signature `fn name() -> bool`", + ); + } + self.test_functions.insert(def); + } + + pub(super) fn discover_tests(&mut self, lowerer: &Lowering) { + for (owner, facts) in &lowerer.facts { + if self.test_functions.contains(owner) { + continue; + } + for (callee, span) in facts.all_calls.iter().chain(&facts.schedules) { + if self.test_functions.contains(callee) { + self.error( + "test", + facts.file, + *span, + "test functions can only be called by other tests", + ); + } + } + } + for def in self.test_functions.clone() { + let d = self.defs[def.0].clone(); + if !matches!( + d.info, + DefInfo::Function { + context: Context::Server, + .. + } + ) { + self.error( + "test", + d.file, + d.name_span, + "a test must run without a player or entity executor", + ); + } + let name = format!( + "{}::{}", + self.package.module(d.module).display_path(), + d.name + ); + let runner = format!("{}:sand.lang_test/{}", self.namespace(), self.tests.len()); + self.tests.insert( + def, + TestCase { + name, + runner, + file: d.file, + span: d.name_span, + }, + ); + } + } + + pub(super) fn test_wrapper( + &self, + def: DefId, + test: &TestCase, + index: usize, + ) -> Option { + let (returned, Ty::Bool) = self.fn_slots.get(&def)?.ret.as_ref()? else { + return None; + }; + let score = pc::FieldReference { + state: self.locals_state_id().parse().ok()?, + field: returned.clone(), + }; + let at = |action| op_at(action, test.file, test.span); + let mark = |result| { + at(pc::Action::Raw { + command: format!("say __SAND_TEST_{index}_{result}__"), + }) + }; + Some(pc::Function { + id: test.runner.parse().ok()?, + context: pc::ExecutionContext::Server, + body: vec![ + at(pc::Action::ScoreSet { + score: score.clone(), + value: 0, + }), + at(pc::Action::Call { + function: self.function_reference(def)?, + }), + at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score, + min: Some(1), + max: Some(1), + }), + then: vec![mark("PASS")], + otherwise: vec![mark("FAIL")], + }), + ], + }) + } +} diff --git a/sand-lang/src/analysis/text.rs b/sand-lang/src/analysis/text.rs new file mode 100644 index 00000000..b888d635 --- /dev/null +++ b/sand-lang/src/analysis/text.rs @@ -0,0 +1,967 @@ +//! Runtime text uses owned NBT values, sharing aggregate copies and call frames. +use super::*; +use pc::DataModifyOperation; +use sand::data::NbtValue; + +pub(super) const TEXT_LITERAL_BYTES: usize = 65_536; +pub(super) const DEFAULT_BYTES: usize = 1_048_576; + +pub(super) fn defaults_cost(values: &[LeafDefault]) -> usize { + values.iter().fold(0usize, |total, value| { + total.saturating_add(match value { + LeafDefault::Score(value) => value.to_string().len(), + LeafDefault::Data(value) => value.to_string().len(), + }) + }) +} + +#[derive(Clone)] +pub(super) enum LeafDefault { + Score(i32), + Data(NbtValue), +} + +pub(super) fn text_value(value: &str) -> NbtValue { + NbtValue::List( + value + .chars() + .map(|character| NbtValue::String(character.to_string())) + .collect(), + ) +} + +impl Cx { + /// Format in the negative domain so i32::MIN never needs an overflowing + /// absolute value. Correct floor division to truncation for each digit. + fn integer_text( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + source: &pc::FieldReference, + signed: bool, + span: Span, + ops: &mut Vec, + ) { + let file = body.file; + let at = |action| op_at(action, file, span); + self.register_data_slot(dest, text_value("")); + let number = self.temp(body); + let remainder = self.temp(body); + let digit = self.temp(body); + let digits = self.temp(body); + self.register_data_slot(&digits, text_value("")); + ops.push(at(Self::initialize_leaf( + digits.clone(), + LeafDefault::Data(text_value("0123456789")), + ))); + ops.push(at(Self::initialize_leaf( + dest.clone(), + LeafDefault::Data(text_value("")), + ))); + ops.push(at(pc::Action::ScoreOperation { + score: number.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(source.clone()), + })); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: number.clone(), + min: Some(1), + max: None, + }), + then: vec![at(pc::Action::ScoreOperation { + score: number.clone(), + operator: pc::ScoreOperator::Mul, + operand: pc::ScoreOperand::Value(-1), + })], + otherwise: Vec::new(), + })); + let iteration = vec![ + at(pc::Action::ScoreOperation { + score: remainder.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(number.clone()), + }), + at(pc::Action::ScoreOperation { + score: remainder.clone(), + operator: pc::ScoreOperator::Mod, + operand: pc::ScoreOperand::Value(10), + }), + at(pc::Action::ScoreOperation { + score: number.clone(), + operator: pc::ScoreOperator::Div, + operand: pc::ScoreOperand::Value(10), + }), + at(pc::Action::ScoreSet { + score: digit.clone(), + value: 0, + }), + at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: remainder.clone(), + min: Some(1), + max: None, + }), + then: vec![ + at(pc::Action::ScoreSet { + score: digit.clone(), + value: 10, + }), + at(pc::Action::ScoreOperation { + score: digit.clone(), + operator: pc::ScoreOperator::Sub, + operand: pc::ScoreOperand::Field(remainder), + }), + at(pc::Action::ScoreAdd { + score: number.clone(), + value: 1, + }), + ], + otherwise: Vec::new(), + }), + at(pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Prepend, + source: pc::DataOperand::Reference { + value: Self::stored_element(&digits, &digit), + }, + }), + ]; + ops.push(at(pc::Action::While { + condition: pc::Condition::Range(pc::ScoreComparison { + score: number, + min: None, + max: Some(-1), + }), + body: iteration, + })); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: source.clone(), + min: Some(0), + max: Some(0), + }), + then: vec![at(Self::initialize_leaf( + dest.clone(), + LeafDefault::Data(text_value("0")), + ))], + otherwise: Vec::new(), + })); + if signed { + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: source.clone(), + min: None, + max: Some(-1), + }), + then: vec![at(pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Prepend, + source: pc::DataOperand::Value { + value: NbtValue::String("-".into()), + }, + })], + otherwise: Vec::new(), + })); + } + } + + fn emit_to_string( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Method { + receiver, + name, + type_arguments: _, + args, + span, + } = expr + else { + unreachable!() + }; + let builtin = crate::builtins::value_method(&name.name)?; + self.references_builtin(body.file, name.span, builtin); + self.bind_args(body, builtin, args, *span)?; + let depth = body.temp_depth; + let ty = self.type_of(body, receiver); + let source = self.temp(body); + self.emit(body, &source, ty, receiver, ops)?; + let file = body.file; + let at = |action| op_at(action, file, *span); + match ty { + Ty::Number => self.integer_text(body, dest, &source, true, *span, ops), + Ty::Bool => ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: source, + min: Some(0), + max: Some(0), + }), + then: vec![at(Self::initialize_leaf( + dest.clone(), + LeafDefault::Data(text_value("false")), + ))], + otherwise: vec![at(Self::initialize_leaf( + dest.clone(), + LeafDefault::Data(text_value("true")), + ))], + })), + Ty::Enum(def) => { + self.integer_text(body, dest, &source, true, *span, ops); + let DefInfo::Enum { variants } = self.defs[def.0].info.clone() else { + unreachable!() + }; + for variant in variants { + let DefInfo::Variant { value: Some(value) } = self.defs[variant.0].info else { + continue; + }; + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: source.clone(), + min: Some(value as i32), + max: Some(value as i32), + }), + then: vec![at(Self::initialize_leaf( + dest.clone(), + LeafDefault::Data(text_value(&self.defs[variant.0].name)), + ))], + otherwise: Vec::new(), + })); + } + } + Ty::Float => { + let digits = self.temp(body); + self.integer_text(body, &digits, &source, false, *span, ops); + let length = self.temp(body); + ops.push(at(Self::text_length(&digits, &length))); + ops.push(at(pc::Action::While { + condition: pc::Condition::Range(pc::ScoreComparison { + score: length.clone(), + min: None, + max: Some(3), + }), + body: vec![ + at(pc::Action::DataModify { + target: Self::data_reference(&digits), + operator: DataModifyOperation::Prepend, + source: pc::DataOperand::Value { + value: NbtValue::String("0".into()), + }, + }), + at(pc::Action::ScoreAdd { + score: length.clone(), + value: 1, + }), + ], + })); + let zero = self.temp(body); + ops.push(at(pc::Action::ScoreSet { + score: zero.clone(), + value: 0, + })); + let point = self.temp(body); + ops.push(at(pc::Action::ScoreOperation { + score: point.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length.clone()), + })); + ops.push(at(pc::Action::ScoreAdd { + score: point.clone(), + value: -3, + })); + self.slice_text(body, dest, &digits, (&zero, &point), *span, ops); + ops.push(at(pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Value { + value: NbtValue::String(".".into()), + }, + })); + let fractional = self.temp(body); + self.slice_text(body, &fractional, &digits, (&point, &length), *span, ops); + ops.push(at(Self::append_text(dest, &fractional))); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: source, + min: None, + max: Some(-1), + }), + then: vec![at(pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Prepend, + source: pc::DataOperand::Value { + value: NbtValue::String("-".into()), + }, + })], + otherwise: Vec::new(), + })); + } + _ => unreachable!("scalar formatting is type checked"), + } + body.temp_depth = depth; + Some(()) + } + + fn text_length(source: &pc::FieldReference, score: &pc::FieldReference) -> pc::Action { + pc::Action::DataRead { + score: score.clone(), + source: Self::data_reference(source), + } + } + + pub(super) fn stored_element( + source: &pc::FieldReference, + index: &pc::FieldReference, + ) -> pc::DataReference { + let mut source = Self::data_reference(source); + source.path.push(pc::DataProjection::Index { + index: pc::ScoreOperand::Field(index.clone()), + }); + source + } + + pub(super) fn emit_text_index( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Index(value, index, span) = expr else { + unreachable!() + }; + let depth = body.temp_depth; + let source = self.temp(body); + self.emit(body, &source, Ty::String, value, ops)?; + let selected = self.temp(body); + if Self::is_const_in(body, index) + && self.eval_i32(body.module, body.file, index, Some(Ty::Number), None)? < 0 + { + self.error( + "index", + body.file, + index.span(), + "string indices must be nonnegative", + ); + return None; + } + self.emit(body, &selected, Ty::Number, index, ops)?; + ops.push(op_at( + Self::initialize_leaf(dest.clone(), LeafDefault::Data(text_value(""))), + body.file, + *span, + )); + ops.push(op_at( + pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::stored_element(&source, &selected), + }, + }, + body.file, + *span, + )); + body.temp_depth = depth; + Some(()) + } + + /// Copy a clamped scalar-character range. Its source and bounds are already + /// evaluated, and no user code runs during the copy. + fn slice_text( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + source: &pc::FieldReference, + bounds: (&pc::FieldReference, &pc::FieldReference), + span: Span, + ops: &mut Vec, + ) { + let (start, end) = bounds; + let file = body.file; + let at = |action| op_at(action, file, span); + self.register_data_slot(dest, text_value("")); + let counter = self.temp(body); + let limit = self.temp(body); + let length = self.temp(body); + ops.push(at(Self::text_length(source, &length))); + ops.push(at(pc::Action::ScoreOperation { + score: counter.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(start.clone()), + })); + ops.push(at(pc::Action::ScoreOperation { + score: counter.clone(), + operator: pc::ScoreOperator::Max, + operand: pc::ScoreOperand::Value(0), + })); + ops.push(at(pc::Action::ScoreOperation { + score: limit.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(end.clone()), + })); + ops.push(at(pc::Action::ScoreOperation { + score: limit.clone(), + operator: pc::ScoreOperator::Min, + operand: pc::ScoreOperand::Field(length), + })); + ops.push(at(Self::initialize_leaf( + dest.clone(), + LeafDefault::Data(text_value("")), + ))); + ops.push(at(pc::Action::While { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: counter.clone(), + relation: pc::Relation::Lt, + right: limit, + }), + body: vec![ + at(pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { + value: Self::stored_element(source, &counter), + }, + }), + at(pc::Action::ScoreAdd { + score: counter, + value: 1, + }), + ], + })); + } + + pub(super) fn emit_text_method( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let Expr::Method { + receiver, + name, + type_arguments: _, + args, + span, + } = expr + else { + unreachable!() + }; + let Some(builtin) = crate::builtins::string_method(&name.name) else { + self.error( + "method", + body.file, + name.span, + format!("strings have no method `{}`", name.name), + ); + return None; + }; + self.references_builtin(body.file, name.span, builtin); + let bound = self.bind_args(body, builtin, args, *span)?; + let result_ty = match name.name.as_str() { + "len" => Ty::Number, + "slice" => Ty::String, + _ => Ty::Bool, + }; + if !self.types_agree(body.file, *span, ty, result_ty) { + return None; + } + let depth = body.temp_depth; + let source = self.temp(body); + self.emit(body, &source, Ty::String, receiver, ops)?; + let mut values = BTreeMap::new(); + for argument in args { + let (¶meter, _) = bound + .iter() + .find(|(_, value)| std::ptr::eq(**value, argument))?; + let ArgValue::Expr(value) = &argument.value else { + self.error( + "argument", + body.file, + argument.span, + "this method argument needs a value expression", + ); + return None; + }; + let slot = self.temp(body); + self.emit( + body, + &slot, + if parameter == "value" { + Ty::String + } else { + Ty::Number + }, + value, + ops, + )?; + values.insert(parameter, slot); + } + let file = body.file; + let at = |action| op_at(action, file, *span); + let length = self.temp(body); + ops.push(at(Self::text_length(&source, &length))); + match name.name.as_str() { + "len" => ops.push(at(pc::Action::ScoreOperation { + score: dest.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length), + })), + "is_empty" => { + ops.push(at(pc::Action::ScoreSet { + score: dest.clone(), + value: 0, + })); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: length, + min: Some(0), + max: Some(0), + }), + then: vec![at(pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + })], + otherwise: Vec::new(), + })); + } + "slice" => self.slice_text( + body, + dest, + &source, + (&values["start"], &values["end"]), + *span, + ops, + ), + "starts_with" | "ends_with" => { + let needle = &values["value"]; + let needle_length = self.temp(body); + ops.push(at(Self::text_length(needle, &needle_length))); + let start = self.temp(body); + let end = self.temp(body); + if name.name == "starts_with" { + ops.push(at(pc::Action::ScoreSet { + score: start.clone(), + value: 0, + })); + ops.push(at(pc::Action::ScoreOperation { + score: end.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(needle_length), + })); + } else { + ops.push(at(pc::Action::ScoreOperation { + score: start.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length.clone()), + })); + ops.push(at(pc::Action::ScoreOperation { + score: start.clone(), + operator: pc::ScoreOperator::Sub, + operand: pc::ScoreOperand::Field(needle_length), + })); + ops.push(at(pc::Action::ScoreOperation { + score: end.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length), + })); + } + let part = self.temp(body); + self.slice_text(body, &part, &source, (&start, &end), *span, ops); + ops.push(at(pc::Action::DataEqual { + score: dest.clone(), + left: Self::data_reference(&part), + right: Self::data_reference(needle), + })); + } + "contains" => { + let needle = &values["value"]; + let needle_length = self.temp(body); + ops.push(at(Self::text_length(needle, &needle_length))); + let last = self.temp(body); + ops.push(at(pc::Action::ScoreOperation { + score: last.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(length), + })); + ops.push(at(pc::Action::ScoreOperation { + score: last.clone(), + operator: pc::ScoreOperator::Sub, + operand: pc::ScoreOperand::Field(needle_length.clone()), + })); + let start = self.temp(body); + let end = self.temp(body); + let part = self.temp(body); + let matched = self.temp(body); + let running = self.temp(body); + ops.push(at(pc::Action::ScoreSet { + score: dest.clone(), + value: 0, + })); + ops.push(at(pc::Action::ScoreSet { + score: start.clone(), + value: 0, + })); + ops.push(at(pc::Action::ScoreSet { + score: running.clone(), + value: 0, + })); + ops.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: last.clone(), + min: Some(0), + max: None, + }), + then: vec![at(pc::Action::ScoreSet { + score: running.clone(), + value: 1, + })], + otherwise: Vec::new(), + })); + let mut iteration = vec![ + at(pc::Action::ScoreOperation { + score: end.clone(), + operator: pc::ScoreOperator::Set, + operand: pc::ScoreOperand::Field(start.clone()), + }), + at(pc::Action::ScoreOperation { + score: end.clone(), + operator: pc::ScoreOperator::Add, + operand: pc::ScoreOperand::Field(needle_length), + }), + ]; + self.slice_text(body, &part, &source, (&start, &end), *span, &mut iteration); + iteration.push(at(pc::Action::DataEqual { + score: matched.clone(), + left: Self::data_reference(&part), + right: Self::data_reference(needle), + })); + iteration.push(at(pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: matched, + min: Some(1), + max: Some(1), + }), + then: vec![ + at(pc::Action::ScoreSet { + score: dest.clone(), + value: 1, + }), + at(pc::Action::ScoreSet { + score: running.clone(), + value: 0, + }), + ], + otherwise: Vec::new(), + })); + // Check the last index before incrementing, avoiding wrap at the + // scoreboard boundary even for an extremely large stored list. + iteration.push(at(pc::Action::Branch { + condition: pc::Condition::Relation(pc::ScoreRelation { + left: start.clone(), + relation: pc::Relation::Ge, + right: last, + }), + then: vec![at(pc::Action::ScoreSet { + score: running.clone(), + value: 0, + })], + otherwise: vec![at(pc::Action::ScoreAdd { + score: start, + value: 1, + })], + })); + ops.push(at(pc::Action::While { + condition: pc::Condition::Range(pc::ScoreComparison { + score: running, + min: Some(1), + max: Some(1), + }), + body: iteration, + })); + } + _ => unreachable!(), + } + body.temp_depth = depth; + Some(()) + } + + pub(super) fn data_field(base: &pc::FieldReference) -> pc::FieldReference { + pc::FieldReference { + state: base.state.clone(), + field: format!("__sand_data_{}", base.field), + } + } + + pub(super) fn data_reference(base: &pc::FieldReference) -> pc::DataReference { + pc::DataReference { + field: Self::data_field(base), + path: Vec::new(), + } + } + + pub(super) fn register_data_slot(&mut self, base: &pc::FieldReference, default: NbtValue) { + if base.state.to_string() == self.locals_state_id() { + self.local_data_fields + .entry(Self::data_field(base).field) + .or_insert(default); + } + } + + pub(super) fn initialize_leaf(score: pc::FieldReference, value: LeafDefault) -> pc::Action { + match value { + LeafDefault::Score(value) => pc::Action::ScoreSet { score, value }, + LeafDefault::Data(value) => pc::Action::DataModify { + target: Self::data_reference(&score), + operator: DataModifyOperation::Set, + source: pc::DataOperand::Value { value }, + }, + } + } + + pub(super) fn copy_data(dest: &pc::FieldReference, source: &pc::FieldReference) -> pc::Action { + pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Set, + source: pc::DataOperand::Reference { + value: Self::data_reference(source), + }, + } + } + + pub(super) fn append_text( + dest: &pc::FieldReference, + source: &pc::FieldReference, + ) -> pc::Action { + let mut value = Self::data_reference(source); + value.path.push(pc::DataProjection::Each); + pc::Action::DataModify { + target: Self::data_reference(dest), + operator: DataModifyOperation::Append, + source: pc::DataOperand::Reference { value }, + } + } + + pub(super) fn constant_text( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + stack: &mut Vec, + ) -> Option { + self.constant_text_depth(module, file, expr, stack, 0) + } + + fn constant_text_depth( + &mut self, + module: ModuleId, + file: FileId, + expr: &Expr, + stack: &mut Vec, + depth: usize, + ) -> Option { + if depth > 64 { + self.error( + "const", + file, + expr.span(), + "constant string expansion exceeds 64 levels", + ); + return None; + } + match expr { + Expr::Str { value, .. } => { + if !self.text_size(file, expr.span(), value.len()) { + return None; + } + Some(value.clone()) + } + Expr::Binary(left, BinOp::Add, right, _) => { + let mut value = self.constant_text_depth(module, file, left, stack, depth + 1)?; + let right = self.constant_text_depth(module, file, right, stack, depth + 1)?; + if !self.text_size(file, expr.span(), value.len().saturating_add(right.len())) { + return None; + } + value.push_str(&right); + Some(value) + } + Expr::Path(path) => { + let def = self.expect_path(module, path, &[DefKind::Const], "a string constant")?; + if stack.contains(&def) { + self.error( + "cycle", + file, + path.span, + "cycle detected while evaluating a string constant", + ); + return None; + } + if let Some(value) = self.text_constants.get(&def) { + return Some(value.clone()); + } + let source = &self.const_src[&def]; + if source.ty != Ty::String { + self.error("type", file, path.span, "expected a string constant"); + return None; + } + let (module, file, expr) = (source.module, source.file, source.expr.clone()); + stack.push(def); + let value = self.constant_text_depth(module, file, &expr, stack, depth + 1); + stack.pop(); + value + } + _ => { + self.error( + "const", + file, + expr.span(), + "expected a constant string expression", + ); + None + } + } + } + + fn text_size(&mut self, file: FileId, span: Span, bytes: usize) -> bool { + if bytes > TEXT_LITERAL_BYTES { + self.error( + "const", + file, + span, + "text literals and expanded constants support at most 65536 UTF-8 bytes", + ); + return false; + } + true + } + + pub(super) fn default_size(&mut self, file: FileId, span: Span, bytes: usize) -> bool { + if bytes > DEFAULT_BYTES { + self.error( + "const", + file, + span, + "expanded State default exceeds 1048576 bytes; build larger values at runtime", + ); + return false; + } + true + } + + pub(super) fn emit_text( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + let span = expr.span(); + let found = self.type_of(body, expr); + if !self.types_agree(body.file, span, Ty::String, found) { + return None; + } + self.register_data_slot(dest, text_value("")); + match expr { + Expr::Str { value, .. } => { + if !self.text_size(body.file, span, value.len()) { + return None; + } + ops.push(op_at( + Self::initialize_leaf(dest.clone(), LeafDefault::Data(text_value(value))), + body.file, + span, + )); + } + Expr::Binary(left, BinOp::Add, right, _) => { + let depth = body.temp_depth; + let lhs = self.temp(body); + self.emit(body, &lhs, Ty::String, left, ops)?; + let rhs = self.temp(body); + self.emit(body, &rhs, Ty::String, right, ops)?; + ops.push(op_at(Self::append_text(&lhs, &rhs), body.file, span)); + self.copy_value(dest, &lhs, Ty::String, body.file, span, ops); + body.temp_depth = depth; + } + Expr::Path(path) => { + if let Some(local) = Self::local_of(body, expr) { + body.used.insert(local); + self.references.push(Reference { + file: body.file, + span: path.last().span, + def: local, + }); + let source = self.local_ref(local); + self.copy_value(dest, &source, Ty::String, body.file, span, ops); + } else { + let value = + self.constant_text(body.module, body.file, expr, &mut Vec::new())?; + ops.push(op_at( + Self::initialize_leaf(dest.clone(), LeafDefault::Data(text_value(&value))), + body.file, + span, + )); + } + } + Expr::Place(place) => { + let source = self.place_value(body, place, false)?; + self.copy_value(dest, &source.reference, Ty::String, body.file, span, ops); + } + Expr::Project(value, field, _) => { + return self.emit_projection(body, dest, Ty::String, value, field, ops); + } + Expr::Index(value, _, _) if self.type_of(body, value) != Ty::String => { + return self.emit_index(body, dest, Ty::String, expr, ops); + } + Expr::Index(..) => return self.emit_text_index(body, dest, expr, ops), + Expr::Method { receiver, .. } + if matches!(self.type_of(body, receiver), Ty::List(_)) => + { + return self.emit_list_method(body, dest, Ty::String, expr, ops); + } + Expr::Method { receiver, .. } if self.type_of(body, receiver) == Ty::String => { + return self.emit_text_method(body, dest, Ty::String, expr, ops); + } + Expr::Call { path, args, .. } => { + return self.emit_call(body, dest, Ty::String, path, args, span, ops); + } + Expr::Method { receiver, name, .. } + if name.name == "to_string" + && matches!( + self.type_of(body, receiver), + Ty::Number | Ty::Float | Ty::Bool | Ty::Enum(_) + ) => + { + return self.emit_to_string(body, dest, expr, ops); + } + Expr::Method { + receiver, + name, + type_arguments, + args, + .. + } if self.type_of(body, receiver) != Ty::String => { + return self.emit_method( + body, + dest, + Ty::String, + receiver, + name, + type_arguments, + args, + span, + ops, + ); + } + _ => { + self.error("type", body.file, span, "expected a string expression"); + return None; + } + } + Some(()) + } +} diff --git a/sand-lang/src/analysis/traits.rs b/sand-lang/src/analysis/traits.rs new file mode 100644 index 00000000..2bbf2ec9 --- /dev/null +++ b/sand-lang/src/analysis/traits.rs @@ -0,0 +1,214 @@ +//! Trait bounds select statically checked impls through the existing method model. +use super::*; +use std::collections::BTreeSet; + +#[derive(Default)] +pub(super) struct Traits { + pub declarations: BTreeMap>, + pub implementations: BTreeMap<(DefId, DefId), (FileId, Span)>, + pub function_bounds: BTreeMap>, +} + +impl Cx { + pub(super) fn collect_trait(&mut self, def: DefId, declaration: &TraitItem) { + let file = self.defs[def.0].file; + let mut seen = HashSet::new(); + for method in &declaration.methods { + if !seen.insert(&method.name.name) { + self.error("trait", file, method.name.span, "duplicate trait method"); + } + let mut params = HashSet::new(); + for parameter in &method.params { + if !params.insert(¶meter.name.name) { + self.error( + "trait", + file, + parameter.name.span, + "duplicate trait method parameter", + ); + } + } + } + self.traits + .declarations + .insert(def, declaration.methods.clone()); + } + + pub(super) fn register_trait_impl( + &mut self, + contract: DefId, + target: DefId, + file: FileId, + span: Span, + ) { + if let Some((prior_file, prior_span)) = self + .traits + .implementations + .insert((contract, target), (file, span)) + { + self.diagnostics.push( + Diagnostic::error( + "trait", + file, + span, + "this trait is already implemented for this type", + ) + .with_note(prior_file, prior_span, "previous implementation"), + ); + } + } + + /// Validate the authored method set even when the generic target is unused. + pub(super) fn validate_trait_members( + &mut self, + contract: DefId, + file: FileId, + span: Span, + methods: &mut [Item], + ) { + let required = self.traits.declarations[&contract].clone(); + let mut named = HashSet::new(); + for method in methods { + let ItemKind::Fn(function) = &method.kind else { + continue; + }; + named.insert(function.name.name.clone()); + let Some(signature) = required.iter().find(|r| r.name.name == function.name.name) + else { + self.error( + "trait", + file, + function.name.span, + "method is not in this trait", + ); + continue; + }; + let receiver = |receiver: Option<&Receiver>| receiver.map(|r| (r.borrowed, r.mutable)); + if receiver(signature.receiver.as_ref()) != receiver(function.receiver.as_ref()) { + self.error( + "trait", + file, + function.name.span, + "receiver must match the trait signature", + ); + } + if !function.generics.is_empty() { + self.error( + "trait", + file, + function.name.span, + "trait methods cannot declare their own type parameters", + ); + } + // The trait controls visibility of its contract. Methods are + // callable anywhere the implementing type and trait are visible. + method.is_pub = self.defs[contract.0].is_pub; + } + for signature in required { + if !named.contains(&signature.name.name) { + self.error( + "trait", + file, + span, + format!("missing trait method `{}`", signature.name.name), + ); + } + } + } + + pub(super) fn validate_trait_signatures(&mut self, checked: &mut BTreeSet<(DefId, DefId)>) { + loop { + let next = self + .traits + .implementations + .iter() + .find(|(key, _)| !checked.contains(*key)); + let Some((&(contract, target), &(file, span))) = next else { + break; + }; + checked.insert((contract, target)); + let signatures = self.traits.declarations[&contract].clone(); + let module = self.defs[contract.0].module; + let mut bindings = BTreeMap::new(); + bindings.insert("Self".to_owned(), (Ty::Struct(target), target)); + let saved = std::mem::replace(&mut self.generics.bindings, bindings); + for signature in signatures { + let Some(method) = self.members[&target].get(&signature.name.name).copied() else { + continue; + }; + let Some(slots) = self.fn_slots.get(&method).cloned() else { + continue; + }; + let expected: Vec<_> = signature + .params + .iter() + .map(|param| self.resolve_type(module, ¶m.ty)) + .collect(); + let expected_return = signature + .ret + .as_ref() + .map(|ty| self.resolve_type(module, ty)); + let found: Vec<_> = slots + .params + .iter() + .skip(usize::from(signature.receiver.is_some())) + .map(|(_, _, ty)| *ty) + .collect(); + if expected != found || expected_return != slots.ret.as_ref().map(|(_, ty)| *ty) { + let method = &self.defs[method.0]; + self.diagnostics.push( + Diagnostic::error( + "trait", + file, + method.name_span, + format!( + "method `{}` has an incompatible trait signature", + method.name + ), + ) + .with_note( + self.defs[contract.0].file, + signature.name.span, + "required signature", + ) + .with_note( + file, + span, + "implementation for this type", + ), + ); + } + } + self.generics.bindings = saved; + } + } + + pub(super) fn collect_trait_bounds(&mut self, def: DefId, function: &FnItem) { + let module = self.defs[def.0].module; + let file = self.defs[def.0].file; + let mut bounds = Vec::new(); + for (parameter, path) in &function.bounds { + let Some(position) = function + .generics + .iter() + .position(|name| name.name == parameter.name) + else { + continue; + }; + let Some(contract) = self.expect_path(module, path, &[DefKind::Trait], "a trait") + else { + continue; + }; + if bounds.contains(&(position, contract)) { + self.error("trait", file, path.span, "duplicate trait bound"); + } else { + bounds.push((position, contract)); + } + } + self.traits.function_bounds.insert(def, bounds); + } + + pub(super) fn trait_bound_holds(&self, ty: Ty, contract: DefId) -> bool { + matches!(ty, Ty::Struct(target) if self.traits.implementations.contains_key(&(contract, target))) + } +} diff --git a/sand-lang/src/analysis/values.rs b/sand-lang/src/analysis/values.rs new file mode 100644 index 00000000..d6e1f41f --- /dev/null +++ b/sand-lang/src/analysis/values.rs @@ -0,0 +1,1401 @@ +//! Record layouts and inherent methods reuse ordinary score slots and calls. +use super::statements::Value; +use super::*; +use crate::builtins::{self, BuiltinKind}; + +#[derive(Clone)] +pub(super) struct Method { + pub target: DefId, + pub receiver: Option, + pub state_receiver: bool, +} + +pub(super) struct PlaceValue { + pub reference: pc::FieldReference, + pub ty: Ty, + pub field: DefId, +} + +pub(super) fn child(base: &pc::FieldReference, name: &str) -> pc::FieldReference { + pc::FieldReference { + state: base.state.clone(), + field: format!("{}_f{}_{name}", base.field, name.len()), + } +} + +impl Cx { + pub(super) fn collect_struct( + &mut self, + module: ModuleId, + file: FileId, + item: &Item, + record: &StructItem, + ) -> DefId { + self.reject_attrs(file, item); + let id = self.push_def(Def { + kind: DefKind::Struct, + name: record.name.name.clone(), + module, + file, + name_span: record.name.span, + span: item.span, + docs: item.docs.clone(), + is_pub: item.is_pub, + parent: None, + info: DefInfo::Struct { fields: Vec::new() }, + }); + let mut fields = Vec::new(); + let mut members = BTreeMap::new(); + for field in &record.fields { + let def = self.push_def(Def { + kind: DefKind::Field, + name: field.name.name.clone(), + module, + file, + name_span: field.name.span, + span: field.span, + docs: field.docs.clone(), + is_pub: field.is_pub, + parent: Some(id), + info: DefInfo::Field { + ty: Ty::Unknown, + default: None, + bounds: None, + timer: false, + }, + }); + if members.insert(field.name.name.clone(), def).is_some() { + self.error( + "duplicate", + file, + field.name.span, + format!("duplicate field `{}`", field.name.name), + ); + } + fields.push(def); + } + self.defs[id.0].info = DefInfo::Struct { fields }; + self.members.insert(id, members); + if !record.generics.is_empty() { + if record.fields.is_empty() { + self.error( + "struct", + file, + record.name.span, + "a struct needs at least one field", + ); + } + for field in &record.fields { + if !field.attrs.is_empty() || field.default.is_some() { + self.error( + "struct", + file, + field.span, + "struct fields declare types; defaults and clamps belong on State fields", + ); + } + } + let parameters = self.generic_parameters(id, &record.generics); + self.generics + .records + .insert(id, (record.clone(), parameters)); + } + id + } + + pub(super) fn collect_impls(&mut self) { + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + let items = self.package.module(module).items.clone(); + for item in items { + let ItemKind::Impl(mut implementation) = item.kind else { + continue; + }; + if item.is_pub || !item.attrs.is_empty() { + self.error( + "impl", + file, + item.span, + "visibility and attributes belong on impl methods, not the impl block", + ); + } + let Some(target) = self.expect_path( + module, + &implementation.target, + &[DefKind::State, DefKind::Struct], + "a State or struct", + ) else { + continue; + }; + let contract = if let Some(path) = &implementation.contract { + let Some(contract) = + self.expect_path(module, path, &[DefKind::Trait], "a trait") + else { + continue; + }; + if self.defs[target.0].kind != DefKind::Struct { + self.error( + "trait", + file, + path.span, + "traits are implemented on struct values", + ); + continue; + } + self.validate_trait_members( + contract, + file, + item.span, + &mut implementation.methods, + ); + Some(contract) + } else { + None + }; + if self.generics.records.contains_key(&target) { + self.register_generic_impl( + module, + file, + target, + implementation, + item.span, + contract, + ); + continue; + } + if !implementation.generics.is_empty() + || !implementation.target.arguments().is_empty() + { + self.error( + "generic", + file, + implementation.target.span, + "type parameters on an impl require a generic struct", + ); + continue; + } + if let Some(contract) = contract { + self.register_trait_impl(contract, target, file, item.span); + } + let state = self.defs[target.0].kind == DefKind::State; + for method in implementation.methods { + if let Some((_, method)) = + self.collect_method(module, file, target, state, method) + { + self.package.modules[index].items.push(method); + } + } + } + } + } + + pub(super) fn collect_method( + &mut self, + module: ModuleId, + file: FileId, + target: DefId, + state: bool, + mut method: Item, + ) -> Option<(DefId, Item)> { + let ItemKind::Fn(function) = &mut method.kind else { + self.error("impl", file, method.span, "impl blocks contain functions"); + return None; + }; + let receiver = function.receiver.take(); + if !state && let Some(receiver) = &receiver { + let self_span = Span::new(receiver.span.end.saturating_sub(4), receiver.span.end); + function.params.insert( + 0, + Param { + mutable: receiver.mutable, + name: Ident { + name: "self".into(), + span: self_span, + }, + ty: Type::named(Path { + applications: Vec::new(), + segments: vec![Ident { + name: "Self".into(), + span: self_span, + }], + span: self_span, + }), + span: receiver.span, + }, + ); + } + let name = function.name.clone(); + if self.members[&target].contains_key(&name.name) { + self.error( + "duplicate", + file, + name.span, + format!( + "`{}` already has a member named `{}`", + self.defs[target.0].name, name.name + ), + ); + return None; + } + let id = format!( + "{}.method/{}", + self.item_id(module, &self.defs[target.0].name), + name.name + ); + let def = self.push_def(Def { + kind: DefKind::Function, + name: name.name.clone(), + module, + file, + name_span: name.span, + span: method.span, + docs: method.docs.clone(), + is_pub: method.is_pub, + parent: Some(target), + info: DefInfo::Function { + id, + context: Context::Server, + player_reason: None, + entry: Vec::new(), + signature: "()".into(), + }, + }); + self.methods.insert( + def, + Method { + target, + state_receiver: state && receiver.is_some(), + receiver, + }, + ); + self.members + .get_mut(&target) + .expect("type members") + .insert(name.name, def); + Some((def, method)) + } + + pub(super) fn evaluate_structs(&mut self) { + for index in 0..self.package.modules.len() { + let module = ModuleId(index); + let file = self.package.module(module).file; + for item in self.package.module(module).items.clone() { + let ItemKind::Struct(record) = &item.kind else { + continue; + }; + let Some(def) = self.def_by_span(module, record.name.span) else { + continue; + }; + if !record.generics.is_empty() { + continue; + } + let fields = self.struct_fields(def); + if fields.is_empty() { + self.error( + "struct", + file, + record.name.span, + "a struct needs at least one field", + ); + } + for (source, field) in record.fields.iter().zip(fields) { + if !source.attrs.is_empty() || source.default.is_some() { + self.error("struct", file, source.span, "struct fields declare types; defaults and clamps belong on State fields"); + } + let ty = self.resolve_type(module, &source.ty); + self.defs[field.0].info = DefInfo::Field { + ty, + default: None, + bounds: None, + timer: false, + }; + } + } + } + let structs: Vec<_> = self + .defs + .iter() + .enumerate() + .filter(|(_, d)| d.kind == DefKind::Struct) + .map(|(i, _)| DefId(i)) + .collect(); + for def in structs { + if self.layout_leaves(Ty::Struct(def)).is_none() { + let d = self.defs[def.0].clone(); + self.error( + "struct", + d.file, + d.name_span, + "struct layouts must be finite, at most 32 levels deep and 1024 scalar fields", + ); + self.defs[def.0].info = DefInfo::Struct { fields: Vec::new() }; + } + } + } + + /// Validate one aggregate layout, including inferred arrays created while + /// lowering bodies, before any recursive slot expansion can run. + pub(super) fn layout_leaves(&self, ty: Ty) -> Option { + fn visit(cx: &Cx, ty: Ty, stack: &mut Vec) -> Option { + let Ty::Struct(def) = ty else { + return Some(1); + }; + if stack.len() >= 32 || stack.contains(&def) { + return None; + } + stack.push(def); + let mut leaves = 0usize; + for field in cx.struct_fields(def) { + leaves = leaves.checked_add(visit(cx, cx.field_ty(field), stack)?)?; + if leaves > 1024 { + return None; + } + } + stack.pop(); + Some(leaves) + } + visit(self, ty, &mut Vec::new()) + } + + pub(super) fn struct_fields(&self, def: DefId) -> Vec { + match &self.defs[def.0].info { + DefInfo::Struct { fields } | DefInfo::Array { fields, .. } => fields.clone(), + _ => Vec::new(), + } + } + pub(super) fn field_ty(&self, field: DefId) -> Ty { + match self.defs[field.0].info { + DefInfo::Field { ty, .. } => ty, + _ => Ty::Unknown, + } + } + pub(super) fn record_member(&self, ty: Ty, name: &str) -> Option { + let Ty::Struct(def) = ty else { return None }; + self.members + .get(&def)? + .get(name) + .copied() + .filter(|field| self.defs[field.0].kind == DefKind::Field) + } + pub(super) fn value_slots( + &mut self, + base: &pc::FieldReference, + ty: Ty, + ) -> Vec<(pc::FieldReference, Ty)> { + if let Ty::Struct(def) = ty { + self.struct_fields(def) + .into_iter() + .flat_map(|field| { + self.value_slots( + &child(base, &self.defs[field.0].name.clone()), + self.field_ty(field), + ) + }) + .collect() + } else { + if matches!(ty, Ty::Callable(_)) { + self.register_data_slot(base, Self::empty_callable()); + } else if matches!(ty, Ty::String | Ty::List(_)) { + self.register_data_slot(base, text::text_value("")); + } else if base.state.to_string() == self.locals_state_id() { + self.slot(base.field.clone()); + } + vec![(base.clone(), ty)] + } + } + pub(super) fn entity_storage(&self, reference: &pc::FieldReference) -> bool { + if reference.state.to_string() == self.locals_state_id() { + return false; + } + let state = reference.state.to_string(); + self.defs.iter().any(|def| matches!(&def.info, DefInfo::State { scope: Scope::Entity, id, .. } if *id == state)) + } + + pub(super) fn entity_place(&mut self, body: &BodyCx, place: &Place) -> bool { + if place.state.segments.len() == 1 + && Self::lookup_local(body, &place.state.last().name).is_some() + { + return false; + } + self.resolve_path(body.module, &place.state) + .is_ok_and(|(def, _)| { + matches!( + self.defs[def.0].info, + DefInfo::State { + scope: Scope::Entity, + .. + } + ) + }) + } + + pub(super) fn copy_value( + &mut self, + dest: &pc::FieldReference, + source: &pc::FieldReference, + ty: Ty, + file: FileId, + span: Span, + ops: &mut Vec, + ) { + let default_missing = self.entity_storage(source); + for ((dest, leaf_ty), (source, _)) in self + .value_slots(dest, ty) + .into_iter() + .zip(self.value_slots(source, ty)) + { + if dest.state == source.state && dest.field == source.field { + continue; + } + let default = default_missing.then(|| { + self.record_constant(ModuleId(0), file, None, leaf_ty) + .and_then(|values| values.into_iter().next()) + .unwrap_or(text::LeafDefault::Score(0)) + }); + if matches!(leaf_ty, Ty::String | Ty::List(_) | Ty::Callable(_)) { + if let Some(default) = default { + ops.push(op_at( + Self::initialize_leaf(dest.clone(), default), + file, + span, + )); + } + ops.push(op_at(Self::copy_data(&dest, &source), file, span)); + } else if let Some(action) = Self::set_from(&dest, Value::Read(source.clone())) { + if let Some(default) = default { + ops.push(op_at( + pc::Action::Branch { + condition: pc::Condition::Range(pc::ScoreComparison { + score: source, + min: Some(i32::MIN), + max: Some(i32::MAX), + }), + then: vec![op_at(action, file, span)], + otherwise: vec![op_at( + Self::initialize_leaf(dest, default), + file, + span, + )], + }, + file, + span, + )); + } else { + ops.push(op_at(action, file, span)); + } + } + } + } + pub(super) fn place_ty(&mut self, body: &BodyCx, place: &Place) -> Ty { + if !place.state.applications.is_empty() { + return Ty::Unknown; + } + let local = (place.state.segments.len() == 1) + .then(|| Self::lookup_local(body, &place.state.last().name)) + .flatten(); + let (mut ty, projections) = if let Some(local) = local { + ( + self.local_ty(local), + std::iter::once(&place.field) + .chain(&place.projections) + .collect::>(), + ) + } else { + let Ok((state, _)) = self.resolve_path(body.module, &place.state) else { + return Ty::Unknown; + }; + let Some(field) = self + .members + .get(&state) + .and_then(|m| m.get(&place.field.name)) + else { + return Ty::Unknown; + }; + ( + self.field_ty(*field), + place.projections.iter().collect::>(), + ) + }; + for field in projections { + let Some(member) = self.record_member(ty, &field.name) else { + return Ty::Unknown; + }; + ty = self.field_ty(member); + } + ty + } + pub(super) fn place_value( + &mut self, + body: &mut BodyCx, + place: &Place, + write: bool, + ) -> Option { + if !place.state.applications.is_empty() { + self.error( + "generic", + body.file, + place.state.span, + "a value or State field access does not take type arguments", + ); + return None; + } + let local = (place.state.segments.len() == 1) + .then(|| Self::lookup_local(body, &place.state.last().name)) + .flatten(); + let (mut reference, mut ty, mut field, projections) = if let Some(local) = local { + let DefInfo::Local { ty, mutable, .. } = self.defs[local.0].info else { + return None; + }; + if write && !mutable { + self.error( + "mutability", + body.file, + place.state.span, + "cannot change a field of an immutable value; use `let mut` or `mut self`", + ); + return None; + } + body.used.insert(local); + if write { + body.assigned.insert(local); + } + self.references.push(Reference { + file: body.file, + span: place.state.span, + def: local, + }); + let projections = std::iter::once(place.field.clone()) + .chain(place.projections.clone()) + .collect::>(); + (self.local_ref(local), ty, local, projections) + } else { + let (state, field, ty) = self.resolve_place(body.module, body.file, place)?; + if write && !self.check_state_write(body, state, place.span) { + return None; + } + body.note_state(self, state, place, if write { "writes" } else { "reads" }); + ( + self.field_reference(state, field)?, + ty, + field, + place.projections.clone(), + ) + }; + for projection in projections { + let Some(member) = self.record_member(ty, &projection.name) else { + self.error( + "field", + body.file, + projection.span, + format!("`{}` has no field `{}`", self.ty_name(ty), projection.name), + ); + return None; + }; + if !self.visible( + body.module, + self.defs[member.0].module, + self.defs[member.0].is_pub, + ) { + self.error( + "privacy", + body.file, + projection.span, + format!("field `{}` is private", projection.name), + ); + return None; + } + reference = child(&reference, &projection.name); + self.references.push(Reference { + file: body.file, + span: projection.span, + def: member, + }); + ty = self.field_ty(member); + field = member; + } + self.value_slots(&reference, ty); + Some(PlaceValue { + reference, + ty, + field, + }) + } + + pub(super) fn check_state_write(&mut self, body: &BodyCx, state: DefId, span: Span) -> bool { + if let Some(method) = body.owner.and_then(|owner| self.methods.get(&owner)) + && method.target == state + && method.receiver.as_ref().is_some_and(|r| !r.mutable) + { + self.error( + "mutability", + body.file, + span, + "this State receiver is read-only; use `&mut self`", + ); + return false; + } + true + } + + pub(super) fn lower_reference_loop( + &mut self, + body: &mut BodyCx, + stmt: &Stmt, + ops: &mut Vec, + ) { + let Stmt::For { + binding, + source, + args, + body: block, + span, + } = stmt + else { + unreachable!() + }; + let players = source.last().name == "resolve_player"; + let builtin = builtins::find(&source.last().name, BuiltinKind::Expression) + .expect("reference builtin"); + self.references_builtin(body.file, source.span, builtin); + let Some(bound) = self.bind_args(body, builtin, args, *span) else { + return; + }; + let ArgValue::Expr(expr) = &bound["reference"].value else { + return; + }; + let depth = body.temp_depth; + let reference = self.temp(body); + if self + .emit(body, &reference, Ty::EntityRef, expr, ops) + .is_none() + { + body.temp_depth = depth; + return; + } + let was = body.in_players; + body.in_players = true; + body.loops.push(if players { + LoopKind::Players + } else { + LoopKind::Entities + }); + body.loop_bindings.push(binding.name.clone()); + if players { + body.player_loops += 1; + } + self.handle_scopes + .push((body.file, block.span, binding.name.clone(), players)); + let inner = self.lower_block(body, block); + if players { + body.player_loops -= 1; + } + body.loops.pop(); + body.loop_bindings.pop(); + body.in_players = was; + body.temp_depth = depth; + ops.push(op_at( + pc::Action::WithEntity { + reference, + players, + body: inner, + }, + body.file, + *span, + )); + } + + /// Resolve a mutable receiver to existing writable storage. A method call + /// commits its receiver result after restoring the caller's recursive frame. + pub(super) fn receiver_destination( + &mut self, + body: &mut BodyCx, + expr: &Expr, + ) -> Option { + match expr { + Expr::Path(path) if path.segments.len() == 1 => { + let local = Self::lookup_local(body, &path.last().name)?; + if !matches!( + self.defs[local.0].info, + DefInfo::Local { mutable: true, .. } + ) { + self.error( + "mutability", + body.file, + path.span, + "a mutable method needs a mutable receiver; declare it with `let mut`", + ); + return None; + } + body.assigned.insert(local); + body.used.insert(local); + self.references.push(Reference { + file: body.file, + span: path.span, + def: local, + }); + Some(self.local_ref(local)) + } + Expr::Place(place) => self + .place_value(body, place, true) + .map(|value| value.reference), + _ => { + self.error("receiver", body.file, expr.span(), "a mutable method needs a variable or State field; store this value in `let mut` first"); + None + } + } + } + + pub(super) fn finish_receiver( + &mut self, + body: &BodyCx, + span: Span, + ops: &mut Vec, + ) { + if let Some((source, dest, ty)) = &body.receiver_out { + self.copy_value(dest, source, *ty, body.file, span, ops); + } + } + + pub(super) fn record_constant( + &mut self, + module: ModuleId, + file: FileId, + expr: Option<&Expr>, + ty: Ty, + ) -> Option> { + if matches!(ty, Ty::Callable(_)) { + if let Some(value) = expr { + self.error( + "callable", + file, + value.span(), + "set function values at runtime, not in a State default", + ); + return None; + } + return Some(vec![text::LeafDefault::Data(Self::empty_callable())]); + } + if let Ty::List(def) = ty { + return self + .list_constant(module, file, def, expr) + .map(|value| vec![text::LeafDefault::Data(value)]); + } + if ty == Ty::String { + let value = match expr { + Some(expr) => self.constant_text(module, file, expr, &mut Vec::new())?, + None => String::new(), + }; + return Some(vec![text::LeafDefault::Data(text::text_value(&value))]); + } + if let Some((element, length)) = self.array_shape(ty) { + if let Some(Expr::ArrayRepeat { + value, + length: count, + span, + }) = expr + { + let count = self.eval_i32(module, file, count, Some(Ty::Number), None)?; + if count != length as i64 { + self.error( + "const", + file, + *span, + format!("expected {length} array elements, found {count}"), + ); + return None; + } + let repeated = self.record_constant(module, file, Some(value), element)?; + if !self.default_size( + file, + *span, + text::defaults_cost(&repeated).saturating_mul(length), + ) { + return None; + } + return Some((0..length).flat_map(|_| repeated.clone()).collect()); + } + let values = match expr { + Some(Expr::Array(values, _)) if values.len() == length => Some(values), + Some(value) => { + self.error( + "const", + file, + value.span(), + format!("expected an array literal with {length} elements"), + ); + return None; + } + None => None, + }; + let mut leaves = Vec::new(); + for index in 0..length { + let next = + self.record_constant(module, file, values.map(|v| &v[index]), element)?; + if !self.default_size( + file, + expr.map(Expr::span).unwrap_or_default(), + text::defaults_cost(&leaves).saturating_add(text::defaults_cost(&next)), + ) { + return None; + } + leaves.extend(next); + } + return Some(leaves); + } + if let Ty::Struct(def) = ty { + let mut supplied = BTreeMap::new(); + if let Some(expr) = expr { + let Expr::Struct { path, fields, .. } = expr else { + self.error( + "const", + file, + expr.span(), + "a struct State default must be a record literal", + ); + return None; + }; + let found = + self.record_literal_type(None, module, file, path, fields, Some(ty), true)?; + if found != ty { + self.error( + "type", + file, + path.span, + "record default has the wrong struct type", + ); + return None; + } + for (name, value) in fields { + if let Some(member) = self.record_member(ty, &name.name) { + if !self.visible( + module, + self.defs[member.0].module, + self.defs[member.0].is_pub, + ) { + self.error( + "privacy", + file, + name.span, + format!("field `{}` is private", name.name), + ); + return None; + } + self.references.push(Reference { + file, + span: name.span, + def: member, + }); + } + if supplied.insert(name.name.clone(), value).is_some() { + self.error("duplicate", file, name.span, "duplicate record field"); + } + } + } + let fields = self.struct_fields(def); + for name in supplied.keys() { + if !fields.iter().any(|f| &self.defs[f.0].name == name) { + self.error( + "field", + file, + expr.expect("literal").span(), + format!("unknown record field `{name}`"), + ); + } + } + let mut values = Vec::new(); + for field in fields { + let name = self.defs[field.0].name.clone(); + let value = supplied.remove(&name); + if let Some(expr) = expr + && value.is_none() + { + self.error( + "field", + file, + expr.span(), + format!("missing record field `{name}`"), + ); + return None; + } + let next = self.record_constant(module, file, value, self.field_ty(field))?; + if !self.default_size( + file, + expr.map(Expr::span).unwrap_or_default(), + text::defaults_cost(&values).saturating_add(text::defaults_cost(&next)), + ) { + return None; + } + values.extend(next); + } + Some(values) + } else { + let value = match expr { + Some(expr) => self.eval_i32(module, file, expr, Some(ty), None)?, + None => match ty { + Ty::Enum(def) => match &self.defs[def.0].info { + DefInfo::Enum { variants } => variants + .first() + .and_then(|v| match self.defs[v.0].info { + DefInfo::Variant { value } => value, + _ => None, + }) + .unwrap_or(0), + _ => 0, + }, + _ => 0, + }, + }; + Some(vec![text::LeafDefault::Score(value as i32)]) + } + } + + pub(super) fn emit_record( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + expr: &Expr, + ops: &mut Vec, + ) -> Option<()> { + if matches!(expr, Expr::Array(..) | Expr::ArrayRepeat { .. }) { + return self.emit_array(body, dest, ty, expr, ops); + } + self.value_slots(dest, ty); + let found = if let Expr::Struct { path, fields, .. } = expr { + self.record_literal_type( + Some(body), + body.module, + body.file, + path, + fields, + Some(ty), + true, + )? + } else { + self.type_of(body, expr) + }; + if !self.types_agree(body.file, expr.span(), ty, found) { + return None; + } + match expr { + Expr::Struct { path, fields, span } => { + let Ty::Struct(def) = ty else { + return None; + }; + let _ = path; + let expected = self.struct_fields(def); + let mut seen = HashSet::new(); + for (name, value) in fields { + if !seen.insert(name.name.clone()) { + self.error("duplicate", body.file, name.span, "duplicate record field"); + return None; + } + let Some(field) = self.record_member(Ty::Struct(def), &name.name) else { + self.error( + "field", + body.file, + name.span, + format!("unknown field `{}`", name.name), + ); + return None; + }; + if !self.visible( + body.module, + self.defs[field.0].module, + self.defs[field.0].is_pub, + ) { + self.error( + "privacy", + body.file, + name.span, + format!("field `{}` is private", name.name), + ); + return None; + } + self.references.push(Reference { + file: body.file, + span: name.span, + def: field, + }); + self.emit( + body, + &child(dest, &name.name), + self.field_ty(field), + value, + ops, + )?; + } + for field in expected { + if !seen.contains(&self.defs[field.0].name) { + self.error( + "field", + body.file, + *span, + format!("missing record field `{}`", self.defs[field.0].name), + ); + return None; + } + } + Some(()) + } + Expr::Path(path) => { + let Some(local) = Self::lookup_local(body, &path.last().name) else { + self.error( + "resolve", + body.file, + path.span, + format!("cannot find struct value `{}`", path.display()), + ); + return None; + }; + body.used.insert(local); + self.references.push(Reference { + file: body.file, + span: path.span, + def: local, + }); + let source = self.local_ref(local); + self.copy_value(dest, &source, ty, body.file, expr.span(), ops); + Some(()) + } + Expr::Place(place) => { + let value = self.place_value(body, place, false)?; + self.copy_value(dest, &value.reference, ty, body.file, place.span, ops); + Some(()) + } + Expr::Call { path, args, span } => { + self.emit_call(body, dest, ty, path, args, *span, ops) + } + Expr::Method { + receiver, + name, + type_arguments, + args, + span, + } => { + let receiver_ty = self.type_of(body, receiver); + if self.list_element(receiver_ty).is_some() { + return self.emit_list_method(body, dest, ty, expr, ops); + } + if self.array_shape(receiver_ty).is_some() { + return self.emit_array_method(body, dest, ty, expr, ops); + } + self.emit_method( + body, + dest, + ty, + receiver, + name, + type_arguments, + args, + *span, + ops, + ) + } + Expr::Index(..) => self.emit_index(body, dest, ty, expr, ops), + Expr::Project(value, field, _) => { + self.emit_projection(body, dest, ty, value, field, ops) + } + _ => { + self.error("type", body.file, expr.span(), "expected a struct value"); + None + } + } + } + + fn direct_projection(body: &BodyCx, value: &Expr) -> bool { + match value { + Expr::Path(path) => { + path.segments.len() == 1 + && path.applications.is_empty() + && Self::lookup_local(body, &path.last().name).is_some() + } + Expr::Place(_) => true, + Expr::Project(value, ..) => Self::direct_projection(body, value), + Expr::Index(value, index, _) => { + Self::direct_projection(body, value) && !super::statements::contains_call(index) + } + _ => false, + } + } + + pub(super) fn emit_projection( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + value: &Expr, + field: &Ident, + ops: &mut Vec, + ) -> Option<()> { + let span = Span::new(value.span().start, field.span.end); + let parent_ty = self.type_of(body, value); + let Some(member) = self.record_member(parent_ty, &field.name) else { + self.error( + "field", + body.file, + field.span, + format!( + "`{}` has no field `{}`", + self.ty_name(parent_ty), + field.name + ), + ); + return None; + }; + if !self.visible( + body.module, + self.defs[member.0].module, + self.defs[member.0].is_pub, + ) { + self.error( + "privacy", + body.file, + field.span, + format!("field `{}` is private", field.name), + ); + return None; + } + let found = self.field_ty(member); + if !self.types_agree(body.file, span, ty, found) { + return None; + } + if Self::direct_projection(body, value) { + // Reading one stored member should not unpack every sibling field. + // Called indices retain the full snapshot path below: they may + // mutate the original collection while computing the index. + let depth = body.temp_depth; + let projected = Expr::Project(Box::new(value.clone()), field.clone(), span); + let address = self.value_address_access(body, &projected, false, ops); + let result = + address.and_then(|address| self.read_address(body, dest, &address, span, ops)); + body.temp_depth = depth; + return result; + } + let depth = body.temp_depth; + let temp = self.temp(body); + self.emit(body, &temp, parent_ty, value, ops)?; + self.references.push(Reference { + file: body.file, + span: field.span, + def: member, + }); + self.copy_value(dest, &child(&temp, &field.name), ty, body.file, span, ops); + body.temp_depth = depth; + Some(()) + } + + pub(super) fn method_target(&mut self, body: &BodyCx, receiver: &Expr) -> Option { + if let Expr::Path(path) = receiver + && Self::lookup_local(body, &path.last().name).is_none() + && let Ok((def, _)) = self.resolve_path(body.module, path) + && self.defs[def.0].kind == DefKind::State + { + return Some(def); + } + None + } + pub(super) fn method_call( + &mut self, + body: &mut BodyCx, + receiver: &Expr, + name: &Ident, + args: &[Arg], + ) -> Option<(DefId, Vec)> { + let target = + self.method_target(body, receiver) + .or_else(|| match self.type_of(body, receiver) { + Ty::Struct(def) => Some(def), + _ => None, + }); + let Some(target) = target else { + self.error( + "method", + body.file, + name.span, + "methods need a struct value or a State receiver", + ); + return None; + }; + let Some(def) = self + .members + .get(&target) + .and_then(|m| m.get(&name.name)) + .copied() + .filter(|d| self.methods.contains_key(d)) + else { + self.error( + "method", + body.file, + name.span, + format!( + "`{}` has no method `{}`", + self.defs[target.0].name, name.name + ), + ); + return None; + }; + let method = self.methods[&def].clone(); + let mut arguments = args.to_vec(); + if self.defs[target.0].kind == DefKind::Struct { + if method.receiver.is_none() { + self.error( + "method", + body.file, + name.span, + "call associated functions with `Type::function(...)`", + ); + return None; + } + arguments.insert( + 0, + Arg { + name: None, + value: ArgValue::Expr(receiver.clone()), + span: receiver.span(), + }, + ); + } else if let Expr::Path(path) = receiver { + let _ = self.expect_path(body.module, path, &[DefKind::State], "a State"); + } + if !self.visible( + body.module, + self.defs[def.0].module, + self.defs[def.0].is_pub, + ) { + self.error( + "privacy", + body.file, + name.span, + format!("method `{}` is private", name.name), + ); + return None; + } + self.references.push(Reference { + file: body.file, + span: name.span, + def, + }); + Some((def, arguments)) + } + + pub(super) fn validate_method_type_arguments(&mut self, body: &BodyCx, expr: &Expr) -> bool { + if let Expr::Method { + receiver, + name, + type_arguments, + .. + } = expr + && !type_arguments.is_empty() + && !matches!(self.type_of(body, receiver), Ty::Struct(_)) + && self.method_target(body, receiver).is_none() + { + self.error( + "generic", + body.file, + name.span, + "intrinsic methods do not take type arguments", + ); + return false; + } + true + } + + #[allow(clippy::too_many_arguments)] + pub(super) fn emit_method( + &mut self, + body: &mut BodyCx, + dest: &pc::FieldReference, + ty: Ty, + receiver: &Expr, + name: &Ident, + type_arguments: &[Type], + args: &[Arg], + span: Span, + ops: &mut Vec, + ) -> Option<()> { + let (def, args) = self.method_call(body, receiver, name, args)?; + let path = Path { + segments: vec![name.clone()], + applications: if type_arguments.is_empty() { + Vec::new() + } else { + vec![PathApplication { + segment: 0, + arguments: type_arguments.to_vec(), + }] + }, + span: name.span, + }; + let def = self.specialize_call(body, def, &path, &args, Some(ty), true)?; + self.emit_user_result(body, dest, ty, def, &path, &args, span, ops) + } + + pub(super) fn lower_value_statement( + &mut self, + body: &mut BodyCx, + expr: &Expr, + span: Span, + ops: &mut Vec, + ) { + if !self.validate_method_type_arguments(body, expr) { + return; + } + if let Expr::Method { + receiver, + name, + type_arguments, + args, + .. + } = expr + { + let receiver_ty = self.type_of(body, receiver); + if self.list_element(receiver_ty).is_some() { + self.lower_list_statement(body, expr, ops); + return; + } + if receiver_ty == Ty::String + || (name.name == "to_string" + && matches!(receiver_ty, Ty::Number | Ty::Float | Ty::Bool | Ty::Enum(_))) + { + let depth = body.temp_depth; + let ty = self.type_of(body, expr); + let ignored = self.temp(body); + self.emit(body, &ignored, ty, expr, ops); + body.temp_depth = depth; + return; + } + if self.array_shape(receiver_ty).is_some() { + self.lower_array_statement(body, expr, ops); + return; + } + if let Some((def, args)) = self.method_call(body, receiver, name, args) { + let path = Path { + segments: vec![name.clone()], + applications: if type_arguments.is_empty() { + Vec::new() + } else { + vec![PathApplication { + segment: 0, + arguments: type_arguments.to_vec(), + }] + }, + span: name.span, + }; + if let Some(def) = self.specialize_call(body, def, &path, &args, None, true) + && let Some(slots) = self.fn_slots.get(&def).cloned() + { + self.call_user(body, def, &slots, &path, &args, span, ops); + } + } + } else { + self.error( + "statement", + body.file, + span, + "only function and method calls can be used as statements", + ); + } + } +} diff --git a/sand-lang/src/ast.rs b/sand-lang/src/ast.rs new file mode 100644 index 00000000..2215e1cb --- /dev/null +++ b/sand-lang/src/ast.rs @@ -0,0 +1,1201 @@ +//! Span-carrying syntax tree for one Sand source file. +//! +//! The tree mirrors the surface syntax. Every node records the byte [`Span`] +//! it covers so diagnostics, hover, go-to-definition, and rename can map back +//! to source text. Malformed items and statements are kept as +//! [`ItemKind::Error`] and [`Stmt::Error`] so the rest of the file stays usable. + +/// A half-open byte range within one source file. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, PartialOrd, Ord)] +pub struct Span { + /// Inclusive start byte offset. + pub start: usize, + /// Exclusive end byte offset. + pub end: usize, +} + +impl Span { + /// Construct a span from byte offsets. + pub fn new(start: usize, end: usize) -> Self { + Self { start, end } + } + + /// Whether `offset` lies within the span, inclusive of its end so a cursor + /// placed directly after an identifier still refers to it. + pub fn contains(&self, offset: usize) -> bool { + self.start <= offset && offset <= self.end + } + + /// The smallest span covering both spans. + pub fn to(self, other: Span) -> Span { + Span::new(self.start.min(other.start), self.end.max(other.end)) + } +} + +/// A source type annotation, shared by fields, parameters, returns and casts. +#[derive(Debug, Clone)] +pub struct Type { + /// Type syntax. + pub kind: TypeKind, + /// Whole annotation. + pub span: Span, +} + +/// Named and composite source type forms. +#[derive(Debug, Clone)] +pub enum TypeKind { + /// A named scalar, enum, record or imported type. + Named(Path), + /// A concrete callable signature. + Function { + /// Argument types in call order. + parameters: Vec, + /// Return type, or no value for a statement function. + returns: Option>, + }, + /// A named type applied to other value types. + Applied { path: Path, arguments: Vec }, + /// A fixed-length homogeneous array with a constant length. + Array { + element: Box, + length: Box, + }, +} + +impl Type { + /// Construct a named annotation without losing its source span. + pub fn named(path: Path) -> Self { + Self { + span: path.span, + kind: TypeKind::Named(path), + } + } +} + +/// An identifier together with its source location. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Ident { + /// Identifier text. + pub name: String, + /// Location of the identifier. + pub span: Span, +} + +/// A `::`-separated path such as `crate::combat::Phase`. +#[derive(Debug, Clone)] +pub struct Path { + /// Path segments, including leading `crate`, `super`, or `self`. + pub segments: Vec, + /// Explicit applications on individual segments, written `::`. + pub applications: Vec, + /// Location of the whole path. + pub span: Span, +} + +/// A type application on one segment of a qualified path. +#[derive(Debug, Clone)] +pub struct PathApplication { + /// Zero-based index into the path's segments. + pub segment: usize, + /// Concrete type syntax. + pub arguments: Vec, +} + +impl Path { + /// Explicit arguments on the final item; preceding applications belong to types. + pub fn arguments(&self) -> &[Type] { + self.applications + .iter() + .find(|application| application.segment + 1 == self.segments.len()) + .map_or(&[], |application| application.arguments.as_slice()) + } + /// The final segment, which names the referenced item. + pub fn last(&self) -> &Ident { + self.segments.last().expect("paths are never empty") + } + + /// Render the path back to source form. + pub fn display(&self) -> String { + self.segments + .iter() + .map(|segment| segment.name.as_str()) + .collect::>() + .join("::") + } +} + +/// A parsed source file. +#[derive(Debug, Clone, Default)] +pub struct SourceFile { + /// `//!` documentation lines. + pub docs: Vec, + /// `#![...]` attributes. + pub inner_attrs: Vec, + /// Items in source order. + pub items: Vec, +} + +/// An `#[name(args)]` or `#![name(args)]` attribute. +#[derive(Debug, Clone)] +pub struct Attr { + /// Attribute name path. + pub path: Path, + /// Arguments in source order. + pub args: Vec, + /// Whole attribute, including `#[` and `]`. + pub span: Span, +} + +impl Attr { + /// The attribute name, if it is a single identifier. + pub fn name(&self) -> &str { + &self.path.last().name + } +} + +/// One attribute argument, optionally `key = value`. +#[derive(Debug, Clone)] +pub struct AttrArg { + /// Key for `key = value` arguments. + pub key: Option, + /// Argument value. + pub value: AttrValue, + /// Location of the whole argument. + pub span: Span, +} + +/// An attribute argument value. +#[derive(Debug, Clone)] +pub enum AttrValue { + /// A string literal. + Str(String, Span), + /// A constant range such as `0..=100`. + Range(Range), + /// A constant expression. + Expr(Expr), +} + +/// A top-level or module-level declaration. +#[derive(Debug, Clone)] +pub struct Item { + /// `///` documentation lines. + pub docs: Vec, + /// Outer attributes. + pub attrs: Vec, + /// Whether the item is `pub`. + pub is_pub: bool, + /// Declaration body. + pub kind: ItemKind, + /// Location of the whole item, including docs and attributes. + pub span: Span, +} + +impl Item { + /// The declared name, when the item declares one. + pub fn name(&self) -> Option<&Ident> { + match &self.kind { + ItemKind::Mod(item) => Some(&item.name), + ItemKind::Const(item) => Some(&item.name), + ItemKind::Enum(item) => Some(&item.name), + ItemKind::State(item) => Some(&item.name), + ItemKind::Struct(item) => Some(&item.name), + ItemKind::Trait(item) => Some(&item.name), + ItemKind::Flow(item) => Some(&item.name), + ItemKind::Fn(item) => Some(&item.name), + ItemKind::ExternFn(item) => Some(&item.name), + ItemKind::Data(item) => Some(&item.name), + ItemKind::Event(item) => Some(&item.name), + ItemKind::Use(_) | ItemKind::Impl(_) | ItemKind::Error(_) => None, + } + } + + /// Find an outer attribute by name. + pub fn attr(&self, name: &str) -> Option<&Attr> { + self.attrs.iter().find(|attr| attr.name() == name) + } +} + +/// The kinds of item Sand understands. +#[derive(Debug, Clone)] +pub enum ItemKind { + /// `mod name;` or `mod name { ... }`. + Mod(ModItem), + /// `use path;`. + Use(UseItem), + /// `const NAME: i32 = expr;`. + Const(ConstItem), + /// `enum Name { A, B = 2 }`. + Enum(EnumItem), + /// `player state Name { ... }` or `global state Name { ... }`. + State(StateItem), + /// A named, copyable record value. + Struct(StructItem), + /// A contract for a set of methods on a value type. + Trait(TraitItem), + /// Associated functions and methods for a State or struct. + Impl(ImplItem), + /// `flow Name on State.field { ... }`. + Flow(FlowItem), + /// `fn name() { ... }`. + Fn(FnItem), + /// `extern "ns:id" fn name();`. + ExternFn(ExternFnItem), + /// `item`, `recipe`, a tag, boss bar, or loot table declaration. + Data(DataItem), + /// `event Name(params);`. + Event(EventItem), + /// Unparseable source, with the strict parser's explanation. + Error(SyntaxError), +} + +/// A syntax error recovered from by skipping source. +#[derive(Debug, Clone)] +pub struct SyntaxError { + /// Human-readable expectation. + pub message: String, + /// The precise failure location. + pub span: Span, +} + +/// A module declaration. +#[derive(Debug, Clone)] +pub struct ModItem { + /// Module name. + pub name: Ident, + /// Inline items for `mod name { ... }`; `None` for a file module. + pub inline: Option>, +} + +/// A `use` declaration. +#[derive(Debug, Clone)] +pub struct UseItem { + /// The import tree. + pub tree: UseTree, +} + +/// One branch of a `use` tree. +#[derive(Debug, Clone)] +pub struct UseTree { + /// Path prefix. + pub path: Path, + /// Nested `{a, b}` group following the prefix. + pub group: Option>, + /// `as name` alias. + pub alias: Option, +} + +/// A named compile-time integer constant. +#[derive(Debug, Clone)] +pub struct ConstItem { + /// Constant name. + pub name: Ident, + /// Declared type. + pub ty: Type, + /// Value expression. + pub value: Expr, +} + +/// An enumeration whose variants are integer phases. +#[derive(Debug, Clone)] +pub struct EnumItem { + /// Enum name. + pub name: Ident, + /// Variants in declaration order. + pub variants: Vec, +} + +/// One enum variant. +#[derive(Debug, Clone)] +pub struct Variant { + /// Documentation lines. + pub docs: Vec, + /// Variant name. + pub name: Ident, + /// Explicit discriminant. + pub value: Option, +} + +/// Who owns a State's values. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Scope { + /// One value per player. + Player, + /// One shared value for the server. + Global, + /// One value per entity that has it attached. + Entity, +} + +/// A persistent State declaration. +#[derive(Debug, Clone)] +pub struct StateItem { + /// Ownership scope. + pub scope: Scope, + /// Location of the scope keyword. + pub scope_span: Span, + /// State name. + pub name: Ident, + /// Fields in declaration order. + pub fields: Vec, +} + +/// A named record with typed fields. +#[derive(Debug, Clone)] +pub struct StructItem { + /// Type parameters specialized in each concrete record layout. + pub generics: Vec, + /// Type name. + pub name: Ident, + /// Fields in declaration order. + pub fields: Vec, +} + +/// A named method contract. +#[derive(Debug, Clone)] +pub struct TraitItem { + /// Contract name. + pub name: Ident, + /// Methods required by this contract. + pub methods: Vec, +} + +/// The source signature of a required method. +#[derive(Debug, Clone)] +pub struct TraitMethod { + /// Method name. + pub name: Ident, + /// Optional value or borrowed receiver. + pub receiver: Option, + /// Explicit parameters. + pub params: Vec, + /// Declared return type. + pub ret: Option, +} + +/// An inherent implementation for a State or struct. +#[derive(Debug, Clone)] +pub struct ImplItem { + /// Contract implemented by this block, if any. + pub contract: Option, + /// Type parameters bound by the implemented type. + pub generics: Vec, + /// Implemented type. + pub target: Path, + /// Functions declared inside the implementation. + pub methods: Vec, +} + +/// The explicit `self` parameter of a method. +#[derive(Debug, Clone)] +pub struct Receiver { + /// Whether writes through this receiver are allowed. + pub mutable: bool, + /// Whether the receiver uses `&` syntax. + pub borrowed: bool, + /// Source location. + pub span: Span, +} + +/// One State field. +#[derive(Debug, Clone)] +pub struct Field { + /// Whether this struct field is public outside its module. + pub is_pub: bool, + /// Documentation lines. + pub docs: Vec, + /// Field attributes such as `#[clamp(0..=100)]`. + pub attrs: Vec, + /// Field name. + pub name: Ident, + /// Field value type. + pub ty: Type, + /// Default value. + pub default: Option, + /// Location of the whole field. + pub span: Span, +} + +/// A state machine over one integer or enum State field. +#[derive(Debug, Clone)] +pub struct FlowItem { + /// Flow name. + pub name: Ident, + /// The driven field. + pub on: Place, + /// Transitions in declaration order. + pub transitions: Vec, + /// Hooks in declaration order. + pub hooks: Vec, + /// Recovered malformed entries. + pub errors: Vec, +} + +/// `From -> To if cond priority n;`. +#[derive(Debug, Clone)] +pub struct Transition { + /// Source phase. + pub from: Expr, + /// Destination phase. + pub to: Expr, + /// Optional guard. + pub guard: Option, + /// Optional priority. + pub priority: Option, + /// Location of the whole transition. + pub span: Span, +} + +/// The lifecycle point a hook runs at. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum HookPhase { + /// After entering the phase. + Enter, + /// Before leaving the phase. + Exit, + /// Each cycle while in the phase. + Tick, +} + +/// `enter Phase => function;` or `tick Phase every 2 { ... }`. +#[derive(Debug, Clone)] +pub struct Hook { + /// Lifecycle point. + pub phase: HookPhase, + /// Phase that triggers the hook. + pub state: Expr, + /// Tick cadence. + pub every: Option, + /// Named function or inline body. + pub target: HookTarget, + /// Location of the whole hook. + pub span: Span, +} + +/// What a hook runs. +#[derive(Debug, Clone)] +pub enum HookTarget { + /// A named function. + Function(Path), + /// An inline body compiled into a generated function. + Block(Block), +} + +/// `event Name(params);`: a custom event. +#[derive(Debug, Clone)] +pub struct EventItem { + /// Event name. + pub name: Ident, + /// Payload passed to every handler. + pub params: Vec, +} + +/// The kind of a data resource declaration. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum DataKind { + /// `item Name { ... }`: a custom item. + Item, + /// `recipe Name { ... }`. + Recipe, + /// `tag Name: Item { values: [...] }`. + Tag, + /// `bossbar Name { title: "..." }`. + BossBar, + /// `loot Name { items: [...] }`. + Loot, + /// `damage_type Name { message_id: "..." }`. + DamageType, + /// `predicate Name { ... }`. + Predicate, + /// `advancement Name { ... }`. + Advancement, + /// `dialog Name { ... }`. + Dialog, + Dimension, + Biome, + StructureTemplate, + InventoryTransfer, + Hud, + Menu, +} + +impl DataKind { + /// Source keyword. + pub fn keyword(self) -> &'static str { + match self { + DataKind::Item => "item", + DataKind::Recipe => "recipe", + DataKind::Tag => "tag", + DataKind::BossBar => "bossbar", + DataKind::Loot => "loot", + DataKind::DamageType => "damage_type", + DataKind::Predicate => "predicate", + DataKind::Advancement => "advancement", + DataKind::Dialog => "dialog", + DataKind::Dimension => "dimension", + DataKind::Biome => "biome", + DataKind::StructureTemplate => "structure_template", + DataKind::InventoryTransfer => "inventory_transfer", + DataKind::Hud => "hud", + DataKind::Menu => "menu", + } + } +} + +/// A data resource declaration such as `item RubySword { ... }`. +#[derive(Debug, Clone)] +pub struct DataItem { + /// Resource kind. + pub kind: DataKind, + /// Declared name. + pub name: Ident, + /// The grouped type of a `tag`, such as `Item` in `tag Ores: Item`. + pub tag_type: Option, + /// Fields in source order. + pub fields: Vec, + /// The `{ ... }` body. + pub body: Span, +} + +/// One `key: value` field. +#[derive(Debug, Clone)] +pub struct DataField { + /// Field name (an identifier or a quoted string). + pub key: Ident, + /// Field value. + pub value: DataValue, + /// Whole field. + pub span: Span, +} + +/// A field value. +#[derive(Debug, Clone)] +pub enum DataValue { + /// A single expression: a string, number, path, or typed value. + Expr(Expr), + /// `[a, b, ...]`. + Array(Vec, Span), + /// `{ key: value, ... }`. + Object(Vec, Span), +} + +impl DataValue { + /// Location of the value. + pub fn span(&self) -> Span { + match self { + DataValue::Expr(expr) => expr.span(), + DataValue::Array(_, span) | DataValue::Object(_, span) => *span, + } + } +} + +/// A function parameter: `name: Type`. +#[derive(Debug, Clone)] +pub struct Param { + /// Whether this parameter can be reassigned with `mut`. + pub mutable: bool, + /// Parameter name. + pub name: Ident, + /// Parameter type. + pub ty: Type, + /// Whole parameter. + pub span: Span, +} + +/// A function definition. +#[derive(Debug, Clone)] +pub struct FnItem { + /// Required traits, paired with their declared type parameters. + pub bounds: Vec<(Ident, Path)>, + /// Type parameters specialized for each concrete call. + pub generics: Vec, + /// Optional method receiver; valid only inside an impl. + pub receiver: Option, + /// Function name. + pub name: Ident, + /// Parameters in order. + pub params: Vec, + /// Declared return type. + pub ret: Option, + /// Body. + pub body: Block, +} + +/// An external function implemented outside this pack. +#[derive(Debug, Clone)] +pub struct ExternFnItem { + /// Minecraft function identity. + pub id: String, + /// Location of the identity string. + pub id_span: Span, + /// Local name. + pub name: Ident, +} + +/// A `{ ... }` statement block. +#[derive(Debug, Clone)] +pub struct Block { + /// Statements in order. + pub stmts: Vec, + /// Location including braces. + pub span: Span, +} + +/// A statement. +#[derive(Debug, Clone)] +pub enum Stmt { + /// A method call or evaluated value statement. + Expr(Expr, Span), + /// `let mut name: Type = value;`. + Let { + /// Whether the binding is `mut`. + mutable: bool, + /// Bound name. + name: Ident, + /// Declared type. + ty: Option, + /// Initial value. + value: Option, + /// Whole statement. + span: Span, + }, + /// Irrefutable destructuring of an owned record or fixed array value. + Destructure { + pattern: Pattern, + ty: Option, + value: Expr, + span: Span, + }, + /// `return;` or `return value;`. + Return { + /// Returned value. + value: Option, + /// Whole statement. + span: Span, + }, + /// `continue;`: skip to the next pass of the innermost loop. + Continue(Span), + /// `break;`: leave the innermost `while`, `loop`, or counting `for`. + Break(Span), + /// `emit Event(args);`: run every handler of a custom event. + Emit { + /// The emitted event. + event: Path, + /// Payload arguments, in order. + args: Vec, + /// Whole statement. + span: Span, + }, + /// `loop { ... }`: repeat until `break` or `return`. + Loop { + /// Repeated body. + body: Block, + /// Whole statement. + span: Span, + }, + /// Iterate an independent snapshot of a fixed-size array. + ForValues { + /// Immutable element binding. + binding: Ident, + /// Array expression, evaluated once. + value: Expr, + /// Loop body. + body: Block, + /// Whole statement. + span: Span, + }, + /// `for i in start..end { ... }`: count through a range of numbers. + ForRange { + /// Loop variable. + binding: Ident, + /// Counted range; `..=` includes the end. + range: Range, + /// Iterate from the last included value down to the start. + reverse: bool, + /// Positive constant increment magnitude, defaulting to one. + step: Option, + /// Loop body. + body: Block, + /// Whole statement. + span: Span, + }, + /// Select one exhaustive arm after evaluating the value once. + Match { + /// Matched value. + value: Expr, + /// Arms in source order. + arms: Vec, + /// Whole statement. + span: Span, + }, + /// `while condition { ... }`. + While { + /// Checked before every pass. + cond: Cond, + /// Repeated body. + body: Block, + /// Whole statement. + span: Span, + }, + /// `target = expr;`, `target += expr;`, and the other compound forms. + Assign { + /// Assigned field or local. + target: AssignTarget, + /// Operator. + op: AssignOp, + /// Constant value. + value: Expr, + /// Whole statement. + span: Span, + }, + /// `name(args);`. + Call { + /// Called function or builtin. + path: Path, + /// Arguments in source order. + args: Vec, + /// Whole statement. + span: Span, + }, + /// `name!(args);`, such as `chat!("Hi {player}")` or `raw!("say hi")`. + Macro { + /// Macro name. + name: Ident, + /// Arguments in source order. + args: Vec, + /// Whole statement. + span: Span, + }, + /// `if cond { } else { }`. + If(Box), + /// `for player in players() { }`. + For { + /// Loop binding. + binding: Ident, + /// Iterator source. + source: Path, + /// Iterator arguments, such as `entities(type = Entity::Zombie)`. + args: Vec, + /// Loop body. + body: Block, + /// Whole statement. + span: Span, + }, + /// A recovered malformed statement. + Error(SyntaxError), +} + +/// An irrefutable value pattern. Bindings receive independent owned copies. +#[derive(Debug, Clone)] +pub enum Pattern { + /// A binding, with optional per-binding mutability. + Bind { name: Ident, mutable: bool }, + /// Ignore this value. + Ignore(Span), + /// A record's named fields; `rest` permits omitted fields. + Record { + path: Path, + fields: Vec<(Ident, Pattern)>, + rest: bool, + span: Span, + }, + /// An exact-length fixed array pattern. + Array(Vec, Span), +} + +impl Pattern { + /// Location of the whole pattern. + pub fn span(&self) -> Span { + match self { + Self::Bind { name, .. } => name.span, + Self::Ignore(span) | Self::Array(_, span) | Self::Record { span, .. } => *span, + } + } +} + +/// A selector for one match arm. +#[derive(Debug, Clone)] +pub enum MatchPattern { + /// Covers every remaining value without introducing bindings. + Wildcard, + /// Constant alternatives separated by `|`. + Constants(Vec), + /// Copies some or all of the matched value into arm-local bindings. + Binding(Pattern), +} + +/// One arm of a `match` statement. +#[derive(Debug, Clone)] +pub struct MatchArm { + /// Selector and any local bindings. + pub pattern: MatchPattern, + /// Optional condition evaluated after the pattern matches. + pub guard: Option, + /// Body scoped to this arm. + pub body: Block, + /// Whole arm. + pub span: Span, +} + +/// One value-producing match arm. Only the selected expression is evaluated. +#[derive(Debug, Clone)] +pub struct MatchValueArm { + /// Selector and any local bindings. + pub pattern: MatchPattern, + /// Optional condition evaluated after the pattern matches. + pub guard: Option, + /// Value produced by this arm. + pub value: Expr, + /// Whole arm. + pub span: Span, +} + +/// An `if` statement. +#[derive(Debug, Clone)] +pub struct IfStmt { + /// Condition. + pub cond: Cond, + /// Taken branch. + pub then: Block, + /// `else` branch. + pub otherwise: Option, + /// Whole statement. + pub span: Span, +} + +/// The `else` part of an `if`. +#[derive(Debug, Clone)] +pub enum Else { + /// `else if ...`. + If(Box), + /// `else { ... }`. + Block(Block), +} + +/// The left-hand side of an assignment. +#[derive(Debug, Clone)] +pub enum AssignTarget { + /// A State field. + Place(Place), + /// A local variable or parameter. + Local(Ident), + /// An indexed or projected writable value. + Value(Box), +} + +impl AssignTarget { + /// Location of the target. + pub fn span(&self) -> Span { + match self { + AssignTarget::Place(place) => place.span, + AssignTarget::Local(ident) => ident.span, + AssignTarget::Value(value) => value.span(), + } + } +} + +/// Assignment operators. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum AssignOp { + /// `=`. + Set, + /// `+=`. + Add, + /// `-=`. + Sub, + /// `*=`. + Mul, + /// `/=`. + Div, + /// `%=`. + Rem, +} + +/// `State.field`. +#[derive(Debug, Clone)] +pub struct Place { + /// State path. + pub state: Path, + /// Field name. + pub field: Ident, + /// Further record-field projections. + pub projections: Vec, + /// Whole place. + pub span: Span, +} + +/// A boolean condition over State fields. +#[derive(Debug, Clone)] +pub enum Cond { + /// `a || b`. + Or(Box, Box), + /// `a && b`. + And(Box, Box), + /// `!a`. + Not(Box, Span), + /// `lhs op rhs`. + Compare { + /// Left operand. + lhs: Expr, + /// Operator. + op: CmpOp, + /// Right operand. + rhs: Expr, + /// Whole comparison. + span: Span, + }, + /// A boolean value tested directly: `if ready { ... }`. + Value(Expr), + /// A predicate call such as `has_state(Mana)`. + Call { + /// Called predicate. + path: Path, + /// Arguments. + args: Vec, + /// Whole call. + span: Span, + }, + /// `value in range`. + InRange { + /// Tested value. + value: Expr, + /// Range. + range: Range, + /// Whole test. + span: Span, + }, +} + +impl Cond { + /// Location of the whole condition. + pub fn span(&self) -> Span { + match self { + Cond::Or(a, b) | Cond::And(a, b) => a.span().to(b.span()), + Cond::Not(_, span) + | Cond::Compare { span, .. } + | Cond::InRange { span, .. } + | Cond::Call { span, .. } => *span, + Cond::Value(expr) => expr.span(), + } + } +} + +/// Comparison operators. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum CmpOp { + /// `==`. + Eq, + /// `!=`. + Ne, + /// `<`. + Lt, + /// `<=`. + Le, + /// `>`. + Gt, + /// `>=`. + Ge, +} + +impl CmpOp { + /// The operator that holds when operands are swapped. + pub fn flipped(self) -> CmpOp { + match self { + CmpOp::Lt => CmpOp::Gt, + CmpOp::Le => CmpOp::Ge, + CmpOp::Gt => CmpOp::Lt, + CmpOp::Ge => CmpOp::Le, + other => other, + } + } +} + +/// A constant range `a..b` or `a..=b`; either end may be omitted. +#[derive(Debug, Clone)] +pub struct Range { + /// Lower bound. + pub start: Option, + /// Upper bound. + pub end: Option, + /// Whether the upper bound is inclusive. + pub inclusive: bool, + /// Whole range. + pub span: Span, +} + +/// One call or macro argument, optionally named. +#[derive(Debug, Clone)] +pub struct Arg { + /// Name for `name = value` arguments. + pub name: Option, + /// Argument value. + pub value: ArgValue, + /// Whole argument. + pub span: Span, +} + +/// An argument value. +#[derive(Debug, Clone)] +pub enum ArgValue { + /// An expression. + Expr(Expr), + /// A range such as `1..=6`. + Range(Range), +} + +impl ArgValue { + /// Location of the value. + pub fn span(&self) -> Span { + match self { + ArgValue::Expr(expr) => expr.span(), + ArgValue::Range(range) => range.span, + } + } +} + +/// One authored move closure. +#[derive(Debug, Clone)] +pub struct ClosureExpr { + /// Explicitly typed arguments. + pub parameters: Vec, + /// Return annotation, if the closure produces a value. + pub returns: Option, + /// Authored closure body. + pub body: Block, + /// Whole closure. + pub span: Span, +} + +/// An expression: a constant, a State field read, or a builtin call. +#[derive(Debug, Clone)] +pub enum Expr { + /// A callable with an owned snapshot of its captured locals. + Closure(Box), + /// An integer literal. + Int(i64, Span), + /// A decimal literal such as `0.5`. + Float(f64, Span), + /// `true` or `false`. + Bool(bool, Span), + /// A string literal; `raw` keeps the escaped source text for spans. + Str { + /// Unescaped value. + value: String, + /// Text between the quotes, exactly as written. + raw: String, + /// Location including quotes. + span: Span, + }, + /// A homogeneous array literal, evaluated from left to right. + Array(Vec, Span), + /// Repeat one evaluated value a constant number of times. + ArrayRepeat { + value: Box, + length: Box, + span: Span, + }, + /// Scoped statements followed by a value expression. + Block { + /// Statements evaluated before the result. + body: Block, + /// The result expression, without a terminating semicolon. + value: Box, + /// Whole expression. + span: Span, + }, + /// An exhaustive match that evaluates only the selected arm's value. + Match { + value: Box, + arms: Vec, + span: Span, + }, + /// An indexed element of an array value. + Index(Box, Box, Span), + /// A named record literal, evaluated in authored field order. + Struct { + /// Record type. + path: Path, + /// Field initializers. + fields: Vec<(Ident, Expr)>, + /// Whole expression. + span: Span, + }, + /// A call using a value or State receiver. + Method { + /// Receiver expression. + receiver: Box, + /// Method name. + name: Ident, + /// Explicit generic arguments, written `::`. + type_arguments: Vec, + /// Explicit arguments. + args: Vec, + /// Whole expression. + span: Span, + }, + /// A field selected from a computed record value. + Project(Box, Ident, Span), + /// A condition used as a boolean value: `let ok = a > b;`. + Cond(Box, Span), + /// A call such as `random(1..=6)`. + Call { + /// Called builtin. + path: Path, + /// Arguments. + args: Vec, + /// Whole call. + span: Span, + }, + /// A path to a constant, enum variant, or bare variant. + Path(Path), + /// A State field. + Place(Place), + /// Unary negation. + Neg(Box, Span), + /// Binary arithmetic. + Binary(Box, BinOp, Box, Span), + /// `expr as Type`. + Cast(Box, Type, Span), +} + +impl Expr { + /// Location of the expression. + pub fn span(&self) -> Span { + match self { + Expr::Closure(closure) => closure.span, + Expr::Int(_, span) + | Expr::Float(_, span) + | Expr::Bool(_, span) + | Expr::Str { span, .. } + | Expr::Call { span, .. } + | Expr::Struct { span, .. } + | Expr::Method { span, .. } + | Expr::Project(_, _, span) + | Expr::Array(_, span) + | Expr::Match { span, .. } + | Expr::Block { span, .. } + | Expr::ArrayRepeat { span, .. } + | Expr::Index(_, _, span) + | Expr::Cond(_, span) + | Expr::Neg(_, span) + | Expr::Binary(_, _, _, span) + | Expr::Cast(_, _, span) => *span, + Expr::Path(path) => path.span, + Expr::Place(place) => place.span, + } + } +} + +/// Binary arithmetic operators. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum BinOp { + /// `+`. + Add, + /// `-`. + Sub, + /// `*`. + Mul, + /// `/`. + Div, + /// `%`. + Rem, +} diff --git a/sand-lang/src/builtins.rs b/sand-lang/src/builtins.rs new file mode 100644 index 00000000..aec5ac53 --- /dev/null +++ b/sand-lang/src/builtins.rs @@ -0,0 +1,3172 @@ +//! The built-in vocabulary of the Sand language, with its documentation. +//! +//! One table drives argument checking in analysis and the explanations shown +//! by hover and completion, so documentation cannot drift from behaviour. + +/// How a builtin is written. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum BuiltinKind { + /// A statement call: `play_sound("...");`. + Statement, + /// A macro taking a format string: `chat!("...");`. + Macro, + /// An expression: `random(1..=6)`. + Expression, + /// A predicate in a condition: `if has_state(Mana) { ... }`. + Condition, +} + +/// What an argument accepts. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ParamKind { + /// A typed vanilla registry value such as `Item::Diamond`, named by its + /// registry. A namespaced string is accepted for modded or custom values. + Registry(&'static str), + /// A text format string with `{...}` interpolation. + Format, + /// A plain string. + Text, + /// A whole number; individual builtins document whether runtime values are accepted. + Int, + /// A decimal or integer; individual builtins document whether runtime values are accepted. + Number, + /// `true` or `false`. + Bool, + /// A function name. + Function, + /// A constant range such as `1..=6`. + Range, + /// A declared `entity state`. + EntityState, + /// A scoreboard-backed number field on player or entity State. + QueryScore, + /// A compile-time typed Minecraft NBT compound. + NbtCompound, + /// A `timer` State field, written `State.field`. + Timer, + /// A block position: `pos(x, y, z)` or `offset(dx, dy, dz)`. + Position, + /// A declared `bossbar`. + BossBar, + /// A declared or external native predicate resource. + Predicate, + /// A declared or external native advancement. + Advancement, + /// A declared or external native dialog. + Dialog, + /// A declared or external native structure template. + StructureTemplate, + /// An authored inventory transfer definition. + InventoryTransfer, + /// An authored player-owned HUD. + Hud, + /// An authored player-owned dialog menu. + Menu, + /// A declared `loot` table. + Loot, + /// A retained EntityRef value. + EntityRef, + /// A value of the receiver collection's element type. + Value, +} + +/// One builtin parameter. +#[derive(Debug, Clone, Copy)] +pub struct Param { + /// Parameter name, usable as `name = value`. + pub name: &'static str, + /// Accepted value. + pub kind: ParamKind, + /// Whether the argument must be supplied. + pub required: bool, + /// Explanation shown in hover. + pub doc: &'static str, +} + +/// One builtin statement, macro, or expression. +#[derive(Debug, Clone, Copy)] +pub struct Builtin { + /// Source name, without `!` for macros. + pub name: &'static str, + /// How it is written. + pub kind: BuiltinKind, + /// Signature shown in hover and completion. + pub signature: &'static str, + /// One-line summary. + pub summary: &'static str, + /// Longer explanation. + pub details: &'static str, + /// The Minecraft command it becomes. + pub minecraft: &'static str, + /// Whether it needs a player executor. + pub needs_player: bool, + /// Parameters in positional order. + pub params: &'static [Param], + /// Completion snippet. + pub snippet: &'static str, +} + +const fn p(name: &'static str, kind: ParamKind, required: bool, doc: &'static str) -> Param { + Param { + name, + kind, + required, + doc, + } +} + +const FORMAT_DOC: &str = "Text with `{...}` interpolation: `{State.field}` shows a live score, `{player}` the player's name, and `{gold}`, `{bold}`, `{italic}`, `{underlined}`, `{reset}` change the style of the text that follows. Write `{{` and `}}` for literal braces. Use `Text::translate(\"key\", ...)` for client-localized text."; + +/// Filters shared by `entities(...)` and `count_entities(...)`. +const QUERY: &[Param] = &[ + p( + "type", + ParamKind::Registry("Entity"), + false, + "Only this entity type, such as `Entity::Zombie`.", + ), + p( + "tag", + ParamKind::Text, + false, + "Only entities with this tag.", + ), + p( + "distance", + ParamKind::Range, + false, + "Only entities this far from the executor, such as `..=16`.", + ), + p( + "with", + ParamKind::EntityState, + false, + "Only entities with this `entity state` attached.", + ), + p( + "limit", + ParamKind::Int, + false, + "At most this many entities.", + ), + p( + "sort", + ParamKind::Registry("Sort"), + false, + "Order before `limit`: `Sort::Nearest`, `Sort::Furthest`, `Sort::Random`, or `Sort::Arbitrary`.", + ), + p( + "score", + ParamKind::QueryScore, + false, + "Filter a number field on each candidate.", + ), + p( + "score_range", + ParamKind::Range, + false, + "Required bounds or exact number for the scoreboard filter.", + ), + p( + "nbt", + ParamKind::NbtCompound, + false, + "Match static entity data, such as Nbt { Silent: true }.", + ), +]; + +/// Builtins that act on the executing entity (`@s`), so they need a player or +/// an entity to run as. +pub const EXECUTOR_BUILTINS: &[&str] = &[ + "kill", + "add_tag", + "remove_tag", + "damage", + "attach_state", + "detach_state", + "teleport", + "teleport_by", + "set_velocity", + "teleport_to", + "mount", + "dismount", + "wait", + "cancel_waits", + "holding", + "equip", + "clear_equipment", + "is_sneaking", + "is_sprinting", + "is_swimming", + "is_on_fire", +]; + +/// Every builtin, in documentation order. +pub const BUILTINS: &[Builtin] = &[ + Builtin { + name: "wait", + kind: BuiltinKind::Statement, + signature: "wait(ticks?, seconds?)", + summary: "Resume this function later with its own local values.", + details: "Use one positive number duration in a function body or an if/else branch with an entity executor. The continuation keeps its locals and original execution position. Invalid runtime durations continue immediately. Player and entity State are read live when it resumes.", + minecraft: "Start a canonical owner-bound Sand lifetime.", + needs_player: false, + params: &[ + p("ticks", ParamKind::Int, false, "Loaded Minecraft ticks."), + p( + "seconds", + ParamKind::Int, + false, + "Seconds at twenty game ticks per second.", + ), + ], + snippet: "wait(${1:20})", + }, + Builtin { + name: "cancel_waits", + kind: BuiltinKind::Statement, + signature: "cancel_waits()", + summary: "Cancel outstanding waits for the executing entity.", + details: "Cleans up this entity's pending continuations in the current pack. Other owners' waits continue.", + minecraft: "Cancel the executor's instances of the pack's wait lifetimes.", + needs_player: false, + params: &[], + snippet: "cancel_waits()", + }, + Builtin { + name: "mount", + kind: BuiltinKind::Statement, + signature: "mount(vehicle)", + summary: "Mount the executing entity on a retained vehicle.", + details: "The vehicle must be a loaded non-player entity in the current dimension. Missing and empty references do nothing. Vanilla checks whether mounting is possible.", + minecraft: "ride @s mount ", + needs_player: false, + params: &[p( + "vehicle", + ParamKind::EntityRef, + true, + "Retained reference to the vehicle.", + )], + snippet: "mount(${1:vehicle})", + }, + Builtin { + name: "dismount", + kind: BuiltinKind::Statement, + signature: "dismount()", + summary: "Dismount the executing entity from its current vehicle.", + details: "The entity remains at the position chosen by vanilla for dismounting.", + minecraft: "ride @s dismount", + needs_player: false, + params: &[], + snippet: "dismount()", + }, + Builtin { + name: "entity_ref", + kind: BuiltinKind::Expression, + signature: "entity_ref(relation?) -> EntityRef", + summary: "Retain the executing entity or one related entity.", + details: "The identity survives reload and can be stored in State or records. It is pack-owned and never reused. A missing relation or exhausted identity allocation returns an empty reference. Resolve players across dimensions; other entities resolve while loaded in the current dimension.", + minecraft: "Capture the canonical Sand runtime owner identity.", + needs_player: false, + params: &[p( + "relation", + ParamKind::Registry("Relation"), + false, + "Read one related entity, such as `Relation::Owner` or `Relation::Vehicle`. Omit this argument to retain the executor.", + )], + snippet: "entity_ref()", + }, + Builtin { + name: "resolve_entity", + kind: BuiltinKind::Expression, + signature: "resolve_entity(reference)", + summary: "Run a loop body as a retained entity when it is present.", + details: "Use `for entity in resolve_entity(reference) { ... }`. Missing or unloaded entities skip the body. The body is positioned at the entity; references remain valid outside this loop.", + minecraft: "Resolve a canonical Sand runtime owner score.", + needs_player: false, + params: &[p( + "reference", + ParamKind::EntityRef, + true, + "Retained entity identity.", + )], + snippet: "resolve_entity(${1:reference})", + }, + Builtin { + name: "resolve_player", + kind: BuiltinKind::Expression, + signature: "resolve_player(reference)", + summary: "Run a loop body as an online retained player.", + details: "Use `for player in resolve_player(reference) { ... }`. Offline players or references to non-player entities skip the body. Online players resolve across dimensions.", + minecraft: "Resolve a canonical Sand runtime owner score on @a.", + needs_player: false, + params: &[p( + "reference", + ParamKind::EntityRef, + true, + "Retained entity identity.", + )], + snippet: "resolve_player(${1:reference})", + }, + Builtin { + name: "start_timer", + kind: BuiltinKind::Statement, + signature: "start_timer(State.field, ticks = .. | seconds = ..)", + summary: "Start a `timer` field counting down.", + details: "Give exactly one of `ticks` (20 per second) or `seconds`; both accept runtime number values. Invalid runtime durations leave the timer unchanged (ticks 1..=2147483647, seconds 1..=107374182). Starting a running timer restarts it. Timers are numbers of ticks left, so you can also read and compare them.", + minecraft: "scoreboard players set ", + needs_player: false, + params: &[ + p("timer", ParamKind::Timer, true, "The `timer` field."), + p("ticks", ParamKind::Int, false, "Duration in game ticks."), + p("seconds", ParamKind::Int, false, "Duration in seconds."), + ], + snippet: "start_timer(${1:State.field}, seconds = ${2:5});", + }, + Builtin { + name: "stop_timer", + kind: BuiltinKind::Statement, + signature: "stop_timer(State.field)", + summary: "Stop a `timer` field, so it reads as done.", + details: "Sets the time left to zero.", + minecraft: "scoreboard players set 0", + needs_player: false, + params: &[p("timer", ParamKind::Timer, true, "The `timer` field.")], + snippet: "stop_timer(${1:State.field});", + }, + Builtin { + name: "timer_running", + kind: BuiltinKind::Condition, + signature: "timer_running(State.field)", + summary: "Whether a `timer` field still has time left.", + details: "Use it as a cooldown check: `if timer_running(Ability.dash) { return; }`.", + minecraft: "execute if score matches 1..", + needs_player: false, + params: &[p("timer", ParamKind::Timer, true, "The `timer` field.")], + snippet: "timer_running(${1:State.field})", + }, + Builtin { + name: "timer_done", + kind: BuiltinKind::Condition, + signature: "timer_done(State.field)", + summary: "Whether a `timer` field has reached zero.", + details: "True before the timer is first started.", + minecraft: "execute if score matches 0", + needs_player: false, + params: &[p("timer", ParamKind::Timer, true, "The `timer` field.")], + snippet: "timer_done(${1:State.field})", + }, + Builtin { + name: "any_entities", + kind: BuiltinKind::Condition, + signature: "any_entities(type?, tag?, distance?, with?, limit?, sort?, score?, score_range?, nbt?)", + summary: "Whether at least one entity matches the filters.", + details: "Takes the same filters as `entities(..)`. Distances are measured from the executor.", + minecraft: "execute if entity @e[...]", + needs_player: false, + params: QUERY, + snippet: "any_entities(type = Entity::${1:Zombie})", + }, + Builtin { + name: "entity_data_number", + kind: BuiltinKind::Expression, + signature: "entity_data_number(path) -> number", + summary: "Read the integer result of an NBT query on the executing entity.", + details: "Use a literal NBT path. Vanilla returns numeric values and collection lengths. A failed read produces zero.", + minecraft: "execute store result score ... run data get entity @s ", + needs_player: false, + params: &[p( + "path", + ParamKind::Text, + true, + "Checked NBT path written as a quoted literal.", + )], + snippet: "entity_data_number(\"${1:Air}\")", + }, + Builtin { + name: "inventory_count", + kind: BuiltinKind::Expression, + signature: "inventory_count(item) -> number", + summary: "Count matching items in the executing player's inventory.", + details: "Pass a vanilla item or a declared custom item. This query leaves the inventory intact.", + minecraft: "execute store result score ... run clear @s 0", + needs_player: true, + params: &[p( + "item", + ParamKind::Registry("Item"), + true, + "The matching item.", + )], + snippet: "inventory_count(Item::${1:Bread})", + }, + Builtin { + name: "block_data_number", + kind: BuiltinKind::Expression, + signature: "block_data_number(at, path) -> number", + summary: "Read the integer result of a block entity data query.", + details: "Reads a numeric tag or the size of a collection using vanilla data results. A failed read produces zero.", + minecraft: "execute store result score ... run data get block ", + needs_player: false, + params: &[ + p( + "at", + ParamKind::Position, + true, + "Position of a block entity.", + ), + p( + "path", + ParamKind::Text, + true, + "Checked NBT path written as a quoted literal.", + ), + ], + snippet: "block_data_number(${1:at}, \"${2:path}\")", + }, + Builtin { + name: "set_block_data", + kind: BuiltinKind::Statement, + signature: "set_block_data(at, path, value)", + summary: "Write typed NBT to a block entity.", + details: "Accepts a runtime number or a typed NBT literal, including compounds, lists, and strings. Minecraft applies the block entity's own data rules.", + minecraft: "data modify block set value ", + needs_player: false, + params: &[ + p( + "at", + ParamKind::Position, + true, + "Position of a block entity.", + ), + p( + "path", + ParamKind::Text, + true, + "Checked NBT path written as a quoted literal.", + ), + p( + "value", + ParamKind::Value, + true, + "Typed NBT literal or runtime integer.", + ), + ], + snippet: "set_block_data(${1:at}, \"${2:path}\", ${3:value})", + }, + Builtin { + name: "copy_block_data", + kind: BuiltinKind::Statement, + signature: "copy_block_data(from, source_path, to, destination_path)", + summary: "Copy a native value between loaded block entities.", + details: "The checked paths select the source and destination values. Both positions may be relative.", + minecraft: "data modify block set from block ", + needs_player: false, + params: &[ + p("from", ParamKind::Position, true, "Source block entity."), + p("source_path", ParamKind::Text, true, "Path in the source."), + p("to", ParamKind::Position, true, "Destination block entity."), + p( + "destination_path", + ParamKind::Text, + true, + "Path in the destination.", + ), + ], + snippet: "copy_block_data(${1:from}, \"${2:source_path}\", ${3:to}, \"${4:destination_path}\")", + }, + Builtin { + name: "remove_block_data", + kind: BuiltinKind::Statement, + signature: "remove_block_data(at, path)", + summary: "Remove a path from a block entity's NBT.", + details: "Uses a checked NBT path. An absent or immutable selection has no effect.", + minecraft: "data remove block ", + needs_player: false, + params: &[ + p( + "at", + ParamKind::Position, + true, + "Position of a block entity.", + ), + p( + "path", + ParamKind::Text, + true, + "Checked NBT path written as a quoted literal.", + ), + ], + snippet: "remove_block_data(${1:at}, \"${2:path}\")", + }, + Builtin { + name: "block_is", + kind: BuiltinKind::Condition, + signature: "block_is(Block::..., position)", + summary: "Whether a position holds a block, or a block of a `tag`.", + details: "Write the position as `pos(x, y, z)` or `offset(dx, dy, dz)`: `if block_is(Block::Water, offset(0, -1, 0)) { ... }`.", + minecraft: "execute if block ", + needs_player: false, + params: &[ + p( + "block", + ParamKind::Registry("Block"), + true, + "Block, or a declared `Block` tag.", + ), + p("at", ParamKind::Position, true, "Position to test."), + ], + snippet: "block_is(Block::${1:Stone}, offset(${2:0}, ${3:-1}, ${4:0}))", + }, + Builtin { + name: "biome_is", + kind: BuiltinKind::Condition, + signature: "biome_is(biome, at)", + summary: "Whether a block position is in the given biome.", + details: "Uses the biome registry for the pack's Minecraft target. Use `pos(...)` or `offset(...)` for the position and a namespaced identity for a custom biome.", + minecraft: "execute if biome ", + needs_player: false, + params: &[ + p( + "biome", + ParamKind::Registry("Biome"), + true, + "Biome to test, such as `Biome::Plains`.", + ), + p( + "at", + ParamKind::Position, + true, + "Position whose biome is tested.", + ), + ], + snippet: "biome_is(Biome::${1:Plains}, offset(0, 0, 0))", + }, + Builtin { + name: "dimension_is", + kind: BuiltinKind::Condition, + signature: "dimension_is(dimension)", + summary: "Whether commands are running in the given dimension.", + details: "Tests the current execution context. It also works in server functions and inside `in_dimension`.", + minecraft: "execute if dimension ", + needs_player: false, + params: &[p( + "dimension", + ParamKind::Registry("Dimension"), + true, + "A vanilla dimension or a custom namespaced dimension.", + )], + snippet: "dimension_is(Dimension::${1:Overworld})", + }, + Builtin { + name: "in_dimension", + kind: BuiltinKind::Statement, + signature: "in_dimension(dimension, function)", + summary: "Call a function in the selected dimension.", + details: "Keeps the current executor. Vanilla scales horizontal coordinates when crossing between the Overworld and Nether. The original execution context remains available to subsequent statements.", + minecraft: "execute in run function ", + needs_player: false, + params: &[ + p( + "dimension", + ParamKind::Registry("Dimension"), + true, + "A vanilla dimension or a custom namespaced dimension.", + ), + p( + "function", + ParamKind::Function, + true, + "A parameterless function to call.", + ), + ], + snippet: "in_dimension(Dimension::${1:TheNether}, ${2:run})", + }, + Builtin { + name: "clone_blocks", + kind: BuiltinKind::Statement, + signature: "clone_blocks(from, to, destination, masked?, filter?, mode?)", + summary: "Copy or move a region of blocks.", + details: "The source corners are inclusive. All positions may be absolute or relative. Masked copies skip air. Use a block or block tag filter to copy only matches. `CloneMode::Move` also clears the copied source blocks.", + minecraft: "clone [mask] [mode]", + needs_player: false, + params: &[ + p("from", ParamKind::Position, true, "One source corner."), + p("to", ParamKind::Position, true, "Opposite source corner."), + p( + "destination", + ParamKind::Position, + true, + "Lower corner of the destination.", + ), + p("masked", ParamKind::Bool, false, "Skip air blocks."), + p( + "filter", + ParamKind::Registry("Block"), + false, + "Clone only this block or a declared block tag.", + ), + p( + "mode", + ParamKind::Registry("CloneMode"), + false, + "Normal, Force, or Move.", + ), + ], + snippet: "clone_blocks(${1:from}, ${2:to}, ${3:destination})", + }, + Builtin { + name: "holding", + kind: BuiltinKind::Condition, + signature: "holding(item, offhand = false, slot?)", + summary: "Whether the executing entity has an item in a hand or armor slot.", + details: "The default slot is the main hand. Choose either offhand or an explicit slot. Custom items match by identity.", + minecraft: "execute if items entity @s weapon.mainhand ", + needs_player: false, + params: &[ + p( + "item", + ParamKind::Registry("Item"), + true, + "Item or custom item.", + ), + p( + "offhand", + ParamKind::Bool, + false, + "Test the off hand instead.", + ), + p( + "slot", + ParamKind::Registry("EquipmentSlot"), + false, + "Explicit hand or armor slot.", + ), + ], + snippet: "holding(Item::${1:Diamond})", + }, + Builtin { + name: "equip", + kind: BuiltinKind::Statement, + signature: "equip(item, slot, count = 1)", + summary: "Replace one of the executing entity's equipment slots.", + details: "Use a vanilla or declared custom item. Replaces the existing stack and supports constant counts from 1 to 99.", + minecraft: "item replace entity @s with [count]", + needs_player: false, + params: &[ + p( + "item", + ParamKind::Registry("Item"), + true, + "Item or custom item.", + ), + p( + "slot", + ParamKind::Registry("EquipmentSlot"), + true, + "Hand or armor slot.", + ), + p( + "count", + ParamKind::Int, + false, + "Number of items in the new stack.", + ), + ], + snippet: "equip(Item::${1:IronHelmet}, EquipmentSlot::${2:Head})", + }, + Builtin { + name: "clear_equipment", + kind: BuiltinKind::Statement, + signature: "clear_equipment(slot)", + summary: "Clear one hand or armor slot on the executing entity.", + details: "The previous stack is discarded.", + minecraft: "item replace entity @s with air", + needs_player: false, + params: &[p( + "slot", + ParamKind::Registry("EquipmentSlot"), + true, + "Hand or armor slot.", + )], + snippet: "clear_equipment(EquipmentSlot::${1:Head})", + }, + Builtin { + name: "is_sneaking", + kind: BuiltinKind::Condition, + signature: "is_sneaking()", + summary: "Whether the executing entity is crouching.", + details: "Checked at the moment the condition runs.", + minecraft: "execute if predicate ", + needs_player: false, + params: &[], + snippet: "is_sneaking()", + }, + Builtin { + name: "is_sprinting", + kind: BuiltinKind::Condition, + signature: "is_sprinting()", + summary: "Whether the executing entity is sprinting.", + details: "Checked at the moment the condition runs.", + minecraft: "execute if predicate ", + needs_player: false, + params: &[], + snippet: "is_sprinting()", + }, + Builtin { + name: "is_swimming", + kind: BuiltinKind::Condition, + signature: "is_swimming()", + summary: "Whether the executing entity is swimming.", + details: "Checked at the moment the condition runs.", + minecraft: "execute if predicate ", + needs_player: false, + params: &[], + snippet: "is_swimming()", + }, + Builtin { + name: "is_on_fire", + kind: BuiltinKind::Condition, + signature: "is_on_fire()", + summary: "Whether the executing entity is burning.", + details: "Checked at the moment the condition runs.", + minecraft: "execute if predicate ", + needs_player: false, + params: &[], + snippet: "is_on_fire()", + }, + Builtin { + name: "place_template", + kind: BuiltinKind::Statement, + signature: "place_template(template, at)", + summary: "Place a native structure template into the world.", + details: "Use a declared template or a quoted namespaced identity and an absolute or relative block position. The destination chunks must be loaded.", + minecraft: "place template