From 0210c970f24545ca664ec2dca925c8f5083eaa27 Mon Sep 17 00:00:00 2001 From: Asger F Date: Wed, 6 May 2026 15:46:44 +0200 Subject: [PATCH 1/7] Add tree-sitter for Swift (called 'unified') --- Cargo.lock | 28 + Cargo.toml | 1 + MODULE.bazel | 1 + .../tree_sitter_extractors_deps/BUILD.bazel | 12 + .../BUILD.tree-sitter-swift-0.7.2.bazel | 166 + .../tree_sitter_extractors_deps/defs.bzl | 50 + unified/.gitignore | 6 + unified/BUILD.bazel | 57 + unified/codeql-extractor.yml | 17 + unified/extractor/BUILD.bazel | 19 + unified/extractor/Cargo.toml | 22 + unified/extractor/src/autobuilder.rs | 20 + unified/extractor/src/extractor.rs | 43 + unified/extractor/src/generator.rs | 27 + unified/extractor/src/main.rs | 23 + unified/ql/lib/BUILD.bazel | 13 + unified/ql/lib/codeql/Locations.qll | 70 + unified/ql/lib/codeql/files/FileSystem.qll | 38 + unified/ql/lib/codeql/unified/Ast.qll | 2842 +++++++++++++++++ unified/ql/lib/qlpack.lock.yml | 4 + unified/ql/lib/qlpack.yml | 11 + unified/ql/lib/unified.dbscheme | 2741 ++++++++++++++++ unified/ql/lib/unified.dbscheme.stats | 4 + unified/ql/src/qlpack.lock.yml | 4 + unified/ql/src/qlpack.yml | 11 + .../library-tests/BasicTest/test.expected | 100 + .../ql/test/library-tests/BasicTest/test.ql | 5 + .../test/library-tests/BasicTest/test.swift | 88 + unified/ql/test/qlpack.lock.yml | 4 + unified/ql/test/qlpack.yml | 8 + unified/scripts/create-extractor-pack.sh | 25 + unified/tools/BUILD.bazel | 11 + unified/tools/autobuild.cmd | 5 + unified/tools/autobuild.sh | 3 + unified/tools/index-files.cmd | 9 + unified/tools/index-files.sh | 9 + unified/tools/qltest.cmd | 14 + unified/tools/qltest.sh | 12 + 38 files changed, 6523 insertions(+) create mode 100644 misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.tree-sitter-swift-0.7.2.bazel create mode 100644 unified/.gitignore create mode 100644 unified/BUILD.bazel create mode 100644 unified/codeql-extractor.yml create mode 100644 unified/extractor/BUILD.bazel create mode 100644 unified/extractor/Cargo.toml create mode 100644 unified/extractor/src/autobuilder.rs create mode 100644 unified/extractor/src/extractor.rs create mode 100644 unified/extractor/src/generator.rs create mode 100644 unified/extractor/src/main.rs create mode 100644 unified/ql/lib/BUILD.bazel create mode 100644 unified/ql/lib/codeql/Locations.qll create mode 100644 unified/ql/lib/codeql/files/FileSystem.qll create mode 100644 unified/ql/lib/codeql/unified/Ast.qll create mode 100644 unified/ql/lib/qlpack.lock.yml create mode 100644 unified/ql/lib/qlpack.yml create mode 100644 unified/ql/lib/unified.dbscheme create mode 100644 unified/ql/lib/unified.dbscheme.stats create mode 100644 unified/ql/src/qlpack.lock.yml create mode 100644 unified/ql/src/qlpack.yml create mode 100644 unified/ql/test/library-tests/BasicTest/test.expected create mode 100644 unified/ql/test/library-tests/BasicTest/test.ql create mode 100644 unified/ql/test/library-tests/BasicTest/test.swift create mode 100644 unified/ql/test/qlpack.lock.yml create mode 100644 unified/ql/test/qlpack.yml create mode 100755 unified/scripts/create-extractor-pack.sh create mode 100644 unified/tools/BUILD.bazel create mode 100644 unified/tools/autobuild.cmd create mode 100755 unified/tools/autobuild.sh create mode 100644 unified/tools/index-files.cmd create mode 100755 unified/tools/index-files.sh create mode 100644 unified/tools/qltest.cmd create mode 100755 unified/tools/qltest.sh diff --git a/Cargo.lock b/Cargo.lock index 12be6b1cc435..895349ca6e38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -438,6 +438,24 @@ dependencies = [ "tree-sitter-ruby", ] +[[package]] +name = "codeql-extractor-unified" +version = "0.1.0" +dependencies = [ + "clap", + "codeql-extractor", + "encoding", + "lazy_static", + "rayon", + "regex", + "serde_json", + "tracing", + "tracing-subscriber", + "tree-sitter", + "tree-sitter-embedded-template", + "tree-sitter-swift", +] + [[package]] name = "codeql-rust" version = "0.1.0" @@ -2922,6 +2940,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-swift" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3b98fb6bc8e6a6a10023f401aa6a1858115e849dfaf7de57dd8b8ea0f257bd9" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "triomphe" version = "0.1.14" diff --git a/Cargo.toml b/Cargo.toml index 1e2be0d9ca56..4054c3a50bee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ "shared/yeast", "shared/yeast-macros", "ruby/extractor", + "unified/extractor", "rust/extractor", "rust/extractor/macros", "rust/ast-generator", diff --git a/MODULE.bazel b/MODULE.bazel index e7474e9a393f..ee40f7789e4c 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -153,6 +153,7 @@ use_repo( "vendor_ts__tree-sitter-python-0.23.6", "vendor_ts__tree-sitter-ql-0.23.1", "vendor_ts__tree-sitter-ruby-0.23.1", + "vendor_ts__tree-sitter-swift-0.7.2", "vendor_ts__triomphe-0.1.14", "vendor_ts__ungrammar-1.16.1", "vendor_ts__zstd-0.13.3", diff --git a/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.bazel b/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.bazel index 27d36c221ea4..1d1b47192a26 100644 --- a/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.bazel +++ b/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.bazel @@ -673,6 +673,18 @@ alias( tags = ["manual"], ) +alias( + name = "tree-sitter-swift-0.7.2", + actual = "@vendor_ts__tree-sitter-swift-0.7.2//:tree_sitter_swift", + tags = ["manual"], +) + +alias( + name = "tree-sitter-swift", + actual = "@vendor_ts__tree-sitter-swift-0.7.2//:tree_sitter_swift", + tags = ["manual"], +) + alias( name = "triomphe-0.1.14", actual = "@vendor_ts__triomphe-0.1.14//:triomphe", diff --git a/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.tree-sitter-swift-0.7.2.bazel b/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.tree-sitter-swift-0.7.2.bazel new file mode 100644 index 000000000000..f9bb6fa50c38 --- /dev/null +++ b/misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.tree-sitter-swift-0.7.2.bazel @@ -0,0 +1,166 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @@//misc/bazel/3rdparty:vendor_tree_sitter_extractors +############################################################################### + +load( + "@rules_rust//cargo:defs.bzl", + "cargo_build_script", + "cargo_toml_env_vars", +) +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +cargo_toml_env_vars( + name = "cargo_toml_env_vars", + src = "Cargo.toml", +) + +rust_library( + name = "tree_sitter_swift", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "bindings/rust/lib.rs", + edition = "2018", + rustc_env_files = [ + ":cargo_toml_env_vars", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=tree-sitter-swift", + "manual", + "noclippy", + "norustfmt", + ], + target_compatible_with = select({ + "@rules_rust//rust/platform:aarch64-apple-darwin": [], + "@rules_rust//rust/platform:aarch64-apple-ios": [], + "@rules_rust//rust/platform:aarch64-apple-ios-sim": [], + "@rules_rust//rust/platform:aarch64-linux-android": [], + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [], + "@rules_rust//rust/platform:aarch64-unknown-fuchsia": [], + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [], + "@rules_rust//rust/platform:aarch64-unknown-uefi": [], + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:arm-unknown-linux-musleabi": [], + "@rules_rust//rust/platform:armv7-linux-androideabi": [], + "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [], + "@rules_rust//rust/platform:i686-apple-darwin": [], + "@rules_rust//rust/platform:i686-linux-android": [], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [], + "@rules_rust//rust/platform:i686-unknown-freebsd": [], + "@rules_rust//rust/platform:i686-unknown-linux-gnu": [], + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], + "@rules_rust//rust/platform:riscv64gc-unknown-linux-gnu": [], + "@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [], + "@rules_rust//rust/platform:s390x-unknown-linux-gnu": [], + "@rules_rust//rust/platform:thumbv7em-none-eabi": [], + "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], + "@rules_rust//rust/platform:wasm32-unknown-emscripten": [], + "@rules_rust//rust/platform:wasm32-unknown-unknown": [], + "@rules_rust//rust/platform:wasm32-wasip1": [], + "@rules_rust//rust/platform:wasm32-wasip1-threads": [], + "@rules_rust//rust/platform:wasm32-wasip2": [], + "@rules_rust//rust/platform:x86_64-apple-darwin": [], + "@rules_rust//rust/platform:x86_64-apple-ios": [], + "@rules_rust//rust/platform:x86_64-linux-android": [], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [], + "@rules_rust//rust/platform:x86_64-unknown-freebsd": [], + "@rules_rust//rust/platform:x86_64-unknown-fuchsia": [], + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [], + "@rules_rust//rust/platform:x86_64-unknown-none": [], + "@rules_rust//rust/platform:x86_64-unknown-uefi": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + version = "0.7.2", + deps = [ + "@vendor_ts__tree-sitter-language-0.1.5//:tree_sitter_language", + "@vendor_ts__tree-sitter-swift-0.7.2//:build_script_build", + ], +) + +cargo_build_script( + name = "_bs", + srcs = glob( + include = ["**/*.rs"], + allow_empty = True, + ), + compile_data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + "**/*.rs", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_name = "build_script_build", + crate_root = "bindings/rust/build.rs", + data = glob( + include = ["**"], + allow_empty = True, + exclude = [ + "**/* *", + ".tmp_git_root/**/*", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + pkg_name = "tree-sitter-swift", + rustc_env_files = [ + ":cargo_toml_env_vars", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=tree-sitter-swift", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.7.2", + visibility = ["//visibility:private"], + deps = [ + "@vendor_ts__cc-1.2.61//:cc", + ], +) + +alias( + name = "build_script_build", + actual = ":_bs", + tags = ["manual"], +) diff --git a/misc/bazel/3rdparty/tree_sitter_extractors_deps/defs.bzl b/misc/bazel/3rdparty/tree_sitter_extractors_deps/defs.bzl index d1da77819f3d..4f70edd6ab37 100644 --- a/misc/bazel/3rdparty/tree_sitter_extractors_deps/defs.bzl +++ b/misc/bazel/3rdparty/tree_sitter_extractors_deps/defs.bzl @@ -403,6 +403,21 @@ _NORMAL_DEPENDENCIES = { "syn": Label("@vendor_ts__syn-2.0.106//:syn"), }, }, + "unified/extractor": { + _COMMON_CONDITION: { + "clap": Label("@vendor_ts__clap-4.5.48//:clap"), + "encoding": Label("@vendor_ts__encoding-0.2.33//:encoding"), + "lazy_static": Label("@vendor_ts__lazy_static-1.5.0//:lazy_static"), + "rayon": Label("@vendor_ts__rayon-1.11.0//:rayon"), + "regex": Label("@vendor_ts__regex-1.11.3//:regex"), + "serde_json": Label("@vendor_ts__serde_json-1.0.145//:serde_json"), + "tracing": Label("@vendor_ts__tracing-0.1.41//:tracing"), + "tracing-subscriber": Label("@vendor_ts__tracing-subscriber-0.3.20//:tracing_subscriber"), + "tree-sitter": Label("@vendor_ts__tree-sitter-0.26.8//:tree_sitter"), + "tree-sitter-embedded-template": Label("@vendor_ts__tree-sitter-embedded-template-0.25.0//:tree_sitter_embedded_template"), + "tree-sitter-swift": Label("@vendor_ts__tree-sitter-swift-0.7.2//:tree_sitter_swift"), + }, + }, } _NORMAL_ALIASES = { @@ -437,6 +452,10 @@ _NORMAL_ALIASES = { _COMMON_CONDITION: { }, }, + "unified/extractor": { + _COMMON_CONDITION: { + }, + }, } _NORMAL_DEV_DEPENDENCIES = { @@ -461,6 +480,8 @@ _NORMAL_DEV_DEPENDENCIES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _NORMAL_DEV_ALIASES = { @@ -482,6 +503,8 @@ _NORMAL_DEV_ALIASES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _PROC_MACRO_DEPENDENCIES = { @@ -501,6 +524,8 @@ _PROC_MACRO_DEPENDENCIES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _PROC_MACRO_ALIASES = { @@ -520,6 +545,8 @@ _PROC_MACRO_ALIASES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _PROC_MACRO_DEV_DEPENDENCIES = { @@ -539,6 +566,8 @@ _PROC_MACRO_DEV_DEPENDENCIES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _PROC_MACRO_DEV_ALIASES = { @@ -560,6 +589,8 @@ _PROC_MACRO_DEV_ALIASES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _BUILD_DEPENDENCIES = { @@ -579,6 +610,8 @@ _BUILD_DEPENDENCIES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _BUILD_ALIASES = { @@ -598,6 +631,8 @@ _BUILD_ALIASES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _BUILD_PROC_MACRO_DEPENDENCIES = { @@ -617,6 +652,8 @@ _BUILD_PROC_MACRO_DEPENDENCIES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _BUILD_PROC_MACRO_ALIASES = { @@ -636,6 +673,8 @@ _BUILD_PROC_MACRO_ALIASES = { }, "shared/yeast-macros": { }, + "unified/extractor": { + }, } _CONDITIONS = { @@ -3497,6 +3536,16 @@ def crate_repositories(): build_file = Label("//misc/bazel/3rdparty/tree_sitter_extractors_deps:BUILD.tree-sitter-ruby-0.23.1.bazel"), ) + maybe( + http_archive, + name = "vendor_ts__tree-sitter-swift-0.7.2", + sha256 = "f3b98fb6bc8e6a6a10023f401aa6a1858115e849dfaf7de57dd8b8ea0f257bd9", + type = "tar.gz", + urls = ["https://static.crates.io/crates/tree-sitter-swift/0.7.2/download"], + strip_prefix = "tree-sitter-swift-0.7.2", + build_file = Label("//misc/bazel/3rdparty/tree_sitter_extractors_deps:BUILD.tree-sitter-swift-0.7.2.bazel"), + ) + maybe( http_archive, name = "vendor_ts__triomphe-0.1.14", @@ -4238,6 +4287,7 @@ def crate_repositories(): struct(repo = "vendor_ts__tree-sitter-embedded-template-0.25.0", is_dev_dep = False), struct(repo = "vendor_ts__tree-sitter-python-0.23.6", is_dev_dep = False), struct(repo = "vendor_ts__tree-sitter-ruby-0.23.1", is_dev_dep = False), + struct(repo = "vendor_ts__tree-sitter-swift-0.7.2", is_dev_dep = False), struct(repo = "vendor_ts__triomphe-0.1.14", is_dev_dep = False), struct(repo = "vendor_ts__ungrammar-1.16.1", is_dev_dep = False), struct(repo = "vendor_ts__zstd-0.13.3", is_dev_dep = False), diff --git a/unified/.gitignore b/unified/.gitignore new file mode 100644 index 000000000000..5878737805f2 --- /dev/null +++ b/unified/.gitignore @@ -0,0 +1,6 @@ +target +.vscode/launch.json +.cache +ql/test/**/*.testproj +ql/test/**/*.actual +.codeql diff --git a/unified/BUILD.bazel b/unified/BUILD.bazel new file mode 100644 index 000000000000..e702fd251594 --- /dev/null +++ b/unified/BUILD.bazel @@ -0,0 +1,57 @@ +load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup") +load("//misc/bazel:pkg.bzl", "codeql_pack", "codeql_pkg_files") + +package(default_visibility = ["//visibility:public"]) + +alias( + name = "dbscheme", + actual = "//unified/ql/lib:dbscheme", +) + +alias( + name = "dbscheme-stats", + actual = "//unified/ql/lib:dbscheme-stats", +) + +codeql_pkg_files( + name = "dbscheme-group", + srcs = [ + ":dbscheme", + ":dbscheme-stats", + ], + strip_prefix = None, +) + +pkg_filegroup( + name = "db-files", + srcs = [ + ":dbscheme-group", + ], +) + +codeql_pkg_files( + name = "codeql-extractor-yml", + srcs = [ + "codeql-extractor.yml", + "//:LICENSE", + ], + strip_prefix = None, +) + +codeql_pkg_files( + name = "extractor-arch", + exes = [ + "//unified/extractor", + ], + prefix = "tools/{CODEQL_PLATFORM}", +) + +codeql_pack( + name = "unified", + srcs = [ + ":codeql-extractor-yml", + ":dbscheme-group", + ":extractor-arch", + "//unified/tools", + ], +) diff --git a/unified/codeql-extractor.yml b/unified/codeql-extractor.yml new file mode 100644 index 000000000000..388566c09f11 --- /dev/null +++ b/unified/codeql-extractor.yml @@ -0,0 +1,17 @@ +name: "unified" +display_name: "Unified Language" +version: 0.0.1 +column_kind: "utf8" +legacy_qltest_extraction: true +build_modes: + - none +github_api_languages: + - Swift +scc_languages: + - Swift +file_types: + - name: swift + display_name: Swift files + extensions: + - .swift + - .swiftinterface diff --git a/unified/extractor/BUILD.bazel b/unified/extractor/BUILD.bazel new file mode 100644 index 000000000000..8c22b4775f29 --- /dev/null +++ b/unified/extractor/BUILD.bazel @@ -0,0 +1,19 @@ +load("//misc/bazel:rust.bzl", "codeql_rust_binary") +load("//misc/bazel/3rdparty/tree_sitter_extractors_deps:defs.bzl", "aliases", "all_crate_deps") + +exports_files(["Cargo.toml"]) + +codeql_rust_binary( + name = "extractor", + srcs = glob(["src/*.rs"]), + aliases = aliases(), + proc_macro_deps = all_crate_deps( + proc_macro = True, + ), + visibility = ["//visibility:public"], + deps = all_crate_deps( + normal = True, + ) + [ + "//shared/tree-sitter-extractor", + ], +) diff --git a/unified/extractor/Cargo.toml b/unified/extractor/Cargo.toml new file mode 100644 index 000000000000..fb377a995e7f --- /dev/null +++ b/unified/extractor/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "codeql-extractor-unified" +description = "CodeQL Unified extractor" +version = "0.1.0" +authors = ["GitHub"] +edition = "2024" + +# When updating these dependencies, run `misc/bazel/3rdparty/update_cargo_deps.sh` +[dependencies] +tree-sitter = ">= 0.23.0" +tree-sitter-embedded-template = "0.25.0" +tree-sitter-swift = "0.7.2" +clap = { version = "4.5", features = ["derive"] } +tracing = "0.1" +tracing-subscriber = { version = "0.3.20", features = ["env-filter"] } +rayon = "1.11.0" +regex = "1.11.3" +encoding = "0.2" +lazy_static = "1.5.0" +serde_json = "1.0.145" + +codeql-extractor = { path = "../../shared/tree-sitter-extractor" } diff --git a/unified/extractor/src/autobuilder.rs b/unified/extractor/src/autobuilder.rs new file mode 100644 index 000000000000..3bcb87aedd83 --- /dev/null +++ b/unified/extractor/src/autobuilder.rs @@ -0,0 +1,20 @@ +use std::env; +use std::path::PathBuf; + +use clap::Args; + +use codeql_extractor::autobuilder; + +#[derive(Args)] +// The autobuilder takes no command-line options, but this may change in the future. +pub struct Options {} + +pub fn run(_: Options) -> std::io::Result<()> { + let database = env::var("CODEQL_EXTRACTOR_UNIFIED_WIP_DATABASE") + .expect("CODEQL_EXTRACTOR_UNIFIED_WIP_DATABASE not set"); + + autobuilder::Autobuilder::new("unified", PathBuf::from(database)) + .include_extensions(&[".swift", ".swiftinterface"]) + .size_limit("10m") + .run() +} diff --git a/unified/extractor/src/extractor.rs b/unified/extractor/src/extractor.rs new file mode 100644 index 000000000000..ae9e538a5ec6 --- /dev/null +++ b/unified/extractor/src/extractor.rs @@ -0,0 +1,43 @@ +use clap::Args; +use std::path::PathBuf; + +use codeql_extractor::extractor::simple; +use codeql_extractor::trap; + +#[derive(Args)] +pub struct Options { + /// Sets a custom source achive folder + #[arg(long)] + source_archive_dir: PathBuf, + + /// Sets a custom trap folder + #[arg(long)] + output_dir: PathBuf, + + /// A text file containing the paths of the files to extract + #[arg(long)] + file_list: PathBuf, +} + +pub fn run(options: Options) -> std::io::Result<()> { + codeql_extractor::extractor::set_tracing_level("ql"); + + let extractor = simple::Extractor { + prefix: "unified".to_string(), + languages: vec![ + simple::LanguageSpec { + prefix: "swift", + ts_language: tree_sitter_swift::LANGUAGE.into(), + node_types: tree_sitter_swift::NODE_TYPES, + file_globs: vec!["*.swift".into(), "*.swiftinterface".into()], + desugar: None, + }, + ], + trap_dir: options.output_dir, + trap_compression: trap::Compression::from_env("CODEQL_QL_TRAP_COMPRESSION"), + source_archive_dir: options.source_archive_dir, + file_lists: vec![options.file_list], + }; + + extractor.run() +} diff --git a/unified/extractor/src/generator.rs b/unified/extractor/src/generator.rs new file mode 100644 index 000000000000..ee65da7a6005 --- /dev/null +++ b/unified/extractor/src/generator.rs @@ -0,0 +1,27 @@ +use clap::Args; +use std::path::PathBuf; + +use codeql_extractor::generator::{generate, language::Language}; + +#[derive(Args)] +pub struct Options { + /// Path of the generated dbscheme file + #[arg(long)] + dbscheme: PathBuf, + + /// Path of the generated QLL file + #[arg(long)] + library: PathBuf, +} + +pub fn run(options: Options) -> std::io::Result<()> { + codeql_extractor::extractor::set_tracing_level("ql"); + + let languages = vec![Language { + name: "Swift".to_owned(), + node_types: tree_sitter_swift::NODE_TYPES, + desugar: None, + }]; + + generate(languages, options.dbscheme, options.library, "run ql/unified/scripts/create-extractor-pack.sh") +} diff --git a/unified/extractor/src/main.rs b/unified/extractor/src/main.rs new file mode 100644 index 000000000000..e6721d4e2243 --- /dev/null +++ b/unified/extractor/src/main.rs @@ -0,0 +1,23 @@ +use clap::Parser; + +mod autobuilder; +mod extractor; +mod generator; + +#[derive(Parser)] +#[command(author, version, about)] +enum Cli { + Extract(extractor::Options), + Generate(generator::Options), + Autobuild(autobuilder::Options), +} + +fn main() -> std::io::Result<()> { + let cli = Cli::parse(); + + match cli { + Cli::Extract(options) => extractor::run(options), + Cli::Generate(options) => generator::run(options), + Cli::Autobuild(options) => autobuilder::run(options), + } +} diff --git a/unified/ql/lib/BUILD.bazel b/unified/ql/lib/BUILD.bazel new file mode 100644 index 000000000000..3636225ba533 --- /dev/null +++ b/unified/ql/lib/BUILD.bazel @@ -0,0 +1,13 @@ +load("@rules_pkg//pkg:mappings.bzl", "pkg_files") + +package(default_visibility = ["//unified:__pkg__"]) + +pkg_files( + name = "dbscheme", + srcs = ["unified.dbscheme"], +) + +pkg_files( + name = "dbscheme-stats", + srcs = ["unified.dbscheme.stats"], +) diff --git a/unified/ql/lib/codeql/Locations.qll b/unified/ql/lib/codeql/Locations.qll new file mode 100644 index 000000000000..df52d6822a2e --- /dev/null +++ b/unified/ql/lib/codeql/Locations.qll @@ -0,0 +1,70 @@ +/** Provides classes for working with locations. */ +overlay[local] +module; + +import files.FileSystem + +/** + * A location as given by a file, a start line, a start column, + * an end line, and an end column. + * + * For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +class Location extends @location_default { + /** Gets the file for this location. */ + File getFile() { locations_default(this, result, _, _, _, _) } + + /** Gets the 1-based line number (inclusive) where this location starts. */ + int getStartLine() { locations_default(this, _, result, _, _, _) } + + /** Gets the 1-based column number (inclusive) where this location starts. */ + int getStartColumn() { locations_default(this, _, _, result, _, _) } + + /** Gets the 1-based line number (inclusive) where this location ends. */ + int getEndLine() { locations_default(this, _, _, _, result, _) } + + /** Gets the 1-based column number (inclusive) where this location ends. */ + int getEndColumn() { locations_default(this, _, _, _, _, result) } + + /** Gets the number of lines covered by this location. */ + int getNumLines() { result = this.getEndLine() - this.getStartLine() + 1 } + + /** Gets a textual representation of this element. */ + bindingset[this] + pragma[inline_late] + string toString() { + exists(string filepath, int startline, int startcolumn, int endline, int endcolumn | + this.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and + result = filepath + "@" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn + ) + } + + /** + * Holds if this element is at the specified location. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `filepath`. + * For more information, see + * [Providing locations in CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ + predicate hasLocationInfo( + string filepath, int startline, int startcolumn, int endline, int endcolumn + ) { + exists(File f | + locations_default(this, f, startline, startcolumn, endline, endcolumn) and + filepath = f.getAbsolutePath() + ) + } + + /** Holds if this location starts strictly before the specified location. */ + pragma[inline] + predicate strictlyBefore(Location other) { + this.getStartLine() < other.getStartLine() + or + this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn() + } +} + +/** An entity representing an empty location. */ +class EmptyLocation extends Location { + EmptyLocation() { empty_location(this) } +} diff --git a/unified/ql/lib/codeql/files/FileSystem.qll b/unified/ql/lib/codeql/files/FileSystem.qll new file mode 100644 index 000000000000..6cc771fad9d2 --- /dev/null +++ b/unified/ql/lib/codeql/files/FileSystem.qll @@ -0,0 +1,38 @@ +/** Provides classes for working with files and folders. */ +overlay[local] +module; + +private import codeql.Locations +private import codeql.util.FileSystem + +private module Input implements InputSig { + abstract class ContainerBase extends @container { + abstract string getAbsolutePath(); + + ContainerBase getParentContainer() { containerparent(result, this) } + + string toString() { result = this.getAbsolutePath() } + } + + class FolderBase extends ContainerBase, @folder { + override string getAbsolutePath() { folders(this, result) } + } + + class FileBase extends ContainerBase, @file { + override string getAbsolutePath() { files(this, result) } + } + + predicate hasSourceLocationPrefix = sourceLocationPrefix/1; +} + +private module Impl = Make; + +class Container = Impl::Container; + +class Folder = Impl::Folder; + +/** A file. */ +class File extends Container, Impl::File { + /** Holds if this file was extracted from ordinary source code. */ + predicate fromSource() { any() } +} diff --git a/unified/ql/lib/codeql/unified/Ast.qll b/unified/ql/lib/codeql/unified/Ast.qll new file mode 100644 index 000000000000..54c1caceaf4b --- /dev/null +++ b/unified/ql/lib/codeql/unified/Ast.qll @@ -0,0 +1,2842 @@ +/** + * CodeQL library for Swift + * Automatically generated from the tree-sitter grammar; do not edit + */ + +import codeql.Locations as L + +/** Holds if the database is an overlay. */ +overlay[local] +private predicate isOverlay() { databaseMetadata("isOverlay", "true") } + +/** Holds if `loc` is in the `file` and is part of the overlay base database. */ +overlay[local] +private predicate discardableLocation(@file file, @location_default loc) { + not isOverlay() and locations_default(loc, file, _, _, _, _) +} + +/** Holds if `loc` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */ +overlay[discard_entity] +private predicate discardLocation(@location_default loc) { + exists(@file file, string path | files(file, path) | + discardableLocation(file, loc) and overlayChangedFiles(path) + ) +} + +overlay[local] +module Swift { + /** The base class for all AST nodes */ + class AstNode extends @swift_ast_node { + /** Gets a string representation of this element. */ + string toString() { result = this.getAPrimaryQlClass() } + + /** Gets the location of this element. */ + final L::Location getLocation() { swift_ast_node_location(this, result) } + + /** Gets the parent of this element. */ + final AstNode getParent() { swift_ast_node_parent(this, result, _) } + + /** Gets the index of this node among the children of its parent. */ + final int getParentIndex() { swift_ast_node_parent(this, _, result) } + + /** Gets a field or child node of this node. */ + AstNode getAFieldOrChild() { none() } + + /** Gets the name of the primary QL class for this element. */ + string getAPrimaryQlClass() { result = "???" } + + /** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */ + string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") } + } + + /** A token. */ + class Token extends @swift_token, AstNode { + /** Gets the value of this token. */ + final string getValue() { swift_tokeninfo(this, _, result) } + + /** Gets a string representation of this element. */ + final override string toString() { result = this.getValue() } + + /** Gets the name of the primary QL class for this element. */ + override string getAPrimaryQlClass() { result = "Token" } + } + + /** A reserved word. */ + class ReservedWord extends @swift_reserved_word, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ReservedWord" } + } + + /** Gets the file containing the given `node`. */ + private @file getNodeFile(@swift_ast_node node) { + exists(@location_default loc | swift_ast_node_location(node, loc) | + locations_default(loc, result, _, _, _, _) + ) + } + + /** Holds if `node` is in the `file` and is part of the overlay base database. */ + private predicate discardableAstNode(@file file, @swift_ast_node node) { + not isOverlay() and file = getNodeFile(node) + } + + /** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */ + overlay[discard_entity] + private predicate discardAstNode(@swift_ast_node node) { + exists(@file file, string path | files(file, path) | + discardableAstNode(file, node) and overlayChangedFiles(path) + ) + } + + /** A class representing `_expression` tokens. */ + class UnderscoreExpression extends @swift_token__expression, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "UnderscoreExpression" } + } + + /** A class representing `additive_expression` nodes. */ + class AdditiveExpression extends @swift_additive_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "AdditiveExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_additive_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_additive_expression_def(this, value) | + result = "+" and value = 0 + or + result = "-" and value = 1 + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_additive_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_additive_expression_lhs(this, _, result) or + swift_additive_expression_rhs(this, _, result) + } + } + + /** A class representing `array_literal` nodes. */ + class ArrayLiteral extends @swift_array_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ArrayLiteral" } + + /** Gets the node corresponding to the field `element`. */ + final AstNode getElement(int i) { swift_array_literal_element(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_array_literal_element(this, _, result) } + } + + /** A class representing `array_type` nodes. */ + class ArrayType extends @swift_array_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ArrayType" } + + /** Gets the node corresponding to the field `element`. */ + final AstNode getElement(int i) { swift_array_type_element(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_array_type_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_array_type_element(this, _, result) or swift_array_type_def(this, result) + } + } + + /** A class representing `as_expression` nodes. */ + class AsExpression extends @swift_as_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "AsExpression" } + + /** Gets the node corresponding to the field `expr`. */ + final AstNode getExpr(int i) { swift_as_expression_expr(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_as_expression_def(this, result, _) } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType(int i) { swift_as_expression_type(this, i, result) } + + /** Gets the child of this node. */ + final AsOperator getChild() { swift_as_expression_def(this, _, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_as_expression_expr(this, _, result) or + swift_as_expression_def(this, result, _) or + swift_as_expression_type(this, _, result) or + swift_as_expression_def(this, _, result) + } + } + + /** A class representing `as_operator` tokens. */ + class AsOperator extends @swift_token_as_operator, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "AsOperator" } + } + + /** A class representing `assignment` nodes. */ + class Assignment extends @swift_assignment, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Assignment" } + + /** Gets the node corresponding to the field `operator`. */ + final string getOperator() { + exists(int value | swift_assignment_def(this, value, _) | + result = "%=" and value = 0 + or + result = "*=" and value = 1 + or + result = "+=" and value = 2 + or + result = "-=" and value = 3 + or + result = "/=" and value = 4 + or + result = "=" and value = 5 + ) + } + + /** Gets the node corresponding to the field `result`. */ + final AstNode getResult(int i) { swift_assignment_result(this, i, result) } + + /** Gets the node corresponding to the field `target`. */ + final DirectlyAssignableExpression getTarget() { swift_assignment_def(this, _, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_assignment_result(this, _, result) or swift_assignment_def(this, _, result) + } + } + + /** A class representing `associatedtype_declaration` nodes. */ + class AssociatedtypeDeclaration extends @swift_associatedtype_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "AssociatedtypeDeclaration" } + + /** Gets the node corresponding to the field `default_value`. */ + final AstNode getDefaultValue(int i) { + swift_associatedtype_declaration_default_value(this, i, result) + } + + /** Gets the node corresponding to the field `must_inherit`. */ + final AstNode getMustInherit(int i) { + swift_associatedtype_declaration_must_inherit(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_associatedtype_declaration_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_associatedtype_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_associatedtype_declaration_default_value(this, _, result) or + swift_associatedtype_declaration_must_inherit(this, _, result) or + swift_associatedtype_declaration_name(this, _, result) or + swift_associatedtype_declaration_child(this, _, result) + } + } + + /** A class representing `attribute` nodes. */ + class Attribute extends @swift_attribute, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Attribute" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_attribute_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_attribute_child(this, _, result) } + } + + /** A class representing `availability_condition` nodes. */ + class AvailabilityCondition extends @swift_availability_condition, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "AvailabilityCondition" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_availability_condition_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_availability_condition_child(this, _, result) + } + } + + /** A class representing `await_expression` nodes. */ + class AwaitExpression extends @swift_await_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "AwaitExpression" } + + /** Gets the node corresponding to the field `expr`. */ + final AstNode getExpr(int i) { swift_await_expression_expr(this, i, result) } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_await_expression_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_await_expression_expr(this, _, result) or swift_await_expression_child(this, result) + } + } + + /** A class representing `bang` tokens. */ + class Bang extends @swift_token_bang, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Bang" } + } + + /** A class representing `bin_literal` tokens. */ + class BinLiteral extends @swift_token_bin_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "BinLiteral" } + } + + /** A class representing `bitwise_operation` nodes. */ + class BitwiseOperation extends @swift_bitwise_operation, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "BitwiseOperation" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_bitwise_operation_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_bitwise_operation_def(this, value) | + result = "&" and value = 0 + or + result = "<<" and value = 1 + or + result = ">>" and value = 2 + or + result = "^" and value = 3 + or + result = "|" and value = 4 + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_bitwise_operation_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_bitwise_operation_lhs(this, _, result) or swift_bitwise_operation_rhs(this, _, result) + } + } + + /** A class representing `boolean_literal` tokens. */ + class BooleanLiteral extends @swift_token_boolean_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "BooleanLiteral" } + } + + /** A class representing `call_expression` nodes. */ + class CallExpression extends @swift_call_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CallExpression" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_call_expression_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_call_expression_child(this, _, result) } + } + + /** A class representing `call_suffix` nodes. */ + class CallSuffix extends @swift_call_suffix, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CallSuffix" } + + /** Gets the node corresponding to the field `name`. */ + final SimpleIdentifier getName(int i) { swift_call_suffix_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_call_suffix_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_call_suffix_name(this, _, result) or swift_call_suffix_child(this, _, result) + } + } + + /** A class representing `capture_list` nodes. */ + class CaptureList extends @swift_capture_list, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CaptureList" } + + /** Gets the `i`th child of this node. */ + final CaptureListItem getChild(int i) { swift_capture_list_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_capture_list_child(this, _, result) } + } + + /** A class representing `capture_list_item` nodes. */ + class CaptureListItem extends @swift_capture_list_item, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CaptureListItem" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_capture_list_item_def(this, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_capture_list_item_value(this, i, result) } + + /** Gets the child of this node. */ + final OwnershipModifier getChild() { swift_capture_list_item_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_capture_list_item_def(this, result) or + swift_capture_list_item_value(this, _, result) or + swift_capture_list_item_child(this, result) + } + } + + /** A class representing `catch_block` nodes. */ + class CatchBlock extends @swift_catch_block, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CatchBlock" } + + /** Gets the node corresponding to the field `error`. */ + final Pattern getError() { swift_catch_block_error(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_catch_block_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_catch_block_error(this, result) or swift_catch_block_child(this, _, result) + } + } + + /** A class representing `catch_keyword` tokens. */ + class CatchKeyword extends @swift_token_catch_keyword, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CatchKeyword" } + } + + /** A class representing `check_expression` nodes. */ + class CheckExpression extends @swift_check_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CheckExpression" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_check_expression_def(this, result, _) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_check_expression_def(this, _, value) | (result = "is" and value = 0)) + } + + /** Gets the node corresponding to the field `target`. */ + final AstNode getTarget(int i) { swift_check_expression_target(this, i, result) } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType(int i) { swift_check_expression_type(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_check_expression_def(this, result, _) or + swift_check_expression_target(this, _, result) or + swift_check_expression_type(this, _, result) + } + } + + /** A class representing `class_body` nodes. */ + class ClassBody extends @swift_class_body, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ClassBody" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_class_body_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_class_body_child(this, _, result) } + } + + /** A class representing `class_declaration` nodes. */ + class ClassDeclaration extends @swift_class_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ClassDeclaration" } + + /** Gets the node corresponding to the field `body`. */ + final AstNode getBody() { swift_class_declaration_def(this, result, _, _) } + + /** Gets the node corresponding to the field `declaration_kind`. */ + final string getDeclarationKind() { + exists(int value | swift_class_declaration_def(this, _, value, _) | + result = "actor" and value = 0 + or + result = "class" and value = 1 + or + result = "enum" and value = 2 + or + result = "extension" and value = 3 + or + result = "struct" and value = 4 + ) + } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_class_declaration_def(this, _, _, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_class_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_class_declaration_def(this, result, _, _) or + swift_class_declaration_def(this, _, _, result) or + swift_class_declaration_child(this, _, result) + } + } + + /** A class representing `comment` tokens. */ + class Comment extends @swift_token_comment, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Comment" } + } + + /** A class representing `comparison_expression` nodes. */ + class ComparisonExpression extends @swift_comparison_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ComparisonExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_comparison_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_comparison_expression_def(this, value) | + result = "<" and value = 0 + or + result = "<=" and value = 1 + or + result = ">" and value = 2 + or + result = ">=" and value = 3 + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_comparison_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_comparison_expression_lhs(this, _, result) or + swift_comparison_expression_rhs(this, _, result) + } + } + + /** A class representing `computed_getter` nodes. */ + class ComputedGetter extends @swift_computed_getter, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ComputedGetter" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_computed_getter_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_computed_getter_child(this, _, result) } + } + + /** A class representing `computed_modify` nodes. */ + class ComputedModify extends @swift_computed_modify, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ComputedModify" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_computed_modify_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_computed_modify_child(this, _, result) } + } + + /** A class representing `computed_property` nodes. */ + class ComputedProperty extends @swift_computed_property, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ComputedProperty" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_computed_property_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_computed_property_child(this, _, result) } + } + + /** A class representing `computed_setter` nodes. */ + class ComputedSetter extends @swift_computed_setter, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ComputedSetter" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_computed_setter_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_computed_setter_child(this, _, result) } + } + + /** A class representing `conjunction_expression` nodes. */ + class ConjunctionExpression extends @swift_conjunction_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ConjunctionExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_conjunction_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_conjunction_expression_def(this, value) | + (result = "&&" and value = 0) + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_conjunction_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_conjunction_expression_lhs(this, _, result) or + swift_conjunction_expression_rhs(this, _, result) + } + } + + /** A class representing `constructor_expression` nodes. */ + class ConstructorExpression extends @swift_constructor_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ConstructorExpression" } + + /** Gets the node corresponding to the field `constructed_type`. */ + final AstNode getConstructedType() { swift_constructor_expression_def(this, result, _) } + + /** Gets the child of this node. */ + final ConstructorSuffix getChild() { swift_constructor_expression_def(this, _, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_constructor_expression_def(this, result, _) or + swift_constructor_expression_def(this, _, result) + } + } + + /** A class representing `constructor_suffix` nodes. */ + class ConstructorSuffix extends @swift_constructor_suffix, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ConstructorSuffix" } + + /** Gets the node corresponding to the field `name`. */ + final SimpleIdentifier getName(int i) { swift_constructor_suffix_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_constructor_suffix_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_constructor_suffix_name(this, _, result) or + swift_constructor_suffix_child(this, _, result) + } + } + + /** A class representing `control_transfer_statement` nodes. */ + class ControlTransferStatement extends @swift_control_transfer_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ControlTransferStatement" } + + /** Gets the node corresponding to the field `result`. */ + final AstNode getResult(int i) { swift_control_transfer_statement_result(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_control_transfer_statement_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_control_transfer_statement_result(this, _, result) or + swift_control_transfer_statement_child(this, _, result) + } + } + + /** A class representing `custom_operator` tokens. */ + class CustomOperator extends @swift_token_custom_operator, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "CustomOperator" } + } + + /** A class representing `default_keyword` tokens. */ + class DefaultKeyword extends @swift_token_default_keyword, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DefaultKeyword" } + } + + /** A class representing `deinit_declaration` nodes. */ + class DeinitDeclaration extends @swift_deinit_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DeinitDeclaration" } + + /** Gets the node corresponding to the field `body`. */ + final FunctionBody getBody() { swift_deinit_declaration_def(this, result) } + + /** Gets the child of this node. */ + final Modifiers getChild() { swift_deinit_declaration_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_deinit_declaration_def(this, result) or swift_deinit_declaration_child(this, result) + } + } + + /** A class representing `deprecated_operator_declaration_body` nodes. */ + class DeprecatedOperatorDeclarationBody extends @swift_deprecated_operator_declaration_body, + AstNode + { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DeprecatedOperatorDeclarationBody" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { + swift_deprecated_operator_declaration_body_child(this, i, result) + } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_deprecated_operator_declaration_body_child(this, _, result) + } + } + + /** A class representing `diagnostic` tokens. */ + class Diagnostic extends @swift_token_diagnostic, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Diagnostic" } + } + + /** A class representing `dictionary_literal` nodes. */ + class DictionaryLiteral extends @swift_dictionary_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DictionaryLiteral" } + + /** Gets the node corresponding to the field `key`. */ + final AstNode getKey(int i) { swift_dictionary_literal_key(this, i, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_dictionary_literal_value(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_dictionary_literal_key(this, _, result) or + swift_dictionary_literal_value(this, _, result) + } + } + + /** A class representing `dictionary_type` nodes. */ + class DictionaryType extends @swift_dictionary_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DictionaryType" } + + /** Gets the node corresponding to the field `key`. */ + final AstNode getKey(int i) { swift_dictionary_type_key(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_dictionary_type_name(this, i, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_dictionary_type_value(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_dictionary_type_key(this, _, result) or + swift_dictionary_type_name(this, _, result) or + swift_dictionary_type_value(this, _, result) + } + } + + /** A class representing `didset_clause` nodes. */ + class DidsetClause extends @swift_didset_clause, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DidsetClause" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_didset_clause_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_didset_clause_child(this, _, result) } + } + + /** A class representing `directive` nodes. */ + class Directive extends @swift_directive, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Directive" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_directive_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_directive_child(this, _, result) } + } + + /** A class representing `directly_assignable_expression` nodes. */ + class DirectlyAssignableExpression extends @swift_directly_assignable_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DirectlyAssignableExpression" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_directly_assignable_expression_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_directly_assignable_expression_child(this, result) + } + } + + /** A class representing `disjunction_expression` nodes. */ + class DisjunctionExpression extends @swift_disjunction_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DisjunctionExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_disjunction_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_disjunction_expression_def(this, value) | + (result = "||" and value = 0) + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_disjunction_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_disjunction_expression_lhs(this, _, result) or + swift_disjunction_expression_rhs(this, _, result) + } + } + + /** A class representing `do_statement` nodes. */ + class DoStatement extends @swift_do_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "DoStatement" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_do_statement_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_do_statement_child(this, _, result) } + } + + /** A class representing `else` tokens. */ + class Else extends @swift_token_else, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Else" } + } + + /** A class representing `enum_class_body` nodes. */ + class EnumClassBody extends @swift_enum_class_body, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "EnumClassBody" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_enum_class_body_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_enum_class_body_child(this, _, result) } + } + + /** A class representing `enum_entry` nodes. */ + class EnumEntry extends @swift_enum_entry, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "EnumEntry" } + + /** Gets the node corresponding to the field `data_contents`. */ + final EnumTypeParameters getDataContents(int i) { + swift_enum_entry_data_contents(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final SimpleIdentifier getName(int i) { swift_enum_entry_name(this, i, result) } + + /** Gets the node corresponding to the field `raw_value`. */ + final AstNode getRawValue(int i) { swift_enum_entry_raw_value(this, i, result) } + + /** Gets the child of this node. */ + final Modifiers getChild() { swift_enum_entry_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_enum_entry_data_contents(this, _, result) or + swift_enum_entry_name(this, _, result) or + swift_enum_entry_raw_value(this, _, result) or + swift_enum_entry_child(this, result) + } + } + + /** A class representing `enum_type_parameters` nodes. */ + class EnumTypeParameters extends @swift_enum_type_parameters, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "EnumTypeParameters" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_enum_type_parameters_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_enum_type_parameters_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_enum_type_parameters_name(this, _, result) or + swift_enum_type_parameters_child(this, _, result) + } + } + + /** A class representing `equality_constraint` nodes. */ + class EqualityConstraint extends @swift_equality_constraint, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "EqualityConstraint" } + + /** Gets the node corresponding to the field `constrained_type`. */ + final AstNode getConstrainedType(int i) { + swift_equality_constraint_constrained_type(this, i, result) + } + + /** Gets the node corresponding to the field `must_equal`. */ + final AstNode getMustEqual(int i) { swift_equality_constraint_must_equal(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_equality_constraint_def(this, result) } + + /** Gets the `i`th child of this node. */ + final Attribute getChild(int i) { swift_equality_constraint_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_equality_constraint_constrained_type(this, _, result) or + swift_equality_constraint_must_equal(this, _, result) or + swift_equality_constraint_def(this, result) or + swift_equality_constraint_child(this, _, result) + } + } + + /** A class representing `equality_expression` nodes. */ + class EqualityExpression extends @swift_equality_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "EqualityExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_equality_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_equality_expression_def(this, value) | + result = "!=" and value = 0 + or + result = "!==" and value = 1 + or + result = "==" and value = 2 + or + result = "===" and value = 3 + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_equality_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_equality_expression_lhs(this, _, result) or + swift_equality_expression_rhs(this, _, result) + } + } + + /** A class representing `existential_type` nodes. */ + class ExistentialType extends @swift_existential_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ExistentialType" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_existential_type_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_existential_type_def(this, result) } + } + + /** A class representing `external_macro_definition` nodes. */ + class ExternalMacroDefinition extends @swift_external_macro_definition, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ExternalMacroDefinition" } + + /** Gets the child of this node. */ + final ValueArguments getChild() { swift_external_macro_definition_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_external_macro_definition_def(this, result) } + } + + /** A class representing `for_statement` nodes. */ + class ForStatement extends @swift_for_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ForStatement" } + + /** Gets the node corresponding to the field `collection`. */ + final AstNode getCollection(int i) { swift_for_statement_collection(this, i, result) } + + /** Gets the node corresponding to the field `item`. */ + final Pattern getItem() { swift_for_statement_def(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_for_statement_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_for_statement_collection(this, _, result) or + swift_for_statement_def(this, result) or + swift_for_statement_child(this, _, result) + } + } + + /** A class representing `fully_open_range` tokens. */ + class FullyOpenRange extends @swift_token_fully_open_range, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "FullyOpenRange" } + } + + /** A class representing `function_body` nodes. */ + class FunctionBody extends @swift_function_body, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "FunctionBody" } + + /** Gets the child of this node. */ + final Statements getChild() { swift_function_body_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_function_body_child(this, result) } + } + + /** A class representing `function_declaration` nodes. */ + class FunctionDeclaration extends @swift_function_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "FunctionDeclaration" } + + /** Gets the node corresponding to the field `body`. */ + final FunctionBody getBody() { swift_function_declaration_def(this, result) } + + /** Gets the node corresponding to the field `default_value`. */ + final AstNode getDefaultValue(int i) { + swift_function_declaration_default_value(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_function_declaration_name(this, i, result) } + + /** Gets the node corresponding to the field `return_type`. */ + final AstNode getReturnType(int i) { swift_function_declaration_return_type(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_function_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_function_declaration_def(this, result) or + swift_function_declaration_default_value(this, _, result) or + swift_function_declaration_name(this, _, result) or + swift_function_declaration_return_type(this, _, result) or + swift_function_declaration_child(this, _, result) + } + } + + /** A class representing `function_modifier` tokens. */ + class FunctionModifier extends @swift_token_function_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "FunctionModifier" } + } + + /** A class representing `function_type` nodes. */ + class FunctionType extends @swift_function_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "FunctionType" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_function_type_def(this, result, _) } + + /** Gets the node corresponding to the field `params`. */ + final AstNode getParams() { swift_function_type_def(this, _, result) } + + /** Gets the node corresponding to the field `return_type`. */ + final AstNode getReturnType(int i) { swift_function_type_return_type(this, i, result) } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_function_type_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_function_type_def(this, result, _) or + swift_function_type_def(this, _, result) or + swift_function_type_return_type(this, _, result) or + swift_function_type_child(this, result) + } + } + + /** A class representing `getter_specifier` nodes. */ + class GetterSpecifier extends @swift_getter_specifier, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "GetterSpecifier" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_getter_specifier_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_getter_specifier_child(this, _, result) } + } + + /** A class representing `guard_statement` nodes. */ + class GuardStatement extends @swift_guard_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "GuardStatement" } + + /** Gets the node corresponding to the field `bound_identifier`. */ + final SimpleIdentifier getBoundIdentifier(int i) { + swift_guard_statement_bound_identifier(this, i, result) + } + + /** Gets the node corresponding to the field `condition`. */ + final AstNode getCondition(int i) { swift_guard_statement_condition(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_guard_statement_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_guard_statement_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_guard_statement_bound_identifier(this, _, result) or + swift_guard_statement_condition(this, _, result) or + swift_guard_statement_name(this, _, result) or + swift_guard_statement_child(this, _, result) + } + } + + /** A class representing `hex_literal` tokens. */ + class HexLiteral extends @swift_token_hex_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "HexLiteral" } + } + + /** A class representing `identifier` nodes. */ + class Identifier extends @swift_identifier, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Identifier" } + + /** Gets the `i`th child of this node. */ + final SimpleIdentifier getChild(int i) { swift_identifier_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_identifier_child(this, _, result) } + } + + /** A class representing `if_statement` nodes. */ + class IfStatement extends @swift_if_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "IfStatement" } + + /** Gets the node corresponding to the field `bound_identifier`. */ + final SimpleIdentifier getBoundIdentifier(int i) { + swift_if_statement_bound_identifier(this, i, result) + } + + /** Gets the node corresponding to the field `condition`. */ + final AstNode getCondition(int i) { swift_if_statement_condition(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_if_statement_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_if_statement_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_if_statement_bound_identifier(this, _, result) or + swift_if_statement_condition(this, _, result) or + swift_if_statement_name(this, _, result) or + swift_if_statement_child(this, _, result) + } + } + + /** A class representing `import_declaration` nodes. */ + class ImportDeclaration extends @swift_import_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ImportDeclaration" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_import_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_import_declaration_child(this, _, result) } + } + + /** A class representing `infix_expression` nodes. */ + class InfixExpression extends @swift_infix_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "InfixExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_infix_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final CustomOperator getOp() { swift_infix_expression_def(this, result) } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_infix_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_infix_expression_lhs(this, _, result) or + swift_infix_expression_def(this, result) or + swift_infix_expression_rhs(this, _, result) + } + } + + /** A class representing `inheritance_constraint` nodes. */ + class InheritanceConstraint extends @swift_inheritance_constraint, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "InheritanceConstraint" } + + /** Gets the node corresponding to the field `constrained_type`. */ + final AstNode getConstrainedType(int i) { + swift_inheritance_constraint_constrained_type(this, i, result) + } + + /** Gets the node corresponding to the field `inherits_from`. */ + final AstNode getInheritsFrom(int i) { + swift_inheritance_constraint_inherits_from(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_inheritance_constraint_def(this, result) } + + /** Gets the `i`th child of this node. */ + final Attribute getChild(int i) { swift_inheritance_constraint_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_inheritance_constraint_constrained_type(this, _, result) or + swift_inheritance_constraint_inherits_from(this, _, result) or + swift_inheritance_constraint_def(this, result) or + swift_inheritance_constraint_child(this, _, result) + } + } + + /** A class representing `inheritance_modifier` tokens. */ + class InheritanceModifier extends @swift_token_inheritance_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "InheritanceModifier" } + } + + /** A class representing `inheritance_specifier` nodes. */ + class InheritanceSpecifier extends @swift_inheritance_specifier, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "InheritanceSpecifier" } + + /** Gets the node corresponding to the field `inherits_from`. */ + final AstNode getInheritsFrom() { swift_inheritance_specifier_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_inheritance_specifier_def(this, result) } + } + + /** A class representing `init_declaration` nodes. */ + class InitDeclaration extends @swift_init_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "InitDeclaration" } + + /** Gets the node corresponding to the field `body`. */ + final FunctionBody getBody() { swift_init_declaration_body(this, result) } + + /** Gets the node corresponding to the field `default_value`. */ + final AstNode getDefaultValue(int i) { swift_init_declaration_default_value(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final string getName() { + exists(int value | swift_init_declaration_def(this, value) | (result = "init" and value = 0)) + } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_init_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_init_declaration_body(this, result) or + swift_init_declaration_default_value(this, _, result) or + swift_init_declaration_child(this, _, result) + } + } + + /** A class representing `integer_literal` tokens. */ + class IntegerLiteral extends @swift_token_integer_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "IntegerLiteral" } + } + + /** A class representing `interpolated_expression` nodes. */ + class InterpolatedExpression extends @swift_interpolated_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "InterpolatedExpression" } + + /** Gets the node corresponding to the field `name`. */ + final ValueArgumentLabel getName() { swift_interpolated_expression_name(this, result) } + + /** Gets the node corresponding to the field `reference_specifier`. */ + final ValueArgumentLabel getReferenceSpecifier(int i) { + swift_interpolated_expression_reference_specifier(this, i, result) + } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_interpolated_expression_value(this, i, result) } + + /** Gets the child of this node. */ + final TypeModifiers getChild() { swift_interpolated_expression_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_interpolated_expression_name(this, result) or + swift_interpolated_expression_reference_specifier(this, _, result) or + swift_interpolated_expression_value(this, _, result) or + swift_interpolated_expression_child(this, result) + } + } + + /** A class representing `key_path_expression` nodes. */ + class KeyPathExpression extends @swift_key_path_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "KeyPathExpression" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_key_path_expression_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_key_path_expression_child(this, _, result) } + } + + /** A class representing `key_path_string_expression` nodes. */ + class KeyPathStringExpression extends @swift_key_path_string_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "KeyPathStringExpression" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_key_path_string_expression_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_key_path_string_expression_child(this, result) + } + } + + /** A class representing `lambda_function_type` nodes. */ + class LambdaFunctionType extends @swift_lambda_function_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "LambdaFunctionType" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_lambda_function_type_name(this, result) } + + /** Gets the node corresponding to the field `return_type`. */ + final AstNode getReturnType(int i) { swift_lambda_function_type_return_type(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_lambda_function_type_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_lambda_function_type_name(this, result) or + swift_lambda_function_type_return_type(this, _, result) or + swift_lambda_function_type_child(this, _, result) + } + } + + /** A class representing `lambda_function_type_parameters` nodes. */ + class LambdaFunctionTypeParameters extends @swift_lambda_function_type_parameters, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "LambdaFunctionTypeParameters" } + + /** Gets the `i`th child of this node. */ + final LambdaParameter getChild(int i) { + swift_lambda_function_type_parameters_child(this, i, result) + } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_lambda_function_type_parameters_child(this, _, result) + } + } + + /** A class representing `lambda_literal` nodes. */ + class LambdaLiteral extends @swift_lambda_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "LambdaLiteral" } + + /** Gets the node corresponding to the field `captures`. */ + final CaptureList getCaptures() { swift_lambda_literal_captures(this, result) } + + /** Gets the node corresponding to the field `type`. */ + final LambdaFunctionType getType() { swift_lambda_literal_type(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_lambda_literal_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_lambda_literal_captures(this, result) or + swift_lambda_literal_type(this, result) or + swift_lambda_literal_child(this, _, result) + } + } + + /** A class representing `lambda_parameter` nodes. */ + class LambdaParameter extends @swift_lambda_parameter, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "LambdaParameter" } + + /** Gets the node corresponding to the field `external_name`. */ + final SimpleIdentifier getExternalName() { swift_lambda_parameter_external_name(this, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_lambda_parameter_name(this, i, result) } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType(int i) { swift_lambda_parameter_type(this, i, result) } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_lambda_parameter_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_lambda_parameter_external_name(this, result) or + swift_lambda_parameter_name(this, _, result) or + swift_lambda_parameter_type(this, _, result) or + swift_lambda_parameter_child(this, result) + } + } + + /** A class representing `line_str_text` tokens. */ + class LineStrText extends @swift_token_line_str_text, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "LineStrText" } + } + + /** A class representing `line_string_literal` nodes. */ + class LineStringLiteral extends @swift_line_string_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "LineStringLiteral" } + + /** Gets the node corresponding to the field `interpolation`. */ + final InterpolatedExpression getInterpolation(int i) { + swift_line_string_literal_interpolation(this, i, result) + } + + /** Gets the node corresponding to the field `text`. */ + final AstNode getText(int i) { swift_line_string_literal_text(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_line_string_literal_interpolation(this, _, result) or + swift_line_string_literal_text(this, _, result) + } + } + + /** A class representing `macro_declaration` nodes. */ + class MacroDeclaration extends @swift_macro_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MacroDeclaration" } + + /** Gets the node corresponding to the field `default_value`. */ + final AstNode getDefaultValue(int i) { swift_macro_declaration_default_value(this, i, result) } + + /** Gets the node corresponding to the field `definition`. */ + final MacroDefinition getDefinition() { swift_macro_declaration_definition(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_macro_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_macro_declaration_default_value(this, _, result) or + swift_macro_declaration_definition(this, result) or + swift_macro_declaration_child(this, _, result) + } + } + + /** A class representing `macro_definition` nodes. */ + class MacroDefinition extends @swift_macro_definition, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MacroDefinition" } + + /** Gets the node corresponding to the field `body`. */ + final AstNode getBody(int i) { swift_macro_definition_body(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_macro_definition_body(this, _, result) } + } + + /** A class representing `macro_invocation` nodes. */ + class MacroInvocation extends @swift_macro_invocation, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MacroInvocation" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_macro_invocation_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_macro_invocation_child(this, _, result) } + } + + /** A class representing `member_modifier` tokens. */ + class MemberModifier extends @swift_token_member_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MemberModifier" } + } + + /** A class representing `metatype` nodes. */ + class Metatype extends @swift_metatype, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Metatype" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_metatype_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_metatype_def(this, result) } + } + + /** A class representing `modifiers` nodes. */ + class Modifiers extends @swift_modifiers, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Modifiers" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_modifiers_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_modifiers_child(this, _, result) } + } + + /** A class representing `modify_specifier` nodes. */ + class ModifySpecifier extends @swift_modify_specifier, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ModifySpecifier" } + + /** Gets the child of this node. */ + final MutationModifier getChild() { swift_modify_specifier_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_modify_specifier_child(this, result) } + } + + /** A class representing `multi_line_str_text` tokens. */ + class MultiLineStrText extends @swift_token_multi_line_str_text, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MultiLineStrText" } + } + + /** A class representing `multi_line_string_literal` nodes. */ + class MultiLineStringLiteral extends @swift_multi_line_string_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MultiLineStringLiteral" } + + /** Gets the node corresponding to the field `interpolation`. */ + final InterpolatedExpression getInterpolation(int i) { + swift_multi_line_string_literal_interpolation(this, i, result) + } + + /** Gets the node corresponding to the field `text`. */ + final AstNode getText(int i) { swift_multi_line_string_literal_text(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_multi_line_string_literal_interpolation(this, _, result) or + swift_multi_line_string_literal_text(this, _, result) + } + } + + /** A class representing `multiline_comment` tokens. */ + class MultilineComment extends @swift_token_multiline_comment, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MultilineComment" } + } + + /** A class representing `multiplicative_expression` nodes. */ + class MultiplicativeExpression extends @swift_multiplicative_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MultiplicativeExpression" } + + /** Gets the node corresponding to the field `lhs`. */ + final AstNode getLhs(int i) { swift_multiplicative_expression_lhs(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_multiplicative_expression_def(this, value) | + result = "%" and value = 0 + or + result = "*" and value = 1 + or + result = "/" and value = 2 + ) + } + + /** Gets the node corresponding to the field `rhs`. */ + final AstNode getRhs(int i) { swift_multiplicative_expression_rhs(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_multiplicative_expression_lhs(this, _, result) or + swift_multiplicative_expression_rhs(this, _, result) + } + } + + /** A class representing `mutation_modifier` tokens. */ + class MutationModifier extends @swift_token_mutation_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "MutationModifier" } + } + + /** A class representing `navigation_expression` nodes. */ + class NavigationExpression extends @swift_navigation_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "NavigationExpression" } + + /** Gets the node corresponding to the field `element`. */ + final AstNode getElement() { swift_navigation_expression_element(this, result) } + + /** Gets the node corresponding to the field `suffix`. */ + final NavigationSuffix getSuffix() { swift_navigation_expression_def(this, result) } + + /** Gets the node corresponding to the field `target`. */ + final AstNode getTarget(int i) { swift_navigation_expression_target(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_navigation_expression_element(this, result) or + swift_navigation_expression_def(this, result) or + swift_navigation_expression_target(this, _, result) + } + } + + /** A class representing `navigation_suffix` nodes. */ + class NavigationSuffix extends @swift_navigation_suffix, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "NavigationSuffix" } + + /** Gets the node corresponding to the field `suffix`. */ + final AstNode getSuffix() { swift_navigation_suffix_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_navigation_suffix_def(this, result) } + } + + /** A class representing `nil_coalescing_expression` nodes. */ + class NilCoalescingExpression extends @swift_nil_coalescing_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "NilCoalescingExpression" } + + /** Gets the node corresponding to the field `if_nil`. */ + final AstNode getIfNil(int i) { swift_nil_coalescing_expression_if_nil(this, i, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_nil_coalescing_expression_value(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_nil_coalescing_expression_if_nil(this, _, result) or + swift_nil_coalescing_expression_value(this, _, result) + } + } + + /** A class representing `oct_literal` tokens. */ + class OctLiteral extends @swift_token_oct_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OctLiteral" } + } + + /** A class representing `opaque_type` nodes. */ + class OpaqueType extends @swift_opaque_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OpaqueType" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_opaque_type_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_opaque_type_def(this, result) } + } + + /** A class representing `open_end_range_expression` nodes. */ + class OpenEndRangeExpression extends @swift_open_end_range_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OpenEndRangeExpression" } + + /** Gets the node corresponding to the field `start`. */ + final AstNode getStart(int i) { swift_open_end_range_expression_start(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_open_end_range_expression_start(this, _, result) + } + } + + /** A class representing `open_start_range_expression` nodes. */ + class OpenStartRangeExpression extends @swift_open_start_range_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OpenStartRangeExpression" } + + /** Gets the node corresponding to the field `end`. */ + final AstNode getEnd(int i) { swift_open_start_range_expression_end(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_open_start_range_expression_end(this, _, result) + } + } + + /** A class representing `operator_declaration` nodes. */ + class OperatorDeclaration extends @swift_operator_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OperatorDeclaration" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_operator_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_operator_declaration_child(this, _, result) } + } + + /** A class representing `optional_type` nodes. */ + class OptionalType extends @swift_optional_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OptionalType" } + + /** Gets the node corresponding to the field `wrapped`. */ + final AstNode getWrapped() { swift_optional_type_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_optional_type_def(this, result) } + } + + /** A class representing `ownership_modifier` tokens. */ + class OwnershipModifier extends @swift_token_ownership_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "OwnershipModifier" } + } + + /** A class representing `parameter` nodes. */ + class Parameter extends @swift_parameter, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Parameter" } + + /** Gets the node corresponding to the field `external_name`. */ + final SimpleIdentifier getExternalName() { swift_parameter_external_name(this, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_parameter_name(this, i, result) } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType(int i) { swift_parameter_type(this, i, result) } + + /** Gets the child of this node. */ + final ParameterModifiers getChild() { swift_parameter_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_parameter_external_name(this, result) or + swift_parameter_name(this, _, result) or + swift_parameter_type(this, _, result) or + swift_parameter_child(this, result) + } + } + + /** A class representing `parameter_modifier` tokens. */ + class ParameterModifier extends @swift_token_parameter_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ParameterModifier" } + } + + /** A class representing `parameter_modifiers` nodes. */ + class ParameterModifiers extends @swift_parameter_modifiers, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ParameterModifiers" } + + /** Gets the `i`th child of this node. */ + final ParameterModifier getChild(int i) { swift_parameter_modifiers_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_parameter_modifiers_child(this, _, result) } + } + + /** A class representing `pattern` nodes. */ + class Pattern extends @swift_pattern, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Pattern" } + + /** Gets the node corresponding to the field `bound_identifier`. */ + final SimpleIdentifier getBoundIdentifier() { swift_pattern_bound_identifier(this, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_pattern_name(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_pattern_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_pattern_bound_identifier(this, result) or + swift_pattern_name(this, result) or + swift_pattern_child(this, _, result) + } + } + + /** A class representing `playground_literal` nodes. */ + class PlaygroundLiteral extends @swift_playground_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PlaygroundLiteral" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_playground_literal_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_playground_literal_child(this, _, result) } + } + + /** A class representing `postfix_expression` nodes. */ + class PostfixExpression extends @swift_postfix_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PostfixExpression" } + + /** Gets the node corresponding to the field `operation`. */ + final AstNode getOperation() { swift_postfix_expression_def(this, result) } + + /** Gets the node corresponding to the field `target`. */ + final AstNode getTarget(int i) { swift_postfix_expression_target(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_postfix_expression_def(this, result) or swift_postfix_expression_target(this, _, result) + } + } + + /** A class representing `precedence_group_attribute` nodes. */ + class PrecedenceGroupAttribute extends @swift_precedence_group_attribute, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PrecedenceGroupAttribute" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_precedence_group_attribute_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_precedence_group_attribute_child(this, _, result) + } + } + + /** A class representing `precedence_group_attributes` nodes. */ + class PrecedenceGroupAttributes extends @swift_precedence_group_attributes, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PrecedenceGroupAttributes" } + + /** Gets the `i`th child of this node. */ + final PrecedenceGroupAttribute getChild(int i) { + swift_precedence_group_attributes_child(this, i, result) + } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_precedence_group_attributes_child(this, _, result) + } + } + + /** A class representing `precedence_group_declaration` nodes. */ + class PrecedenceGroupDeclaration extends @swift_precedence_group_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PrecedenceGroupDeclaration" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_precedence_group_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_precedence_group_declaration_child(this, _, result) + } + } + + /** A class representing `prefix_expression` nodes. */ + class PrefixExpression extends @swift_prefix_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PrefixExpression" } + + /** Gets the node corresponding to the field `operation`. */ + final AstNode getOperation() { swift_prefix_expression_def(this, result) } + + /** Gets the node corresponding to the field `target`. */ + final AstNode getTarget(int i) { swift_prefix_expression_target(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_prefix_expression_def(this, result) or swift_prefix_expression_target(this, _, result) + } + } + + /** A class representing `property_behavior_modifier` tokens. */ + class PropertyBehaviorModifier extends @swift_token_property_behavior_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PropertyBehaviorModifier" } + } + + /** A class representing `property_declaration` nodes. */ + class PropertyDeclaration extends @swift_property_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PropertyDeclaration" } + + /** Gets the node corresponding to the field `computed_value`. */ + final ComputedProperty getComputedValue(int i) { + swift_property_declaration_computed_value(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final Pattern getName(int i) { swift_property_declaration_name(this, i, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_property_declaration_value(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_property_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_property_declaration_computed_value(this, _, result) or + swift_property_declaration_name(this, _, result) or + swift_property_declaration_value(this, _, result) or + swift_property_declaration_child(this, _, result) + } + } + + /** A class representing `property_modifier` tokens. */ + class PropertyModifier extends @swift_token_property_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "PropertyModifier" } + } + + /** A class representing `protocol_body` nodes. */ + class ProtocolBody extends @swift_protocol_body, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ProtocolBody" } + + /** Gets the node corresponding to the field `body`. */ + final ProtocolFunctionDeclaration getBody(int i) { swift_protocol_body_body(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_protocol_body_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_protocol_body_body(this, _, result) or swift_protocol_body_child(this, _, result) + } + } + + /** A class representing `protocol_composition_type` nodes. */ + class ProtocolCompositionType extends @swift_protocol_composition_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ProtocolCompositionType" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_protocol_composition_type_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_protocol_composition_type_child(this, _, result) + } + } + + /** A class representing `protocol_declaration` nodes. */ + class ProtocolDeclaration extends @swift_protocol_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ProtocolDeclaration" } + + /** Gets the node corresponding to the field `body`. */ + final ProtocolBody getBody() { swift_protocol_declaration_def(this, result, _, _) } + + /** Gets the node corresponding to the field `declaration_kind`. */ + final string getDeclarationKind() { + exists(int value | swift_protocol_declaration_def(this, _, value, _) | + (result = "protocol" and value = 0) + ) + } + + /** Gets the node corresponding to the field `name`. */ + final TypeIdentifier getName() { swift_protocol_declaration_def(this, _, _, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_protocol_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_protocol_declaration_def(this, result, _, _) or + swift_protocol_declaration_def(this, _, _, result) or + swift_protocol_declaration_child(this, _, result) + } + } + + /** A class representing `protocol_function_declaration` nodes. */ + class ProtocolFunctionDeclaration extends @swift_protocol_function_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ProtocolFunctionDeclaration" } + + /** Gets the node corresponding to the field `default_value`. */ + final AstNode getDefaultValue(int i) { + swift_protocol_function_declaration_default_value(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_protocol_function_declaration_name(this, i, result) } + + /** Gets the node corresponding to the field `return_type`. */ + final AstNode getReturnType(int i) { + swift_protocol_function_declaration_return_type(this, i, result) + } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_protocol_function_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_protocol_function_declaration_default_value(this, _, result) or + swift_protocol_function_declaration_name(this, _, result) or + swift_protocol_function_declaration_return_type(this, _, result) or + swift_protocol_function_declaration_child(this, _, result) + } + } + + /** A class representing `protocol_property_declaration` nodes. */ + class ProtocolPropertyDeclaration extends @swift_protocol_property_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ProtocolPropertyDeclaration" } + + /** Gets the node corresponding to the field `name`. */ + final Pattern getName() { swift_protocol_property_declaration_def(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_protocol_property_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_protocol_property_declaration_def(this, result) or + swift_protocol_property_declaration_child(this, _, result) + } + } + + /** A class representing `protocol_property_requirements` nodes. */ + class ProtocolPropertyRequirements extends @swift_protocol_property_requirements, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ProtocolPropertyRequirements" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_protocol_property_requirements_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_protocol_property_requirements_child(this, _, result) + } + } + + /** A class representing `range_expression` nodes. */ + class RangeExpression extends @swift_range_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RangeExpression" } + + /** Gets the node corresponding to the field `end`. */ + final AstNode getEnd(int i) { swift_range_expression_end(this, i, result) } + + /** Gets the node corresponding to the field `op`. */ + final string getOp() { + exists(int value | swift_range_expression_def(this, value) | + result = "..." and value = 0 + or + result = "..<" and value = 1 + ) + } + + /** Gets the node corresponding to the field `start`. */ + final AstNode getStart(int i) { swift_range_expression_start(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_range_expression_end(this, _, result) or swift_range_expression_start(this, _, result) + } + } + + /** A class representing `raw_str_continuing_indicator` tokens. */ + class RawStrContinuingIndicator extends @swift_token_raw_str_continuing_indicator, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RawStrContinuingIndicator" } + } + + /** A class representing `raw_str_end_part` tokens. */ + class RawStrEndPart extends @swift_token_raw_str_end_part, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RawStrEndPart" } + } + + /** A class representing `raw_str_interpolation` nodes. */ + class RawStrInterpolation extends @swift_raw_str_interpolation, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RawStrInterpolation" } + + /** Gets the node corresponding to the field `interpolation`. */ + final InterpolatedExpression getInterpolation(int i) { + swift_raw_str_interpolation_interpolation(this, i, result) + } + + /** Gets the child of this node. */ + final RawStrInterpolationStart getChild() { swift_raw_str_interpolation_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_raw_str_interpolation_interpolation(this, _, result) or + swift_raw_str_interpolation_def(this, result) + } + } + + /** A class representing `raw_str_interpolation_start` tokens. */ + class RawStrInterpolationStart extends @swift_token_raw_str_interpolation_start, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RawStrInterpolationStart" } + } + + /** A class representing `raw_str_part` tokens. */ + class RawStrPart extends @swift_token_raw_str_part, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RawStrPart" } + } + + /** A class representing `raw_string_literal` nodes. */ + class RawStringLiteral extends @swift_raw_string_literal, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RawStringLiteral" } + + /** Gets the node corresponding to the field `interpolation`. */ + final RawStrInterpolation getInterpolation(int i) { + swift_raw_string_literal_interpolation(this, i, result) + } + + /** Gets the node corresponding to the field `text`. */ + final AstNode getText(int i) { swift_raw_string_literal_text(this, i, result) } + + /** Gets the `i`th child of this node. */ + final RawStrContinuingIndicator getChild(int i) { + swift_raw_string_literal_child(this, i, result) + } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_raw_string_literal_interpolation(this, _, result) or + swift_raw_string_literal_text(this, _, result) or + swift_raw_string_literal_child(this, _, result) + } + } + + /** A class representing `real_literal` tokens. */ + class RealLiteral extends @swift_token_real_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RealLiteral" } + } + + /** A class representing `regex_literal` tokens. */ + class RegexLiteral extends @swift_token_regex_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RegexLiteral" } + } + + /** A class representing `repeat_while_statement` nodes. */ + class RepeatWhileStatement extends @swift_repeat_while_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "RepeatWhileStatement" } + + /** Gets the node corresponding to the field `bound_identifier`. */ + final SimpleIdentifier getBoundIdentifier(int i) { + swift_repeat_while_statement_bound_identifier(this, i, result) + } + + /** Gets the node corresponding to the field `condition`. */ + final AstNode getCondition(int i) { swift_repeat_while_statement_condition(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_repeat_while_statement_name(this, i, result) } + + /** Gets the child of this node. */ + final Statements getChild() { swift_repeat_while_statement_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_repeat_while_statement_bound_identifier(this, _, result) or + swift_repeat_while_statement_condition(this, _, result) or + swift_repeat_while_statement_name(this, _, result) or + swift_repeat_while_statement_child(this, result) + } + } + + /** A class representing `selector_expression` nodes. */ + class SelectorExpression extends @swift_selector_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SelectorExpression" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_selector_expression_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_selector_expression_child(this, result) } + } + + /** A class representing `self_expression` tokens. */ + class SelfExpression extends @swift_token_self_expression, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SelfExpression" } + } + + /** A class representing `setter_specifier` nodes. */ + class SetterSpecifier extends @swift_setter_specifier, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SetterSpecifier" } + + /** Gets the child of this node. */ + final MutationModifier getChild() { swift_setter_specifier_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_setter_specifier_child(this, result) } + } + + /** A class representing `shebang_line` tokens. */ + class ShebangLine extends @swift_token_shebang_line, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ShebangLine" } + } + + /** A class representing `simple_identifier` tokens. */ + class SimpleIdentifier extends @swift_token_simple_identifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SimpleIdentifier" } + } + + /** A class representing `source_file` nodes. */ + class SourceFile extends @swift_source_file, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SourceFile" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_source_file_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_source_file_child(this, _, result) } + } + + /** A class representing `special_literal` tokens. */ + class SpecialLiteral extends @swift_token_special_literal, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SpecialLiteral" } + } + + /** A class representing `statement_label` tokens. */ + class StatementLabel extends @swift_token_statement_label, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "StatementLabel" } + } + + /** A class representing `statements` nodes. */ + class Statements extends @swift_statements, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Statements" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_statements_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_statements_child(this, _, result) } + } + + /** A class representing `str_escaped_char` tokens. */ + class StrEscapedChar extends @swift_token_str_escaped_char, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "StrEscapedChar" } + } + + /** A class representing `subscript_declaration` nodes. */ + class SubscriptDeclaration extends @swift_subscript_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SubscriptDeclaration" } + + /** Gets the node corresponding to the field `default_value`. */ + final AstNode getDefaultValue(int i) { + swift_subscript_declaration_default_value(this, i, result) + } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_subscript_declaration_name(this, result) } + + /** Gets the node corresponding to the field `return_type`. */ + final AstNode getReturnType(int i) { swift_subscript_declaration_return_type(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_subscript_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_subscript_declaration_default_value(this, _, result) or + swift_subscript_declaration_name(this, result) or + swift_subscript_declaration_return_type(this, _, result) or + swift_subscript_declaration_child(this, _, result) + } + } + + /** A class representing `super_expression` tokens. */ + class SuperExpression extends @swift_token_super_expression, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SuperExpression" } + } + + /** A class representing `suppressed_constraint` nodes. */ + class SuppressedConstraint extends @swift_suppressed_constraint, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SuppressedConstraint" } + + /** Gets the node corresponding to the field `suppressed`. */ + final TypeIdentifier getSuppressed() { swift_suppressed_constraint_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_suppressed_constraint_def(this, result) } + } + + /** A class representing `switch_entry` nodes. */ + class SwitchEntry extends @swift_switch_entry, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SwitchEntry" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_switch_entry_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_switch_entry_child(this, _, result) } + } + + /** A class representing `switch_pattern` nodes. */ + class SwitchPattern extends @swift_switch_pattern, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SwitchPattern" } + + /** Gets the child of this node. */ + final Pattern getChild() { swift_switch_pattern_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_switch_pattern_def(this, result) } + } + + /** A class representing `switch_statement` nodes. */ + class SwitchStatement extends @swift_switch_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "SwitchStatement" } + + /** Gets the node corresponding to the field `expr`. */ + final AstNode getExpr(int i) { swift_switch_statement_expr(this, i, result) } + + /** Gets the `i`th child of this node. */ + final SwitchEntry getChild(int i) { swift_switch_statement_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_switch_statement_expr(this, _, result) or swift_switch_statement_child(this, _, result) + } + } + + /** A class representing `ternary_expression` nodes. */ + class TernaryExpression extends @swift_ternary_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TernaryExpression" } + + /** Gets the node corresponding to the field `condition`. */ + final AstNode getCondition(int i) { swift_ternary_expression_condition(this, i, result) } + + /** Gets the node corresponding to the field `if_false`. */ + final AstNode getIfFalse(int i) { swift_ternary_expression_if_false(this, i, result) } + + /** Gets the node corresponding to the field `if_true`. */ + final AstNode getIfTrue(int i) { swift_ternary_expression_if_true(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_ternary_expression_condition(this, _, result) or + swift_ternary_expression_if_false(this, _, result) or + swift_ternary_expression_if_true(this, _, result) + } + } + + /** A class representing `throw_keyword` tokens. */ + class ThrowKeyword extends @swift_token_throw_keyword, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ThrowKeyword" } + } + + /** A class representing `throws` tokens. */ + class Throws extends @swift_token_throws, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "Throws" } + } + + /** A class representing `throws_clause` nodes. */ + class ThrowsClause extends @swift_throws_clause, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ThrowsClause" } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType() { swift_throws_clause_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_throws_clause_def(this, result) } + } + + /** A class representing `try_expression` nodes. */ + class TryExpression extends @swift_try_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TryExpression" } + + /** Gets the node corresponding to the field `expr`. */ + final AstNode getExpr(int i) { swift_try_expression_expr(this, i, result) } + + /** Gets the child of this node. */ + final TryOperator getChild() { swift_try_expression_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_try_expression_expr(this, _, result) or swift_try_expression_def(this, result) + } + } + + /** A class representing `try_operator` tokens. */ + class TryOperator extends @swift_token_try_operator, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TryOperator" } + } + + /** A class representing `tuple_expression` nodes. */ + class TupleExpression extends @swift_tuple_expression, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TupleExpression" } + + /** Gets the node corresponding to the field `name`. */ + final SimpleIdentifier getName(int i) { swift_tuple_expression_name(this, i, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_tuple_expression_value(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_tuple_expression_name(this, _, result) or swift_tuple_expression_value(this, _, result) + } + } + + /** A class representing `tuple_type` nodes. */ + class TupleType extends @swift_tuple_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TupleType" } + + /** Gets the node corresponding to the field `element`. */ + final TupleTypeItem getElement(int i) { swift_tuple_type_element(this, i, result) } + + /** Gets the child of this node. */ + final TupleTypeItem getChild() { swift_tuple_type_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_tuple_type_element(this, _, result) or swift_tuple_type_child(this, result) + } + } + + /** A class representing `tuple_type_item` nodes. */ + class TupleTypeItem extends @swift_tuple_type_item, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TupleTypeItem" } + + /** Gets the node corresponding to the field `element`. */ + final AstNode getElement() { swift_tuple_type_item_element(this, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_tuple_type_item_name(this, i, result) } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType(int i) { swift_tuple_type_item_type(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_tuple_type_item_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_tuple_type_item_element(this, result) or + swift_tuple_type_item_name(this, _, result) or + swift_tuple_type_item_type(this, _, result) or + swift_tuple_type_item_child(this, _, result) + } + } + + /** A class representing `type_annotation` nodes. */ + class TypeAnnotation extends @swift_type_annotation, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeAnnotation" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_type_annotation_def(this, result) } + + /** Gets the node corresponding to the field `type`. */ + final AstNode getType(int i) { swift_type_annotation_type(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_type_annotation_def(this, result) or swift_type_annotation_type(this, _, result) + } + } + + /** A class representing `type_arguments` nodes. */ + class TypeArguments extends @swift_type_arguments, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeArguments" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_type_arguments_name(this, i, result) } + + /** Gets the `i`th child of this node. */ + final TypeModifiers getChild(int i) { swift_type_arguments_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_type_arguments_name(this, _, result) or swift_type_arguments_child(this, _, result) + } + } + + /** A class representing `type_constraint` nodes. */ + class TypeConstraint extends @swift_type_constraint, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeConstraint" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_type_constraint_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_type_constraint_def(this, result) } + } + + /** A class representing `type_constraints` nodes. */ + class TypeConstraints extends @swift_type_constraints, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeConstraints" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_type_constraints_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_type_constraints_child(this, _, result) } + } + + /** A class representing `type_identifier` tokens. */ + class TypeIdentifier extends @swift_token_type_identifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeIdentifier" } + } + + /** A class representing `type_modifiers` nodes. */ + class TypeModifiers extends @swift_type_modifiers, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeModifiers" } + + /** Gets the `i`th child of this node. */ + final Attribute getChild(int i) { swift_type_modifiers_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_type_modifiers_child(this, _, result) } + } + + /** A class representing `type_pack_expansion` nodes. */ + class TypePackExpansion extends @swift_type_pack_expansion, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypePackExpansion" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_type_pack_expansion_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_type_pack_expansion_def(this, result) } + } + + /** A class representing `type_parameter` nodes. */ + class TypeParameter extends @swift_type_parameter, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeParameter" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName() { swift_type_parameter_name(this, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_type_parameter_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_type_parameter_name(this, result) or swift_type_parameter_child(this, _, result) + } + } + + /** A class representing `type_parameter_modifiers` nodes. */ + class TypeParameterModifiers extends @swift_type_parameter_modifiers, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeParameterModifiers" } + + /** Gets the `i`th child of this node. */ + final Attribute getChild(int i) { swift_type_parameter_modifiers_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_type_parameter_modifiers_child(this, _, result) + } + } + + /** A class representing `type_parameter_pack` nodes. */ + class TypeParameterPack extends @swift_type_parameter_pack, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeParameterPack" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_type_parameter_pack_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_type_parameter_pack_def(this, result) } + } + + /** A class representing `type_parameters` nodes. */ + class TypeParameters extends @swift_type_parameters, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypeParameters" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_type_parameters_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_type_parameters_child(this, _, result) } + } + + /** A class representing `typealias_declaration` nodes. */ + class TypealiasDeclaration extends @swift_typealias_declaration, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "TypealiasDeclaration" } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_typealias_declaration_name(this, i, result) } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_typealias_declaration_value(this, i, result) } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_typealias_declaration_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_typealias_declaration_name(this, _, result) or + swift_typealias_declaration_value(this, _, result) or + swift_typealias_declaration_child(this, _, result) + } + } + + /** A class representing `user_type` nodes. */ + class UserType extends @swift_user_type, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "UserType" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_user_type_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_user_type_child(this, _, result) } + } + + /** A class representing `value_argument` nodes. */ + class ValueArgument extends @swift_value_argument, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ValueArgument" } + + /** Gets the node corresponding to the field `name`. */ + final ValueArgumentLabel getName() { swift_value_argument_name(this, result) } + + /** Gets the node corresponding to the field `reference_specifier`. */ + final ValueArgumentLabel getReferenceSpecifier(int i) { + swift_value_argument_reference_specifier(this, i, result) + } + + /** Gets the node corresponding to the field `value`. */ + final AstNode getValue(int i) { swift_value_argument_value(this, i, result) } + + /** Gets the child of this node. */ + final TypeModifiers getChild() { swift_value_argument_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_value_argument_name(this, result) or + swift_value_argument_reference_specifier(this, _, result) or + swift_value_argument_value(this, _, result) or + swift_value_argument_child(this, result) + } + } + + /** A class representing `value_argument_label` nodes. */ + class ValueArgumentLabel extends @swift_value_argument_label, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ValueArgumentLabel" } + + /** Gets the child of this node. */ + final SimpleIdentifier getChild() { swift_value_argument_label_def(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_value_argument_label_def(this, result) } + } + + /** A class representing `value_arguments` nodes. */ + class ValueArguments extends @swift_value_arguments, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ValueArguments" } + + /** Gets the `i`th child of this node. */ + final ValueArgument getChild(int i) { swift_value_arguments_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_value_arguments_child(this, _, result) } + } + + /** A class representing `value_binding_pattern` nodes. */ + class ValueBindingPattern extends @swift_value_binding_pattern, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ValueBindingPattern" } + + /** Gets the node corresponding to the field `mutability`. */ + final string getMutability() { + exists(int value | swift_value_binding_pattern_def(this, value) | + result = "let" and value = 0 + or + result = "var" and value = 1 + ) + } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { none() } + } + + /** A class representing `value_pack_expansion` nodes. */ + class ValuePackExpansion extends @swift_value_pack_expansion, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ValuePackExpansion" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_value_pack_expansion_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_value_pack_expansion_child(this, result) } + } + + /** A class representing `value_parameter_pack` nodes. */ + class ValueParameterPack extends @swift_value_parameter_pack, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "ValueParameterPack" } + + /** Gets the child of this node. */ + final AstNode getChild() { swift_value_parameter_pack_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_value_parameter_pack_child(this, result) } + } + + /** A class representing `visibility_modifier` tokens. */ + class VisibilityModifier extends @swift_token_visibility_modifier, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "VisibilityModifier" } + } + + /** A class representing `where_clause` nodes. */ + class WhereClause extends @swift_where_clause, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "WhereClause" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_where_clause_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_where_clause_child(this, _, result) } + } + + /** A class representing `where_keyword` tokens. */ + class WhereKeyword extends @swift_token_where_keyword, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "WhereKeyword" } + } + + /** A class representing `while_statement` nodes. */ + class WhileStatement extends @swift_while_statement, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "WhileStatement" } + + /** Gets the node corresponding to the field `bound_identifier`. */ + final SimpleIdentifier getBoundIdentifier(int i) { + swift_while_statement_bound_identifier(this, i, result) + } + + /** Gets the node corresponding to the field `condition`. */ + final AstNode getCondition(int i) { swift_while_statement_condition(this, i, result) } + + /** Gets the node corresponding to the field `name`. */ + final AstNode getName(int i) { swift_while_statement_name(this, i, result) } + + /** Gets the child of this node. */ + final Statements getChild() { swift_while_statement_child(this, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { + swift_while_statement_bound_identifier(this, _, result) or + swift_while_statement_condition(this, _, result) or + swift_while_statement_name(this, _, result) or + swift_while_statement_child(this, result) + } + } + + /** A class representing `wildcard_pattern` tokens. */ + class WildcardPattern extends @swift_token_wildcard_pattern, Token { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "WildcardPattern" } + } + + /** A class representing `willset_clause` nodes. */ + class WillsetClause extends @swift_willset_clause, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "WillsetClause" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_willset_clause_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_willset_clause_child(this, _, result) } + } + + /** A class representing `willset_didset_block` nodes. */ + class WillsetDidsetBlock extends @swift_willset_didset_block, AstNode { + /** Gets the name of the primary QL class for this element. */ + final override string getAPrimaryQlClass() { result = "WillsetDidsetBlock" } + + /** Gets the `i`th child of this node. */ + final AstNode getChild(int i) { swift_willset_didset_block_child(this, i, result) } + + /** Gets a field or child node of this node. */ + final override AstNode getAFieldOrChild() { swift_willset_didset_block_child(this, _, result) } + } +} diff --git a/unified/ql/lib/qlpack.lock.yml b/unified/ql/lib/qlpack.lock.yml new file mode 100644 index 000000000000..06dd07fc7dc7 --- /dev/null +++ b/unified/ql/lib/qlpack.lock.yml @@ -0,0 +1,4 @@ +--- +dependencies: {} +compiled: false +lockVersion: 1.0.0 diff --git a/unified/ql/lib/qlpack.yml b/unified/ql/lib/qlpack.yml new file mode 100644 index 000000000000..896bf37ac5e5 --- /dev/null +++ b/unified/ql/lib/qlpack.yml @@ -0,0 +1,11 @@ +name: codeql/unified-all +version: 0.0.1-dev +groups: unified +dbscheme: unified.dbscheme +extractor: unified +library: true +upgrades: upgrades +dependencies: + codeql/util: ${workspace} +warnOnImplicitThis: true +compileForOverlayEval: true diff --git a/unified/ql/lib/unified.dbscheme b/unified/ql/lib/unified.dbscheme new file mode 100644 index 000000000000..026d4add415d --- /dev/null +++ b/unified/ql/lib/unified.dbscheme @@ -0,0 +1,2741 @@ +// CodeQL database schema for Swift +// Automatically generated from the tree-sitter grammar; do not edit +// To regenerate, run ql/unified/scripts/create-extractor-pack.sh + +/*- Files and folders -*/ + +/** + * The location of an element. + * The location spans column `startcolumn` of line `startline` to + * column `endcolumn` of line `endline` in file `file`. + * For more information, see + * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/). + */ +locations_default( + unique int id: @location_default, + int file: @file ref, + int beginLine: int ref, + int beginColumn: int ref, + int endLine: int ref, + int endColumn: int ref +); + +files( + unique int id: @file, + string name: string ref +); + +folders( + unique int id: @folder, + string name: string ref +); + +@container = @file | @folder + +containerparent( + int parent: @container ref, + unique int child: @container ref +); + +/*- Empty location -*/ + +empty_location( + int location: @location_default ref +); + +/*- Source location prefix -*/ + +/** + * The source location of the snapshot. + */ +sourceLocationPrefix(string prefix : string ref); + +/*- Diagnostic messages -*/ + +diagnostics( + unique int id: @diagnostic, + int severity: int ref, + string error_tag: string ref, + string error_message: string ref, + string full_error_message: string ref, + int location: @location_default ref +); + +/*- Diagnostic messages: severity -*/ + +case @diagnostic.severity of + 10 = @diagnostic_debug +| 20 = @diagnostic_info +| 30 = @diagnostic_warning +| 40 = @diagnostic_error +; + +/*- YAML -*/ + +#keyset[parent, idx] +yaml (unique int id: @yaml_node, + int kind: int ref, + int parent: @yaml_node_parent ref, + int idx: int ref, + string tag: string ref, + string tostring: string ref); + +case @yaml_node.kind of + 0 = @yaml_scalar_node +| 1 = @yaml_mapping_node +| 2 = @yaml_sequence_node +| 3 = @yaml_alias_node +; + +@yaml_collection_node = @yaml_mapping_node | @yaml_sequence_node; + +@yaml_node_parent = @yaml_collection_node | @file; + +yaml_anchors (unique int node: @yaml_node ref, + string anchor: string ref); + +yaml_aliases (unique int alias: @yaml_alias_node ref, + string target: string ref); + +yaml_scalars (unique int scalar: @yaml_scalar_node ref, + int style: int ref, + string value: string ref); + +yaml_errors (unique int id: @yaml_error, + string message: string ref); + +yaml_locations(unique int locatable: @yaml_locatable ref, + int location: @location_default ref); + +@yaml_locatable = @yaml_node | @yaml_error; + +/*- Database metadata -*/ + +/** + * The CLI will automatically emit applicable tuples for this table, + * such as `databaseMetadata("isOverlay", "true")` when building an + * overlay database. + */ +databaseMetadata( + string metadataKey: string ref, + string value: string ref +); + +/*- Overlay support -*/ + +/** + * The CLI will automatically emit tuples for each new/modified/deleted file + * when building an overlay database. + */ +overlayChangedFiles( + string path: string ref +); + +/*- Swift dbscheme -*/ +@swift_additive_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_additive_expression, index] +swift_additive_expression_lhs( + int swift_additive_expression: @swift_additive_expression ref, + int index: int ref, + unique int lhs: @swift_additive_expression_lhs_type ref +); + +case @swift_additive_expression.op of + 0 = @swift_additive_expression_plus +| 1 = @swift_additive_expression_minus +; + + +@swift_additive_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_additive_expression, index] +swift_additive_expression_rhs( + int swift_additive_expression: @swift_additive_expression ref, + int index: int ref, + unique int rhs: @swift_additive_expression_rhs_type ref +); + +swift_additive_expression_def( + unique int id: @swift_additive_expression, + int op: int ref +); + +@swift_array_literal_element_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_array_literal, index] +swift_array_literal_element( + int swift_array_literal: @swift_array_literal ref, + int index: int ref, + unique int element: @swift_array_literal_element_type ref +); + +swift_array_literal_def( + unique int id: @swift_array_literal +); + +@swift_array_type_element_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_array_type, index] +swift_array_type_element( + int swift_array_type: @swift_array_type ref, + int index: int ref, + unique int element: @swift_array_type_element_type ref +); + +@swift_array_type_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_array_type_def( + unique int id: @swift_array_type, + int name: @swift_array_type_name_type ref +); + +@swift_as_expression_expr_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_as_expression, index] +swift_as_expression_expr( + int swift_as_expression: @swift_as_expression ref, + int index: int ref, + unique int expr: @swift_as_expression_expr_type ref +); + +@swift_as_expression_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +@swift_as_expression_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_as_expression, index] +swift_as_expression_type( + int swift_as_expression: @swift_as_expression ref, + int index: int ref, + unique int type__: @swift_as_expression_type_type ref +); + +swift_as_expression_def( + unique int id: @swift_as_expression, + int name: @swift_as_expression_name_type ref, + int child: @swift_token_as_operator ref +); + +case @swift_assignment.operator of + 0 = @swift_assignment_percentequal +| 1 = @swift_assignment_starequal +| 2 = @swift_assignment_plusequal +| 3 = @swift_assignment_minusequal +| 4 = @swift_assignment_slashequal +| 5 = @swift_assignment_equal +; + + +@swift_assignment_result_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_assignment, index] +swift_assignment_result( + int swift_assignment: @swift_assignment ref, + int index: int ref, + unique int result: @swift_assignment_result_type ref +); + +swift_assignment_def( + unique int id: @swift_assignment, + int operator: int ref, + int target: @swift_directly_assignable_expression ref +); + +@swift_associatedtype_declaration_default_value_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_associatedtype_declaration, index] +swift_associatedtype_declaration_default_value( + int swift_associatedtype_declaration: @swift_associatedtype_declaration ref, + int index: int ref, + unique int default_value: @swift_associatedtype_declaration_default_value_type ref +); + +@swift_associatedtype_declaration_must_inherit_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_associatedtype_declaration, index] +swift_associatedtype_declaration_must_inherit( + int swift_associatedtype_declaration: @swift_associatedtype_declaration ref, + int index: int ref, + unique int must_inherit: @swift_associatedtype_declaration_must_inherit_type ref +); + +@swift_associatedtype_declaration_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_type_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_associatedtype_declaration, index] +swift_associatedtype_declaration_name( + int swift_associatedtype_declaration: @swift_associatedtype_declaration ref, + int index: int ref, + unique int name: @swift_associatedtype_declaration_name_type ref +); + +@swift_associatedtype_declaration_child_type = @swift_modifiers | @swift_type_constraints + +#keyset[swift_associatedtype_declaration, index] +swift_associatedtype_declaration_child( + int swift_associatedtype_declaration: @swift_associatedtype_declaration ref, + int index: int ref, + unique int child: @swift_associatedtype_declaration_child_type ref +); + +swift_associatedtype_declaration_def( + unique int id: @swift_associatedtype_declaration +); + +@swift_attribute_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_user_type | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_attribute, index] +swift_attribute_child( + int swift_attribute: @swift_attribute ref, + int index: int ref, + unique int child: @swift_attribute_child_type ref +); + +swift_attribute_def( + unique int id: @swift_attribute +); + +@swift_availability_condition_child_type = @swift_identifier | @swift_token_integer_literal + +#keyset[swift_availability_condition, index] +swift_availability_condition_child( + int swift_availability_condition: @swift_availability_condition ref, + int index: int ref, + unique int child: @swift_availability_condition_child_type ref +); + +swift_availability_condition_def( + unique int id: @swift_availability_condition +); + +@swift_await_expression_expr_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_await_expression, index] +swift_await_expression_expr( + int swift_await_expression: @swift_await_expression ref, + int index: int ref, + unique int expr: @swift_await_expression_expr_type ref +); + +@swift_await_expression_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +swift_await_expression_child( + unique int swift_await_expression: @swift_await_expression ref, + unique int child: @swift_await_expression_child_type ref +); + +swift_await_expression_def( + unique int id: @swift_await_expression +); + +@swift_bitwise_operation_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_bitwise_operation, index] +swift_bitwise_operation_lhs( + int swift_bitwise_operation: @swift_bitwise_operation ref, + int index: int ref, + unique int lhs: @swift_bitwise_operation_lhs_type ref +); + +case @swift_bitwise_operation.op of + 0 = @swift_bitwise_operation_ampersand +| 1 = @swift_bitwise_operation_langlelangle +| 2 = @swift_bitwise_operation_ranglerangle +| 3 = @swift_bitwise_operation_caret +| 4 = @swift_bitwise_operation_pipe +; + + +@swift_bitwise_operation_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_bitwise_operation, index] +swift_bitwise_operation_rhs( + int swift_bitwise_operation: @swift_bitwise_operation ref, + int index: int ref, + unique int rhs: @swift_bitwise_operation_rhs_type ref +); + +swift_bitwise_operation_def( + unique int id: @swift_bitwise_operation, + int op: int ref +); + +@swift_call_expression_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_call_suffix | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_call_expression, index] +swift_call_expression_child( + int swift_call_expression: @swift_call_expression ref, + int index: int ref, + unique int child: @swift_call_expression_child_type ref +); + +swift_call_expression_def( + unique int id: @swift_call_expression +); + +#keyset[swift_call_suffix, index] +swift_call_suffix_name( + int swift_call_suffix: @swift_call_suffix ref, + int index: int ref, + unique int name: @swift_token_simple_identifier ref +); + +@swift_call_suffix_child_type = @swift_lambda_literal | @swift_value_arguments + +#keyset[swift_call_suffix, index] +swift_call_suffix_child( + int swift_call_suffix: @swift_call_suffix ref, + int index: int ref, + unique int child: @swift_call_suffix_child_type ref +); + +swift_call_suffix_def( + unique int id: @swift_call_suffix +); + +#keyset[swift_capture_list, index] +swift_capture_list_child( + int swift_capture_list: @swift_capture_list ref, + int index: int ref, + unique int child: @swift_capture_list_item ref +); + +swift_capture_list_def( + unique int id: @swift_capture_list +); + +@swift_capture_list_item_name_type = @swift_token_self_expression | @swift_token_simple_identifier + +@swift_capture_list_item_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_capture_list_item, index] +swift_capture_list_item_value( + int swift_capture_list_item: @swift_capture_list_item ref, + int index: int ref, + unique int value: @swift_capture_list_item_value_type ref +); + +swift_capture_list_item_child( + unique int swift_capture_list_item: @swift_capture_list_item ref, + unique int child: @swift_token_ownership_modifier ref +); + +swift_capture_list_item_def( + unique int id: @swift_capture_list_item, + int name: @swift_capture_list_item_name_type ref +); + +swift_catch_block_error( + unique int swift_catch_block: @swift_catch_block ref, + unique int error: @swift_pattern ref +); + +@swift_catch_block_child_type = @swift_statements | @swift_token_catch_keyword | @swift_where_clause + +#keyset[swift_catch_block, index] +swift_catch_block_child( + int swift_catch_block: @swift_catch_block ref, + int index: int ref, + unique int child: @swift_catch_block_child_type ref +); + +swift_catch_block_def( + unique int id: @swift_catch_block +); + +@swift_check_expression_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +case @swift_check_expression.op of + 0 = @swift_check_expression_is +; + + +@swift_check_expression_target_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_check_expression, index] +swift_check_expression_target( + int swift_check_expression: @swift_check_expression ref, + int index: int ref, + unique int target: @swift_check_expression_target_type ref +); + +@swift_check_expression_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_check_expression, index] +swift_check_expression_type( + int swift_check_expression: @swift_check_expression ref, + int index: int ref, + unique int type__: @swift_check_expression_type_type ref +); + +swift_check_expression_def( + unique int id: @swift_check_expression, + int name: @swift_check_expression_name_type ref, + int op: int ref +); + +@swift_class_body_child_type = @swift_associatedtype_declaration | @swift_class_declaration | @swift_deinit_declaration | @swift_function_declaration | @swift_import_declaration | @swift_init_declaration | @swift_operator_declaration | @swift_precedence_group_declaration | @swift_property_declaration | @swift_protocol_declaration | @swift_subscript_declaration | @swift_token_multiline_comment | @swift_typealias_declaration + +#keyset[swift_class_body, index] +swift_class_body_child( + int swift_class_body: @swift_class_body ref, + int index: int ref, + unique int child: @swift_class_body_child_type ref +); + +swift_class_body_def( + unique int id: @swift_class_body +); + +@swift_class_declaration_body_type = @swift_class_body | @swift_enum_class_body + +case @swift_class_declaration.declaration_kind of + 0 = @swift_class_declaration_actor +| 1 = @swift_class_declaration_class +| 2 = @swift_class_declaration_enum +| 3 = @swift_class_declaration_extension +| 4 = @swift_class_declaration_struct +; + + +@swift_class_declaration_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_type_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +@swift_class_declaration_child_type = @swift_attribute | @swift_inheritance_specifier | @swift_modifiers | @swift_token_inheritance_modifier | @swift_token_ownership_modifier | @swift_token_property_behavior_modifier | @swift_type_constraints | @swift_type_parameters + +#keyset[swift_class_declaration, index] +swift_class_declaration_child( + int swift_class_declaration: @swift_class_declaration ref, + int index: int ref, + unique int child: @swift_class_declaration_child_type ref +); + +swift_class_declaration_def( + unique int id: @swift_class_declaration, + int body: @swift_class_declaration_body_type ref, + int declaration_kind: int ref, + int name: @swift_class_declaration_name_type ref +); + +@swift_comparison_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_comparison_expression, index] +swift_comparison_expression_lhs( + int swift_comparison_expression: @swift_comparison_expression ref, + int index: int ref, + unique int lhs: @swift_comparison_expression_lhs_type ref +); + +case @swift_comparison_expression.op of + 0 = @swift_comparison_expression_langle +| 1 = @swift_comparison_expression_langleequal +| 2 = @swift_comparison_expression_rangle +| 3 = @swift_comparison_expression_rangleequal +; + + +@swift_comparison_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_comparison_expression, index] +swift_comparison_expression_rhs( + int swift_comparison_expression: @swift_comparison_expression ref, + int index: int ref, + unique int rhs: @swift_comparison_expression_rhs_type ref +); + +swift_comparison_expression_def( + unique int id: @swift_comparison_expression, + int op: int ref +); + +@swift_computed_getter_child_type = @swift_attribute | @swift_getter_specifier | @swift_statements + +#keyset[swift_computed_getter, index] +swift_computed_getter_child( + int swift_computed_getter: @swift_computed_getter ref, + int index: int ref, + unique int child: @swift_computed_getter_child_type ref +); + +swift_computed_getter_def( + unique int id: @swift_computed_getter +); + +@swift_computed_modify_child_type = @swift_attribute | @swift_modify_specifier | @swift_statements + +#keyset[swift_computed_modify, index] +swift_computed_modify_child( + int swift_computed_modify: @swift_computed_modify ref, + int index: int ref, + unique int child: @swift_computed_modify_child_type ref +); + +swift_computed_modify_def( + unique int id: @swift_computed_modify +); + +@swift_computed_property_child_type = @swift_computed_getter | @swift_computed_modify | @swift_computed_setter | @swift_statements + +#keyset[swift_computed_property, index] +swift_computed_property_child( + int swift_computed_property: @swift_computed_property ref, + int index: int ref, + unique int child: @swift_computed_property_child_type ref +); + +swift_computed_property_def( + unique int id: @swift_computed_property +); + +@swift_computed_setter_child_type = @swift_attribute | @swift_setter_specifier | @swift_statements | @swift_token_simple_identifier + +#keyset[swift_computed_setter, index] +swift_computed_setter_child( + int swift_computed_setter: @swift_computed_setter ref, + int index: int ref, + unique int child: @swift_computed_setter_child_type ref +); + +swift_computed_setter_def( + unique int id: @swift_computed_setter +); + +@swift_conjunction_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_conjunction_expression, index] +swift_conjunction_expression_lhs( + int swift_conjunction_expression: @swift_conjunction_expression ref, + int index: int ref, + unique int lhs: @swift_conjunction_expression_lhs_type ref +); + +case @swift_conjunction_expression.op of + 0 = @swift_conjunction_expression_ampersandampersand +; + + +@swift_conjunction_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_conjunction_expression, index] +swift_conjunction_expression_rhs( + int swift_conjunction_expression: @swift_conjunction_expression ref, + int index: int ref, + unique int rhs: @swift_conjunction_expression_rhs_type ref +); + +swift_conjunction_expression_def( + unique int id: @swift_conjunction_expression, + int op: int ref +); + +@swift_constructor_expression_constructed_type_type = @swift_array_type | @swift_dictionary_type | @swift_user_type + +swift_constructor_expression_def( + unique int id: @swift_constructor_expression, + int constructed_type: @swift_constructor_expression_constructed_type_type ref, + int child: @swift_constructor_suffix ref +); + +#keyset[swift_constructor_suffix, index] +swift_constructor_suffix_name( + int swift_constructor_suffix: @swift_constructor_suffix ref, + int index: int ref, + unique int name: @swift_token_simple_identifier ref +); + +@swift_constructor_suffix_child_type = @swift_lambda_literal | @swift_value_arguments + +#keyset[swift_constructor_suffix, index] +swift_constructor_suffix_child( + int swift_constructor_suffix: @swift_constructor_suffix ref, + int index: int ref, + unique int child: @swift_constructor_suffix_child_type ref +); + +swift_constructor_suffix_def( + unique int id: @swift_constructor_suffix +); + +@swift_control_transfer_statement_result_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_control_transfer_statement, index] +swift_control_transfer_statement_result( + int swift_control_transfer_statement: @swift_control_transfer_statement ref, + int index: int ref, + unique int result: @swift_control_transfer_statement_result_type ref +); + +@swift_control_transfer_statement_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_throw_keyword | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_control_transfer_statement, index] +swift_control_transfer_statement_child( + int swift_control_transfer_statement: @swift_control_transfer_statement ref, + int index: int ref, + unique int child: @swift_control_transfer_statement_child_type ref +); + +swift_control_transfer_statement_def( + unique int id: @swift_control_transfer_statement +); + +swift_deinit_declaration_child( + unique int swift_deinit_declaration: @swift_deinit_declaration ref, + unique int child: @swift_modifiers ref +); + +swift_deinit_declaration_def( + unique int id: @swift_deinit_declaration, + int body: @swift_function_body ref +); + +@swift_deprecated_operator_declaration_body_child_type = @swift_line_string_literal | @swift_multi_line_string_literal | @swift_raw_string_literal | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_simple_identifier + +#keyset[swift_deprecated_operator_declaration_body, index] +swift_deprecated_operator_declaration_body_child( + int swift_deprecated_operator_declaration_body: @swift_deprecated_operator_declaration_body ref, + int index: int ref, + unique int child: @swift_deprecated_operator_declaration_body_child_type ref +); + +swift_deprecated_operator_declaration_body_def( + unique int id: @swift_deprecated_operator_declaration_body +); + +@swift_dictionary_literal_key_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_dictionary_literal, index] +swift_dictionary_literal_key( + int swift_dictionary_literal: @swift_dictionary_literal ref, + int index: int ref, + unique int key__: @swift_dictionary_literal_key_type ref +); + +@swift_dictionary_literal_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_dictionary_literal, index] +swift_dictionary_literal_value( + int swift_dictionary_literal: @swift_dictionary_literal ref, + int index: int ref, + unique int value: @swift_dictionary_literal_value_type ref +); + +swift_dictionary_literal_def( + unique int id: @swift_dictionary_literal +); + +@swift_dictionary_type_key_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_dictionary_type, index] +swift_dictionary_type_key( + int swift_dictionary_type: @swift_dictionary_type ref, + int index: int ref, + unique int key__: @swift_dictionary_type_key_type ref +); + +@swift_dictionary_type_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_dictionary_type, index] +swift_dictionary_type_name( + int swift_dictionary_type: @swift_dictionary_type ref, + int index: int ref, + unique int name: @swift_dictionary_type_name_type ref +); + +@swift_dictionary_type_value_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_dictionary_type, index] +swift_dictionary_type_value( + int swift_dictionary_type: @swift_dictionary_type ref, + int index: int ref, + unique int value: @swift_dictionary_type_value_type ref +); + +swift_dictionary_type_def( + unique int id: @swift_dictionary_type +); + +@swift_didset_clause_child_type = @swift_modifiers | @swift_statements | @swift_token_simple_identifier + +#keyset[swift_didset_clause, index] +swift_didset_clause_child( + int swift_didset_clause: @swift_didset_clause ref, + int index: int ref, + unique int child: @swift_didset_clause_child_type ref +); + +swift_didset_clause_def( + unique int id: @swift_didset_clause +); + +@swift_directive_child_type = @swift_token_boolean_literal | @swift_token_integer_literal | @swift_token_simple_identifier + +#keyset[swift_directive, index] +swift_directive_child( + int swift_directive: @swift_directive ref, + int index: int ref, + unique int child: @swift_directive_child_type ref +); + +swift_directive_def( + unique int id: @swift_directive +); + +@swift_directly_assignable_expression_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +swift_directly_assignable_expression_child( + unique int swift_directly_assignable_expression: @swift_directly_assignable_expression ref, + unique int child: @swift_directly_assignable_expression_child_type ref +); + +swift_directly_assignable_expression_def( + unique int id: @swift_directly_assignable_expression +); + +@swift_disjunction_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_disjunction_expression, index] +swift_disjunction_expression_lhs( + int swift_disjunction_expression: @swift_disjunction_expression ref, + int index: int ref, + unique int lhs: @swift_disjunction_expression_lhs_type ref +); + +case @swift_disjunction_expression.op of + 0 = @swift_disjunction_expression_pipepipe +; + + +@swift_disjunction_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_disjunction_expression, index] +swift_disjunction_expression_rhs( + int swift_disjunction_expression: @swift_disjunction_expression ref, + int index: int ref, + unique int rhs: @swift_disjunction_expression_rhs_type ref +); + +swift_disjunction_expression_def( + unique int id: @swift_disjunction_expression, + int op: int ref +); + +@swift_do_statement_child_type = @swift_catch_block | @swift_statements + +#keyset[swift_do_statement, index] +swift_do_statement_child( + int swift_do_statement: @swift_do_statement ref, + int index: int ref, + unique int child: @swift_do_statement_child_type ref +); + +swift_do_statement_def( + unique int id: @swift_do_statement +); + +@swift_enum_class_body_child_type = @swift_associatedtype_declaration | @swift_class_declaration | @swift_deinit_declaration | @swift_enum_entry | @swift_function_declaration | @swift_import_declaration | @swift_init_declaration | @swift_operator_declaration | @swift_precedence_group_declaration | @swift_property_declaration | @swift_protocol_declaration | @swift_subscript_declaration | @swift_typealias_declaration + +#keyset[swift_enum_class_body, index] +swift_enum_class_body_child( + int swift_enum_class_body: @swift_enum_class_body ref, + int index: int ref, + unique int child: @swift_enum_class_body_child_type ref +); + +swift_enum_class_body_def( + unique int id: @swift_enum_class_body +); + +#keyset[swift_enum_entry, index] +swift_enum_entry_data_contents( + int swift_enum_entry: @swift_enum_entry ref, + int index: int ref, + unique int data_contents: @swift_enum_type_parameters ref +); + +#keyset[swift_enum_entry, index] +swift_enum_entry_name( + int swift_enum_entry: @swift_enum_entry ref, + int index: int ref, + unique int name: @swift_token_simple_identifier ref +); + +@swift_enum_entry_raw_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_enum_entry, index] +swift_enum_entry_raw_value( + int swift_enum_entry: @swift_enum_entry ref, + int index: int ref, + unique int raw_value: @swift_enum_entry_raw_value_type ref +); + +swift_enum_entry_child( + unique int swift_enum_entry: @swift_enum_entry ref, + unique int child: @swift_modifiers ref +); + +swift_enum_entry_def( + unique int id: @swift_enum_entry +); + +@swift_enum_type_parameters_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_enum_type_parameters, index] +swift_enum_type_parameters_name( + int swift_enum_type_parameters: @swift_enum_type_parameters ref, + int index: int ref, + unique int name: @swift_enum_type_parameters_name_type ref +); + +@swift_enum_type_parameters_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_wildcard_pattern | @swift_try_expression | @swift_tuple_expression | @swift_type_modifiers | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_enum_type_parameters, index] +swift_enum_type_parameters_child( + int swift_enum_type_parameters: @swift_enum_type_parameters ref, + int index: int ref, + unique int child: @swift_enum_type_parameters_child_type ref +); + +swift_enum_type_parameters_def( + unique int id: @swift_enum_type_parameters +); + +@swift_equality_constraint_constrained_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_identifier | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_equality_constraint, index] +swift_equality_constraint_constrained_type( + int swift_equality_constraint: @swift_equality_constraint ref, + int index: int ref, + unique int constrained_type: @swift_equality_constraint_constrained_type_type ref +); + +@swift_equality_constraint_must_equal_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_equality_constraint, index] +swift_equality_constraint_must_equal( + int swift_equality_constraint: @swift_equality_constraint ref, + int index: int ref, + unique int must_equal: @swift_equality_constraint_must_equal_type ref +); + +@swift_equality_constraint_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_equality_constraint, index] +swift_equality_constraint_child( + int swift_equality_constraint: @swift_equality_constraint ref, + int index: int ref, + unique int child: @swift_attribute ref +); + +swift_equality_constraint_def( + unique int id: @swift_equality_constraint, + int name: @swift_equality_constraint_name_type ref +); + +@swift_equality_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_equality_expression, index] +swift_equality_expression_lhs( + int swift_equality_expression: @swift_equality_expression ref, + int index: int ref, + unique int lhs: @swift_equality_expression_lhs_type ref +); + +case @swift_equality_expression.op of + 0 = @swift_equality_expression_bangequal +| 1 = @swift_equality_expression_bangequalequal +| 2 = @swift_equality_expression_equalequal +| 3 = @swift_equality_expression_equalequalequal +; + + +@swift_equality_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_equality_expression, index] +swift_equality_expression_rhs( + int swift_equality_expression: @swift_equality_expression ref, + int index: int ref, + unique int rhs: @swift_equality_expression_rhs_type ref +); + +swift_equality_expression_def( + unique int id: @swift_equality_expression, + int op: int ref +); + +@swift_existential_type_child_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_existential_type_def( + unique int id: @swift_existential_type, + int child: @swift_existential_type_child_type ref +); + +swift_external_macro_definition_def( + unique int id: @swift_external_macro_definition, + int child: @swift_value_arguments ref +); + +@swift_for_statement_collection_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_for_statement, index] +swift_for_statement_collection( + int swift_for_statement: @swift_for_statement ref, + int index: int ref, + unique int collection: @swift_for_statement_collection_type ref +); + +@swift_for_statement_child_type = @swift_statements | @swift_token_try_operator | @swift_type_annotation | @swift_where_clause + +#keyset[swift_for_statement, index] +swift_for_statement_child( + int swift_for_statement: @swift_for_statement ref, + int index: int ref, + unique int child: @swift_for_statement_child_type ref +); + +swift_for_statement_def( + unique int id: @swift_for_statement, + int item: @swift_pattern ref +); + +swift_function_body_child( + unique int swift_function_body: @swift_function_body ref, + unique int child: @swift_statements ref +); + +swift_function_body_def( + unique int id: @swift_function_body +); + +@swift_function_declaration_default_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_function_declaration, index] +swift_function_declaration_default_value( + int swift_function_declaration: @swift_function_declaration ref, + int index: int ref, + unique int default_value: @swift_function_declaration_default_value_type ref +); + +@swift_function_declaration_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_token_bang | @swift_token_custom_operator | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_function_declaration, index] +swift_function_declaration_name( + int swift_function_declaration: @swift_function_declaration ref, + int index: int ref, + unique int name: @swift_function_declaration_name_type ref +); + +@swift_function_declaration_return_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_function_declaration, index] +swift_function_declaration_return_type( + int swift_function_declaration: @swift_function_declaration ref, + int index: int ref, + unique int return_type: @swift_function_declaration_return_type_type ref +); + +@swift_function_declaration_child_type = @swift_attribute | @swift_modifiers | @swift_parameter | @swift_throws_clause | @swift_token_inheritance_modifier | @swift_token_ownership_modifier | @swift_token_property_behavior_modifier | @swift_token_throws | @swift_type_constraints | @swift_type_parameters + +#keyset[swift_function_declaration, index] +swift_function_declaration_child( + int swift_function_declaration: @swift_function_declaration ref, + int index: int ref, + unique int child: @swift_function_declaration_child_type ref +); + +swift_function_declaration_def( + unique int id: @swift_function_declaration, + int body: @swift_function_body ref +); + +@swift_function_type_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +@swift_function_type_params_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +@swift_function_type_return_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_function_type, index] +swift_function_type_return_type( + int swift_function_type: @swift_function_type ref, + int index: int ref, + unique int return_type: @swift_function_type_return_type_type ref +); + +@swift_function_type_child_type = @swift_throws_clause | @swift_token_throws + +swift_function_type_child( + unique int swift_function_type: @swift_function_type ref, + unique int child: @swift_function_type_child_type ref +); + +swift_function_type_def( + unique int id: @swift_function_type, + int name: @swift_function_type_name_type ref, + int params: @swift_function_type_params_type ref +); + +@swift_getter_specifier_child_type = @swift_throws_clause | @swift_token_mutation_modifier | @swift_token_throws + +#keyset[swift_getter_specifier, index] +swift_getter_specifier_child( + int swift_getter_specifier: @swift_getter_specifier ref, + int index: int ref, + unique int child: @swift_getter_specifier_child_type ref +); + +swift_getter_specifier_def( + unique int id: @swift_getter_specifier +); + +#keyset[swift_guard_statement, index] +swift_guard_statement_bound_identifier( + int swift_guard_statement: @swift_guard_statement ref, + int index: int ref, + unique int bound_identifier: @swift_token_simple_identifier ref +); + +@swift_guard_statement_condition_type = @swift_additive_expression | @swift_array_literal | @swift_array_type | @swift_as_expression | @swift_assignment | @swift_availability_condition | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_dictionary_type | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_existential_type | @swift_function_type | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_metatype | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_opaque_type | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_optional_type | @swift_pattern | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_protocol_composition_type | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_suppressed_constraint | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_wildcard_pattern | @swift_try_expression | @swift_tuple_expression | @swift_tuple_type | @swift_type_annotation | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type | @swift_value_binding_pattern | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_where_clause + +#keyset[swift_guard_statement, index] +swift_guard_statement_condition( + int swift_guard_statement: @swift_guard_statement ref, + int index: int ref, + unique int condition: @swift_guard_statement_condition_type ref +); + +@swift_guard_statement_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_guard_statement, index] +swift_guard_statement_name( + int swift_guard_statement: @swift_guard_statement ref, + int index: int ref, + unique int name: @swift_guard_statement_name_type ref +); + +@swift_guard_statement_child_type = @swift_statements | @swift_token_else + +#keyset[swift_guard_statement, index] +swift_guard_statement_child( + int swift_guard_statement: @swift_guard_statement ref, + int index: int ref, + unique int child: @swift_guard_statement_child_type ref +); + +swift_guard_statement_def( + unique int id: @swift_guard_statement +); + +#keyset[swift_identifier, index] +swift_identifier_child( + int swift_identifier: @swift_identifier ref, + int index: int ref, + unique int child: @swift_token_simple_identifier ref +); + +swift_identifier_def( + unique int id: @swift_identifier +); + +#keyset[swift_if_statement, index] +swift_if_statement_bound_identifier( + int swift_if_statement: @swift_if_statement ref, + int index: int ref, + unique int bound_identifier: @swift_token_simple_identifier ref +); + +@swift_if_statement_condition_type = @swift_additive_expression | @swift_array_literal | @swift_array_type | @swift_as_expression | @swift_assignment | @swift_availability_condition | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_dictionary_type | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_existential_type | @swift_function_type | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_metatype | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_opaque_type | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_optional_type | @swift_pattern | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_protocol_composition_type | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_suppressed_constraint | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_wildcard_pattern | @swift_try_expression | @swift_tuple_expression | @swift_tuple_type | @swift_type_annotation | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type | @swift_value_binding_pattern | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_where_clause + +#keyset[swift_if_statement, index] +swift_if_statement_condition( + int swift_if_statement: @swift_if_statement ref, + int index: int ref, + unique int condition: @swift_if_statement_condition_type ref +); + +@swift_if_statement_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_if_statement, index] +swift_if_statement_name( + int swift_if_statement: @swift_if_statement ref, + int index: int ref, + unique int name: @swift_if_statement_name_type ref +); + +@swift_if_statement_child_type = @swift_if_statement | @swift_statements | @swift_token_else + +#keyset[swift_if_statement, index] +swift_if_statement_child( + int swift_if_statement: @swift_if_statement ref, + int index: int ref, + unique int child: @swift_if_statement_child_type ref +); + +swift_if_statement_def( + unique int id: @swift_if_statement +); + +@swift_import_declaration_child_type = @swift_identifier | @swift_modifiers + +#keyset[swift_import_declaration, index] +swift_import_declaration_child( + int swift_import_declaration: @swift_import_declaration ref, + int index: int ref, + unique int child: @swift_import_declaration_child_type ref +); + +swift_import_declaration_def( + unique int id: @swift_import_declaration +); + +@swift_infix_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_infix_expression, index] +swift_infix_expression_lhs( + int swift_infix_expression: @swift_infix_expression ref, + int index: int ref, + unique int lhs: @swift_infix_expression_lhs_type ref +); + +@swift_infix_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_infix_expression, index] +swift_infix_expression_rhs( + int swift_infix_expression: @swift_infix_expression ref, + int index: int ref, + unique int rhs: @swift_infix_expression_rhs_type ref +); + +swift_infix_expression_def( + unique int id: @swift_infix_expression, + int op: @swift_token_custom_operator ref +); + +@swift_inheritance_constraint_constrained_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_identifier | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_inheritance_constraint, index] +swift_inheritance_constraint_constrained_type( + int swift_inheritance_constraint: @swift_inheritance_constraint ref, + int index: int ref, + unique int constrained_type: @swift_inheritance_constraint_constrained_type_type ref +); + +@swift_inheritance_constraint_inherits_from_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_inheritance_constraint, index] +swift_inheritance_constraint_inherits_from( + int swift_inheritance_constraint: @swift_inheritance_constraint ref, + int index: int ref, + unique int inherits_from: @swift_inheritance_constraint_inherits_from_type ref +); + +@swift_inheritance_constraint_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_inheritance_constraint, index] +swift_inheritance_constraint_child( + int swift_inheritance_constraint: @swift_inheritance_constraint ref, + int index: int ref, + unique int child: @swift_attribute ref +); + +swift_inheritance_constraint_def( + unique int id: @swift_inheritance_constraint, + int name: @swift_inheritance_constraint_name_type ref +); + +@swift_inheritance_specifier_inherits_from_type = @swift_function_type | @swift_suppressed_constraint | @swift_user_type + +swift_inheritance_specifier_def( + unique int id: @swift_inheritance_specifier, + int inherits_from: @swift_inheritance_specifier_inherits_from_type ref +); + +swift_init_declaration_body( + unique int swift_init_declaration: @swift_init_declaration ref, + unique int body: @swift_function_body ref +); + +@swift_init_declaration_default_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_init_declaration, index] +swift_init_declaration_default_value( + int swift_init_declaration: @swift_init_declaration ref, + int index: int ref, + unique int default_value: @swift_init_declaration_default_value_type ref +); + +case @swift_init_declaration.name of + 0 = @swift_init_declaration_init +; + + +@swift_init_declaration_child_type = @swift_attribute | @swift_modifiers | @swift_parameter | @swift_throws_clause | @swift_token_bang | @swift_token_throws | @swift_type_constraints | @swift_type_parameters + +#keyset[swift_init_declaration, index] +swift_init_declaration_child( + int swift_init_declaration: @swift_init_declaration ref, + int index: int ref, + unique int child: @swift_init_declaration_child_type ref +); + +swift_init_declaration_def( + unique int id: @swift_init_declaration, + int name: int ref +); + +swift_interpolated_expression_name( + unique int swift_interpolated_expression: @swift_interpolated_expression ref, + unique int name: @swift_value_argument_label ref +); + +#keyset[swift_interpolated_expression, index] +swift_interpolated_expression_reference_specifier( + int swift_interpolated_expression: @swift_interpolated_expression ref, + int index: int ref, + unique int reference_specifier: @swift_value_argument_label ref +); + +@swift_interpolated_expression_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_interpolated_expression, index] +swift_interpolated_expression_value( + int swift_interpolated_expression: @swift_interpolated_expression ref, + int index: int ref, + unique int value: @swift_interpolated_expression_value_type ref +); + +swift_interpolated_expression_child( + unique int swift_interpolated_expression: @swift_interpolated_expression ref, + unique int child: @swift_type_modifiers ref +); + +swift_interpolated_expression_def( + unique int id: @swift_interpolated_expression +); + +@swift_key_path_expression_child_type = @swift_array_type | @swift_dictionary_type | @swift_token_bang | @swift_token_simple_identifier | @swift_token_type_identifier | @swift_type_arguments | @swift_value_argument + +#keyset[swift_key_path_expression, index] +swift_key_path_expression_child( + int swift_key_path_expression: @swift_key_path_expression ref, + int index: int ref, + unique int child: @swift_key_path_expression_child_type ref +); + +swift_key_path_expression_def( + unique int id: @swift_key_path_expression +); + +@swift_key_path_string_expression_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +swift_key_path_string_expression_child( + unique int swift_key_path_string_expression: @swift_key_path_string_expression ref, + unique int child: @swift_key_path_string_expression_child_type ref +); + +swift_key_path_string_expression_def( + unique int id: @swift_key_path_string_expression +); + +@swift_lambda_function_type_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_lambda_function_type_name( + unique int swift_lambda_function_type: @swift_lambda_function_type ref, + unique int name: @swift_lambda_function_type_name_type ref +); + +@swift_lambda_function_type_return_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_lambda_function_type, index] +swift_lambda_function_type_return_type( + int swift_lambda_function_type: @swift_lambda_function_type ref, + int index: int ref, + unique int return_type: @swift_lambda_function_type_return_type_type ref +); + +@swift_lambda_function_type_child_type = @swift_lambda_function_type_parameters | @swift_throws_clause | @swift_token_throws + +#keyset[swift_lambda_function_type, index] +swift_lambda_function_type_child( + int swift_lambda_function_type: @swift_lambda_function_type ref, + int index: int ref, + unique int child: @swift_lambda_function_type_child_type ref +); + +swift_lambda_function_type_def( + unique int id: @swift_lambda_function_type +); + +#keyset[swift_lambda_function_type_parameters, index] +swift_lambda_function_type_parameters_child( + int swift_lambda_function_type_parameters: @swift_lambda_function_type_parameters ref, + int index: int ref, + unique int child: @swift_lambda_parameter ref +); + +swift_lambda_function_type_parameters_def( + unique int id: @swift_lambda_function_type_parameters +); + +swift_lambda_literal_captures( + unique int swift_lambda_literal: @swift_lambda_literal ref, + unique int captures: @swift_capture_list ref +); + +swift_lambda_literal_type( + unique int swift_lambda_literal: @swift_lambda_literal ref, + unique int type__: @swift_lambda_function_type ref +); + +@swift_lambda_literal_child_type = @swift_attribute | @swift_statements + +#keyset[swift_lambda_literal, index] +swift_lambda_literal_child( + int swift_lambda_literal: @swift_lambda_literal ref, + int index: int ref, + unique int child: @swift_lambda_literal_child_type ref +); + +swift_lambda_literal_def( + unique int id: @swift_lambda_literal +); + +swift_lambda_parameter_external_name( + unique int swift_lambda_parameter: @swift_lambda_parameter ref, + unique int external_name: @swift_token_simple_identifier ref +); + +@swift_lambda_parameter_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_lambda_parameter, index] +swift_lambda_parameter_name( + int swift_lambda_parameter: @swift_lambda_parameter ref, + int index: int ref, + unique int name: @swift_lambda_parameter_name_type ref +); + +@swift_lambda_parameter_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_lambda_parameter, index] +swift_lambda_parameter_type( + int swift_lambda_parameter: @swift_lambda_parameter ref, + int index: int ref, + unique int type__: @swift_lambda_parameter_type_type ref +); + +@swift_lambda_parameter_child_type = @swift_parameter_modifiers | @swift_token_self_expression + +swift_lambda_parameter_child( + unique int swift_lambda_parameter: @swift_lambda_parameter ref, + unique int child: @swift_lambda_parameter_child_type ref +); + +swift_lambda_parameter_def( + unique int id: @swift_lambda_parameter +); + +#keyset[swift_line_string_literal, index] +swift_line_string_literal_interpolation( + int swift_line_string_literal: @swift_line_string_literal ref, + int index: int ref, + unique int interpolation: @swift_interpolated_expression ref +); + +@swift_line_string_literal_text_type = @swift_token_line_str_text | @swift_token_str_escaped_char + +#keyset[swift_line_string_literal, index] +swift_line_string_literal_text( + int swift_line_string_literal: @swift_line_string_literal ref, + int index: int ref, + unique int text: @swift_line_string_literal_text_type ref +); + +swift_line_string_literal_def( + unique int id: @swift_line_string_literal +); + +@swift_macro_declaration_default_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_macro_declaration, index] +swift_macro_declaration_default_value( + int swift_macro_declaration: @swift_macro_declaration ref, + int index: int ref, + unique int default_value: @swift_macro_declaration_default_value_type ref +); + +swift_macro_declaration_definition( + unique int swift_macro_declaration: @swift_macro_declaration ref, + unique int definition: @swift_macro_definition ref +); + +@swift_macro_declaration_child_type = @swift_array_type | @swift_attribute | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_modifiers | @swift_opaque_type | @swift_optional_type | @swift_parameter | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_constraints | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_type_parameters | @swift_user_type + +#keyset[swift_macro_declaration, index] +swift_macro_declaration_child( + int swift_macro_declaration: @swift_macro_declaration ref, + int index: int ref, + unique int child: @swift_macro_declaration_child_type ref +); + +swift_macro_declaration_def( + unique int id: @swift_macro_declaration +); + +@swift_macro_definition_body_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_external_macro_definition | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_macro_definition, index] +swift_macro_definition_body( + int swift_macro_definition: @swift_macro_definition ref, + int index: int ref, + unique int body: @swift_macro_definition_body_type ref +); + +swift_macro_definition_def( + unique int id: @swift_macro_definition +); + +@swift_macro_invocation_child_type = @swift_call_suffix | @swift_token_simple_identifier | @swift_type_parameters + +#keyset[swift_macro_invocation, index] +swift_macro_invocation_child( + int swift_macro_invocation: @swift_macro_invocation ref, + int index: int ref, + unique int child: @swift_macro_invocation_child_type ref +); + +swift_macro_invocation_def( + unique int id: @swift_macro_invocation +); + +@swift_metatype_child_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_metatype_def( + unique int id: @swift_metatype, + int child: @swift_metatype_child_type ref +); + +@swift_modifiers_child_type = @swift_attribute | @swift_token_function_modifier | @swift_token_inheritance_modifier | @swift_token_member_modifier | @swift_token_mutation_modifier | @swift_token_ownership_modifier | @swift_token_parameter_modifier | @swift_token_property_behavior_modifier | @swift_token_property_modifier | @swift_token_visibility_modifier + +#keyset[swift_modifiers, index] +swift_modifiers_child( + int swift_modifiers: @swift_modifiers ref, + int index: int ref, + unique int child: @swift_modifiers_child_type ref +); + +swift_modifiers_def( + unique int id: @swift_modifiers +); + +swift_modify_specifier_child( + unique int swift_modify_specifier: @swift_modify_specifier ref, + unique int child: @swift_token_mutation_modifier ref +); + +swift_modify_specifier_def( + unique int id: @swift_modify_specifier +); + +#keyset[swift_multi_line_string_literal, index] +swift_multi_line_string_literal_interpolation( + int swift_multi_line_string_literal: @swift_multi_line_string_literal ref, + int index: int ref, + unique int interpolation: @swift_interpolated_expression ref +); + +@swift_multi_line_string_literal_text_type = @swift_reserved_word | @swift_token_multi_line_str_text | @swift_token_str_escaped_char + +#keyset[swift_multi_line_string_literal, index] +swift_multi_line_string_literal_text( + int swift_multi_line_string_literal: @swift_multi_line_string_literal ref, + int index: int ref, + unique int text: @swift_multi_line_string_literal_text_type ref +); + +swift_multi_line_string_literal_def( + unique int id: @swift_multi_line_string_literal +); + +@swift_multiplicative_expression_lhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_multiplicative_expression, index] +swift_multiplicative_expression_lhs( + int swift_multiplicative_expression: @swift_multiplicative_expression ref, + int index: int ref, + unique int lhs: @swift_multiplicative_expression_lhs_type ref +); + +case @swift_multiplicative_expression.op of + 0 = @swift_multiplicative_expression_percent +| 1 = @swift_multiplicative_expression_star +| 2 = @swift_multiplicative_expression_slash +; + + +@swift_multiplicative_expression_rhs_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_multiplicative_expression, index] +swift_multiplicative_expression_rhs( + int swift_multiplicative_expression: @swift_multiplicative_expression ref, + int index: int ref, + unique int rhs: @swift_multiplicative_expression_rhs_type ref +); + +swift_multiplicative_expression_def( + unique int id: @swift_multiplicative_expression, + int op: int ref +); + +@swift_navigation_expression_element_type = @swift_dictionary_type | @swift_existential_type | @swift_opaque_type + +swift_navigation_expression_element( + unique int swift_navigation_expression: @swift_navigation_expression ref, + unique int element: @swift_navigation_expression_element_type ref +); + +@swift_navigation_expression_target_type = @swift_additive_expression | @swift_array_literal | @swift_array_type | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_dictionary_type | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_existential_type | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_opaque_type | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_user_type | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_navigation_expression, index] +swift_navigation_expression_target( + int swift_navigation_expression: @swift_navigation_expression ref, + int index: int ref, + unique int target: @swift_navigation_expression_target_type ref +); + +swift_navigation_expression_def( + unique int id: @swift_navigation_expression, + int suffix: @swift_navigation_suffix ref +); + +@swift_navigation_suffix_suffix_type = @swift_token_integer_literal | @swift_token_simple_identifier + +swift_navigation_suffix_def( + unique int id: @swift_navigation_suffix, + int suffix: @swift_navigation_suffix_suffix_type ref +); + +@swift_nil_coalescing_expression_if_nil_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_nil_coalescing_expression, index] +swift_nil_coalescing_expression_if_nil( + int swift_nil_coalescing_expression: @swift_nil_coalescing_expression ref, + int index: int ref, + unique int if_nil: @swift_nil_coalescing_expression_if_nil_type ref +); + +@swift_nil_coalescing_expression_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_nil_coalescing_expression, index] +swift_nil_coalescing_expression_value( + int swift_nil_coalescing_expression: @swift_nil_coalescing_expression ref, + int index: int ref, + unique int value: @swift_nil_coalescing_expression_value_type ref +); + +swift_nil_coalescing_expression_def( + unique int id: @swift_nil_coalescing_expression +); + +@swift_opaque_type_child_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_opaque_type_def( + unique int id: @swift_opaque_type, + int child: @swift_opaque_type_child_type ref +); + +@swift_open_end_range_expression_start_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_open_end_range_expression, index] +swift_open_end_range_expression_start( + int swift_open_end_range_expression: @swift_open_end_range_expression ref, + int index: int ref, + unique int start: @swift_open_end_range_expression_start_type ref +); + +swift_open_end_range_expression_def( + unique int id: @swift_open_end_range_expression +); + +@swift_open_start_range_expression_end_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_open_start_range_expression, index] +swift_open_start_range_expression_end( + int swift_open_start_range_expression: @swift_open_start_range_expression ref, + int index: int ref, + unique int end: @swift_open_start_range_expression_end_type ref +); + +swift_open_start_range_expression_def( + unique int id: @swift_open_start_range_expression +); + +@swift_operator_declaration_child_type = @swift_deprecated_operator_declaration_body | @swift_token_bang | @swift_token_custom_operator | @swift_token_simple_identifier + +#keyset[swift_operator_declaration, index] +swift_operator_declaration_child( + int swift_operator_declaration: @swift_operator_declaration ref, + int index: int ref, + unique int child: @swift_operator_declaration_child_type ref +); + +swift_operator_declaration_def( + unique int id: @swift_operator_declaration +); + +@swift_optional_type_wrapped_type = @swift_array_type | @swift_dictionary_type | @swift_tuple_type | @swift_user_type + +swift_optional_type_def( + unique int id: @swift_optional_type, + int wrapped: @swift_optional_type_wrapped_type ref +); + +swift_parameter_external_name( + unique int swift_parameter: @swift_parameter ref, + unique int external_name: @swift_token_simple_identifier ref +); + +@swift_parameter_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_parameter, index] +swift_parameter_name( + int swift_parameter: @swift_parameter ref, + int index: int ref, + unique int name: @swift_parameter_name_type ref +); + +@swift_parameter_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_parameter, index] +swift_parameter_type( + int swift_parameter: @swift_parameter ref, + int index: int ref, + unique int type__: @swift_parameter_type_type ref +); + +swift_parameter_child( + unique int swift_parameter: @swift_parameter ref, + unique int child: @swift_parameter_modifiers ref +); + +swift_parameter_def( + unique int id: @swift_parameter +); + +#keyset[swift_parameter_modifiers, index] +swift_parameter_modifiers_child( + int swift_parameter_modifiers: @swift_parameter_modifiers ref, + int index: int ref, + unique int child: @swift_token_parameter_modifier ref +); + +swift_parameter_modifiers_def( + unique int id: @swift_parameter_modifiers +); + +swift_pattern_bound_identifier( + unique int swift_pattern: @swift_pattern ref, + unique int bound_identifier: @swift_token_simple_identifier ref +); + +@swift_pattern_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_pattern_name( + unique int swift_pattern: @swift_pattern ref, + unique int name: @swift_pattern_name_type ref +); + +@swift_pattern_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_pattern | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_wildcard_pattern | @swift_try_expression | @swift_tuple_expression | @swift_type_modifiers | @swift_user_type | @swift_value_binding_pattern | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_pattern, index] +swift_pattern_child( + int swift_pattern: @swift_pattern ref, + int index: int ref, + unique int child: @swift_pattern_child_type ref +); + +swift_pattern_def( + unique int id: @swift_pattern +); + +@swift_playground_literal_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_playground_literal, index] +swift_playground_literal_child( + int swift_playground_literal: @swift_playground_literal ref, + int index: int ref, + unique int child: @swift_playground_literal_child_type ref +); + +swift_playground_literal_def( + unique int id: @swift_playground_literal +); + +@swift_postfix_expression_operation_type = @swift_reserved_word | @swift_token_bang + +@swift_postfix_expression_target_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_postfix_expression, index] +swift_postfix_expression_target( + int swift_postfix_expression: @swift_postfix_expression ref, + int index: int ref, + unique int target: @swift_postfix_expression_target_type ref +); + +swift_postfix_expression_def( + unique int id: @swift_postfix_expression, + int operation: @swift_postfix_expression_operation_type ref +); + +@swift_precedence_group_attribute_child_type = @swift_token_boolean_literal | @swift_token_simple_identifier + +#keyset[swift_precedence_group_attribute, index] +swift_precedence_group_attribute_child( + int swift_precedence_group_attribute: @swift_precedence_group_attribute ref, + int index: int ref, + unique int child: @swift_precedence_group_attribute_child_type ref +); + +swift_precedence_group_attribute_def( + unique int id: @swift_precedence_group_attribute +); + +#keyset[swift_precedence_group_attributes, index] +swift_precedence_group_attributes_child( + int swift_precedence_group_attributes: @swift_precedence_group_attributes ref, + int index: int ref, + unique int child: @swift_precedence_group_attribute ref +); + +swift_precedence_group_attributes_def( + unique int id: @swift_precedence_group_attributes +); + +@swift_precedence_group_declaration_child_type = @swift_precedence_group_attributes | @swift_token_simple_identifier + +#keyset[swift_precedence_group_declaration, index] +swift_precedence_group_declaration_child( + int swift_precedence_group_declaration: @swift_precedence_group_declaration ref, + int index: int ref, + unique int child: @swift_precedence_group_declaration_child_type ref +); + +swift_precedence_group_declaration_def( + unique int id: @swift_precedence_group_declaration +); + +@swift_prefix_expression_operation_type = @swift_reserved_word | @swift_token_bang | @swift_token_custom_operator + +@swift_prefix_expression_target_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token__expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_prefix_expression, index] +swift_prefix_expression_target( + int swift_prefix_expression: @swift_prefix_expression ref, + int index: int ref, + unique int target: @swift_prefix_expression_target_type ref +); + +swift_prefix_expression_def( + unique int id: @swift_prefix_expression, + int operation: @swift_prefix_expression_operation_type ref +); + +#keyset[swift_property_declaration, index] +swift_property_declaration_computed_value( + int swift_property_declaration: @swift_property_declaration ref, + int index: int ref, + unique int computed_value: @swift_computed_property ref +); + +#keyset[swift_property_declaration, index] +swift_property_declaration_name( + int swift_property_declaration: @swift_property_declaration ref, + int index: int ref, + unique int name: @swift_pattern ref +); + +@swift_property_declaration_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_property_declaration, index] +swift_property_declaration_value( + int swift_property_declaration: @swift_property_declaration ref, + int index: int ref, + unique int value: @swift_property_declaration_value_type ref +); + +@swift_property_declaration_child_type = @swift_attribute | @swift_modifiers | @swift_token_inheritance_modifier | @swift_token_ownership_modifier | @swift_token_property_behavior_modifier | @swift_type_annotation | @swift_type_constraints | @swift_value_binding_pattern | @swift_willset_didset_block + +#keyset[swift_property_declaration, index] +swift_property_declaration_child( + int swift_property_declaration: @swift_property_declaration ref, + int index: int ref, + unique int child: @swift_property_declaration_child_type ref +); + +swift_property_declaration_def( + unique int id: @swift_property_declaration +); + +#keyset[swift_protocol_body, index] +swift_protocol_body_body( + int swift_protocol_body: @swift_protocol_body ref, + int index: int ref, + unique int body: @swift_protocol_function_declaration ref +); + +@swift_protocol_body_child_type = @swift_associatedtype_declaration | @swift_deinit_declaration | @swift_init_declaration | @swift_protocol_function_declaration | @swift_protocol_property_declaration | @swift_subscript_declaration | @swift_typealias_declaration + +#keyset[swift_protocol_body, index] +swift_protocol_body_child( + int swift_protocol_body: @swift_protocol_body ref, + int index: int ref, + unique int child: @swift_protocol_body_child_type ref +); + +swift_protocol_body_def( + unique int id: @swift_protocol_body +); + +@swift_protocol_composition_type_child_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_protocol_composition_type, index] +swift_protocol_composition_type_child( + int swift_protocol_composition_type: @swift_protocol_composition_type ref, + int index: int ref, + unique int child: @swift_protocol_composition_type_child_type ref +); + +swift_protocol_composition_type_def( + unique int id: @swift_protocol_composition_type +); + +case @swift_protocol_declaration.declaration_kind of + 0 = @swift_protocol_declaration_protocol +; + + +@swift_protocol_declaration_child_type = @swift_attribute | @swift_inheritance_specifier | @swift_modifiers | @swift_type_constraints | @swift_type_parameters + +#keyset[swift_protocol_declaration, index] +swift_protocol_declaration_child( + int swift_protocol_declaration: @swift_protocol_declaration ref, + int index: int ref, + unique int child: @swift_protocol_declaration_child_type ref +); + +swift_protocol_declaration_def( + unique int id: @swift_protocol_declaration, + int body: @swift_protocol_body ref, + int declaration_kind: int ref, + int name: @swift_token_type_identifier ref +); + +@swift_protocol_function_declaration_default_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_protocol_function_declaration, index] +swift_protocol_function_declaration_default_value( + int swift_protocol_function_declaration: @swift_protocol_function_declaration ref, + int index: int ref, + unique int default_value: @swift_protocol_function_declaration_default_value_type ref +); + +@swift_protocol_function_declaration_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_token_bang | @swift_token_custom_operator | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_protocol_function_declaration, index] +swift_protocol_function_declaration_name( + int swift_protocol_function_declaration: @swift_protocol_function_declaration ref, + int index: int ref, + unique int name: @swift_protocol_function_declaration_name_type ref +); + +@swift_protocol_function_declaration_return_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_protocol_function_declaration, index] +swift_protocol_function_declaration_return_type( + int swift_protocol_function_declaration: @swift_protocol_function_declaration ref, + int index: int ref, + unique int return_type: @swift_protocol_function_declaration_return_type_type ref +); + +@swift_protocol_function_declaration_child_type = @swift_attribute | @swift_modifiers | @swift_parameter | @swift_statements | @swift_throws_clause | @swift_token_throws | @swift_type_constraints | @swift_type_parameters + +#keyset[swift_protocol_function_declaration, index] +swift_protocol_function_declaration_child( + int swift_protocol_function_declaration: @swift_protocol_function_declaration ref, + int index: int ref, + unique int child: @swift_protocol_function_declaration_child_type ref +); + +swift_protocol_function_declaration_def( + unique int id: @swift_protocol_function_declaration +); + +@swift_protocol_property_declaration_child_type = @swift_modifiers | @swift_protocol_property_requirements | @swift_type_annotation | @swift_type_constraints + +#keyset[swift_protocol_property_declaration, index] +swift_protocol_property_declaration_child( + int swift_protocol_property_declaration: @swift_protocol_property_declaration ref, + int index: int ref, + unique int child: @swift_protocol_property_declaration_child_type ref +); + +swift_protocol_property_declaration_def( + unique int id: @swift_protocol_property_declaration, + int name: @swift_pattern ref +); + +@swift_protocol_property_requirements_child_type = @swift_getter_specifier | @swift_setter_specifier + +#keyset[swift_protocol_property_requirements, index] +swift_protocol_property_requirements_child( + int swift_protocol_property_requirements: @swift_protocol_property_requirements ref, + int index: int ref, + unique int child: @swift_protocol_property_requirements_child_type ref +); + +swift_protocol_property_requirements_def( + unique int id: @swift_protocol_property_requirements +); + +@swift_range_expression_end_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_range_expression, index] +swift_range_expression_end( + int swift_range_expression: @swift_range_expression ref, + int index: int ref, + unique int end: @swift_range_expression_end_type ref +); + +case @swift_range_expression.op of + 0 = @swift_range_expression_dotdotdot +| 1 = @swift_range_expression_dotdotlangle +; + + +@swift_range_expression_start_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_range_expression, index] +swift_range_expression_start( + int swift_range_expression: @swift_range_expression ref, + int index: int ref, + unique int start: @swift_range_expression_start_type ref +); + +swift_range_expression_def( + unique int id: @swift_range_expression, + int op: int ref +); + +#keyset[swift_raw_str_interpolation, index] +swift_raw_str_interpolation_interpolation( + int swift_raw_str_interpolation: @swift_raw_str_interpolation ref, + int index: int ref, + unique int interpolation: @swift_interpolated_expression ref +); + +swift_raw_str_interpolation_def( + unique int id: @swift_raw_str_interpolation, + int child: @swift_token_raw_str_interpolation_start ref +); + +#keyset[swift_raw_string_literal, index] +swift_raw_string_literal_interpolation( + int swift_raw_string_literal: @swift_raw_string_literal ref, + int index: int ref, + unique int interpolation: @swift_raw_str_interpolation ref +); + +@swift_raw_string_literal_text_type = @swift_token_raw_str_end_part | @swift_token_raw_str_part + +#keyset[swift_raw_string_literal, index] +swift_raw_string_literal_text( + int swift_raw_string_literal: @swift_raw_string_literal ref, + int index: int ref, + unique int text: @swift_raw_string_literal_text_type ref +); + +#keyset[swift_raw_string_literal, index] +swift_raw_string_literal_child( + int swift_raw_string_literal: @swift_raw_string_literal ref, + int index: int ref, + unique int child: @swift_token_raw_str_continuing_indicator ref +); + +swift_raw_string_literal_def( + unique int id: @swift_raw_string_literal +); + +#keyset[swift_repeat_while_statement, index] +swift_repeat_while_statement_bound_identifier( + int swift_repeat_while_statement: @swift_repeat_while_statement ref, + int index: int ref, + unique int bound_identifier: @swift_token_simple_identifier ref +); + +@swift_repeat_while_statement_condition_type = @swift_additive_expression | @swift_array_literal | @swift_array_type | @swift_as_expression | @swift_assignment | @swift_availability_condition | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_dictionary_type | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_existential_type | @swift_function_type | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_metatype | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_opaque_type | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_optional_type | @swift_pattern | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_protocol_composition_type | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_suppressed_constraint | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_wildcard_pattern | @swift_try_expression | @swift_tuple_expression | @swift_tuple_type | @swift_type_annotation | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type | @swift_value_binding_pattern | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_where_clause + +#keyset[swift_repeat_while_statement, index] +swift_repeat_while_statement_condition( + int swift_repeat_while_statement: @swift_repeat_while_statement ref, + int index: int ref, + unique int condition: @swift_repeat_while_statement_condition_type ref +); + +@swift_repeat_while_statement_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_repeat_while_statement, index] +swift_repeat_while_statement_name( + int swift_repeat_while_statement: @swift_repeat_while_statement ref, + int index: int ref, + unique int name: @swift_repeat_while_statement_name_type ref +); + +swift_repeat_while_statement_child( + unique int swift_repeat_while_statement: @swift_repeat_while_statement ref, + unique int child: @swift_statements ref +); + +swift_repeat_while_statement_def( + unique int id: @swift_repeat_while_statement +); + +@swift_selector_expression_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +swift_selector_expression_child( + unique int swift_selector_expression: @swift_selector_expression ref, + unique int child: @swift_selector_expression_child_type ref +); + +swift_selector_expression_def( + unique int id: @swift_selector_expression +); + +swift_setter_specifier_child( + unique int swift_setter_specifier: @swift_setter_specifier ref, + unique int child: @swift_token_mutation_modifier ref +); + +swift_setter_specifier_def( + unique int id: @swift_setter_specifier +); + +@swift_source_file_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_associatedtype_declaration | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_class_declaration | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_do_statement | @swift_equality_expression | @swift_for_statement | @swift_function_declaration | @swift_guard_statement | @swift_if_statement | @swift_import_declaration | @swift_infix_expression | @swift_init_declaration | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_declaration | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_operator_declaration | @swift_playground_literal | @swift_postfix_expression | @swift_precedence_group_declaration | @swift_prefix_expression | @swift_property_declaration | @swift_protocol_declaration | @swift_range_expression | @swift_raw_string_literal | @swift_repeat_while_statement | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_shebang_line | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_statement_label | @swift_token_super_expression | @swift_token_throw_keyword | @swift_try_expression | @swift_tuple_expression | @swift_typealias_declaration | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_while_statement + +#keyset[swift_source_file, index] +swift_source_file_child( + int swift_source_file: @swift_source_file ref, + int index: int ref, + unique int child: @swift_source_file_child_type ref +); + +swift_source_file_def( + unique int id: @swift_source_file +); + +@swift_statements_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_class_declaration | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_control_transfer_statement | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_do_statement | @swift_equality_expression | @swift_for_statement | @swift_function_declaration | @swift_guard_statement | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_property_declaration | @swift_range_expression | @swift_raw_string_literal | @swift_repeat_while_statement | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_statement_label | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_typealias_declaration | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_while_statement + +#keyset[swift_statements, index] +swift_statements_child( + int swift_statements: @swift_statements ref, + int index: int ref, + unique int child: @swift_statements_child_type ref +); + +swift_statements_def( + unique int id: @swift_statements +); + +@swift_subscript_declaration_default_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_subscript_declaration, index] +swift_subscript_declaration_default_value( + int swift_subscript_declaration: @swift_subscript_declaration ref, + int index: int ref, + unique int default_value: @swift_subscript_declaration_default_value_type ref +); + +@swift_subscript_declaration_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_subscript_declaration_name( + unique int swift_subscript_declaration: @swift_subscript_declaration ref, + unique int name: @swift_subscript_declaration_name_type ref +); + +@swift_subscript_declaration_return_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_subscript_declaration, index] +swift_subscript_declaration_return_type( + int swift_subscript_declaration: @swift_subscript_declaration ref, + int index: int ref, + unique int return_type: @swift_subscript_declaration_return_type_type ref +); + +@swift_subscript_declaration_child_type = @swift_attribute | @swift_computed_property | @swift_modifiers | @swift_parameter | @swift_type_constraints | @swift_type_parameters + +#keyset[swift_subscript_declaration, index] +swift_subscript_declaration_child( + int swift_subscript_declaration: @swift_subscript_declaration ref, + int index: int ref, + unique int child: @swift_subscript_declaration_child_type ref +); + +swift_subscript_declaration_def( + unique int id: @swift_subscript_declaration +); + +swift_suppressed_constraint_def( + unique int id: @swift_suppressed_constraint, + int suppressed: @swift_token_type_identifier ref +); + +@swift_switch_entry_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_modifiers | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_statements | @swift_switch_pattern | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_default_keyword | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_where_keyword | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_switch_entry, index] +swift_switch_entry_child( + int swift_switch_entry: @swift_switch_entry ref, + int index: int ref, + unique int child: @swift_switch_entry_child_type ref +); + +swift_switch_entry_def( + unique int id: @swift_switch_entry +); + +swift_switch_pattern_def( + unique int id: @swift_switch_pattern, + int child: @swift_pattern ref +); + +@swift_switch_statement_expr_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_switch_statement, index] +swift_switch_statement_expr( + int swift_switch_statement: @swift_switch_statement ref, + int index: int ref, + unique int expr: @swift_switch_statement_expr_type ref +); + +#keyset[swift_switch_statement, index] +swift_switch_statement_child( + int swift_switch_statement: @swift_switch_statement ref, + int index: int ref, + unique int child: @swift_switch_entry ref +); + +swift_switch_statement_def( + unique int id: @swift_switch_statement +); + +@swift_ternary_expression_condition_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_ternary_expression, index] +swift_ternary_expression_condition( + int swift_ternary_expression: @swift_ternary_expression ref, + int index: int ref, + unique int condition: @swift_ternary_expression_condition_type ref +); + +@swift_ternary_expression_if_false_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_ternary_expression, index] +swift_ternary_expression_if_false( + int swift_ternary_expression: @swift_ternary_expression ref, + int index: int ref, + unique int if_false: @swift_ternary_expression_if_false_type ref +); + +@swift_ternary_expression_if_true_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_ternary_expression, index] +swift_ternary_expression_if_true( + int swift_ternary_expression: @swift_ternary_expression ref, + int index: int ref, + unique int if_true: @swift_ternary_expression_if_true_type ref +); + +swift_ternary_expression_def( + unique int id: @swift_ternary_expression +); + +@swift_throws_clause_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_throws_clause_def( + unique int id: @swift_throws_clause, + int type__: @swift_throws_clause_type_type ref +); + +@swift_try_expression_expr_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_try_expression, index] +swift_try_expression_expr( + int swift_try_expression: @swift_try_expression ref, + int index: int ref, + unique int expr: @swift_try_expression_expr_type ref +); + +swift_try_expression_def( + unique int id: @swift_try_expression, + int child: @swift_token_try_operator ref +); + +#keyset[swift_tuple_expression, index] +swift_tuple_expression_name( + int swift_tuple_expression: @swift_tuple_expression ref, + int index: int ref, + unique int name: @swift_token_simple_identifier ref +); + +@swift_tuple_expression_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_tuple_expression, index] +swift_tuple_expression_value( + int swift_tuple_expression: @swift_tuple_expression ref, + int index: int ref, + unique int value: @swift_tuple_expression_value_type ref +); + +swift_tuple_expression_def( + unique int id: @swift_tuple_expression +); + +#keyset[swift_tuple_type, index] +swift_tuple_type_element( + int swift_tuple_type: @swift_tuple_type ref, + int index: int ref, + unique int element: @swift_tuple_type_item ref +); + +swift_tuple_type_child( + unique int swift_tuple_type: @swift_tuple_type ref, + unique int child: @swift_tuple_type_item ref +); + +swift_tuple_type_def( + unique int id: @swift_tuple_type +); + +@swift_tuple_type_item_element_type = @swift_dictionary_type | @swift_existential_type | @swift_opaque_type + +swift_tuple_type_item_element( + unique int swift_tuple_type_item: @swift_tuple_type_item ref, + unique int element: @swift_tuple_type_item_element_type ref +); + +@swift_tuple_type_item_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_simple_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_tuple_type_item, index] +swift_tuple_type_item_name( + int swift_tuple_type_item: @swift_tuple_type_item ref, + int index: int ref, + unique int name: @swift_tuple_type_item_name_type ref +); + +@swift_tuple_type_item_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_tuple_type_item, index] +swift_tuple_type_item_type( + int swift_tuple_type_item: @swift_tuple_type_item ref, + int index: int ref, + unique int type__: @swift_tuple_type_item_type_type ref +); + +@swift_tuple_type_item_child_type = @swift_parameter_modifiers | @swift_token_wildcard_pattern + +#keyset[swift_tuple_type_item, index] +swift_tuple_type_item_child( + int swift_tuple_type_item: @swift_tuple_type_item ref, + int index: int ref, + unique int child: @swift_tuple_type_item_child_type ref +); + +swift_tuple_type_item_def( + unique int id: @swift_tuple_type_item +); + +@swift_type_annotation_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +@swift_type_annotation_type_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_reserved_word | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_type_annotation, index] +swift_type_annotation_type( + int swift_type_annotation: @swift_type_annotation ref, + int index: int ref, + unique int type__: @swift_type_annotation_type_type ref +); + +swift_type_annotation_def( + unique int id: @swift_type_annotation, + int name: @swift_type_annotation_name_type ref +); + +@swift_type_arguments_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_type_arguments, index] +swift_type_arguments_name( + int swift_type_arguments: @swift_type_arguments ref, + int index: int ref, + unique int name: @swift_type_arguments_name_type ref +); + +#keyset[swift_type_arguments, index] +swift_type_arguments_child( + int swift_type_arguments: @swift_type_arguments ref, + int index: int ref, + unique int child: @swift_type_modifiers ref +); + +swift_type_arguments_def( + unique int id: @swift_type_arguments +); + +@swift_type_constraint_child_type = @swift_equality_constraint | @swift_inheritance_constraint + +swift_type_constraint_def( + unique int id: @swift_type_constraint, + int child: @swift_type_constraint_child_type ref +); + +@swift_type_constraints_child_type = @swift_token_where_keyword | @swift_type_constraint + +#keyset[swift_type_constraints, index] +swift_type_constraints_child( + int swift_type_constraints: @swift_type_constraints ref, + int index: int ref, + unique int child: @swift_type_constraints_child_type ref +); + +swift_type_constraints_def( + unique int id: @swift_type_constraints +); + +#keyset[swift_type_modifiers, index] +swift_type_modifiers_child( + int swift_type_modifiers: @swift_type_modifiers ref, + int index: int ref, + unique int child: @swift_attribute ref +); + +swift_type_modifiers_def( + unique int id: @swift_type_modifiers +); + +@swift_type_pack_expansion_child_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_type_pack_expansion_def( + unique int id: @swift_type_pack_expansion, + int child: @swift_type_pack_expansion_child_type ref +); + +@swift_type_parameter_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_type_parameter_name( + unique int swift_type_parameter: @swift_type_parameter ref, + unique int name: @swift_type_parameter_name_type ref +); + +@swift_type_parameter_child_type = @swift_token_type_identifier | @swift_type_modifiers | @swift_type_parameter_modifiers | @swift_type_parameter_pack + +#keyset[swift_type_parameter, index] +swift_type_parameter_child( + int swift_type_parameter: @swift_type_parameter ref, + int index: int ref, + unique int child: @swift_type_parameter_child_type ref +); + +swift_type_parameter_def( + unique int id: @swift_type_parameter +); + +#keyset[swift_type_parameter_modifiers, index] +swift_type_parameter_modifiers_child( + int swift_type_parameter_modifiers: @swift_type_parameter_modifiers ref, + int index: int ref, + unique int child: @swift_attribute ref +); + +swift_type_parameter_modifiers_def( + unique int id: @swift_type_parameter_modifiers +); + +@swift_type_parameter_pack_child_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +swift_type_parameter_pack_def( + unique int id: @swift_type_parameter_pack, + int child: @swift_type_parameter_pack_child_type ref +); + +@swift_type_parameters_child_type = @swift_type_constraints | @swift_type_parameter + +#keyset[swift_type_parameters, index] +swift_type_parameters_child( + int swift_type_parameters: @swift_type_parameters ref, + int index: int ref, + unique int child: @swift_type_parameters_child_type ref +); + +swift_type_parameters_def( + unique int id: @swift_type_parameters +); + +@swift_typealias_declaration_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_token_type_identifier | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_typealias_declaration, index] +swift_typealias_declaration_name( + int swift_typealias_declaration: @swift_typealias_declaration ref, + int index: int ref, + unique int name: @swift_typealias_declaration_name_type ref +); + +@swift_typealias_declaration_value_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_typealias_declaration, index] +swift_typealias_declaration_value( + int swift_typealias_declaration: @swift_typealias_declaration ref, + int index: int ref, + unique int value: @swift_typealias_declaration_value_type ref +); + +@swift_typealias_declaration_child_type = @swift_attribute | @swift_modifiers | @swift_token_inheritance_modifier | @swift_token_ownership_modifier | @swift_token_property_behavior_modifier | @swift_type_parameters + +#keyset[swift_typealias_declaration, index] +swift_typealias_declaration_child( + int swift_typealias_declaration: @swift_typealias_declaration ref, + int index: int ref, + unique int child: @swift_typealias_declaration_child_type ref +); + +swift_typealias_declaration_def( + unique int id: @swift_typealias_declaration +); + +@swift_user_type_child_type = @swift_token_type_identifier | @swift_type_arguments + +#keyset[swift_user_type, index] +swift_user_type_child( + int swift_user_type: @swift_user_type ref, + int index: int ref, + unique int child: @swift_user_type_child_type ref +); + +swift_user_type_def( + unique int id: @swift_user_type +); + +swift_value_argument_name( + unique int swift_value_argument: @swift_value_argument ref, + unique int name: @swift_value_argument_label ref +); + +#keyset[swift_value_argument, index] +swift_value_argument_reference_specifier( + int swift_value_argument: @swift_value_argument ref, + int index: int ref, + unique int reference_specifier: @swift_value_argument_label ref +); + +@swift_value_argument_value_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_value_argument, index] +swift_value_argument_value( + int swift_value_argument: @swift_value_argument ref, + int index: int ref, + unique int value: @swift_value_argument_value_type ref +); + +swift_value_argument_child( + unique int swift_value_argument: @swift_value_argument ref, + unique int child: @swift_type_modifiers ref +); + +swift_value_argument_def( + unique int id: @swift_value_argument +); + +swift_value_argument_label_def( + unique int id: @swift_value_argument_label, + int child: @swift_token_simple_identifier ref +); + +#keyset[swift_value_arguments, index] +swift_value_arguments_child( + int swift_value_arguments: @swift_value_arguments ref, + int index: int ref, + unique int child: @swift_value_argument ref +); + +swift_value_arguments_def( + unique int id: @swift_value_arguments +); + +case @swift_value_binding_pattern.mutability of + 0 = @swift_value_binding_pattern_let +| 1 = @swift_value_binding_pattern_var +; + + +swift_value_binding_pattern_def( + unique int id: @swift_value_binding_pattern, + int mutability: int ref +); + +@swift_value_pack_expansion_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +swift_value_pack_expansion_child( + unique int swift_value_pack_expansion: @swift_value_pack_expansion ref, + unique int child: @swift_value_pack_expansion_child_type ref +); + +swift_value_pack_expansion_def( + unique int id: @swift_value_pack_expansion +); + +@swift_value_parameter_pack_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +swift_value_parameter_pack_child( + unique int swift_value_parameter_pack: @swift_value_parameter_pack ref, + unique int child: @swift_value_parameter_pack_child_type ref +); + +swift_value_parameter_pack_def( + unique int id: @swift_value_parameter_pack +); + +@swift_where_clause_child_type = @swift_additive_expression | @swift_array_literal | @swift_as_expression | @swift_assignment | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_range_expression | @swift_raw_string_literal | @swift_selector_expression | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_where_keyword | @swift_try_expression | @swift_tuple_expression | @swift_value_pack_expansion | @swift_value_parameter_pack + +#keyset[swift_where_clause, index] +swift_where_clause_child( + int swift_where_clause: @swift_where_clause ref, + int index: int ref, + unique int child: @swift_where_clause_child_type ref +); + +swift_where_clause_def( + unique int id: @swift_where_clause +); + +#keyset[swift_while_statement, index] +swift_while_statement_bound_identifier( + int swift_while_statement: @swift_while_statement ref, + int index: int ref, + unique int bound_identifier: @swift_token_simple_identifier ref +); + +@swift_while_statement_condition_type = @swift_additive_expression | @swift_array_literal | @swift_array_type | @swift_as_expression | @swift_assignment | @swift_availability_condition | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_check_expression | @swift_comparison_expression | @swift_conjunction_expression | @swift_constructor_expression | @swift_dictionary_literal | @swift_dictionary_type | @swift_directive | @swift_disjunction_expression | @swift_equality_expression | @swift_existential_type | @swift_function_type | @swift_if_statement | @swift_infix_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_literal | @swift_line_string_literal | @swift_macro_invocation | @swift_metatype | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_nil_coalescing_expression | @swift_opaque_type | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_optional_type | @swift_pattern | @swift_playground_literal | @swift_postfix_expression | @swift_prefix_expression | @swift_protocol_composition_type | @swift_range_expression | @swift_raw_string_literal | @swift_reserved_word | @swift_selector_expression | @swift_suppressed_constraint | @swift_switch_statement | @swift_ternary_expression | @swift_token_bang | @swift_token_bin_literal | @swift_token_boolean_literal | @swift_token_custom_operator | @swift_token_diagnostic | @swift_token_fully_open_range | @swift_token_hex_literal | @swift_token_integer_literal | @swift_token_oct_literal | @swift_token_real_literal | @swift_token_regex_literal | @swift_token_self_expression | @swift_token_simple_identifier | @swift_token_special_literal | @swift_token_super_expression | @swift_token_wildcard_pattern | @swift_try_expression | @swift_tuple_expression | @swift_tuple_type | @swift_type_annotation | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type | @swift_value_binding_pattern | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_where_clause + +#keyset[swift_while_statement, index] +swift_while_statement_condition( + int swift_while_statement: @swift_while_statement ref, + int index: int ref, + unique int condition: @swift_while_statement_condition_type ref +); + +@swift_while_statement_name_type = @swift_array_type | @swift_dictionary_type | @swift_existential_type | @swift_function_type | @swift_metatype | @swift_opaque_type | @swift_optional_type | @swift_protocol_composition_type | @swift_suppressed_constraint | @swift_tuple_type | @swift_type_pack_expansion | @swift_type_parameter_pack | @swift_user_type + +#keyset[swift_while_statement, index] +swift_while_statement_name( + int swift_while_statement: @swift_while_statement ref, + int index: int ref, + unique int name: @swift_while_statement_name_type ref +); + +swift_while_statement_child( + unique int swift_while_statement: @swift_while_statement ref, + unique int child: @swift_statements ref +); + +swift_while_statement_def( + unique int id: @swift_while_statement +); + +@swift_willset_clause_child_type = @swift_modifiers | @swift_statements | @swift_token_simple_identifier + +#keyset[swift_willset_clause, index] +swift_willset_clause_child( + int swift_willset_clause: @swift_willset_clause ref, + int index: int ref, + unique int child: @swift_willset_clause_child_type ref +); + +swift_willset_clause_def( + unique int id: @swift_willset_clause +); + +@swift_willset_didset_block_child_type = @swift_didset_clause | @swift_willset_clause + +#keyset[swift_willset_didset_block, index] +swift_willset_didset_block_child( + int swift_willset_didset_block: @swift_willset_didset_block ref, + int index: int ref, + unique int child: @swift_willset_didset_block_child_type ref +); + +swift_willset_didset_block_def( + unique int id: @swift_willset_didset_block +); + +swift_tokeninfo( + unique int id: @swift_token, + int kind: int ref, + string value: string ref +); + +case @swift_token.kind of + 0 = @swift_reserved_word +| 1 = @swift_token__expression +| 2 = @swift_token_as_operator +| 3 = @swift_token_bang +| 4 = @swift_token_bin_literal +| 5 = @swift_token_boolean_literal +| 6 = @swift_token_catch_keyword +| 7 = @swift_token_comment +| 8 = @swift_token_custom_operator +| 9 = @swift_token_default_keyword +| 10 = @swift_token_diagnostic +| 11 = @swift_token_else +| 12 = @swift_token_fully_open_range +| 13 = @swift_token_function_modifier +| 14 = @swift_token_hex_literal +| 15 = @swift_token_inheritance_modifier +| 16 = @swift_token_integer_literal +| 17 = @swift_token_line_str_text +| 18 = @swift_token_member_modifier +| 19 = @swift_token_multi_line_str_text +| 20 = @swift_token_multiline_comment +| 21 = @swift_token_mutation_modifier +| 22 = @swift_token_oct_literal +| 23 = @swift_token_ownership_modifier +| 24 = @swift_token_parameter_modifier +| 25 = @swift_token_property_behavior_modifier +| 26 = @swift_token_property_modifier +| 27 = @swift_token_raw_str_continuing_indicator +| 28 = @swift_token_raw_str_end_part +| 29 = @swift_token_raw_str_interpolation_start +| 30 = @swift_token_raw_str_part +| 31 = @swift_token_real_literal +| 32 = @swift_token_regex_literal +| 33 = @swift_token_self_expression +| 34 = @swift_token_shebang_line +| 35 = @swift_token_simple_identifier +| 36 = @swift_token_special_literal +| 37 = @swift_token_statement_label +| 38 = @swift_token_str_escaped_char +| 39 = @swift_token_super_expression +| 40 = @swift_token_throw_keyword +| 41 = @swift_token_throws +| 42 = @swift_token_try_operator +| 43 = @swift_token_type_identifier +| 44 = @swift_token_visibility_modifier +| 45 = @swift_token_where_keyword +| 46 = @swift_token_wildcard_pattern +; + + +@swift_ast_node = @swift_additive_expression | @swift_array_literal | @swift_array_type | @swift_as_expression | @swift_assignment | @swift_associatedtype_declaration | @swift_attribute | @swift_availability_condition | @swift_await_expression | @swift_bitwise_operation | @swift_call_expression | @swift_call_suffix | @swift_capture_list | @swift_capture_list_item | @swift_catch_block | @swift_check_expression | @swift_class_body | @swift_class_declaration | @swift_comparison_expression | @swift_computed_getter | @swift_computed_modify | @swift_computed_property | @swift_computed_setter | @swift_conjunction_expression | @swift_constructor_expression | @swift_constructor_suffix | @swift_control_transfer_statement | @swift_deinit_declaration | @swift_deprecated_operator_declaration_body | @swift_dictionary_literal | @swift_dictionary_type | @swift_didset_clause | @swift_directive | @swift_directly_assignable_expression | @swift_disjunction_expression | @swift_do_statement | @swift_enum_class_body | @swift_enum_entry | @swift_enum_type_parameters | @swift_equality_constraint | @swift_equality_expression | @swift_existential_type | @swift_external_macro_definition | @swift_for_statement | @swift_function_body | @swift_function_declaration | @swift_function_type | @swift_getter_specifier | @swift_guard_statement | @swift_identifier | @swift_if_statement | @swift_import_declaration | @swift_infix_expression | @swift_inheritance_constraint | @swift_inheritance_specifier | @swift_init_declaration | @swift_interpolated_expression | @swift_key_path_expression | @swift_key_path_string_expression | @swift_lambda_function_type | @swift_lambda_function_type_parameters | @swift_lambda_literal | @swift_lambda_parameter | @swift_line_string_literal | @swift_macro_declaration | @swift_macro_definition | @swift_macro_invocation | @swift_metatype | @swift_modifiers | @swift_modify_specifier | @swift_multi_line_string_literal | @swift_multiplicative_expression | @swift_navigation_expression | @swift_navigation_suffix | @swift_nil_coalescing_expression | @swift_opaque_type | @swift_open_end_range_expression | @swift_open_start_range_expression | @swift_operator_declaration | @swift_optional_type | @swift_parameter | @swift_parameter_modifiers | @swift_pattern | @swift_playground_literal | @swift_postfix_expression | @swift_precedence_group_attribute | @swift_precedence_group_attributes | @swift_precedence_group_declaration | @swift_prefix_expression | @swift_property_declaration | @swift_protocol_body | @swift_protocol_composition_type | @swift_protocol_declaration | @swift_protocol_function_declaration | @swift_protocol_property_declaration | @swift_protocol_property_requirements | @swift_range_expression | @swift_raw_str_interpolation | @swift_raw_string_literal | @swift_repeat_while_statement | @swift_selector_expression | @swift_setter_specifier | @swift_source_file | @swift_statements | @swift_subscript_declaration | @swift_suppressed_constraint | @swift_switch_entry | @swift_switch_pattern | @swift_switch_statement | @swift_ternary_expression | @swift_throws_clause | @swift_token | @swift_try_expression | @swift_tuple_expression | @swift_tuple_type | @swift_tuple_type_item | @swift_type_annotation | @swift_type_arguments | @swift_type_constraint | @swift_type_constraints | @swift_type_modifiers | @swift_type_pack_expansion | @swift_type_parameter | @swift_type_parameter_modifiers | @swift_type_parameter_pack | @swift_type_parameters | @swift_typealias_declaration | @swift_user_type | @swift_value_argument | @swift_value_argument_label | @swift_value_arguments | @swift_value_binding_pattern | @swift_value_pack_expansion | @swift_value_parameter_pack | @swift_where_clause | @swift_while_statement | @swift_willset_clause | @swift_willset_didset_block + +swift_ast_node_location( + unique int node: @swift_ast_node ref, + int loc: @location_default ref +); + +#keyset[parent, parent_index] +swift_ast_node_parent( + unique int node: @swift_ast_node ref, + int parent: @swift_ast_node ref, + int parent_index: int ref +); + diff --git a/unified/ql/lib/unified.dbscheme.stats b/unified/ql/lib/unified.dbscheme.stats new file mode 100644 index 000000000000..82714bfe1d07 --- /dev/null +++ b/unified/ql/lib/unified.dbscheme.stats @@ -0,0 +1,4 @@ + + + + diff --git a/unified/ql/src/qlpack.lock.yml b/unified/ql/src/qlpack.lock.yml new file mode 100644 index 000000000000..06dd07fc7dc7 --- /dev/null +++ b/unified/ql/src/qlpack.lock.yml @@ -0,0 +1,4 @@ +--- +dependencies: {} +compiled: false +lockVersion: 1.0.0 diff --git a/unified/ql/src/qlpack.yml b/unified/ql/src/qlpack.yml new file mode 100644 index 000000000000..2de97863ddaf --- /dev/null +++ b/unified/ql/src/qlpack.yml @@ -0,0 +1,11 @@ +name: codeql/unified-queries +version: 0.0.1-dev +groups: + - unified + - queries +suites: codeql-suites +dependencies: + codeql/unified-all: ${workspace} + codeql/suite-helpers: ${workspace} + codeql/util: ${workspace} +warnOnImplicitThis: true diff --git a/unified/ql/test/library-tests/BasicTest/test.expected b/unified/ql/test/library-tests/BasicTest/test.expected new file mode 100644 index 000000000000..c24fee85b689 --- /dev/null +++ b/unified/ql/test/library-tests/BasicTest/test.expected @@ -0,0 +1,100 @@ +identifier +| test.swift:1:8:1:17 | Foundation | Foundation | +| test.swift:5:9:5:13 | items | items | +| test.swift:7:19:7:21 | add | add | +| test.swift:7:23:7:23 | _ | _ | +| test.swift:7:25:7:28 | item | item | +| test.swift:8:9:8:13 | items | items | +| test.swift:8:15:8:20 | append | append | +| test.swift:8:22:8:25 | item | item | +| test.swift:11:10:11:17 | contains | contains | +| test.swift:11:19:11:19 | _ | _ | +| test.swift:11:21:11:24 | item | item | +| test.swift:12:16:12:20 | items | items | +| test.swift:12:22:12:29 | contains | contains | +| test.swift:12:31:12:34 | item | item | +| test.swift:19:9:19:13 | count | count | +| test.swift:20:10:20:13 | item | item | +| test.swift:20:15:20:16 | at | at | +| test.swift:20:18:20:22 | index | index | +| test.swift:24:6:24:10 | merge | merge | +| test.swift:24:27:24:27 | _ | _ | +| test.swift:24:29:24:33 | first | first | +| test.swift:24:39:24:39 | _ | _ | +| test.swift:24:41:24:46 | second | second | +| test.swift:24:73:24:73 | T | T | +| test.swift:24:75:24:81 | Element | Element | +| test.swift:25:9:25:14 | result | result | +| test.swift:25:18:25:22 | Array | Array | +| test.swift:25:24:25:28 | first | first | +| test.swift:26:9:26:12 | item | item | +| test.swift:26:17:26:22 | second | second | +| test.swift:27:13:27:18 | result | result | +| test.swift:27:20:27:27 | contains | contains | +| test.swift:27:29:27:32 | item | item | +| test.swift:28:13:28:18 | result | result | +| test.swift:28:20:28:25 | append | append | +| test.swift:28:27:28:30 | item | item | +| test.swift:31:12:31:17 | result | result | +| test.swift:37:17:37:20 | data | data | +| test.swift:39:9:39:13 | count | count | +| test.swift:40:16:40:19 | data | data | +| test.swift:40:21:40:25 | count | count | +| test.swift:43:9:43:15 | isEmpty | isEmpty | +| test.swift:44:9:44:12 | data | data | +| test.swift:44:14:44:20 | isEmpty | isEmpty | +| test.swift:47:10:47:13 | item | item | +| test.swift:47:15:47:16 | at | at | +| test.swift:47:18:47:22 | index | index | +| test.swift:48:15:48:19 | index | index | +| test.swift:48:29:48:33 | index | index | +| test.swift:48:37:48:40 | data | data | +| test.swift:48:42:48:46 | count | count | +| test.swift:49:16:49:19 | data | data | +| test.swift:49:21:49:25 | index | index | +| test.swift:52:10:52:12 | add | add | +| test.swift:52:14:52:14 | _ | _ | +| test.swift:52:16:52:19 | item | item | +| test.swift:53:9:53:12 | data | data | +| test.swift:53:14:53:19 | append | append | +| test.swift:53:21:53:24 | item | item | +| test.swift:59:10:59:16 | success | success | +| test.swift:60:10:60:16 | failure | failure | +| test.swift:62:10:62:12 | map | map | +| test.swift:62:17:62:17 | _ | _ | +| test.swift:62:19:62:27 | transform | transform | +| test.swift:64:15:64:21 | success | success | +| test.swift:64:27:64:31 | value | value | +| test.swift:65:21:65:27 | success | success | +| test.swift:65:29:65:37 | transform | transform | +| test.swift:65:39:65:43 | value | value | +| test.swift:66:15:66:21 | failure | failure | +| test.swift:66:27:66:31 | error | error | +| test.swift:67:21:67:27 | failure | failure | +| test.swift:67:29:67:33 | error | error | +| test.swift:73:23:73:29 | Element | Element | +| test.swift:74:10:74:17 | isSorted | isSorted | +| test.swift:75:13:75:13 | i | i | +| test.swift:75:23:75:27 | count | count | +| test.swift:76:21:76:21 | i | i | +| test.swift:76:31:76:31 | i | i | +| test.swift:85:6:85:12 | combine | combine | +| test.swift:85:17:85:17 | _ | _ | +| test.swift:85:19:85:24 | values | values | +| test.swift:85:32:85:40 | transform | transform | +| test.swift:86:12:86:17 | values | values | +| test.swift:86:19:86:25 | isEmpty | isEmpty | +| test.swift:87:12:87:17 | values | values | +| test.swift:87:19:87:27 | dropFirst | dropFirst | +| test.swift:87:31:87:36 | reduce | reduce | +| test.swift:87:38:87:43 | values | values | +| test.swift:87:49:87:57 | transform | transform | +func +| test.swift:7:5:9:5 | FunctionDeclaration | +| test.swift:11:5:13:5 | FunctionDeclaration | +| test.swift:24:1:32:1 | FunctionDeclaration | +| test.swift:47:5:50:5 | FunctionDeclaration | +| test.swift:52:5:54:5 | FunctionDeclaration | +| test.swift:62:5:69:5 | FunctionDeclaration | +| test.swift:74:5:81:5 | FunctionDeclaration | +| test.swift:85:1:88:1 | FunctionDeclaration | diff --git a/unified/ql/test/library-tests/BasicTest/test.ql b/unified/ql/test/library-tests/BasicTest/test.ql new file mode 100644 index 000000000000..a294e8768811 --- /dev/null +++ b/unified/ql/test/library-tests/BasicTest/test.ql @@ -0,0 +1,5 @@ +import codeql.unified.Ast + +query predicate identifier(Swift::SimpleIdentifier node, string name) { name = node.getValue() } + +query predicate func(Swift::FunctionDeclaration node) { any() } diff --git a/unified/ql/test/library-tests/BasicTest/test.swift b/unified/ql/test/library-tests/BasicTest/test.swift new file mode 100644 index 000000000000..158ef26f598b --- /dev/null +++ b/unified/ql/test/library-tests/BasicTest/test.swift @@ -0,0 +1,88 @@ +import Foundation + +// Generic struct with type constraint +struct Container { + var items: [T] = [] + + mutating func add(_ item: T) { + items.append(item) + } + + func contains(_ item: T) -> Bool { + return items.contains(item) + } +} + +// Protocol with associated type +protocol DataSource { + associatedtype Element + var count: Int { get } + func item(at index: Int) -> Element? +} + +// Generic function with where clause +func merge(_ first: T, _ second: T) -> [T.Element] where T.Element: Equatable { + var result = Array(first) + for item in second { + if !result.contains(item) { + result.append(item) + } + } + return result +} + +// Class with inheritance and computed properties +class DataManager: DataSource { + typealias Element = T + private var data: [T] = [] + + var count: Int { + return data.count + } + + var isEmpty: Bool { + data.isEmpty + } + + func item(at index: Int) -> T? { + guard index >= 0 && index < data.count else { return nil } + return data[index] + } + + func add(_ item: T) { + data.append(item) + } +} + +// Enum with associated values +enum Result { + case success(Success) + case failure(Failure) + + func map(_ transform: (Success) -> U) -> Result { + switch self { + case .success(let value): + return .success(transform(value)) + case .failure(let error): + return .failure(error) + } + } +} + +// Extension with generic constraints +extension Array where Element: Comparable { + func isSorted() -> Bool { + for i in 0..<(count - 1) { + if self[i] > self[i + 1] { + return false + } + } + return true + } +} + +// Higher-order function +func combine(_ values: [T], transform: (T, T) -> T) -> T? { + guard !values.isEmpty else { return nil } + return values.dropFirst().reduce(values[0], transform) +} diff --git a/unified/ql/test/qlpack.lock.yml b/unified/ql/test/qlpack.lock.yml new file mode 100644 index 000000000000..06dd07fc7dc7 --- /dev/null +++ b/unified/ql/test/qlpack.lock.yml @@ -0,0 +1,4 @@ +--- +dependencies: {} +compiled: false +lockVersion: 1.0.0 diff --git a/unified/ql/test/qlpack.yml b/unified/ql/test/qlpack.yml new file mode 100644 index 000000000000..8c567d531c91 --- /dev/null +++ b/unified/ql/test/qlpack.yml @@ -0,0 +1,8 @@ +name: codeql/unified-tests +groups: [unified, test] +dependencies: + codeql/unified-queries: ${workspace} + codeql/unified-all: ${workspace} +extractor: unified +tests: . +warnOnImplicitThis: true diff --git a/unified/scripts/create-extractor-pack.sh b/unified/scripts/create-extractor-pack.sh new file mode 100755 index 000000000000..7a41092e4a74 --- /dev/null +++ b/unified/scripts/create-extractor-pack.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -eux +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + platform="linux64" +elif [[ "$OSTYPE" == "darwin"* ]]; then + platform="osx64" +else + echo "Unknown OS" + exit 1 +fi +cd "$(dirname "$0")/.." + +(cd extractor && cargo build --release) + +# we are in a cargo workspace rooted at the git checkout +BIN_DIR=../target/release +"$BIN_DIR/codeql-extractor-unified" generate --dbscheme ql/lib/unified.dbscheme --library ql/lib/codeql/unified/Ast.qll + +codeql query format -i ql/lib/codeql/unified/Ast.qll + +rm -rf extractor-pack +mkdir -p extractor-pack +cp -r codeql-extractor.yml tools ql/lib/unified.dbscheme ql/lib/unified.dbscheme.stats extractor-pack/ +mkdir -p extractor-pack/tools/${platform} +cp "$BIN_DIR/codeql-extractor-unified" extractor-pack/tools/${platform}/extractor diff --git a/unified/tools/BUILD.bazel b/unified/tools/BUILD.bazel new file mode 100644 index 000000000000..a4b4baed225c --- /dev/null +++ b/unified/tools/BUILD.bazel @@ -0,0 +1,11 @@ +load("//misc/bazel:pkg.bzl", "codeql_pkg_files") + +codeql_pkg_files( + name = "tools", + excludes = [ + "BUILD.bazel", + ], + exes = glob(["**/*"]), + prefix = "tools", + visibility = ["//unified:__pkg__"], +) diff --git a/unified/tools/autobuild.cmd b/unified/tools/autobuild.cmd new file mode 100644 index 000000000000..05b59eca1191 --- /dev/null +++ b/unified/tools/autobuild.cmd @@ -0,0 +1,5 @@ +@echo off + +type NUL && "%CODEQL_EXTRACTOR_UNIFIED_ROOT%\tools\%CODEQL_PLATFORM%\extractor" autobuild + +exit /b %ERRORLEVEL% diff --git a/unified/tools/autobuild.sh b/unified/tools/autobuild.sh new file mode 100755 index 000000000000..2b35f39e917f --- /dev/null +++ b/unified/tools/autobuild.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec "${CODEQL_EXTRACTOR_UNIFIED_ROOT}/tools/${CODEQL_PLATFORM}/extractor" autobuild diff --git a/unified/tools/index-files.cmd b/unified/tools/index-files.cmd new file mode 100644 index 000000000000..3b9fca08ea03 --- /dev/null +++ b/unified/tools/index-files.cmd @@ -0,0 +1,9 @@ +@echo off + +type NUL && "%CODEQL_EXTRACTOR_UNIFIED_ROOT%\tools\win64\extractor.exe" ^ + extract ^ + --file-list "%1" ^ + --source-archive-dir "%CODEQL_EXTRACTOR_UNIFIED_SOURCE_ARCHIVE_DIR%" ^ + --output-dir "%CODEQL_EXTRACTOR_UNIFIED_TRAP_DIR%" + +exit /b %ERRORLEVEL% diff --git a/unified/tools/index-files.sh b/unified/tools/index-files.sh new file mode 100755 index 000000000000..ddf98907e837 --- /dev/null +++ b/unified/tools/index-files.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -eu + +exec "${CODEQL_EXTRACTOR_UNIFIED_ROOT}/tools/${CODEQL_PLATFORM}/extractor" \ + extract \ + --file-list "$1" \ + --source-archive-dir "$CODEQL_EXTRACTOR_UNIFIED_SOURCE_ARCHIVE_DIR" \ + --output-dir "$CODEQL_EXTRACTOR_UNIFIED_TRAP_DIR" diff --git a/unified/tools/qltest.cmd b/unified/tools/qltest.cmd new file mode 100644 index 000000000000..3db89dcc1b98 --- /dev/null +++ b/unified/tools/qltest.cmd @@ -0,0 +1,14 @@ +@echo off + +type NUL && "%CODEQL_DIST%\codeql.exe" database index-files ^ + --prune=**/*.testproj ^ + --include-extension=.swift ^ + --include-extension=.swiftinterface ^ + --size-limit=5m ^ + --language=unified ^ + --working-dir=. ^ + "%CODEQL_EXTRACTOR_UNIFIED_WIP_DATABASE%" + +IF %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% + +exit /b %ERRORLEVEL% diff --git a/unified/tools/qltest.sh b/unified/tools/qltest.sh new file mode 100755 index 000000000000..7dcbb9e81f48 --- /dev/null +++ b/unified/tools/qltest.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +set -eu + +"${CODEQL_DIST}/codeql" database index-files \ + --prune="**/*.testproj" \ + --include-extension=.swift \ + --include-extension=.swiftinterface \ + --size-limit=5m \ + --language=unified \ + --working-dir=.\ + "$CODEQL_EXTRACTOR_UNIFIED_WIP_DATABASE" From 4e12a8c8d28ee22c060f17f2f9ed022677508694 Mon Sep 17 00:00:00 2001 From: Asger F Date: Wed, 6 May 2026 16:23:46 +0200 Subject: [PATCH 2/7] Add basic YEAST dependency and rule --- Cargo.lock | 1 + unified/extractor/BUILD.bazel | 1 + unified/extractor/Cargo.toml | 1 + unified/extractor/src/extractor.rs | 15 ++++++++++++++- .../ql/test/library-tests/BasicTest/test.expected | 5 +++-- unified/ql/test/library-tests/BasicTest/test.ql | 4 ++++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 895349ca6e38..856e6fb42e6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,6 +454,7 @@ dependencies = [ "tree-sitter", "tree-sitter-embedded-template", "tree-sitter-swift", + "yeast", ] [[package]] diff --git a/unified/extractor/BUILD.bazel b/unified/extractor/BUILD.bazel index 8c22b4775f29..c5860edc51ad 100644 --- a/unified/extractor/BUILD.bazel +++ b/unified/extractor/BUILD.bazel @@ -15,5 +15,6 @@ codeql_rust_binary( normal = True, ) + [ "//shared/tree-sitter-extractor", + "//shared/yeast", ], ) diff --git a/unified/extractor/Cargo.toml b/unified/extractor/Cargo.toml index fb377a995e7f..3877ec2e106f 100644 --- a/unified/extractor/Cargo.toml +++ b/unified/extractor/Cargo.toml @@ -20,3 +20,4 @@ lazy_static = "1.5.0" serde_json = "1.0.145" codeql-extractor = { path = "../../shared/tree-sitter-extractor" } +yeast = { path = "../../shared/yeast" } diff --git a/unified/extractor/src/extractor.rs b/unified/extractor/src/extractor.rs index ae9e538a5ec6..5a250257c844 100644 --- a/unified/extractor/src/extractor.rs +++ b/unified/extractor/src/extractor.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use codeql_extractor::extractor::simple; use codeql_extractor::trap; +use yeast::{rule, DesugaringConfig}; #[derive(Args)] pub struct Options { @@ -19,9 +20,21 @@ pub struct Options { file_list: PathBuf, } +fn swift_desugaring_rules() -> Vec { + vec![ + rule!( + (additive_expression) + => + (simple_identifier "blah") + ), + ] +} + pub fn run(options: Options) -> std::io::Result<()> { codeql_extractor::extractor::set_tracing_level("ql"); + let swift_desugar = DesugaringConfig::new(swift_desugaring_rules()); + let extractor = simple::Extractor { prefix: "unified".to_string(), languages: vec![ @@ -30,7 +43,7 @@ pub fn run(options: Options) -> std::io::Result<()> { ts_language: tree_sitter_swift::LANGUAGE.into(), node_types: tree_sitter_swift::NODE_TYPES, file_globs: vec!["*.swift".into(), "*.swiftinterface".into()], - desugar: None, + desugar: Some(swift_desugar), }, ], trap_dir: options.output_dir, diff --git a/unified/ql/test/library-tests/BasicTest/test.expected b/unified/ql/test/library-tests/BasicTest/test.expected index c24fee85b689..62b8146bf040 100644 --- a/unified/ql/test/library-tests/BasicTest/test.expected +++ b/unified/ql/test/library-tests/BasicTest/test.expected @@ -75,9 +75,9 @@ identifier | test.swift:73:23:73:29 | Element | Element | | test.swift:74:10:74:17 | isSorted | isSorted | | test.swift:75:13:75:13 | i | i | -| test.swift:75:23:75:27 | count | count | +| test.swift:75:23:75:31 | blah | blah | | test.swift:76:21:76:21 | i | i | -| test.swift:76:31:76:31 | i | i | +| test.swift:76:31:76:35 | blah | blah | | test.swift:85:6:85:12 | combine | combine | | test.swift:85:17:85:17 | _ | _ | | test.swift:85:19:85:24 | values | values | @@ -98,3 +98,4 @@ func | test.swift:62:5:69:5 | FunctionDeclaration | | test.swift:74:5:81:5 | FunctionDeclaration | | test.swift:85:1:88:1 | FunctionDeclaration | +add diff --git a/unified/ql/test/library-tests/BasicTest/test.ql b/unified/ql/test/library-tests/BasicTest/test.ql index a294e8768811..3a5ee2f1c157 100644 --- a/unified/ql/test/library-tests/BasicTest/test.ql +++ b/unified/ql/test/library-tests/BasicTest/test.ql @@ -3,3 +3,7 @@ import codeql.unified.Ast query predicate identifier(Swift::SimpleIdentifier node, string name) { name = node.getValue() } query predicate func(Swift::FunctionDeclaration node) { any() } + +query predicate add(Swift::AdditiveExpression node, Swift::AstNode lhs, Swift::AstNode rhs) { + lhs = node.getLhs(0) and rhs = node.getRhs(0) +} From cd457a7d6bced5a117b9ac73bdb16a1c61c66af1 Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 7 May 2026 09:47:27 +0200 Subject: [PATCH 3/7] Move Swift language into its own module --- unified/extractor/src/extractor.rs | 24 ++++--------------- .../extractor/src/languages/swift/swift.rs | 23 ++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 unified/extractor/src/languages/swift/swift.rs diff --git a/unified/extractor/src/extractor.rs b/unified/extractor/src/extractor.rs index 5a250257c844..137b2f3c0e49 100644 --- a/unified/extractor/src/extractor.rs +++ b/unified/extractor/src/extractor.rs @@ -3,7 +3,9 @@ use std::path::PathBuf; use codeql_extractor::extractor::simple; use codeql_extractor::trap; -use yeast::{rule, DesugaringConfig}; + +#[path = "languages/swift/swift.rs"] +mod swift; #[derive(Args)] pub struct Options { @@ -20,31 +22,13 @@ pub struct Options { file_list: PathBuf, } -fn swift_desugaring_rules() -> Vec { - vec![ - rule!( - (additive_expression) - => - (simple_identifier "blah") - ), - ] -} - pub fn run(options: Options) -> std::io::Result<()> { codeql_extractor::extractor::set_tracing_level("ql"); - let swift_desugar = DesugaringConfig::new(swift_desugaring_rules()); - let extractor = simple::Extractor { prefix: "unified".to_string(), languages: vec![ - simple::LanguageSpec { - prefix: "swift", - ts_language: tree_sitter_swift::LANGUAGE.into(), - node_types: tree_sitter_swift::NODE_TYPES, - file_globs: vec!["*.swift".into(), "*.swiftinterface".into()], - desugar: Some(swift_desugar), - }, + swift::language_spec(), ], trap_dir: options.output_dir, trap_compression: trap::Compression::from_env("CODEQL_QL_TRAP_COMPRESSION"), diff --git a/unified/extractor/src/languages/swift/swift.rs b/unified/extractor/src/languages/swift/swift.rs new file mode 100644 index 000000000000..5b21473874c0 --- /dev/null +++ b/unified/extractor/src/languages/swift/swift.rs @@ -0,0 +1,23 @@ +use codeql_extractor::extractor::simple; +use yeast::{rule, DesugaringConfig}; + +fn desugaring_rules() -> Vec { + vec![ + rule!( + (additive_expression) + => + (simple_identifier "blah") + ), + ] +} + +pub fn language_spec() -> simple::LanguageSpec { + let desugar = DesugaringConfig::new(desugaring_rules()); + simple::LanguageSpec { + prefix: "swift", + ts_language: tree_sitter_swift::LANGUAGE.into(), + node_types: tree_sitter_swift::NODE_TYPES, + file_globs: vec!["*.swift".into(), "*.swiftinterface".into()], + desugar: Some(desugar), + } +} From a1447075e8e26b629f660c7d3efd800eacd7f9e8 Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 7 May 2026 10:48:22 +0200 Subject: [PATCH 4/7] Add AGENTS.md with build/test instructions --- unified/AGENTS.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 unified/AGENTS.md diff --git a/unified/AGENTS.md b/unified/AGENTS.md new file mode 100644 index 000000000000..44cb74372883 --- /dev/null +++ b/unified/AGENTS.md @@ -0,0 +1,15 @@ +# Agent instructions + +This is a CodeQL extractor based on tree-sitter. + +## Building +To build the extractor, run `scripts/create-extractor-pack.sh` + +## Testing +- If you changed the extractor code, always rebuild it before running tests. + +- To run all tests, run `codeql test run --search-path extractor-pack ql/test` + +- Do not edit `.expected` files manually. To update the expected output, pass `--learn` to the `codeql test run` command. + +- To run a specific test, pass the specific directory to the `codeql test run` command instead of `ql/test`. From 28028191702733ba96465a2d28303454fcb7380c Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 7 May 2026 21:37:42 +0200 Subject: [PATCH 5/7] Use new YEAST API after rebasing --- unified/extractor/src/languages/swift/swift.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/extractor/src/languages/swift/swift.rs b/unified/extractor/src/languages/swift/swift.rs index 5b21473874c0..c3843a5979c5 100644 --- a/unified/extractor/src/languages/swift/swift.rs +++ b/unified/extractor/src/languages/swift/swift.rs @@ -12,7 +12,7 @@ fn desugaring_rules() -> Vec { } pub fn language_spec() -> simple::LanguageSpec { - let desugar = DesugaringConfig::new(desugaring_rules()); + let desugar = DesugaringConfig::new().add_phase("desugar", desugaring_rules()); simple::LanguageSpec { prefix: "swift", ts_language: tree_sitter_swift::LANGUAGE.into(), From 9a2b7bac8f0210200e829fa21d407fd74d7527b3 Mon Sep 17 00:00:00 2001 From: Asger F Date: Fri, 8 May 2026 08:56:40 +0200 Subject: [PATCH 6/7] Fix Bazel glob to include subdirectories Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- unified/extractor/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/extractor/BUILD.bazel b/unified/extractor/BUILD.bazel index c5860edc51ad..5a53d7cc3e07 100644 --- a/unified/extractor/BUILD.bazel +++ b/unified/extractor/BUILD.bazel @@ -5,7 +5,7 @@ exports_files(["Cargo.toml"]) codeql_rust_binary( name = "extractor", - srcs = glob(["src/*.rs"]), + srcs = glob(["src/**/*.rs"]), aliases = aliases(), proc_macro_deps = all_crate_deps( proc_macro = True, From 33e89ea1237157da58f9c38124fb3978864d1f5a Mon Sep 17 00:00:00 2001 From: Asger F Date: Fri, 8 May 2026 09:03:18 +0200 Subject: [PATCH 7/7] Address review comments --- unified/extractor/src/extractor.rs | 6 +++--- unified/extractor/src/generator.rs | 4 ++-- unified/ql/lib/unified.dbscheme | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/unified/extractor/src/extractor.rs b/unified/extractor/src/extractor.rs index 137b2f3c0e49..eb6f06eb259b 100644 --- a/unified/extractor/src/extractor.rs +++ b/unified/extractor/src/extractor.rs @@ -9,7 +9,7 @@ mod swift; #[derive(Args)] pub struct Options { - /// Sets a custom source achive folder + /// Sets a custom source archive folder #[arg(long)] source_archive_dir: PathBuf, @@ -23,7 +23,7 @@ pub struct Options { } pub fn run(options: Options) -> std::io::Result<()> { - codeql_extractor::extractor::set_tracing_level("ql"); + codeql_extractor::extractor::set_tracing_level("unified"); let extractor = simple::Extractor { prefix: "unified".to_string(), @@ -31,7 +31,7 @@ pub fn run(options: Options) -> std::io::Result<()> { swift::language_spec(), ], trap_dir: options.output_dir, - trap_compression: trap::Compression::from_env("CODEQL_QL_TRAP_COMPRESSION"), + trap_compression: trap::Compression::from_env("CODEQL_EXTRACTOR_UNIFIED_OPTION_TRAP_COMPRESSION"), source_archive_dir: options.source_archive_dir, file_lists: vec![options.file_list], }; diff --git a/unified/extractor/src/generator.rs b/unified/extractor/src/generator.rs index ee65da7a6005..ce1f37144a4e 100644 --- a/unified/extractor/src/generator.rs +++ b/unified/extractor/src/generator.rs @@ -15,7 +15,7 @@ pub struct Options { } pub fn run(options: Options) -> std::io::Result<()> { - codeql_extractor::extractor::set_tracing_level("ql"); + codeql_extractor::extractor::set_tracing_level("unified"); let languages = vec![Language { name: "Swift".to_owned(), @@ -23,5 +23,5 @@ pub fn run(options: Options) -> std::io::Result<()> { desugar: None, }]; - generate(languages, options.dbscheme, options.library, "run ql/unified/scripts/create-extractor-pack.sh") + generate(languages, options.dbscheme, options.library, "run unified/scripts/create-extractor-pack.sh") } diff --git a/unified/ql/lib/unified.dbscheme b/unified/ql/lib/unified.dbscheme index 026d4add415d..c580e8e69271 100644 --- a/unified/ql/lib/unified.dbscheme +++ b/unified/ql/lib/unified.dbscheme @@ -1,6 +1,6 @@ // CodeQL database schema for Swift // Automatically generated from the tree-sitter grammar; do not edit -// To regenerate, run ql/unified/scripts/create-extractor-pack.sh +// To regenerate, run unified/scripts/create-extractor-pack.sh /*- Files and folders -*/