commit 67e3f73ab42b0a68cd0fc3bf93426306612c9b36 Author: kjuulh Date: Mon Jul 3 20:16:09 2023 +0200 feat: add base parser Signed-off-by: kjuulh feat: with basic assignment Signed-off-by: kjuulh feat: remove target Signed-off-by: kjuulh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1e44fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +node_modules/ +target/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..abf2377 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,59 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "regex" +version = "1.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" + +[[package]] +name = "tree-sitter" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d" +dependencies = [ + "cc", + "regex", +] + +[[package]] +name = "tree-sitter-rhai" +version = "0.0.1" +dependencies = [ + "cc", + "tree-sitter", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a952d2d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "tree-sitter-rhai" +description = "rhai grammar for the tree-sitter parsing library" +version = "0.0.1" +authors = ["Kasper J. Hermansen "] +keywords = ["incremental", "parsing", "rhai"] +categories = ["parsing", "text-editors"] +repository = "https://github.com/tree-sitter/tree-sitter-rhai" +edition = "2018" +license = "MIT" + +build = "bindings/rust/build.rs" +include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] + +[lib] +path = "bindings/rust/lib.rs" + +[dependencies] +tree-sitter = "~0.20.10" + +[build-dependencies] +cc = "1.0" diff --git a/binding.gyp b/binding.gyp new file mode 100644 index 0000000..823c7e8 --- /dev/null +++ b/binding.gyp @@ -0,0 +1,20 @@ +{ + "targets": [ + { + "target_name": "tree_sitter_rhai_binding", + "include_dirs": [ + " +#include "nan.h" + +using namespace v8; + +extern "C" TSLanguage * tree_sitter_rhai(); + +namespace { + +NAN_METHOD(New) {} + +void Init(Local exports, Local module) { + Local tpl = Nan::New(New); + tpl->SetClassName(Nan::New("Language").ToLocalChecked()); + tpl->InstanceTemplate()->SetInternalFieldCount(1); + + Local constructor = Nan::GetFunction(tpl).ToLocalChecked(); + Local instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); + Nan::SetInternalFieldPointer(instance, 0, tree_sitter_rhai()); + + Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("rhai").ToLocalChecked()); + Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); +} + +NODE_MODULE(tree_sitter_rhai_binding, Init) + +} // namespace diff --git a/bindings/node/index.js b/bindings/node/index.js new file mode 100644 index 0000000..912adc5 --- /dev/null +++ b/bindings/node/index.js @@ -0,0 +1,19 @@ +try { + module.exports = require("../../build/Release/tree_sitter_rhai_binding"); +} catch (error1) { + if (error1.code !== 'MODULE_NOT_FOUND') { + throw error1; + } + try { + module.exports = require("../../build/Debug/tree_sitter_rhai_binding"); + } catch (error2) { + if (error2.code !== 'MODULE_NOT_FOUND') { + throw error2; + } + throw error1 + } +} + +try { + module.exports.nodeTypeInfo = require("../../src/node-types.json"); +} catch (_) {} diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs new file mode 100644 index 0000000..c6061f0 --- /dev/null +++ b/bindings/rust/build.rs @@ -0,0 +1,40 @@ +fn main() { + let src_dir = std::path::Path::new("src"); + + let mut c_config = cc::Build::new(); + c_config.include(&src_dir); + c_config + .flag_if_supported("-Wno-unused-parameter") + .flag_if_supported("-Wno-unused-but-set-variable") + .flag_if_supported("-Wno-trigraphs"); + let parser_path = src_dir.join("parser.c"); + c_config.file(&parser_path); + + // If your language uses an external scanner written in C, + // then include this block of code: + + /* + let scanner_path = src_dir.join("scanner.c"); + c_config.file(&scanner_path); + println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); + */ + + c_config.compile("parser"); + println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); + + // If your language uses an external scanner written in C++, + // then include this block of code: + + /* + let mut cpp_config = cc::Build::new(); + cpp_config.cpp(true); + cpp_config.include(&src_dir); + cpp_config + .flag_if_supported("-Wno-unused-parameter") + .flag_if_supported("-Wno-unused-but-set-variable"); + let scanner_path = src_dir.join("scanner.cc"); + cpp_config.file(&scanner_path); + cpp_config.compile("scanner"); + println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); + */ +} diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs new file mode 100644 index 0000000..583f669 --- /dev/null +++ b/bindings/rust/lib.rs @@ -0,0 +1,52 @@ +//! This crate provides rhai language support for the [tree-sitter][] parsing library. +//! +//! Typically, you will use the [language][language func] function to add this language to a +//! tree-sitter [Parser][], and then use the parser to parse some code: +//! +//! ``` +//! let code = ""; +//! let mut parser = tree_sitter::Parser::new(); +//! parser.set_language(tree_sitter_rhai::language()).expect("Error loading rhai grammar"); +//! let tree = parser.parse(code, None).unwrap(); +//! ``` +//! +//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html +//! [language func]: fn.language.html +//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html +//! [tree-sitter]: https://tree-sitter.github.io/ + +use tree_sitter::Language; + +extern "C" { + fn tree_sitter_rhai() -> Language; +} + +/// Get the tree-sitter [Language][] for this grammar. +/// +/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html +pub fn language() -> Language { + unsafe { tree_sitter_rhai() } +} + +/// The content of the [`node-types.json`][] file for this grammar. +/// +/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types +pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); + +// Uncomment these to include any queries that this grammar contains + +// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm"); +// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); +// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm"); +// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); + +#[cfg(test)] +mod tests { + #[test] + fn test_can_load_grammar() { + let mut parser = tree_sitter::Parser::new(); + parser + .set_language(super::language()) + .expect("Error loading rhai language"); + } +} diff --git a/corpus/assignment.txt b/corpus/assignment.txt new file mode 100644 index 0000000..00d4719 --- /dev/null +++ b/corpus/assignment.txt @@ -0,0 +1,52 @@ +================================================================================ +let assignment integer +================================================================================ + +let a = 42; + +-------------------------------------------------------------------------------- + +(source_file + (let_declaration + (identifier) + (integer_literal))) + +================================================================================ +let assignment string +================================================================================ + +let some_value = "string"; + +-------------------------------------------------------------------------------- + +(source_file + (let_declaration + (identifier) + (string_literal))) + +================================================================================ +let assignment object +================================================================================ + +let some_value = some_other_value; + +-------------------------------------------------------------------------------- + +(source_file + (let_declaration + (identifier) + (identifier))) + +================================================================================ +naked assignment integer +================================================================================ + +some_value = some_other_value; + +-------------------------------------------------------------------------------- + +(source_file + (expression_statement + (assignment_expression + left: (identifier) + right: (identifier)))) diff --git a/example-file.rhai b/example-file.rhai new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/example-file.rhai @@ -0,0 +1 @@ +hello diff --git a/grammar.js b/grammar.js new file mode 100644 index 0000000..4e8d152 --- /dev/null +++ b/grammar.js @@ -0,0 +1,110 @@ +const PREC = { + range: 15, + call: 14, + field: 13, + unary: 12, + cast: 11, + multiplicative: 10, + additive: 9, + shift: 8, + bitand: 7, + bitxor: 6, + bitor: 5, + comparative: 4, + and: 3, + or: 2, + assign: 0, + closure: -1, +}; + +module.exports = grammar({ + name: "rhai", + + externals: ($) => [ + $._string_content, + $.raw_string_literal, + $.float_literal, + $.block_comment, + ], + + extras: (_) => [/\s/], + + word: ($) => $.identifier, + + inline: ($) => [$._declaration_statement], + + supertypes: ($) => [ + $._expression, + $._literal, + $._literal_pattern, + $._declaration_statement, + $._pattern, + ], + + rules: { + source_file: ($) => repeat($._statement), + + // statements + + _statement: ($) => choice($.expression_statement, $._declaration_statement), + + expression_statement: ($) => choice(seq($._expression, ";")), + + _declaration_statement: ($) => choice($.let_declaration), + + let_declaration: ($) => + seq( + "let", + field("pattern", $._pattern), + optional(seq("=", field("value", $._expression))), + ";" + ), + + // patterns + + _pattern: ($) => choice($._literal_pattern, $.identifier, "_"), + + // expressions + + _expression: ($) => + choice($.assignment_expression, $._literal, prec.left($.identifier)), + + assignment_expression: ($) => + prec.left( + PREC.assign, + seq(field("left", $._expression), "=", field("right", $._expression)) + ), + + // literals + _literal: ($) => + choice($.string_literal, $.raw_string_literal, $.integer_literal), + + _literal_pattern: ($) => + choice($.string_literal, $.raw_string_literal, $.integer_literal), + + integer_literal: (_) => token(seq(choice(/[0-9][0-9_]*/))), + + string_literal: ($) => seq( + alias(/b?"/, '"'), + repeat(choice($.escape_sequence, $._string_content)), + token.immediate('"') + ), + + escape_sequence: (_) => + token.immediate( + seq( + "\\", + choice( + /[^xu]/, + /u[0-9a-fA-F]{4}/, + /u{[0-9a-fA-F]+}/, + /x[0-9a-fA-F]{2}/ + ) + ) + ), + + // identifiers + + identifier: ($) => /(r#)?[_\p{XID_Start}][_\p{XID_Continue}]*/, + }, +}); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..17a6351 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,50 @@ +{ + "name": "tree-sitter-rhai", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "tree-sitter-rhai", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "nan": "^2.17.0" + }, + "devDependencies": { + "prettier": "^2.8.8", + "tree-sitter-cli": "^0.20.8" + } + }, + "node_modules/nan": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", + "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==" + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/tree-sitter-cli": { + "version": "0.20.8", + "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz", + "integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "tree-sitter": "cli.js" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3c0ccab --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "tree-sitter-rhai", + "version": "1.0.0", + "description": "", + "main": "bindings/node", + "scripts": { + "tree-sitter": "tree-sitter", + "generate": "tree-sitter generate", + "test": "tree-sitter test", + "format": "prettier -w grammar.js" + }, + "author": "", + "license": "ISC", + "dependencies": { + "nan": "^2.17.0" + }, + "devDependencies": { + "tree-sitter-cli": "^0.20.8", + "prettier": "^2.8.8" + }, + "tree-sitter": [ + { + "scope": "source.rust", + "injection-regex": "rust", + "file-type": [ + "rs" + ] + } + ] +} diff --git a/src/grammar.json b/src/grammar.json new file mode 100644 index 0000000..66462c4 --- /dev/null +++ b/src/grammar.json @@ -0,0 +1,328 @@ +{ + "name": "rhai", + "word": "identifier", + "rules": { + "source_file": { + "type": "REPEAT", + "content": { + "type": "SYMBOL", + "name": "_statement" + } + }, + "_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "expression_statement" + }, + { + "type": "SYMBOL", + "name": "_declaration_statement" + } + ] + }, + "expression_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "SYMBOL", + "name": "_expression" + }, + { + "type": "STRING", + "value": ";" + } + ] + } + ] + }, + "_declaration_statement": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "let_declaration" + } + ] + }, + "let_declaration": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "let" + }, + { + "type": "FIELD", + "name": "pattern", + "content": { + "type": "SYMBOL", + "name": "_pattern" + } + }, + { + "type": "CHOICE", + "members": [ + { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "value", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + } + ] + }, + { + "type": "BLANK" + } + ] + }, + { + "type": "STRING", + "value": ";" + } + ] + }, + "_pattern": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "_literal_pattern" + }, + { + "type": "SYMBOL", + "name": "identifier" + }, + { + "type": "STRING", + "value": "_" + } + ] + }, + "_expression": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "assignment_expression" + }, + { + "type": "SYMBOL", + "name": "_literal" + }, + { + "type": "PREC_LEFT", + "value": 0, + "content": { + "type": "SYMBOL", + "name": "identifier" + } + } + ] + }, + "assignment_expression": { + "type": "PREC_LEFT", + "value": 0, + "content": { + "type": "SEQ", + "members": [ + { + "type": "FIELD", + "name": "left", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + }, + { + "type": "STRING", + "value": "=" + }, + { + "type": "FIELD", + "name": "right", + "content": { + "type": "SYMBOL", + "name": "_expression" + } + } + ] + } + }, + "_literal": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "string_literal" + }, + { + "type": "SYMBOL", + "name": "raw_string_literal" + }, + { + "type": "SYMBOL", + "name": "integer_literal" + } + ] + }, + "_literal_pattern": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "string_literal" + }, + { + "type": "SYMBOL", + "name": "raw_string_literal" + }, + { + "type": "SYMBOL", + "name": "integer_literal" + } + ] + }, + "integer_literal": { + "type": "TOKEN", + "content": { + "type": "SEQ", + "members": [ + { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "[0-9][0-9_]*" + } + ] + } + ] + } + }, + "string_literal": { + "type": "SEQ", + "members": [ + { + "type": "ALIAS", + "content": { + "type": "PATTERN", + "value": "b?\"" + }, + "named": false, + "value": "\"" + }, + { + "type": "REPEAT", + "content": { + "type": "CHOICE", + "members": [ + { + "type": "SYMBOL", + "name": "escape_sequence" + }, + { + "type": "SYMBOL", + "name": "_string_content" + } + ] + } + }, + { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "STRING", + "value": "\"" + } + } + ] + }, + "escape_sequence": { + "type": "IMMEDIATE_TOKEN", + "content": { + "type": "SEQ", + "members": [ + { + "type": "STRING", + "value": "\\" + }, + { + "type": "CHOICE", + "members": [ + { + "type": "PATTERN", + "value": "[^xu]" + }, + { + "type": "PATTERN", + "value": "u[0-9a-fA-F]{4}" + }, + { + "type": "PATTERN", + "value": "u{[0-9a-fA-F]+}" + }, + { + "type": "PATTERN", + "value": "x[0-9a-fA-F]{2}" + } + ] + } + ] + } + }, + "identifier": { + "type": "PATTERN", + "value": "(r#)?[_\\p{XID_Start}][_\\p{XID_Continue}]*" + } + }, + "extras": [ + { + "type": "PATTERN", + "value": "\\s" + } + ], + "conflicts": [], + "precedences": [], + "externals": [ + { + "type": "SYMBOL", + "name": "_string_content" + }, + { + "type": "SYMBOL", + "name": "raw_string_literal" + }, + { + "type": "SYMBOL", + "name": "float_literal" + }, + { + "type": "SYMBOL", + "name": "block_comment" + } + ], + "inline": [ + "_declaration_statement" + ], + "supertypes": [ + "_expression", + "_literal", + "_literal_pattern", + "_declaration_statement", + "_pattern" + ] +} + diff --git a/src/node-types.json b/src/node-types.json new file mode 100644 index 0000000..2b99f80 --- /dev/null +++ b/src/node-types.json @@ -0,0 +1,221 @@ +[ + { + "type": "_declaration_statement", + "named": true, + "subtypes": [ + { + "type": "let_declaration", + "named": true + } + ] + }, + { + "type": "_expression", + "named": true, + "subtypes": [ + { + "type": "_literal", + "named": true + }, + { + "type": "assignment_expression", + "named": true + }, + { + "type": "identifier", + "named": true + } + ] + }, + { + "type": "_literal", + "named": true, + "subtypes": [ + { + "type": "integer_literal", + "named": true + }, + { + "type": "raw_string_literal", + "named": true + }, + { + "type": "string_literal", + "named": true + } + ] + }, + { + "type": "_literal_pattern", + "named": true, + "subtypes": [ + { + "type": "integer_literal", + "named": true + }, + { + "type": "raw_string_literal", + "named": true + }, + { + "type": "string_literal", + "named": true + } + ] + }, + { + "type": "_pattern", + "named": true, + "subtypes": [ + { + "type": "_", + "named": false + }, + { + "type": "_literal_pattern", + "named": true + }, + { + "type": "identifier", + "named": true + } + ] + }, + { + "type": "assignment_expression", + "named": true, + "fields": { + "left": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_expression", + "named": true + } + ] + }, + "right": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_expression", + "named": true + } + ] + } + } + }, + { + "type": "expression_statement", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_expression", + "named": true + } + ] + } + }, + { + "type": "let_declaration", + "named": true, + "fields": { + "pattern": { + "multiple": false, + "required": true, + "types": [ + { + "type": "_pattern", + "named": true + } + ] + }, + "value": { + "multiple": false, + "required": false, + "types": [ + { + "type": "_expression", + "named": true + } + ] + } + } + }, + { + "type": "source_file", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "_declaration_statement", + "named": true + }, + { + "type": "expression_statement", + "named": true + } + ] + } + }, + { + "type": "string_literal", + "named": true, + "fields": {}, + "children": { + "multiple": true, + "required": false, + "types": [ + { + "type": "escape_sequence", + "named": true + } + ] + } + }, + { + "type": "\"", + "named": false + }, + { + "type": ";", + "named": false + }, + { + "type": "=", + "named": false + }, + { + "type": "_", + "named": false + }, + { + "type": "escape_sequence", + "named": true + }, + { + "type": "identifier", + "named": true + }, + { + "type": "integer_literal", + "named": true + }, + { + "type": "let", + "named": false + }, + { + "type": "raw_string_literal", + "named": true + } +] \ No newline at end of file diff --git a/src/parser.c b/src/parser.c new file mode 100644 index 0000000..8598775 --- /dev/null +++ b/src/parser.c @@ -0,0 +1,2663 @@ +#include + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#define LANGUAGE_VERSION 14 +#define STATE_COUNT 25 +#define LARGE_STATE_COUNT 4 +#define SYMBOL_COUNT 26 +#define ALIAS_COUNT 0 +#define TOKEN_COUNT 14 +#define EXTERNAL_TOKEN_COUNT 4 +#define FIELD_COUNT 4 +#define MAX_ALIAS_SEQUENCE_LENGTH 5 +#define PRODUCTION_ID_COUNT 4 + +enum { + sym_identifier = 1, + anon_sym_SEMI = 2, + anon_sym_let = 3, + anon_sym_EQ = 4, + anon_sym__ = 5, + sym_integer_literal = 6, + aux_sym_string_literal_token1 = 7, + anon_sym_DQUOTE = 8, + sym_escape_sequence = 9, + sym__string_content = 10, + sym_raw_string_literal = 11, + sym_float_literal = 12, + sym_block_comment = 13, + sym_source_file = 14, + sym__statement = 15, + sym_expression_statement = 16, + sym_let_declaration = 17, + sym__pattern = 18, + sym__expression = 19, + sym_assignment_expression = 20, + sym__literal = 21, + sym__literal_pattern = 22, + sym_string_literal = 23, + aux_sym_source_file_repeat1 = 24, + aux_sym_string_literal_repeat1 = 25, +}; + +static const char * const ts_symbol_names[] = { + [ts_builtin_sym_end] = "end", + [sym_identifier] = "identifier", + [anon_sym_SEMI] = ";", + [anon_sym_let] = "let", + [anon_sym_EQ] = "=", + [anon_sym__] = "_", + [sym_integer_literal] = "integer_literal", + [aux_sym_string_literal_token1] = "\"", + [anon_sym_DQUOTE] = "\"", + [sym_escape_sequence] = "escape_sequence", + [sym__string_content] = "_string_content", + [sym_raw_string_literal] = "raw_string_literal", + [sym_float_literal] = "float_literal", + [sym_block_comment] = "block_comment", + [sym_source_file] = "source_file", + [sym__statement] = "_statement", + [sym_expression_statement] = "expression_statement", + [sym_let_declaration] = "let_declaration", + [sym__pattern] = "_pattern", + [sym__expression] = "_expression", + [sym_assignment_expression] = "assignment_expression", + [sym__literal] = "_literal", + [sym__literal_pattern] = "_literal_pattern", + [sym_string_literal] = "string_literal", + [aux_sym_source_file_repeat1] = "source_file_repeat1", + [aux_sym_string_literal_repeat1] = "string_literal_repeat1", +}; + +static const TSSymbol ts_symbol_map[] = { + [ts_builtin_sym_end] = ts_builtin_sym_end, + [sym_identifier] = sym_identifier, + [anon_sym_SEMI] = anon_sym_SEMI, + [anon_sym_let] = anon_sym_let, + [anon_sym_EQ] = anon_sym_EQ, + [anon_sym__] = anon_sym__, + [sym_integer_literal] = sym_integer_literal, + [aux_sym_string_literal_token1] = anon_sym_DQUOTE, + [anon_sym_DQUOTE] = anon_sym_DQUOTE, + [sym_escape_sequence] = sym_escape_sequence, + [sym__string_content] = sym__string_content, + [sym_raw_string_literal] = sym_raw_string_literal, + [sym_float_literal] = sym_float_literal, + [sym_block_comment] = sym_block_comment, + [sym_source_file] = sym_source_file, + [sym__statement] = sym__statement, + [sym_expression_statement] = sym_expression_statement, + [sym_let_declaration] = sym_let_declaration, + [sym__pattern] = sym__pattern, + [sym__expression] = sym__expression, + [sym_assignment_expression] = sym_assignment_expression, + [sym__literal] = sym__literal, + [sym__literal_pattern] = sym__literal_pattern, + [sym_string_literal] = sym_string_literal, + [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1, + [aux_sym_string_literal_repeat1] = aux_sym_string_literal_repeat1, +}; + +static const TSSymbolMetadata ts_symbol_metadata[] = { + [ts_builtin_sym_end] = { + .visible = false, + .named = true, + }, + [sym_identifier] = { + .visible = true, + .named = true, + }, + [anon_sym_SEMI] = { + .visible = true, + .named = false, + }, + [anon_sym_let] = { + .visible = true, + .named = false, + }, + [anon_sym_EQ] = { + .visible = true, + .named = false, + }, + [anon_sym__] = { + .visible = true, + .named = false, + }, + [sym_integer_literal] = { + .visible = true, + .named = true, + }, + [aux_sym_string_literal_token1] = { + .visible = true, + .named = false, + }, + [anon_sym_DQUOTE] = { + .visible = true, + .named = false, + }, + [sym_escape_sequence] = { + .visible = true, + .named = true, + }, + [sym__string_content] = { + .visible = false, + .named = true, + }, + [sym_raw_string_literal] = { + .visible = true, + .named = true, + }, + [sym_float_literal] = { + .visible = true, + .named = true, + }, + [sym_block_comment] = { + .visible = true, + .named = true, + }, + [sym_source_file] = { + .visible = true, + .named = true, + }, + [sym__statement] = { + .visible = false, + .named = true, + }, + [sym_expression_statement] = { + .visible = true, + .named = true, + }, + [sym_let_declaration] = { + .visible = true, + .named = true, + }, + [sym__pattern] = { + .visible = false, + .named = true, + .supertype = true, + }, + [sym__expression] = { + .visible = false, + .named = true, + .supertype = true, + }, + [sym_assignment_expression] = { + .visible = true, + .named = true, + }, + [sym__literal] = { + .visible = false, + .named = true, + .supertype = true, + }, + [sym__literal_pattern] = { + .visible = false, + .named = true, + .supertype = true, + }, + [sym_string_literal] = { + .visible = true, + .named = true, + }, + [aux_sym_source_file_repeat1] = { + .visible = false, + .named = false, + }, + [aux_sym_string_literal_repeat1] = { + .visible = false, + .named = false, + }, +}; + +enum { + field_left = 1, + field_pattern = 2, + field_right = 3, + field_value = 4, +}; + +static const char * const ts_field_names[] = { + [0] = NULL, + [field_left] = "left", + [field_pattern] = "pattern", + [field_right] = "right", + [field_value] = "value", +}; + +static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { + [1] = {.index = 0, .length = 1}, + [2] = {.index = 1, .length = 2}, + [3] = {.index = 3, .length = 2}, +}; + +static const TSFieldMapEntry ts_field_map_entries[] = { + [0] = + {field_pattern, 1}, + [1] = + {field_left, 0}, + {field_right, 2}, + [3] = + {field_pattern, 1}, + {field_value, 3}, +}; + +static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { + [0] = {0}, +}; + +static const uint16_t ts_non_terminal_alias_map[] = { + 0, +}; + +static const TSStateId ts_primary_state_ids[STATE_COUNT] = { + [0] = 0, + [1] = 1, + [2] = 2, + [3] = 3, + [4] = 4, + [5] = 5, + [6] = 6, + [7] = 7, + [8] = 8, + [9] = 9, + [10] = 10, + [11] = 11, + [12] = 12, + [13] = 13, + [14] = 14, + [15] = 15, + [16] = 16, + [17] = 17, + [18] = 18, + [19] = 19, + [20] = 20, + [21] = 21, + [22] = 22, + [23] = 23, + [24] = 24, +}; + +static inline bool sym_identifier_character_set_1(int32_t c) { + return (c < 43514 + ? (c < 4193 + ? (c < 2707 + ? (c < 1994 + ? (c < 910 + ? (c < 736 + ? (c < 186 + ? (c < 'a' + ? (c < '_' + ? (c >= 'A' && c <= 'Z') + : c <= '_') + : (c <= 'z' || (c < 181 + ? c == 170 + : c <= 181))) + : (c <= 186 || (c < 248 + ? (c < 216 + ? (c >= 192 && c <= 214) + : c <= 246) + : (c <= 705 || (c >= 710 && c <= 721))))) + : (c <= 740 || (c < 891 + ? (c < 880 + ? (c < 750 + ? c == 748 + : c <= 750) + : (c <= 884 || (c >= 886 && c <= 887))) + : (c <= 893 || (c < 904 + ? (c < 902 + ? c == 895 + : c <= 902) + : (c <= 906 || c == 908)))))) + : (c <= 929 || (c < 1649 + ? (c < 1376 + ? (c < 1162 + ? (c < 1015 + ? (c >= 931 && c <= 1013) + : c <= 1153) + : (c <= 1327 || (c < 1369 + ? (c >= 1329 && c <= 1366) + : c <= 1369))) + : (c <= 1416 || (c < 1568 + ? (c < 1519 + ? (c >= 1488 && c <= 1514) + : c <= 1522) + : (c <= 1610 || (c >= 1646 && c <= 1647))))) + : (c <= 1747 || (c < 1791 + ? (c < 1774 + ? (c < 1765 + ? c == 1749 + : c <= 1766) + : (c <= 1775 || (c >= 1786 && c <= 1788))) + : (c <= 1791 || (c < 1869 + ? (c < 1810 + ? c == 1808 + : c <= 1839) + : (c <= 1957 || c == 1969)))))))) + : (c <= 2026 || (c < 2482 + ? (c < 2208 + ? (c < 2088 + ? (c < 2048 + ? (c < 2042 + ? (c >= 2036 && c <= 2037) + : c <= 2042) + : (c <= 2069 || (c < 2084 + ? c == 2074 + : c <= 2084))) + : (c <= 2088 || (c < 2160 + ? (c < 2144 + ? (c >= 2112 && c <= 2136) + : c <= 2154) + : (c <= 2183 || (c >= 2185 && c <= 2190))))) + : (c <= 2249 || (c < 2417 + ? (c < 2384 + ? (c < 2365 + ? (c >= 2308 && c <= 2361) + : c <= 2365) + : (c <= 2384 || (c >= 2392 && c <= 2401))) + : (c <= 2432 || (c < 2451 + ? (c < 2447 + ? (c >= 2437 && c <= 2444) + : c <= 2448) + : (c <= 2472 || (c >= 2474 && c <= 2480))))))) + : (c <= 2482 || (c < 2579 + ? (c < 2527 + ? (c < 2510 + ? (c < 2493 + ? (c >= 2486 && c <= 2489) + : c <= 2493) + : (c <= 2510 || (c >= 2524 && c <= 2525))) + : (c <= 2529 || (c < 2565 + ? (c < 2556 + ? (c >= 2544 && c <= 2545) + : c <= 2556) + : (c <= 2570 || (c >= 2575 && c <= 2576))))) + : (c <= 2600 || (c < 2649 + ? (c < 2613 + ? (c < 2610 + ? (c >= 2602 && c <= 2608) + : c <= 2611) + : (c <= 2614 || (c >= 2616 && c <= 2617))) + : (c <= 2652 || (c < 2693 + ? (c < 2674 + ? c == 2654 + : c <= 2676) + : (c <= 2701 || (c >= 2703 && c <= 2705))))))))))) + : (c <= 2728 || (c < 3242 + ? (c < 2962 + ? (c < 2858 + ? (c < 2784 + ? (c < 2741 + ? (c < 2738 + ? (c >= 2730 && c <= 2736) + : c <= 2739) + : (c <= 2745 || (c < 2768 + ? c == 2749 + : c <= 2768))) + : (c <= 2785 || (c < 2831 + ? (c < 2821 + ? c == 2809 + : c <= 2828) + : (c <= 2832 || (c >= 2835 && c <= 2856))))) + : (c <= 2864 || (c < 2911 + ? (c < 2877 + ? (c < 2869 + ? (c >= 2866 && c <= 2867) + : c <= 2873) + : (c <= 2877 || (c >= 2908 && c <= 2909))) + : (c <= 2913 || (c < 2949 + ? (c < 2947 + ? c == 2929 + : c <= 2947) + : (c <= 2954 || (c >= 2958 && c <= 2960))))))) + : (c <= 2965 || (c < 3090 + ? (c < 2984 + ? (c < 2974 + ? (c < 2972 + ? (c >= 2969 && c <= 2970) + : c <= 2972) + : (c <= 2975 || (c >= 2979 && c <= 2980))) + : (c <= 2986 || (c < 3077 + ? (c < 3024 + ? (c >= 2990 && c <= 3001) + : c <= 3024) + : (c <= 3084 || (c >= 3086 && c <= 3088))))) + : (c <= 3112 || (c < 3168 + ? (c < 3160 + ? (c < 3133 + ? (c >= 3114 && c <= 3129) + : c <= 3133) + : (c <= 3162 || c == 3165)) + : (c <= 3169 || (c < 3214 + ? (c < 3205 + ? c == 3200 + : c <= 3212) + : (c <= 3216 || (c >= 3218 && c <= 3240))))))))) + : (c <= 3251 || (c < 3648 + ? (c < 3412 + ? (c < 3332 + ? (c < 3293 + ? (c < 3261 + ? (c >= 3253 && c <= 3257) + : c <= 3261) + : (c <= 3294 || (c < 3313 + ? (c >= 3296 && c <= 3297) + : c <= 3314))) + : (c <= 3340 || (c < 3389 + ? (c < 3346 + ? (c >= 3342 && c <= 3344) + : c <= 3386) + : (c <= 3389 || c == 3406)))) + : (c <= 3414 || (c < 3507 + ? (c < 3461 + ? (c < 3450 + ? (c >= 3423 && c <= 3425) + : c <= 3455) + : (c <= 3478 || (c >= 3482 && c <= 3505))) + : (c <= 3515 || (c < 3585 + ? (c < 3520 + ? c == 3517 + : c <= 3526) + : (c <= 3632 || c == 3634)))))) + : (c <= 3654 || (c < 3782 + ? (c < 3749 + ? (c < 3718 + ? (c < 3716 + ? (c >= 3713 && c <= 3714) + : c <= 3716) + : (c <= 3722 || (c >= 3724 && c <= 3747))) + : (c <= 3749 || (c < 3773 + ? (c < 3762 + ? (c >= 3751 && c <= 3760) + : c <= 3762) + : (c <= 3773 || (c >= 3776 && c <= 3780))))) + : (c <= 3782 || (c < 3976 + ? (c < 3904 + ? (c < 3840 + ? (c >= 3804 && c <= 3807) + : c <= 3840) + : (c <= 3911 || (c >= 3913 && c <= 3948))) + : (c <= 3980 || (c < 4176 + ? (c < 4159 + ? (c >= 4096 && c <= 4138) + : c <= 4159) + : (c <= 4181 || (c >= 4186 && c <= 4189))))))))))))) + : (c <= 4193 || (c < 8134 + ? (c < 6176 + ? (c < 4808 + ? (c < 4688 + ? (c < 4295 + ? (c < 4213 + ? (c < 4206 + ? (c >= 4197 && c <= 4198) + : c <= 4208) + : (c <= 4225 || (c < 4256 + ? c == 4238 + : c <= 4293))) + : (c <= 4295 || (c < 4348 + ? (c < 4304 + ? c == 4301 + : c <= 4346) + : (c <= 4680 || (c >= 4682 && c <= 4685))))) + : (c <= 4694 || (c < 4752 + ? (c < 4704 + ? (c < 4698 + ? c == 4696 + : c <= 4701) + : (c <= 4744 || (c >= 4746 && c <= 4749))) + : (c <= 4784 || (c < 4800 + ? (c < 4792 + ? (c >= 4786 && c <= 4789) + : c <= 4798) + : (c <= 4800 || (c >= 4802 && c <= 4805))))))) + : (c <= 4822 || (c < 5792 + ? (c < 5024 + ? (c < 4888 + ? (c < 4882 + ? (c >= 4824 && c <= 4880) + : c <= 4885) + : (c <= 4954 || (c >= 4992 && c <= 5007))) + : (c <= 5109 || (c < 5743 + ? (c < 5121 + ? (c >= 5112 && c <= 5117) + : c <= 5740) + : (c <= 5759 || (c >= 5761 && c <= 5786))))) + : (c <= 5866 || (c < 5984 + ? (c < 5919 + ? (c < 5888 + ? (c >= 5870 && c <= 5880) + : c <= 5905) + : (c <= 5937 || (c >= 5952 && c <= 5969))) + : (c <= 5996 || (c < 6103 + ? (c < 6016 + ? (c >= 5998 && c <= 6000) + : c <= 6067) + : (c <= 6103 || c == 6108)))))))) + : (c <= 6264 || (c < 7312 + ? (c < 6823 + ? (c < 6512 + ? (c < 6320 + ? (c < 6314 + ? (c >= 6272 && c <= 6312) + : c <= 6314) + : (c <= 6389 || (c < 6480 + ? (c >= 6400 && c <= 6430) + : c <= 6509))) + : (c <= 6516 || (c < 6656 + ? (c < 6576 + ? (c >= 6528 && c <= 6571) + : c <= 6601) + : (c <= 6678 || (c >= 6688 && c <= 6740))))) + : (c <= 6823 || (c < 7098 + ? (c < 7043 + ? (c < 6981 + ? (c >= 6917 && c <= 6963) + : c <= 6988) + : (c <= 7072 || (c >= 7086 && c <= 7087))) + : (c <= 7141 || (c < 7258 + ? (c < 7245 + ? (c >= 7168 && c <= 7203) + : c <= 7247) + : (c <= 7293 || (c >= 7296 && c <= 7304))))))) + : (c <= 7354 || (c < 8008 + ? (c < 7418 + ? (c < 7406 + ? (c < 7401 + ? (c >= 7357 && c <= 7359) + : c <= 7404) + : (c <= 7411 || (c >= 7413 && c <= 7414))) + : (c <= 7418 || (c < 7960 + ? (c < 7680 + ? (c >= 7424 && c <= 7615) + : c <= 7957) + : (c <= 7965 || (c >= 7968 && c <= 8005))))) + : (c <= 8013 || (c < 8031 + ? (c < 8027 + ? (c < 8025 + ? (c >= 8016 && c <= 8023) + : c <= 8025) + : (c <= 8027 || c == 8029)) + : (c <= 8061 || (c < 8126 + ? (c < 8118 + ? (c >= 8064 && c <= 8116) + : c <= 8124) + : (c <= 8126 || (c >= 8130 && c <= 8132))))))))))) + : (c <= 8140 || (c < 12337 + ? (c < 8544 + ? (c < 8458 + ? (c < 8305 + ? (c < 8160 + ? (c < 8150 + ? (c >= 8144 && c <= 8147) + : c <= 8155) + : (c <= 8172 || (c < 8182 + ? (c >= 8178 && c <= 8180) + : c <= 8188))) + : (c <= 8305 || (c < 8450 + ? (c < 8336 + ? c == 8319 + : c <= 8348) + : (c <= 8450 || c == 8455)))) + : (c <= 8467 || (c < 8488 + ? (c < 8484 + ? (c < 8472 + ? c == 8469 + : c <= 8477) + : (c <= 8484 || c == 8486)) + : (c <= 8488 || (c < 8517 + ? (c < 8508 + ? (c >= 8490 && c <= 8505) + : c <= 8511) + : (c <= 8521 || c == 8526)))))) + : (c <= 8584 || (c < 11680 + ? (c < 11559 + ? (c < 11506 + ? (c < 11499 + ? (c >= 11264 && c <= 11492) + : c <= 11502) + : (c <= 11507 || (c >= 11520 && c <= 11557))) + : (c <= 11559 || (c < 11631 + ? (c < 11568 + ? c == 11565 + : c <= 11623) + : (c <= 11631 || (c >= 11648 && c <= 11670))))) + : (c <= 11686 || (c < 11720 + ? (c < 11704 + ? (c < 11696 + ? (c >= 11688 && c <= 11694) + : c <= 11702) + : (c <= 11710 || (c >= 11712 && c <= 11718))) + : (c <= 11726 || (c < 12293 + ? (c < 11736 + ? (c >= 11728 && c <= 11734) + : c <= 11742) + : (c <= 12295 || (c >= 12321 && c <= 12329))))))))) + : (c <= 12341 || (c < 42891 + ? (c < 19968 + ? (c < 12549 + ? (c < 12445 + ? (c < 12353 + ? (c >= 12344 && c <= 12348) + : c <= 12438) + : (c <= 12447 || (c < 12540 + ? (c >= 12449 && c <= 12538) + : c <= 12543))) + : (c <= 12591 || (c < 12784 + ? (c < 12704 + ? (c >= 12593 && c <= 12686) + : c <= 12735) + : (c <= 12799 || (c >= 13312 && c <= 19903))))) + : (c <= 42124 || (c < 42560 + ? (c < 42512 + ? (c < 42240 + ? (c >= 42192 && c <= 42237) + : c <= 42508) + : (c <= 42527 || (c >= 42538 && c <= 42539))) + : (c <= 42606 || (c < 42775 + ? (c < 42656 + ? (c >= 42623 && c <= 42653) + : c <= 42735) + : (c <= 42783 || (c >= 42786 && c <= 42888))))))) + : (c <= 42954 || (c < 43250 + ? (c < 43011 + ? (c < 42965 + ? (c < 42963 + ? (c >= 42960 && c <= 42961) + : c <= 42963) + : (c <= 42969 || (c >= 42994 && c <= 43009))) + : (c <= 43013 || (c < 43072 + ? (c < 43020 + ? (c >= 43015 && c <= 43018) + : c <= 43042) + : (c <= 43123 || (c >= 43138 && c <= 43187))))) + : (c <= 43255 || (c < 43360 + ? (c < 43274 + ? (c < 43261 + ? c == 43259 + : c <= 43262) + : (c <= 43301 || (c >= 43312 && c <= 43334))) + : (c <= 43388 || (c < 43488 + ? (c < 43471 + ? (c >= 43396 && c <= 43442) + : c <= 43471) + : (c <= 43492 || (c >= 43494 && c <= 43503))))))))))))))) + : (c <= 43518 || (c < 70727 + ? (c < 66956 + ? (c < 64914 + ? (c < 43868 + ? (c < 43714 + ? (c < 43646 + ? (c < 43588 + ? (c < 43584 + ? (c >= 43520 && c <= 43560) + : c <= 43586) + : (c <= 43595 || (c < 43642 + ? (c >= 43616 && c <= 43638) + : c <= 43642))) + : (c <= 43695 || (c < 43705 + ? (c < 43701 + ? c == 43697 + : c <= 43702) + : (c <= 43709 || c == 43712)))) + : (c <= 43714 || (c < 43785 + ? (c < 43762 + ? (c < 43744 + ? (c >= 43739 && c <= 43741) + : c <= 43754) + : (c <= 43764 || (c >= 43777 && c <= 43782))) + : (c <= 43790 || (c < 43816 + ? (c < 43808 + ? (c >= 43793 && c <= 43798) + : c <= 43814) + : (c <= 43822 || (c >= 43824 && c <= 43866))))))) + : (c <= 43881 || (c < 64287 + ? (c < 63744 + ? (c < 55216 + ? (c < 44032 + ? (c >= 43888 && c <= 44002) + : c <= 55203) + : (c <= 55238 || (c >= 55243 && c <= 55291))) + : (c <= 64109 || (c < 64275 + ? (c < 64256 + ? (c >= 64112 && c <= 64217) + : c <= 64262) + : (c <= 64279 || c == 64285)))) + : (c <= 64296 || (c < 64323 + ? (c < 64318 + ? (c < 64312 + ? (c >= 64298 && c <= 64310) + : c <= 64316) + : (c <= 64318 || (c >= 64320 && c <= 64321))) + : (c <= 64324 || (c < 64612 + ? (c < 64467 + ? (c >= 64326 && c <= 64433) + : c <= 64605) + : (c <= 64829 || (c >= 64848 && c <= 64911))))))))) + : (c <= 64967 || (c < 65599 + ? (c < 65382 + ? (c < 65147 + ? (c < 65139 + ? (c < 65137 + ? (c >= 65008 && c <= 65017) + : c <= 65137) + : (c <= 65139 || (c < 65145 + ? c == 65143 + : c <= 65145))) + : (c <= 65147 || (c < 65313 + ? (c < 65151 + ? c == 65149 + : c <= 65276) + : (c <= 65338 || (c >= 65345 && c <= 65370))))) + : (c <= 65437 || (c < 65498 + ? (c < 65482 + ? (c < 65474 + ? (c >= 65440 && c <= 65470) + : c <= 65479) + : (c <= 65487 || (c >= 65490 && c <= 65495))) + : (c <= 65500 || (c < 65576 + ? (c < 65549 + ? (c >= 65536 && c <= 65547) + : c <= 65574) + : (c <= 65594 || (c >= 65596 && c <= 65597))))))) + : (c <= 65613 || (c < 66464 + ? (c < 66208 + ? (c < 65856 + ? (c < 65664 + ? (c >= 65616 && c <= 65629) + : c <= 65786) + : (c <= 65908 || (c >= 66176 && c <= 66204))) + : (c <= 66256 || (c < 66384 + ? (c < 66349 + ? (c >= 66304 && c <= 66335) + : c <= 66378) + : (c <= 66421 || (c >= 66432 && c <= 66461))))) + : (c <= 66499 || (c < 66776 + ? (c < 66560 + ? (c < 66513 + ? (c >= 66504 && c <= 66511) + : c <= 66517) + : (c <= 66717 || (c >= 66736 && c <= 66771))) + : (c <= 66811 || (c < 66928 + ? (c < 66864 + ? (c >= 66816 && c <= 66855) + : c <= 66915) + : (c <= 66938 || (c >= 66940 && c <= 66954))))))))))) + : (c <= 66962 || (c < 68864 + ? (c < 67828 + ? (c < 67506 + ? (c < 67072 + ? (c < 66979 + ? (c < 66967 + ? (c >= 66964 && c <= 66965) + : c <= 66977) + : (c <= 66993 || (c < 67003 + ? (c >= 66995 && c <= 67001) + : c <= 67004))) + : (c <= 67382 || (c < 67456 + ? (c < 67424 + ? (c >= 67392 && c <= 67413) + : c <= 67431) + : (c <= 67461 || (c >= 67463 && c <= 67504))))) + : (c <= 67514 || (c < 67644 + ? (c < 67594 + ? (c < 67592 + ? (c >= 67584 && c <= 67589) + : c <= 67592) + : (c <= 67637 || (c >= 67639 && c <= 67640))) + : (c <= 67644 || (c < 67712 + ? (c < 67680 + ? (c >= 67647 && c <= 67669) + : c <= 67702) + : (c <= 67742 || (c >= 67808 && c <= 67826))))))) + : (c <= 67829 || (c < 68224 + ? (c < 68096 + ? (c < 67968 + ? (c < 67872 + ? (c >= 67840 && c <= 67861) + : c <= 67897) + : (c <= 68023 || (c >= 68030 && c <= 68031))) + : (c <= 68096 || (c < 68121 + ? (c < 68117 + ? (c >= 68112 && c <= 68115) + : c <= 68119) + : (c <= 68149 || (c >= 68192 && c <= 68220))))) + : (c <= 68252 || (c < 68448 + ? (c < 68352 + ? (c < 68297 + ? (c >= 68288 && c <= 68295) + : c <= 68324) + : (c <= 68405 || (c >= 68416 && c <= 68437))) + : (c <= 68466 || (c < 68736 + ? (c < 68608 + ? (c >= 68480 && c <= 68497) + : c <= 68680) + : (c <= 68786 || (c >= 68800 && c <= 68850))))))))) + : (c <= 68899 || (c < 70106 + ? (c < 69749 + ? (c < 69488 + ? (c < 69376 + ? (c < 69296 + ? (c >= 69248 && c <= 69289) + : c <= 69297) + : (c <= 69404 || (c < 69424 + ? c == 69415 + : c <= 69445))) + : (c <= 69505 || (c < 69635 + ? (c < 69600 + ? (c >= 69552 && c <= 69572) + : c <= 69622) + : (c <= 69687 || (c >= 69745 && c <= 69746))))) + : (c <= 69749 || (c < 69959 + ? (c < 69891 + ? (c < 69840 + ? (c >= 69763 && c <= 69807) + : c <= 69864) + : (c <= 69926 || c == 69956)) + : (c <= 69959 || (c < 70019 + ? (c < 70006 + ? (c >= 69968 && c <= 70002) + : c <= 70006) + : (c <= 70066 || (c >= 70081 && c <= 70084))))))) + : (c <= 70106 || (c < 70405 + ? (c < 70280 + ? (c < 70163 + ? (c < 70144 + ? c == 70108 + : c <= 70161) + : (c <= 70187 || (c >= 70272 && c <= 70278))) + : (c <= 70280 || (c < 70303 + ? (c < 70287 + ? (c >= 70282 && c <= 70285) + : c <= 70301) + : (c <= 70312 || (c >= 70320 && c <= 70366))))) + : (c <= 70412 || (c < 70453 + ? (c < 70442 + ? (c < 70419 + ? (c >= 70415 && c <= 70416) + : c <= 70440) + : (c <= 70448 || (c >= 70450 && c <= 70451))) + : (c <= 70457 || (c < 70493 + ? (c < 70480 + ? c == 70461 + : c <= 70480) + : (c <= 70497 || (c >= 70656 && c <= 70708))))))))))))) + : (c <= 70730 || (c < 119894 + ? (c < 73056 + ? (c < 72001 + ? (c < 71424 + ? (c < 71128 + ? (c < 70852 + ? (c < 70784 + ? (c >= 70751 && c <= 70753) + : c <= 70831) + : (c <= 70853 || (c < 71040 + ? c == 70855 + : c <= 71086))) + : (c <= 71131 || (c < 71296 + ? (c < 71236 + ? (c >= 71168 && c <= 71215) + : c <= 71236) + : (c <= 71338 || c == 71352)))) + : (c <= 71450 || (c < 71945 + ? (c < 71840 + ? (c < 71680 + ? (c >= 71488 && c <= 71494) + : c <= 71723) + : (c <= 71903 || (c >= 71935 && c <= 71942))) + : (c <= 71945 || (c < 71960 + ? (c < 71957 + ? (c >= 71948 && c <= 71955) + : c <= 71958) + : (c <= 71983 || c == 71999)))))) + : (c <= 72001 || (c < 72349 + ? (c < 72192 + ? (c < 72161 + ? (c < 72106 + ? (c >= 72096 && c <= 72103) + : c <= 72144) + : (c <= 72161 || c == 72163)) + : (c <= 72192 || (c < 72272 + ? (c < 72250 + ? (c >= 72203 && c <= 72242) + : c <= 72250) + : (c <= 72272 || (c >= 72284 && c <= 72329))))) + : (c <= 72349 || (c < 72818 + ? (c < 72714 + ? (c < 72704 + ? (c >= 72368 && c <= 72440) + : c <= 72712) + : (c <= 72750 || c == 72768)) + : (c <= 72847 || (c < 72971 + ? (c < 72968 + ? (c >= 72960 && c <= 72966) + : c <= 72969) + : (c <= 73008 || c == 73030)))))))) + : (c <= 73061 || (c < 93952 + ? (c < 82944 + ? (c < 73728 + ? (c < 73112 + ? (c < 73066 + ? (c >= 73063 && c <= 73064) + : c <= 73097) + : (c <= 73112 || (c < 73648 + ? (c >= 73440 && c <= 73458) + : c <= 73648))) + : (c <= 74649 || (c < 77712 + ? (c < 74880 + ? (c >= 74752 && c <= 74862) + : c <= 75075) + : (c <= 77808 || (c >= 77824 && c <= 78894))))) + : (c <= 83526 || (c < 92928 + ? (c < 92784 + ? (c < 92736 + ? (c >= 92160 && c <= 92728) + : c <= 92766) + : (c <= 92862 || (c >= 92880 && c <= 92909))) + : (c <= 92975 || (c < 93053 + ? (c < 93027 + ? (c >= 92992 && c <= 92995) + : c <= 93047) + : (c <= 93071 || (c >= 93760 && c <= 93823))))))) + : (c <= 94026 || (c < 110589 + ? (c < 94208 + ? (c < 94176 + ? (c < 94099 + ? c == 94032 + : c <= 94111) + : (c <= 94177 || c == 94179)) + : (c <= 100343 || (c < 110576 + ? (c < 101632 + ? (c >= 100352 && c <= 101589) + : c <= 101640) + : (c <= 110579 || (c >= 110581 && c <= 110587))))) + : (c <= 110590 || (c < 113664 + ? (c < 110948 + ? (c < 110928 + ? (c >= 110592 && c <= 110882) + : c <= 110930) + : (c <= 110951 || (c >= 110960 && c <= 111355))) + : (c <= 113770 || (c < 113808 + ? (c < 113792 + ? (c >= 113776 && c <= 113788) + : c <= 113800) + : (c <= 113817 || (c >= 119808 && c <= 119892))))))))))) + : (c <= 119964 || (c < 125259 + ? (c < 120572 + ? (c < 120086 + ? (c < 119995 + ? (c < 119973 + ? (c < 119970 + ? (c >= 119966 && c <= 119967) + : c <= 119970) + : (c <= 119974 || (c < 119982 + ? (c >= 119977 && c <= 119980) + : c <= 119993))) + : (c <= 119995 || (c < 120071 + ? (c < 120005 + ? (c >= 119997 && c <= 120003) + : c <= 120069) + : (c <= 120074 || (c >= 120077 && c <= 120084))))) + : (c <= 120092 || (c < 120138 + ? (c < 120128 + ? (c < 120123 + ? (c >= 120094 && c <= 120121) + : c <= 120126) + : (c <= 120132 || c == 120134)) + : (c <= 120144 || (c < 120514 + ? (c < 120488 + ? (c >= 120146 && c <= 120485) + : c <= 120512) + : (c <= 120538 || (c >= 120540 && c <= 120570))))))) + : (c <= 120596 || (c < 123191 + ? (c < 120714 + ? (c < 120656 + ? (c < 120630 + ? (c >= 120598 && c <= 120628) + : c <= 120654) + : (c <= 120686 || (c >= 120688 && c <= 120712))) + : (c <= 120744 || (c < 122624 + ? (c < 120772 + ? (c >= 120746 && c <= 120770) + : c <= 120779) + : (c <= 122654 || (c >= 123136 && c <= 123180))))) + : (c <= 123197 || (c < 124904 + ? (c < 123584 + ? (c < 123536 + ? c == 123214 + : c <= 123565) + : (c <= 123627 || (c >= 124896 && c <= 124902))) + : (c <= 124907 || (c < 124928 + ? (c < 124912 + ? (c >= 124909 && c <= 124910) + : c <= 124926) + : (c <= 125124 || (c >= 125184 && c <= 125251))))))))) + : (c <= 125259 || (c < 126559 + ? (c < 126535 + ? (c < 126505 + ? (c < 126497 + ? (c < 126469 + ? (c >= 126464 && c <= 126467) + : c <= 126495) + : (c <= 126498 || (c < 126503 + ? c == 126500 + : c <= 126503))) + : (c <= 126514 || (c < 126523 + ? (c < 126521 + ? (c >= 126516 && c <= 126519) + : c <= 126521) + : (c <= 126523 || c == 126530)))) + : (c <= 126535 || (c < 126548 + ? (c < 126541 + ? (c < 126539 + ? c == 126537 + : c <= 126539) + : (c <= 126543 || (c >= 126545 && c <= 126546))) + : (c <= 126548 || (c < 126555 + ? (c < 126553 + ? c == 126551 + : c <= 126553) + : (c <= 126555 || c == 126557)))))) + : (c <= 126559 || (c < 126625 + ? (c < 126580 + ? (c < 126567 + ? (c < 126564 + ? (c >= 126561 && c <= 126562) + : c <= 126564) + : (c <= 126570 || (c >= 126572 && c <= 126578))) + : (c <= 126583 || (c < 126592 + ? (c < 126590 + ? (c >= 126585 && c <= 126588) + : c <= 126590) + : (c <= 126601 || (c >= 126603 && c <= 126619))))) + : (c <= 126627 || (c < 177984 + ? (c < 131072 + ? (c < 126635 + ? (c >= 126629 && c <= 126633) + : c <= 126651) + : (c <= 173791 || (c >= 173824 && c <= 177976))) + : (c <= 178205 || (c < 194560 + ? (c < 183984 + ? (c >= 178208 && c <= 183969) + : c <= 191456) + : (c <= 195101 || (c >= 196608 && c <= 201546))))))))))))))))); +} + +static inline bool sym_identifier_character_set_2(int32_t c) { + return (c < 43616 + ? (c < 3782 + ? (c < 2748 + ? (c < 2045 + ? (c < 1015 + ? (c < 710 + ? (c < 181 + ? (c < '_' + ? (c < 'A' + ? (c >= '0' && c <= '9') + : c <= 'Z') + : (c <= '_' || (c < 170 + ? (c >= 'a' && c <= 'z') + : c <= 170))) + : (c <= 181 || (c < 192 + ? (c < 186 + ? c == 183 + : c <= 186) + : (c <= 214 || (c < 248 + ? (c >= 216 && c <= 246) + : c <= 705))))) + : (c <= 721 || (c < 891 + ? (c < 750 + ? (c < 748 + ? (c >= 736 && c <= 740) + : c <= 748) + : (c <= 750 || (c < 886 + ? (c >= 768 && c <= 884) + : c <= 887))) + : (c <= 893 || (c < 908 + ? (c < 902 + ? c == 895 + : c <= 906) + : (c <= 908 || (c < 931 + ? (c >= 910 && c <= 929) + : c <= 1013))))))) + : (c <= 1153 || (c < 1519 + ? (c < 1425 + ? (c < 1329 + ? (c < 1162 + ? (c >= 1155 && c <= 1159) + : c <= 1327) + : (c <= 1366 || (c < 1376 + ? c == 1369 + : c <= 1416))) + : (c <= 1469 || (c < 1476 + ? (c < 1473 + ? c == 1471 + : c <= 1474) + : (c <= 1477 || (c < 1488 + ? c == 1479 + : c <= 1514))))) + : (c <= 1522 || (c < 1770 + ? (c < 1646 + ? (c < 1568 + ? (c >= 1552 && c <= 1562) + : c <= 1641) + : (c <= 1747 || (c < 1759 + ? (c >= 1749 && c <= 1756) + : c <= 1768))) + : (c <= 1788 || (c < 1869 + ? (c < 1808 + ? c == 1791 + : c <= 1866) + : (c <= 1969 || (c < 2042 + ? (c >= 1984 && c <= 2037) + : c <= 2042))))))))) + : (c <= 2045 || (c < 2558 + ? (c < 2451 + ? (c < 2200 + ? (c < 2144 + ? (c < 2112 + ? (c >= 2048 && c <= 2093) + : c <= 2139) + : (c <= 2154 || (c < 2185 + ? (c >= 2160 && c <= 2183) + : c <= 2190))) + : (c <= 2273 || (c < 2417 + ? (c < 2406 + ? (c >= 2275 && c <= 2403) + : c <= 2415) + : (c <= 2435 || (c < 2447 + ? (c >= 2437 && c <= 2444) + : c <= 2448))))) + : (c <= 2472 || (c < 2507 + ? (c < 2486 + ? (c < 2482 + ? (c >= 2474 && c <= 2480) + : c <= 2482) + : (c <= 2489 || (c < 2503 + ? (c >= 2492 && c <= 2500) + : c <= 2504))) + : (c <= 2510 || (c < 2527 + ? (c < 2524 + ? c == 2519 + : c <= 2525) + : (c <= 2531 || (c < 2556 + ? (c >= 2534 && c <= 2545) + : c <= 2556))))))) + : (c <= 2558 || (c < 2635 + ? (c < 2610 + ? (c < 2575 + ? (c < 2565 + ? (c >= 2561 && c <= 2563) + : c <= 2570) + : (c <= 2576 || (c < 2602 + ? (c >= 2579 && c <= 2600) + : c <= 2608))) + : (c <= 2611 || (c < 2620 + ? (c < 2616 + ? (c >= 2613 && c <= 2614) + : c <= 2617) + : (c <= 2620 || (c < 2631 + ? (c >= 2622 && c <= 2626) + : c <= 2632))))) + : (c <= 2637 || (c < 2693 + ? (c < 2654 + ? (c < 2649 + ? c == 2641 + : c <= 2652) + : (c <= 2654 || (c < 2689 + ? (c >= 2662 && c <= 2677) + : c <= 2691))) + : (c <= 2701 || (c < 2730 + ? (c < 2707 + ? (c >= 2703 && c <= 2705) + : c <= 2728) + : (c <= 2736 || (c < 2741 + ? (c >= 2738 && c <= 2739) + : c <= 2745))))))))))) + : (c <= 2757 || (c < 3168 + ? (c < 2958 + ? (c < 2866 + ? (c < 2809 + ? (c < 2768 + ? (c < 2763 + ? (c >= 2759 && c <= 2761) + : c <= 2765) + : (c <= 2768 || (c < 2790 + ? (c >= 2784 && c <= 2787) + : c <= 2799))) + : (c <= 2815 || (c < 2831 + ? (c < 2821 + ? (c >= 2817 && c <= 2819) + : c <= 2828) + : (c <= 2832 || (c < 2858 + ? (c >= 2835 && c <= 2856) + : c <= 2864))))) + : (c <= 2867 || (c < 2908 + ? (c < 2887 + ? (c < 2876 + ? (c >= 2869 && c <= 2873) + : c <= 2884) + : (c <= 2888 || (c < 2901 + ? (c >= 2891 && c <= 2893) + : c <= 2903))) + : (c <= 2909 || (c < 2929 + ? (c < 2918 + ? (c >= 2911 && c <= 2915) + : c <= 2927) + : (c <= 2929 || (c < 2949 + ? (c >= 2946 && c <= 2947) + : c <= 2954))))))) + : (c <= 2960 || (c < 3031 + ? (c < 2984 + ? (c < 2972 + ? (c < 2969 + ? (c >= 2962 && c <= 2965) + : c <= 2970) + : (c <= 2972 || (c < 2979 + ? (c >= 2974 && c <= 2975) + : c <= 2980))) + : (c <= 2986 || (c < 3014 + ? (c < 3006 + ? (c >= 2990 && c <= 3001) + : c <= 3010) + : (c <= 3016 || (c < 3024 + ? (c >= 3018 && c <= 3021) + : c <= 3024))))) + : (c <= 3031 || (c < 3132 + ? (c < 3086 + ? (c < 3072 + ? (c >= 3046 && c <= 3055) + : c <= 3084) + : (c <= 3088 || (c < 3114 + ? (c >= 3090 && c <= 3112) + : c <= 3129))) + : (c <= 3140 || (c < 3157 + ? (c < 3146 + ? (c >= 3142 && c <= 3144) + : c <= 3149) + : (c <= 3158 || (c < 3165 + ? (c >= 3160 && c <= 3162) + : c <= 3165))))))))) + : (c <= 3171 || (c < 3450 + ? (c < 3293 + ? (c < 3242 + ? (c < 3205 + ? (c < 3200 + ? (c >= 3174 && c <= 3183) + : c <= 3203) + : (c <= 3212 || (c < 3218 + ? (c >= 3214 && c <= 3216) + : c <= 3240))) + : (c <= 3251 || (c < 3270 + ? (c < 3260 + ? (c >= 3253 && c <= 3257) + : c <= 3268) + : (c <= 3272 || (c < 3285 + ? (c >= 3274 && c <= 3277) + : c <= 3286))))) + : (c <= 3294 || (c < 3346 + ? (c < 3313 + ? (c < 3302 + ? (c >= 3296 && c <= 3299) + : c <= 3311) + : (c <= 3314 || (c < 3342 + ? (c >= 3328 && c <= 3340) + : c <= 3344))) + : (c <= 3396 || (c < 3412 + ? (c < 3402 + ? (c >= 3398 && c <= 3400) + : c <= 3406) + : (c <= 3415 || (c < 3430 + ? (c >= 3423 && c <= 3427) + : c <= 3439))))))) + : (c <= 3455 || (c < 3570 + ? (c < 3520 + ? (c < 3482 + ? (c < 3461 + ? (c >= 3457 && c <= 3459) + : c <= 3478) + : (c <= 3505 || (c < 3517 + ? (c >= 3507 && c <= 3515) + : c <= 3517))) + : (c <= 3526 || (c < 3542 + ? (c < 3535 + ? c == 3530 + : c <= 3540) + : (c <= 3542 || (c < 3558 + ? (c >= 3544 && c <= 3551) + : c <= 3567))))) + : (c <= 3571 || (c < 3718 + ? (c < 3664 + ? (c < 3648 + ? (c >= 3585 && c <= 3642) + : c <= 3662) + : (c <= 3673 || (c < 3716 + ? (c >= 3713 && c <= 3714) + : c <= 3716))) + : (c <= 3722 || (c < 3751 + ? (c < 3749 + ? (c >= 3724 && c <= 3747) + : c <= 3749) + : (c <= 3773 || (c >= 3776 && c <= 3780))))))))))))) + : (c <= 3782 || (c < 8025 + ? (c < 5888 + ? (c < 4688 + ? (c < 3953 + ? (c < 3872 + ? (c < 3804 + ? (c < 3792 + ? (c >= 3784 && c <= 3789) + : c <= 3801) + : (c <= 3807 || (c < 3864 + ? c == 3840 + : c <= 3865))) + : (c <= 3881 || (c < 3897 + ? (c < 3895 + ? c == 3893 + : c <= 3895) + : (c <= 3897 || (c < 3913 + ? (c >= 3902 && c <= 3911) + : c <= 3948))))) + : (c <= 3972 || (c < 4256 + ? (c < 4038 + ? (c < 3993 + ? (c >= 3974 && c <= 3991) + : c <= 4028) + : (c <= 4038 || (c < 4176 + ? (c >= 4096 && c <= 4169) + : c <= 4253))) + : (c <= 4293 || (c < 4304 + ? (c < 4301 + ? c == 4295 + : c <= 4301) + : (c <= 4346 || (c < 4682 + ? (c >= 4348 && c <= 4680) + : c <= 4685))))))) + : (c <= 4694 || (c < 4882 + ? (c < 4786 + ? (c < 4704 + ? (c < 4698 + ? c == 4696 + : c <= 4701) + : (c <= 4744 || (c < 4752 + ? (c >= 4746 && c <= 4749) + : c <= 4784))) + : (c <= 4789 || (c < 4802 + ? (c < 4800 + ? (c >= 4792 && c <= 4798) + : c <= 4800) + : (c <= 4805 || (c < 4824 + ? (c >= 4808 && c <= 4822) + : c <= 4880))))) + : (c <= 4885 || (c < 5112 + ? (c < 4969 + ? (c < 4957 + ? (c >= 4888 && c <= 4954) + : c <= 4959) + : (c <= 4977 || (c < 5024 + ? (c >= 4992 && c <= 5007) + : c <= 5109))) + : (c <= 5117 || (c < 5761 + ? (c < 5743 + ? (c >= 5121 && c <= 5740) + : c <= 5759) + : (c <= 5786 || (c < 5870 + ? (c >= 5792 && c <= 5866) + : c <= 5880))))))))) + : (c <= 5909 || (c < 6688 + ? (c < 6176 + ? (c < 6016 + ? (c < 5984 + ? (c < 5952 + ? (c >= 5919 && c <= 5940) + : c <= 5971) + : (c <= 5996 || (c < 6002 + ? (c >= 5998 && c <= 6000) + : c <= 6003))) + : (c <= 6099 || (c < 6112 + ? (c < 6108 + ? c == 6103 + : c <= 6109) + : (c <= 6121 || (c < 6159 + ? (c >= 6155 && c <= 6157) + : c <= 6169))))) + : (c <= 6264 || (c < 6470 + ? (c < 6400 + ? (c < 6320 + ? (c >= 6272 && c <= 6314) + : c <= 6389) + : (c <= 6430 || (c < 6448 + ? (c >= 6432 && c <= 6443) + : c <= 6459))) + : (c <= 6509 || (c < 6576 + ? (c < 6528 + ? (c >= 6512 && c <= 6516) + : c <= 6571) + : (c <= 6601 || (c < 6656 + ? (c >= 6608 && c <= 6618) + : c <= 6683))))))) + : (c <= 6750 || (c < 7232 + ? (c < 6847 + ? (c < 6800 + ? (c < 6783 + ? (c >= 6752 && c <= 6780) + : c <= 6793) + : (c <= 6809 || (c < 6832 + ? c == 6823 + : c <= 6845))) + : (c <= 6862 || (c < 7019 + ? (c < 6992 + ? (c >= 6912 && c <= 6988) + : c <= 7001) + : (c <= 7027 || (c < 7168 + ? (c >= 7040 && c <= 7155) + : c <= 7223))))) + : (c <= 7241 || (c < 7380 + ? (c < 7312 + ? (c < 7296 + ? (c >= 7245 && c <= 7293) + : c <= 7304) + : (c <= 7354 || (c < 7376 + ? (c >= 7357 && c <= 7359) + : c <= 7378))) + : (c <= 7418 || (c < 7968 + ? (c < 7960 + ? (c >= 7424 && c <= 7957) + : c <= 7965) + : (c <= 8005 || (c < 8016 + ? (c >= 8008 && c <= 8013) + : c <= 8023))))))))))) + : (c <= 8025 || (c < 11720 + ? (c < 8458 + ? (c < 8178 + ? (c < 8126 + ? (c < 8031 + ? (c < 8029 + ? c == 8027 + : c <= 8029) + : (c <= 8061 || (c < 8118 + ? (c >= 8064 && c <= 8116) + : c <= 8124))) + : (c <= 8126 || (c < 8144 + ? (c < 8134 + ? (c >= 8130 && c <= 8132) + : c <= 8140) + : (c <= 8147 || (c < 8160 + ? (c >= 8150 && c <= 8155) + : c <= 8172))))) + : (c <= 8180 || (c < 8336 + ? (c < 8276 + ? (c < 8255 + ? (c >= 8182 && c <= 8188) + : c <= 8256) + : (c <= 8276 || (c < 8319 + ? c == 8305 + : c <= 8319))) + : (c <= 8348 || (c < 8421 + ? (c < 8417 + ? (c >= 8400 && c <= 8412) + : c <= 8417) + : (c <= 8432 || (c < 8455 + ? c == 8450 + : c <= 8455))))))) + : (c <= 8467 || (c < 11499 + ? (c < 8490 + ? (c < 8484 + ? (c < 8472 + ? c == 8469 + : c <= 8477) + : (c <= 8484 || (c < 8488 + ? c == 8486 + : c <= 8488))) + : (c <= 8505 || (c < 8526 + ? (c < 8517 + ? (c >= 8508 && c <= 8511) + : c <= 8521) + : (c <= 8526 || (c < 11264 + ? (c >= 8544 && c <= 8584) + : c <= 11492))))) + : (c <= 11507 || (c < 11647 + ? (c < 11565 + ? (c < 11559 + ? (c >= 11520 && c <= 11557) + : c <= 11559) + : (c <= 11565 || (c < 11631 + ? (c >= 11568 && c <= 11623) + : c <= 11631))) + : (c <= 11670 || (c < 11696 + ? (c < 11688 + ? (c >= 11680 && c <= 11686) + : c <= 11694) + : (c <= 11702 || (c < 11712 + ? (c >= 11704 && c <= 11710) + : c <= 11718))))))))) + : (c <= 11726 || (c < 42623 + ? (c < 12540 + ? (c < 12337 + ? (c < 11744 + ? (c < 11736 + ? (c >= 11728 && c <= 11734) + : c <= 11742) + : (c <= 11775 || (c < 12321 + ? (c >= 12293 && c <= 12295) + : c <= 12335))) + : (c <= 12341 || (c < 12441 + ? (c < 12353 + ? (c >= 12344 && c <= 12348) + : c <= 12438) + : (c <= 12442 || (c < 12449 + ? (c >= 12445 && c <= 12447) + : c <= 12538))))) + : (c <= 12543 || (c < 19968 + ? (c < 12704 + ? (c < 12593 + ? (c >= 12549 && c <= 12591) + : c <= 12686) + : (c <= 12735 || (c < 13312 + ? (c >= 12784 && c <= 12799) + : c <= 19903))) + : (c <= 42124 || (c < 42512 + ? (c < 42240 + ? (c >= 42192 && c <= 42237) + : c <= 42508) + : (c <= 42539 || (c < 42612 + ? (c >= 42560 && c <= 42607) + : c <= 42621))))))) + : (c <= 42737 || (c < 43232 + ? (c < 42965 + ? (c < 42891 + ? (c < 42786 + ? (c >= 42775 && c <= 42783) + : c <= 42888) + : (c <= 42954 || (c < 42963 + ? (c >= 42960 && c <= 42961) + : c <= 42963))) + : (c <= 42969 || (c < 43072 + ? (c < 43052 + ? (c >= 42994 && c <= 43047) + : c <= 43052) + : (c <= 43123 || (c < 43216 + ? (c >= 43136 && c <= 43205) + : c <= 43225))))) + : (c <= 43255 || (c < 43471 + ? (c < 43312 + ? (c < 43261 + ? c == 43259 + : c <= 43309) + : (c <= 43347 || (c < 43392 + ? (c >= 43360 && c <= 43388) + : c <= 43456))) + : (c <= 43481 || (c < 43584 + ? (c < 43520 + ? (c >= 43488 && c <= 43518) + : c <= 43574) + : (c <= 43597 || (c >= 43600 && c <= 43609))))))))))))))) + : (c <= 43638 || (c < 71453 + ? (c < 67639 + ? (c < 65345 + ? (c < 64312 + ? (c < 43888 + ? (c < 43785 + ? (c < 43744 + ? (c < 43739 + ? (c >= 43642 && c <= 43714) + : c <= 43741) + : (c <= 43759 || (c < 43777 + ? (c >= 43762 && c <= 43766) + : c <= 43782))) + : (c <= 43790 || (c < 43816 + ? (c < 43808 + ? (c >= 43793 && c <= 43798) + : c <= 43814) + : (c <= 43822 || (c < 43868 + ? (c >= 43824 && c <= 43866) + : c <= 43881))))) + : (c <= 44010 || (c < 63744 + ? (c < 44032 + ? (c < 44016 + ? (c >= 44012 && c <= 44013) + : c <= 44025) + : (c <= 55203 || (c < 55243 + ? (c >= 55216 && c <= 55238) + : c <= 55291))) + : (c <= 64109 || (c < 64275 + ? (c < 64256 + ? (c >= 64112 && c <= 64217) + : c <= 64262) + : (c <= 64279 || (c < 64298 + ? (c >= 64285 && c <= 64296) + : c <= 64310))))))) + : (c <= 64316 || (c < 65075 + ? (c < 64612 + ? (c < 64323 + ? (c < 64320 + ? c == 64318 + : c <= 64321) + : (c <= 64324 || (c < 64467 + ? (c >= 64326 && c <= 64433) + : c <= 64605))) + : (c <= 64829 || (c < 65008 + ? (c < 64914 + ? (c >= 64848 && c <= 64911) + : c <= 64967) + : (c <= 65017 || (c < 65056 + ? (c >= 65024 && c <= 65039) + : c <= 65071))))) + : (c <= 65076 || (c < 65147 + ? (c < 65139 + ? (c < 65137 + ? (c >= 65101 && c <= 65103) + : c <= 65137) + : (c <= 65139 || (c < 65145 + ? c == 65143 + : c <= 65145))) + : (c <= 65147 || (c < 65296 + ? (c < 65151 + ? c == 65149 + : c <= 65276) + : (c <= 65305 || (c < 65343 + ? (c >= 65313 && c <= 65338) + : c <= 65343))))))))) + : (c <= 65370 || (c < 66513 + ? (c < 65664 + ? (c < 65536 + ? (c < 65482 + ? (c < 65474 + ? (c >= 65382 && c <= 65470) + : c <= 65479) + : (c <= 65487 || (c < 65498 + ? (c >= 65490 && c <= 65495) + : c <= 65500))) + : (c <= 65547 || (c < 65596 + ? (c < 65576 + ? (c >= 65549 && c <= 65574) + : c <= 65594) + : (c <= 65597 || (c < 65616 + ? (c >= 65599 && c <= 65613) + : c <= 65629))))) + : (c <= 65786 || (c < 66304 + ? (c < 66176 + ? (c < 66045 + ? (c >= 65856 && c <= 65908) + : c <= 66045) + : (c <= 66204 || (c < 66272 + ? (c >= 66208 && c <= 66256) + : c <= 66272))) + : (c <= 66335 || (c < 66432 + ? (c < 66384 + ? (c >= 66349 && c <= 66378) + : c <= 66426) + : (c <= 66461 || (c < 66504 + ? (c >= 66464 && c <= 66499) + : c <= 66511))))))) + : (c <= 66517 || (c < 66979 + ? (c < 66864 + ? (c < 66736 + ? (c < 66720 + ? (c >= 66560 && c <= 66717) + : c <= 66729) + : (c <= 66771 || (c < 66816 + ? (c >= 66776 && c <= 66811) + : c <= 66855))) + : (c <= 66915 || (c < 66956 + ? (c < 66940 + ? (c >= 66928 && c <= 66938) + : c <= 66954) + : (c <= 66962 || (c < 66967 + ? (c >= 66964 && c <= 66965) + : c <= 66977))))) + : (c <= 66993 || (c < 67456 + ? (c < 67072 + ? (c < 67003 + ? (c >= 66995 && c <= 67001) + : c <= 67004) + : (c <= 67382 || (c < 67424 + ? (c >= 67392 && c <= 67413) + : c <= 67431))) + : (c <= 67461 || (c < 67584 + ? (c < 67506 + ? (c >= 67463 && c <= 67504) + : c <= 67514) + : (c <= 67589 || (c < 67594 + ? c == 67592 + : c <= 67637))))))))))) + : (c <= 67640 || (c < 69956 + ? (c < 68448 + ? (c < 68101 + ? (c < 67828 + ? (c < 67680 + ? (c < 67647 + ? c == 67644 + : c <= 67669) + : (c <= 67702 || (c < 67808 + ? (c >= 67712 && c <= 67742) + : c <= 67826))) + : (c <= 67829 || (c < 67968 + ? (c < 67872 + ? (c >= 67840 && c <= 67861) + : c <= 67897) + : (c <= 68023 || (c < 68096 + ? (c >= 68030 && c <= 68031) + : c <= 68099))))) + : (c <= 68102 || (c < 68192 + ? (c < 68121 + ? (c < 68117 + ? (c >= 68108 && c <= 68115) + : c <= 68119) + : (c <= 68149 || (c < 68159 + ? (c >= 68152 && c <= 68154) + : c <= 68159))) + : (c <= 68220 || (c < 68297 + ? (c < 68288 + ? (c >= 68224 && c <= 68252) + : c <= 68295) + : (c <= 68326 || (c < 68416 + ? (c >= 68352 && c <= 68405) + : c <= 68437))))))) + : (c <= 68466 || (c < 69424 + ? (c < 68912 + ? (c < 68736 + ? (c < 68608 + ? (c >= 68480 && c <= 68497) + : c <= 68680) + : (c <= 68786 || (c < 68864 + ? (c >= 68800 && c <= 68850) + : c <= 68903))) + : (c <= 68921 || (c < 69296 + ? (c < 69291 + ? (c >= 69248 && c <= 69289) + : c <= 69292) + : (c <= 69297 || (c < 69415 + ? (c >= 69376 && c <= 69404) + : c <= 69415))))) + : (c <= 69456 || (c < 69759 + ? (c < 69600 + ? (c < 69552 + ? (c >= 69488 && c <= 69509) + : c <= 69572) + : (c <= 69622 || (c < 69734 + ? (c >= 69632 && c <= 69702) + : c <= 69749))) + : (c <= 69818 || (c < 69872 + ? (c < 69840 + ? c == 69826 + : c <= 69864) + : (c <= 69881 || (c < 69942 + ? (c >= 69888 && c <= 69940) + : c <= 69951))))))))) + : (c <= 69959 || (c < 70459 + ? (c < 70282 + ? (c < 70108 + ? (c < 70016 + ? (c < 70006 + ? (c >= 69968 && c <= 70003) + : c <= 70006) + : (c <= 70084 || (c < 70094 + ? (c >= 70089 && c <= 70092) + : c <= 70106))) + : (c <= 70108 || (c < 70206 + ? (c < 70163 + ? (c >= 70144 && c <= 70161) + : c <= 70199) + : (c <= 70206 || (c < 70280 + ? (c >= 70272 && c <= 70278) + : c <= 70280))))) + : (c <= 70285 || (c < 70405 + ? (c < 70320 + ? (c < 70303 + ? (c >= 70287 && c <= 70301) + : c <= 70312) + : (c <= 70378 || (c < 70400 + ? (c >= 70384 && c <= 70393) + : c <= 70403))) + : (c <= 70412 || (c < 70442 + ? (c < 70419 + ? (c >= 70415 && c <= 70416) + : c <= 70440) + : (c <= 70448 || (c < 70453 + ? (c >= 70450 && c <= 70451) + : c <= 70457))))))) + : (c <= 70468 || (c < 70855 + ? (c < 70502 + ? (c < 70480 + ? (c < 70475 + ? (c >= 70471 && c <= 70472) + : c <= 70477) + : (c <= 70480 || (c < 70493 + ? c == 70487 + : c <= 70499))) + : (c <= 70508 || (c < 70736 + ? (c < 70656 + ? (c >= 70512 && c <= 70516) + : c <= 70730) + : (c <= 70745 || (c < 70784 + ? (c >= 70750 && c <= 70753) + : c <= 70853))))) + : (c <= 70855 || (c < 71236 + ? (c < 71096 + ? (c < 71040 + ? (c >= 70864 && c <= 70873) + : c <= 71093) + : (c <= 71104 || (c < 71168 + ? (c >= 71128 && c <= 71133) + : c <= 71232))) + : (c <= 71236 || (c < 71360 + ? (c < 71296 + ? (c >= 71248 && c <= 71257) + : c <= 71352) + : (c <= 71369 || (c >= 71424 && c <= 71450))))))))))))) + : (c <= 71467 || (c < 119973 + ? (c < 77824 + ? (c < 72760 + ? (c < 72016 + ? (c < 71945 + ? (c < 71680 + ? (c < 71488 + ? (c >= 71472 && c <= 71481) + : c <= 71494) + : (c <= 71738 || (c < 71935 + ? (c >= 71840 && c <= 71913) + : c <= 71942))) + : (c <= 71945 || (c < 71960 + ? (c < 71957 + ? (c >= 71948 && c <= 71955) + : c <= 71958) + : (c <= 71989 || (c < 71995 + ? (c >= 71991 && c <= 71992) + : c <= 72003))))) + : (c <= 72025 || (c < 72263 + ? (c < 72154 + ? (c < 72106 + ? (c >= 72096 && c <= 72103) + : c <= 72151) + : (c <= 72161 || (c < 72192 + ? (c >= 72163 && c <= 72164) + : c <= 72254))) + : (c <= 72263 || (c < 72368 + ? (c < 72349 + ? (c >= 72272 && c <= 72345) + : c <= 72349) + : (c <= 72440 || (c < 72714 + ? (c >= 72704 && c <= 72712) + : c <= 72758))))))) + : (c <= 72768 || (c < 73056 + ? (c < 72968 + ? (c < 72850 + ? (c < 72818 + ? (c >= 72784 && c <= 72793) + : c <= 72847) + : (c <= 72871 || (c < 72960 + ? (c >= 72873 && c <= 72886) + : c <= 72966))) + : (c <= 72969 || (c < 73020 + ? (c < 73018 + ? (c >= 72971 && c <= 73014) + : c <= 73018) + : (c <= 73021 || (c < 73040 + ? (c >= 73023 && c <= 73031) + : c <= 73049))))) + : (c <= 73061 || (c < 73440 + ? (c < 73104 + ? (c < 73066 + ? (c >= 73063 && c <= 73064) + : c <= 73102) + : (c <= 73105 || (c < 73120 + ? (c >= 73107 && c <= 73112) + : c <= 73129))) + : (c <= 73462 || (c < 74752 + ? (c < 73728 + ? c == 73648 + : c <= 74649) + : (c <= 74862 || (c < 77712 + ? (c >= 74880 && c <= 75075) + : c <= 77808))))))))) + : (c <= 78894 || (c < 110576 + ? (c < 93027 + ? (c < 92864 + ? (c < 92736 + ? (c < 92160 + ? (c >= 82944 && c <= 83526) + : c <= 92728) + : (c <= 92766 || (c < 92784 + ? (c >= 92768 && c <= 92777) + : c <= 92862))) + : (c <= 92873 || (c < 92928 + ? (c < 92912 + ? (c >= 92880 && c <= 92909) + : c <= 92916) + : (c <= 92982 || (c < 93008 + ? (c >= 92992 && c <= 92995) + : c <= 93017))))) + : (c <= 93047 || (c < 94176 + ? (c < 93952 + ? (c < 93760 + ? (c >= 93053 && c <= 93071) + : c <= 93823) + : (c <= 94026 || (c < 94095 + ? (c >= 94031 && c <= 94087) + : c <= 94111))) + : (c <= 94177 || (c < 94208 + ? (c < 94192 + ? (c >= 94179 && c <= 94180) + : c <= 94193) + : (c <= 100343 || (c < 101632 + ? (c >= 100352 && c <= 101589) + : c <= 101640))))))) + : (c <= 110579 || (c < 118528 + ? (c < 110960 + ? (c < 110592 + ? (c < 110589 + ? (c >= 110581 && c <= 110587) + : c <= 110590) + : (c <= 110882 || (c < 110948 + ? (c >= 110928 && c <= 110930) + : c <= 110951))) + : (c <= 111355 || (c < 113792 + ? (c < 113776 + ? (c >= 113664 && c <= 113770) + : c <= 113788) + : (c <= 113800 || (c < 113821 + ? (c >= 113808 && c <= 113817) + : c <= 113822))))) + : (c <= 118573 || (c < 119210 + ? (c < 119149 + ? (c < 119141 + ? (c >= 118576 && c <= 118598) + : c <= 119145) + : (c <= 119154 || (c < 119173 + ? (c >= 119163 && c <= 119170) + : c <= 119179))) + : (c <= 119213 || (c < 119894 + ? (c < 119808 + ? (c >= 119362 && c <= 119364) + : c <= 119892) + : (c <= 119964 || (c < 119970 + ? (c >= 119966 && c <= 119967) + : c <= 119970))))))))))) + : (c <= 119974 || (c < 124912 + ? (c < 120746 + ? (c < 120134 + ? (c < 120071 + ? (c < 119995 + ? (c < 119982 + ? (c >= 119977 && c <= 119980) + : c <= 119993) + : (c <= 119995 || (c < 120005 + ? (c >= 119997 && c <= 120003) + : c <= 120069))) + : (c <= 120074 || (c < 120094 + ? (c < 120086 + ? (c >= 120077 && c <= 120084) + : c <= 120092) + : (c <= 120121 || (c < 120128 + ? (c >= 120123 && c <= 120126) + : c <= 120132))))) + : (c <= 120134 || (c < 120572 + ? (c < 120488 + ? (c < 120146 + ? (c >= 120138 && c <= 120144) + : c <= 120485) + : (c <= 120512 || (c < 120540 + ? (c >= 120514 && c <= 120538) + : c <= 120570))) + : (c <= 120596 || (c < 120656 + ? (c < 120630 + ? (c >= 120598 && c <= 120628) + : c <= 120654) + : (c <= 120686 || (c < 120714 + ? (c >= 120688 && c <= 120712) + : c <= 120744))))))) + : (c <= 120770 || (c < 122907 + ? (c < 121476 + ? (c < 121344 + ? (c < 120782 + ? (c >= 120772 && c <= 120779) + : c <= 120831) + : (c <= 121398 || (c < 121461 + ? (c >= 121403 && c <= 121452) + : c <= 121461))) + : (c <= 121476 || (c < 122624 + ? (c < 121505 + ? (c >= 121499 && c <= 121503) + : c <= 121519) + : (c <= 122654 || (c < 122888 + ? (c >= 122880 && c <= 122886) + : c <= 122904))))) + : (c <= 122913 || (c < 123214 + ? (c < 123136 + ? (c < 122918 + ? (c >= 122915 && c <= 122916) + : c <= 122922) + : (c <= 123180 || (c < 123200 + ? (c >= 123184 && c <= 123197) + : c <= 123209))) + : (c <= 123214 || (c < 124896 + ? (c < 123584 + ? (c >= 123536 && c <= 123566) + : c <= 123641) + : (c <= 124902 || (c < 124909 + ? (c >= 124904 && c <= 124907) + : c <= 124910))))))))) + : (c <= 124926 || (c < 126557 + ? (c < 126521 + ? (c < 126469 + ? (c < 125184 + ? (c < 125136 + ? (c >= 124928 && c <= 125124) + : c <= 125142) + : (c <= 125259 || (c < 126464 + ? (c >= 125264 && c <= 125273) + : c <= 126467))) + : (c <= 126495 || (c < 126503 + ? (c < 126500 + ? (c >= 126497 && c <= 126498) + : c <= 126500) + : (c <= 126503 || (c < 126516 + ? (c >= 126505 && c <= 126514) + : c <= 126519))))) + : (c <= 126521 || (c < 126541 + ? (c < 126535 + ? (c < 126530 + ? c == 126523 + : c <= 126530) + : (c <= 126535 || (c < 126539 + ? c == 126537 + : c <= 126539))) + : (c <= 126543 || (c < 126551 + ? (c < 126548 + ? (c >= 126545 && c <= 126546) + : c <= 126548) + : (c <= 126551 || (c < 126555 + ? c == 126553 + : c <= 126555))))))) + : (c <= 126557 || (c < 126629 + ? (c < 126580 + ? (c < 126564 + ? (c < 126561 + ? c == 126559 + : c <= 126562) + : (c <= 126564 || (c < 126572 + ? (c >= 126567 && c <= 126570) + : c <= 126578))) + : (c <= 126583 || (c < 126592 + ? (c < 126590 + ? (c >= 126585 && c <= 126588) + : c <= 126590) + : (c <= 126601 || (c < 126625 + ? (c >= 126603 && c <= 126619) + : c <= 126627))))) + : (c <= 126633 || (c < 178208 + ? (c < 131072 + ? (c < 130032 + ? (c >= 126635 && c <= 126651) + : c <= 130041) + : (c <= 173791 || (c < 177984 + ? (c >= 173824 && c <= 177976) + : c <= 178205))) + : (c <= 183969 || (c < 196608 + ? (c < 194560 + ? (c >= 183984 && c <= 191456) + : c <= 195101) + : (c <= 201546 || (c >= 917760 && c <= 917999))))))))))))))))); +} + +static bool ts_lex(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + if (eof) ADVANCE(12); + if (lookahead == '"') ADVANCE(17); + if (lookahead == ';') ADVANCE(13); + if (lookahead == '=') ADVANCE(14); + if (lookahead == '\\') ADVANCE(2); + if (lookahead == 'b') ADVANCE(19); + if (lookahead == 'r') ADVANCE(20); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(10) + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(15); + if (sym_identifier_character_set_1(lookahead)) ADVANCE(21); + END_STATE(); + case 1: + if (lookahead == '"') ADVANCE(17); + if (lookahead == '\\') ADVANCE(2); + END_STATE(); + case 2: + if (lookahead == 'u') ADVANCE(3); + if (lookahead == 'x') ADVANCE(8); + if (lookahead != 0) ADVANCE(18); + END_STATE(); + case 3: + if (lookahead == '{') ADVANCE(7); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(5); + END_STATE(); + case 4: + if (lookahead == '}') ADVANCE(18); + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(4); + END_STATE(); + case 5: + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(8); + END_STATE(); + case 6: + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(18); + END_STATE(); + case 7: + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(4); + END_STATE(); + case 8: + if (('0' <= lookahead && lookahead <= '9') || + ('A' <= lookahead && lookahead <= 'F') || + ('a' <= lookahead && lookahead <= 'f')) ADVANCE(6); + END_STATE(); + case 9: + if (sym_identifier_character_set_1(lookahead)) ADVANCE(21); + END_STATE(); + case 10: + if (eof) ADVANCE(12); + if (lookahead == '"') ADVANCE(16); + if (lookahead == ';') ADVANCE(13); + if (lookahead == '=') ADVANCE(14); + if (lookahead == 'b') ADVANCE(19); + if (lookahead == 'r') ADVANCE(20); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(10) + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(15); + if (sym_identifier_character_set_1(lookahead)) ADVANCE(21); + END_STATE(); + case 11: + if (eof) ADVANCE(12); + if (lookahead == '"') ADVANCE(16); + if (lookahead == 'b') ADVANCE(19); + if (lookahead == 'r') ADVANCE(20); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(11) + if (('0' <= lookahead && lookahead <= '9')) ADVANCE(15); + if (sym_identifier_character_set_1(lookahead)) ADVANCE(21); + END_STATE(); + case 12: + ACCEPT_TOKEN(ts_builtin_sym_end); + END_STATE(); + case 13: + ACCEPT_TOKEN(anon_sym_SEMI); + END_STATE(); + case 14: + ACCEPT_TOKEN(anon_sym_EQ); + END_STATE(); + case 15: + ACCEPT_TOKEN(sym_integer_literal); + if (('0' <= lookahead && lookahead <= '9') || + lookahead == '_') ADVANCE(15); + END_STATE(); + case 16: + ACCEPT_TOKEN(aux_sym_string_literal_token1); + END_STATE(); + case 17: + ACCEPT_TOKEN(anon_sym_DQUOTE); + END_STATE(); + case 18: + ACCEPT_TOKEN(sym_escape_sequence); + END_STATE(); + case 19: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == '"') ADVANCE(16); + if (sym_identifier_character_set_2(lookahead)) ADVANCE(21); + END_STATE(); + case 20: + ACCEPT_TOKEN(sym_identifier); + if (lookahead == '#') ADVANCE(9); + if (sym_identifier_character_set_2(lookahead)) ADVANCE(21); + END_STATE(); + case 21: + ACCEPT_TOKEN(sym_identifier); + if (sym_identifier_character_set_2(lookahead)) ADVANCE(21); + END_STATE(); + default: + return false; + } +} + +static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { + START_LEXER(); + eof = lexer->eof(lexer); + switch (state) { + case 0: + if (lookahead == '_') ADVANCE(1); + if (lookahead == 'l') ADVANCE(2); + if (lookahead == '\t' || + lookahead == '\n' || + lookahead == '\r' || + lookahead == ' ') SKIP(0) + END_STATE(); + case 1: + ACCEPT_TOKEN(anon_sym__); + END_STATE(); + case 2: + if (lookahead == 'e') ADVANCE(3); + END_STATE(); + case 3: + if (lookahead == 't') ADVANCE(4); + END_STATE(); + case 4: + ACCEPT_TOKEN(anon_sym_let); + END_STATE(); + default: + return false; + } +} + +static const TSLexMode ts_lex_modes[STATE_COUNT] = { + [0] = {.lex_state = 0, .external_lex_state = 1}, + [1] = {.lex_state = 11, .external_lex_state = 2}, + [2] = {.lex_state = 11, .external_lex_state = 2}, + [3] = {.lex_state = 11, .external_lex_state = 2}, + [4] = {.lex_state = 11, .external_lex_state = 2}, + [5] = {.lex_state = 11, .external_lex_state = 2}, + [6] = {.lex_state = 11, .external_lex_state = 2}, + [7] = {.lex_state = 11, .external_lex_state = 2}, + [8] = {.lex_state = 11, .external_lex_state = 2}, + [9] = {.lex_state = 11, .external_lex_state = 2}, + [10] = {.lex_state = 1, .external_lex_state = 3}, + [11] = {.lex_state = 1, .external_lex_state = 3}, + [12] = {.lex_state = 1, .external_lex_state = 3}, + [13] = {.lex_state = 0}, + [14] = {.lex_state = 0}, + [15] = {.lex_state = 0}, + [16] = {.lex_state = 0}, + [17] = {.lex_state = 0}, + [18] = {.lex_state = 0}, + [19] = {.lex_state = 0}, + [20] = {.lex_state = 0}, + [21] = {.lex_state = 0}, + [22] = {.lex_state = 0}, + [23] = {.lex_state = 0}, + [24] = {.lex_state = 0}, +}; + +enum { + ts_external_token__string_content = 0, + ts_external_token_raw_string_literal = 1, + ts_external_token_float_literal = 2, + ts_external_token_block_comment = 3, +}; + +static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { + [ts_external_token__string_content] = sym__string_content, + [ts_external_token_raw_string_literal] = sym_raw_string_literal, + [ts_external_token_float_literal] = sym_float_literal, + [ts_external_token_block_comment] = sym_block_comment, +}; + +static const bool ts_external_scanner_states[4][EXTERNAL_TOKEN_COUNT] = { + [1] = { + [ts_external_token__string_content] = true, + [ts_external_token_raw_string_literal] = true, + [ts_external_token_float_literal] = true, + [ts_external_token_block_comment] = true, + }, + [2] = { + [ts_external_token_raw_string_literal] = true, + }, + [3] = { + [ts_external_token__string_content] = true, + }, +}; + +static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { + [0] = { + [ts_builtin_sym_end] = ACTIONS(1), + [sym_identifier] = ACTIONS(1), + [anon_sym_SEMI] = ACTIONS(1), + [anon_sym_let] = ACTIONS(1), + [anon_sym_EQ] = ACTIONS(1), + [anon_sym__] = ACTIONS(1), + [sym_integer_literal] = ACTIONS(1), + [aux_sym_string_literal_token1] = ACTIONS(1), + [anon_sym_DQUOTE] = ACTIONS(1), + [sym_escape_sequence] = ACTIONS(1), + [sym__string_content] = ACTIONS(1), + [sym_raw_string_literal] = ACTIONS(1), + [sym_float_literal] = ACTIONS(1), + [sym_block_comment] = ACTIONS(1), + }, + [1] = { + [sym_source_file] = STATE(24), + [sym__statement] = STATE(3), + [sym_expression_statement] = STATE(3), + [sym_let_declaration] = STATE(3), + [sym__expression] = STATE(19), + [sym_assignment_expression] = STATE(18), + [sym__literal] = STATE(18), + [sym_string_literal] = STATE(15), + [aux_sym_source_file_repeat1] = STATE(3), + [ts_builtin_sym_end] = ACTIONS(3), + [sym_identifier] = ACTIONS(5), + [anon_sym_let] = ACTIONS(7), + [sym_integer_literal] = ACTIONS(9), + [aux_sym_string_literal_token1] = ACTIONS(11), + [sym_raw_string_literal] = ACTIONS(9), + }, + [2] = { + [sym__statement] = STATE(2), + [sym_expression_statement] = STATE(2), + [sym_let_declaration] = STATE(2), + [sym__expression] = STATE(19), + [sym_assignment_expression] = STATE(18), + [sym__literal] = STATE(18), + [sym_string_literal] = STATE(15), + [aux_sym_source_file_repeat1] = STATE(2), + [ts_builtin_sym_end] = ACTIONS(13), + [sym_identifier] = ACTIONS(15), + [anon_sym_let] = ACTIONS(18), + [sym_integer_literal] = ACTIONS(21), + [aux_sym_string_literal_token1] = ACTIONS(24), + [sym_raw_string_literal] = ACTIONS(21), + }, + [3] = { + [sym__statement] = STATE(2), + [sym_expression_statement] = STATE(2), + [sym_let_declaration] = STATE(2), + [sym__expression] = STATE(19), + [sym_assignment_expression] = STATE(18), + [sym__literal] = STATE(18), + [sym_string_literal] = STATE(15), + [aux_sym_source_file_repeat1] = STATE(2), + [ts_builtin_sym_end] = ACTIONS(27), + [sym_identifier] = ACTIONS(5), + [anon_sym_let] = ACTIONS(7), + [sym_integer_literal] = ACTIONS(9), + [aux_sym_string_literal_token1] = ACTIONS(11), + [sym_raw_string_literal] = ACTIONS(9), + }, +}; + +static const uint16_t ts_small_parse_table[] = { + [0] = 6, + ACTIONS(11), 1, + aux_sym_string_literal_token1, + STATE(13), 1, + sym__pattern, + STATE(16), 1, + sym__literal_pattern, + STATE(17), 1, + sym_string_literal, + ACTIONS(29), 2, + anon_sym__, + sym_identifier, + ACTIONS(31), 2, + sym_raw_string_literal, + sym_integer_literal, + [21] = 6, + ACTIONS(5), 1, + sym_identifier, + ACTIONS(11), 1, + aux_sym_string_literal_token1, + STATE(15), 1, + sym_string_literal, + STATE(22), 1, + sym__expression, + ACTIONS(9), 2, + sym_raw_string_literal, + sym_integer_literal, + STATE(18), 2, + sym_assignment_expression, + sym__literal, + [42] = 6, + ACTIONS(5), 1, + sym_identifier, + ACTIONS(11), 1, + aux_sym_string_literal_token1, + STATE(15), 1, + sym_string_literal, + STATE(21), 1, + sym__expression, + ACTIONS(9), 2, + sym_raw_string_literal, + sym_integer_literal, + STATE(18), 2, + sym_assignment_expression, + sym__literal, + [63] = 2, + ACTIONS(35), 2, + anon_sym_let, + sym_identifier, + ACTIONS(33), 4, + sym_raw_string_literal, + ts_builtin_sym_end, + sym_integer_literal, + aux_sym_string_literal_token1, + [74] = 2, + ACTIONS(39), 2, + anon_sym_let, + sym_identifier, + ACTIONS(37), 4, + sym_raw_string_literal, + ts_builtin_sym_end, + sym_integer_literal, + aux_sym_string_literal_token1, + [85] = 2, + ACTIONS(43), 2, + anon_sym_let, + sym_identifier, + ACTIONS(41), 4, + sym_raw_string_literal, + ts_builtin_sym_end, + sym_integer_literal, + aux_sym_string_literal_token1, + [96] = 3, + ACTIONS(45), 1, + anon_sym_DQUOTE, + STATE(12), 1, + aux_sym_string_literal_repeat1, + ACTIONS(47), 2, + sym__string_content, + sym_escape_sequence, + [107] = 3, + ACTIONS(49), 1, + anon_sym_DQUOTE, + STATE(10), 1, + aux_sym_string_literal_repeat1, + ACTIONS(51), 2, + sym__string_content, + sym_escape_sequence, + [118] = 3, + ACTIONS(53), 1, + anon_sym_DQUOTE, + STATE(12), 1, + aux_sym_string_literal_repeat1, + ACTIONS(55), 2, + sym__string_content, + sym_escape_sequence, + [129] = 2, + ACTIONS(58), 1, + anon_sym_SEMI, + ACTIONS(60), 1, + anon_sym_EQ, + [136] = 1, + ACTIONS(62), 2, + anon_sym_SEMI, + anon_sym_EQ, + [141] = 1, + ACTIONS(64), 2, + anon_sym_SEMI, + anon_sym_EQ, + [146] = 1, + ACTIONS(66), 2, + anon_sym_SEMI, + anon_sym_EQ, + [151] = 1, + ACTIONS(68), 2, + anon_sym_SEMI, + anon_sym_EQ, + [156] = 1, + ACTIONS(70), 2, + anon_sym_SEMI, + anon_sym_EQ, + [161] = 2, + ACTIONS(72), 1, + anon_sym_SEMI, + ACTIONS(74), 1, + anon_sym_EQ, + [168] = 1, + ACTIONS(76), 2, + anon_sym_SEMI, + anon_sym_EQ, + [173] = 1, + ACTIONS(78), 2, + anon_sym_SEMI, + anon_sym_EQ, + [178] = 2, + ACTIONS(74), 1, + anon_sym_EQ, + ACTIONS(80), 1, + anon_sym_SEMI, + [185] = 1, + ACTIONS(70), 2, + anon_sym_SEMI, + anon_sym_EQ, + [190] = 1, + ACTIONS(82), 1, + ts_builtin_sym_end, +}; + +static const uint32_t ts_small_parse_table_map[] = { + [SMALL_STATE(4)] = 0, + [SMALL_STATE(5)] = 21, + [SMALL_STATE(6)] = 42, + [SMALL_STATE(7)] = 63, + [SMALL_STATE(8)] = 74, + [SMALL_STATE(9)] = 85, + [SMALL_STATE(10)] = 96, + [SMALL_STATE(11)] = 107, + [SMALL_STATE(12)] = 118, + [SMALL_STATE(13)] = 129, + [SMALL_STATE(14)] = 136, + [SMALL_STATE(15)] = 141, + [SMALL_STATE(16)] = 146, + [SMALL_STATE(17)] = 151, + [SMALL_STATE(18)] = 156, + [SMALL_STATE(19)] = 161, + [SMALL_STATE(20)] = 168, + [SMALL_STATE(21)] = 173, + [SMALL_STATE(22)] = 178, + [SMALL_STATE(23)] = 185, + [SMALL_STATE(24)] = 190, +}; + +static const TSParseActionEntry ts_parse_actions[] = { + [0] = {.entry = {.count = 0, .reusable = false}}, + [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), + [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0), + [5] = {.entry = {.count = 1, .reusable = false}}, SHIFT(23), + [7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4), + [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), + [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), + [13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), + [15] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(23), + [18] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(4), + [21] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(15), + [24] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(11), + [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1), + [29] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), + [31] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), + [33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_declaration, 5, .production_id = 3), + [35] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_declaration, 5, .production_id = 3), + [37] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_let_declaration, 3, .production_id = 1), + [39] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_let_declaration, 3, .production_id = 1), + [41] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression_statement, 2), + [43] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression_statement, 2), + [45] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), + [47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), + [49] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), + [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), + [53] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_string_literal_repeat1, 2), + [55] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_string_literal_repeat1, 2), SHIFT_REPEAT(12), + [58] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), + [60] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), + [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string_literal, 2), + [64] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__literal, 1), + [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__pattern, 1), + [68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__literal_pattern, 1), + [70] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__expression, 1), + [72] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), + [74] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), + [76] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string_literal, 3), + [78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_assignment_expression, 3, .production_id = 2), + [80] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), + [82] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), +}; + +#ifdef __cplusplus +extern "C" { +#endif +void *tree_sitter_rhai_external_scanner_create(void); +void tree_sitter_rhai_external_scanner_destroy(void *); +bool tree_sitter_rhai_external_scanner_scan(void *, TSLexer *, const bool *); +unsigned tree_sitter_rhai_external_scanner_serialize(void *, char *); +void tree_sitter_rhai_external_scanner_deserialize(void *, const char *, unsigned); + +#ifdef _WIN32 +#define extern __declspec(dllexport) +#endif + +extern const TSLanguage *tree_sitter_rhai(void) { + static const TSLanguage language = { + .version = LANGUAGE_VERSION, + .symbol_count = SYMBOL_COUNT, + .alias_count = ALIAS_COUNT, + .token_count = TOKEN_COUNT, + .external_token_count = EXTERNAL_TOKEN_COUNT, + .state_count = STATE_COUNT, + .large_state_count = LARGE_STATE_COUNT, + .production_id_count = PRODUCTION_ID_COUNT, + .field_count = FIELD_COUNT, + .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, + .parse_table = &ts_parse_table[0][0], + .small_parse_table = ts_small_parse_table, + .small_parse_table_map = ts_small_parse_table_map, + .parse_actions = ts_parse_actions, + .symbol_names = ts_symbol_names, + .field_names = ts_field_names, + .field_map_slices = ts_field_map_slices, + .field_map_entries = ts_field_map_entries, + .symbol_metadata = ts_symbol_metadata, + .public_symbol_map = ts_symbol_map, + .alias_map = ts_non_terminal_alias_map, + .alias_sequences = &ts_alias_sequences[0][0], + .lex_modes = ts_lex_modes, + .lex_fn = ts_lex, + .keyword_lex_fn = ts_lex_keywords, + .keyword_capture_token = sym_identifier, + .external_scanner = { + &ts_external_scanner_states[0][0], + ts_external_scanner_symbol_map, + tree_sitter_rhai_external_scanner_create, + tree_sitter_rhai_external_scanner_destroy, + tree_sitter_rhai_external_scanner_scan, + tree_sitter_rhai_external_scanner_serialize, + tree_sitter_rhai_external_scanner_deserialize, + }, + .primary_state_ids = ts_primary_state_ids, + }; + return &language; +} +#ifdef __cplusplus +} +#endif diff --git a/src/scanner.c b/src/scanner.c new file mode 100644 index 0000000..751a5bd --- /dev/null +++ b/src/scanner.c @@ -0,0 +1,191 @@ +#include +#include + +enum TokenType { + STRING_CONTENT, + RAW_STRING_LITERAL, + FLOAT_LITERAL, + BLOCK_COMMENT, +}; + +void *tree_sitter_rhai_external_scanner_create() { return NULL; } +void tree_sitter_rhai_external_scanner_destroy(void *p) {} +void tree_sitter_rhai_external_scanner_reset(void *p) {} +unsigned tree_sitter_rhai_external_scanner_serialize(void *p, char *buffer) { + return 0; +} +void tree_sitter_rhai_external_scanner_deserialize(void *p, const char *b, + unsigned n) {} + +static void advance(TSLexer *lexer) { lexer->advance(lexer, false); } + +static bool is_num_char(int32_t c) { return c == '_' || iswdigit(c); } + +bool tree_sitter_rhai_external_scanner_scan(void *payload, TSLexer *lexer, + const bool *valid_symbols) { + if (valid_symbols[STRING_CONTENT] && !valid_symbols[FLOAT_LITERAL]) { + bool has_content = false; + for (;;) { + if (lexer->lookahead == '\"' || lexer->lookahead == '\\') { + break; + } else if (lexer->lookahead == 0) { + return false; + } + has_content = true; + advance(lexer); + } + lexer->result_symbol = STRING_CONTENT; + return has_content; + } + + while (iswspace(lexer->lookahead)) + lexer->advance(lexer, true); + + if (valid_symbols[RAW_STRING_LITERAL] && + (lexer->lookahead == 'r' || lexer->lookahead == 'b')) { + lexer->result_symbol = RAW_STRING_LITERAL; + if (lexer->lookahead == 'b') + advance(lexer); + if (lexer->lookahead != 'r') + return false; + advance(lexer); + + unsigned opening_hash_count = 0; + while (lexer->lookahead == '#') { + advance(lexer); + opening_hash_count++; + } + + if (lexer->lookahead != '"') + return false; + advance(lexer); + + for (;;) { + if (lexer->lookahead == 0) { + return false; + } else if (lexer->lookahead == '"') { + advance(lexer); + unsigned hash_count = 0; + while (lexer->lookahead == '#' && hash_count < opening_hash_count) { + advance(lexer); + hash_count++; + } + if (hash_count == opening_hash_count) { + return true; + } + } else { + advance(lexer); + } + } + } + + if (valid_symbols[FLOAT_LITERAL] && iswdigit(lexer->lookahead)) { + lexer->result_symbol = FLOAT_LITERAL; + + advance(lexer); + while (is_num_char(lexer->lookahead)) { + advance(lexer); + } + + bool has_fraction = false, has_exponent = false; + + if (lexer->lookahead == '.') { + has_fraction = true; + advance(lexer); + if (iswalpha(lexer->lookahead)) { + // The dot is followed by a letter: 1.max(2) => not a float but an + // integer + return false; + } + + if (lexer->lookahead == '.') { + return false; + } + while (is_num_char(lexer->lookahead)) { + advance(lexer); + } + } + + lexer->mark_end(lexer); + + if (lexer->lookahead == 'e' || lexer->lookahead == 'E') { + has_exponent = true; + advance(lexer); + if (lexer->lookahead == '+' || lexer->lookahead == '-') { + advance(lexer); + } + if (!is_num_char(lexer->lookahead)) { + return true; + } + advance(lexer); + while (is_num_char(lexer->lookahead)) { + advance(lexer); + } + + lexer->mark_end(lexer); + } + + if (!has_exponent && !has_fraction) + return false; + + if (lexer->lookahead != 'u' && lexer->lookahead != 'i' && + lexer->lookahead != 'f') { + return true; + } + advance(lexer); + if (!iswdigit(lexer->lookahead)) { + return true; + } + + while (iswdigit(lexer->lookahead)) { + advance(lexer); + } + + lexer->mark_end(lexer); + return true; + } + + if (lexer->lookahead == '/') { + advance(lexer); + if (lexer->lookahead != '*') + return false; + advance(lexer); + + bool after_star = false; + unsigned nesting_depth = 1; + for (;;) { + switch (lexer->lookahead) { + case '\0': + return false; + case '*': + advance(lexer); + after_star = true; + break; + case '/': + if (after_star) { + advance(lexer); + after_star = false; + nesting_depth--; + if (nesting_depth == 0) { + lexer->result_symbol = BLOCK_COMMENT; + return true; + } + } else { + advance(lexer); + after_star = false; + if (lexer->lookahead == '*') { + nesting_depth++; + advance(lexer); + } + } + break; + default: + advance(lexer); + after_star = false; + break; + } + } + } + + return false; +} diff --git a/src/tree_sitter/parser.h b/src/tree_sitter/parser.h new file mode 100644 index 0000000..2b14ac1 --- /dev/null +++ b/src/tree_sitter/parser.h @@ -0,0 +1,224 @@ +#ifndef TREE_SITTER_PARSER_H_ +#define TREE_SITTER_PARSER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define ts_builtin_sym_error ((TSSymbol)-1) +#define ts_builtin_sym_end 0 +#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 + +typedef uint16_t TSStateId; + +#ifndef TREE_SITTER_API_H_ +typedef uint16_t TSSymbol; +typedef uint16_t TSFieldId; +typedef struct TSLanguage TSLanguage; +#endif + +typedef struct { + TSFieldId field_id; + uint8_t child_index; + bool inherited; +} TSFieldMapEntry; + +typedef struct { + uint16_t index; + uint16_t length; +} TSFieldMapSlice; + +typedef struct { + bool visible; + bool named; + bool supertype; +} TSSymbolMetadata; + +typedef struct TSLexer TSLexer; + +struct TSLexer { + int32_t lookahead; + TSSymbol result_symbol; + void (*advance)(TSLexer *, bool); + void (*mark_end)(TSLexer *); + uint32_t (*get_column)(TSLexer *); + bool (*is_at_included_range_start)(const TSLexer *); + bool (*eof)(const TSLexer *); +}; + +typedef enum { + TSParseActionTypeShift, + TSParseActionTypeReduce, + TSParseActionTypeAccept, + TSParseActionTypeRecover, +} TSParseActionType; + +typedef union { + struct { + uint8_t type; + TSStateId state; + bool extra; + bool repetition; + } shift; + struct { + uint8_t type; + uint8_t child_count; + TSSymbol symbol; + int16_t dynamic_precedence; + uint16_t production_id; + } reduce; + uint8_t type; +} TSParseAction; + +typedef struct { + uint16_t lex_state; + uint16_t external_lex_state; +} TSLexMode; + +typedef union { + TSParseAction action; + struct { + uint8_t count; + bool reusable; + } entry; +} TSParseActionEntry; + +struct TSLanguage { + uint32_t version; + uint32_t symbol_count; + uint32_t alias_count; + uint32_t token_count; + uint32_t external_token_count; + uint32_t state_count; + uint32_t large_state_count; + uint32_t production_id_count; + uint32_t field_count; + uint16_t max_alias_sequence_length; + const uint16_t *parse_table; + const uint16_t *small_parse_table; + const uint32_t *small_parse_table_map; + const TSParseActionEntry *parse_actions; + const char * const *symbol_names; + const char * const *field_names; + const TSFieldMapSlice *field_map_slices; + const TSFieldMapEntry *field_map_entries; + const TSSymbolMetadata *symbol_metadata; + const TSSymbol *public_symbol_map; + const uint16_t *alias_map; + const TSSymbol *alias_sequences; + const TSLexMode *lex_modes; + bool (*lex_fn)(TSLexer *, TSStateId); + bool (*keyword_lex_fn)(TSLexer *, TSStateId); + TSSymbol keyword_capture_token; + struct { + const bool *states; + const TSSymbol *symbol_map; + void *(*create)(void); + void (*destroy)(void *); + bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); + unsigned (*serialize)(void *, char *); + void (*deserialize)(void *, const char *, unsigned); + } external_scanner; + const TSStateId *primary_state_ids; +}; + +/* + * Lexer Macros + */ + +#define START_LEXER() \ + bool result = false; \ + bool skip = false; \ + bool eof = false; \ + int32_t lookahead; \ + goto start; \ + next_state: \ + lexer->advance(lexer, skip); \ + start: \ + skip = false; \ + lookahead = lexer->lookahead; + +#define ADVANCE(state_value) \ + { \ + state = state_value; \ + goto next_state; \ + } + +#define SKIP(state_value) \ + { \ + skip = true; \ + state = state_value; \ + goto next_state; \ + } + +#define ACCEPT_TOKEN(symbol_value) \ + result = true; \ + lexer->result_symbol = symbol_value; \ + lexer->mark_end(lexer); + +#define END_STATE() return result; + +/* + * Parse Table Macros + */ + +#define SMALL_STATE(id) id - LARGE_STATE_COUNT + +#define STATE(id) id + +#define ACTIONS(id) id + +#define SHIFT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = state_value \ + } \ + }} + +#define SHIFT_REPEAT(state_value) \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .state = state_value, \ + .repetition = true \ + } \ + }} + +#define SHIFT_EXTRA() \ + {{ \ + .shift = { \ + .type = TSParseActionTypeShift, \ + .extra = true \ + } \ + }} + +#define REDUCE(symbol_val, child_count_val, ...) \ + {{ \ + .reduce = { \ + .type = TSParseActionTypeReduce, \ + .symbol = symbol_val, \ + .child_count = child_count_val, \ + __VA_ARGS__ \ + }, \ + }} + +#define RECOVER() \ + {{ \ + .type = TSParseActionTypeRecover \ + }} + +#define ACCEPT_INPUT() \ + {{ \ + .type = TSParseActionTypeAccept \ + }} + +#ifdef __cplusplus +} +#endif + +#endif // TREE_SITTER_PARSER_H_