├── bindings ├── python │ ├── tree_sitter_godot_resource │ │ ├── py.typed │ │ ├── __init__.pyi │ │ ├── binding.c │ │ └── __init__.py │ └── tests │ │ └── test_binding.py ├── node │ ├── binding_test.js │ ├── index.js │ ├── index.d.ts │ └── binding.cc ├── c │ ├── tree-sitter-godot-resource.h │ └── tree-sitter-godot-resource.pc.in ├── swift │ ├── TreeSitterGodotResource │ │ └── godot_resource.h │ └── TreeSitterGodotResourceTests │ │ └── TreeSitterGodotResourceTests.swift ├── go │ ├── binding.go │ └── binding_test.go ├── nim │ └── treesittergodotresource.nim └── rust │ ├── build.rs │ └── lib.rs ├── examples ├── resource.tres ├── project.godot └── main.tscn ├── .npmignore ├── go.mod ├── README.md ├── test └── corpus │ ├── issues │ ├── issue-3.txt │ ├── issue-9.txt │ ├── issue-4.txt │ ├── issue-12.txt │ └── issue-5.txt │ ├── resource.txt │ └── section.txt ├── .github └── workflows │ ├── test.yml │ └── build_publish.yml ├── .gitignore ├── .editorconfig ├── binding.gyp ├── Cargo.toml ├── tree-sitter.json ├── pyproject.toml ├── .gitattributes ├── LICENSE ├── Package.swift ├── src ├── tree_sitter │ ├── alloc.h │ ├── parser.h │ └── array.h ├── scanner.c ├── node-types.json ├── grammar.json └── parser.c ├── package.json ├── setup.py ├── CMakeLists.txt ├── Makefile └── grammar.js /bindings/python/tree_sitter_godot_resource/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/resource.tres: -------------------------------------------------------------------------------- 1 | [node type="Node"] 2 | s = "hello 3 | \"My World\" world" 4 | other = "Okay" 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | corpus 2 | examples 3 | build 4 | script 5 | parser.exp 6 | parser.lib 7 | parser.obj 8 | scanner.obj 9 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/prestonknopp/tree-sitter-godot-resource 2 | 3 | go 1.22 4 | 5 | require github.com/tree-sitter/go-tree-sitter v0.24.0 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tree-sitter-godot-resource 2 | 3 | Godot resource grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). 4 | 5 | Parses tscn and tres files. 6 | -------------------------------------------------------------------------------- /bindings/node/binding_test.js: -------------------------------------------------------------------------------- 1 | const assert = require("node:assert"); 2 | const { test } = require("node:test"); 3 | 4 | const Parser = require("tree-sitter"); 5 | 6 | test("can load grammar", () => { 7 | const parser = new Parser(); 8 | assert.doesNotThrow(() => parser.setLanguage(require("."))); 9 | }); 10 | -------------------------------------------------------------------------------- /bindings/python/tree_sitter_godot_resource/__init__.pyi: -------------------------------------------------------------------------------- 1 | from typing import Final 2 | 3 | # NOTE: uncomment these to include any queries that this grammar contains: 4 | 5 | # HIGHLIGHTS_QUERY: Final[str] 6 | # INJECTIONS_QUERY: Final[str] 7 | # LOCALS_QUERY: Final[str] 8 | # TAGS_QUERY: Final[str] 9 | 10 | def language() -> object: ... 11 | -------------------------------------------------------------------------------- /bindings/c/tree-sitter-godot-resource.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_SITTER_GODOT_RESOURCE_H_ 2 | #define TREE_SITTER_GODOT_RESOURCE_H_ 3 | 4 | typedef struct TSLanguage TSLanguage; 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | const TSLanguage *tree_sitter_godot_resource(void); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif // TREE_SITTER_GODOT_RESOURCE_H_ 17 | -------------------------------------------------------------------------------- /bindings/c/tree-sitter-godot-resource.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 3 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 4 | 5 | Name: tree-sitter-godot-resource 6 | Description: @PROJECT_DESCRIPTION@ 7 | URL: @PROJECT_HOMEPAGE_URL@ 8 | Version: @PROJECT_VERSION@ 9 | Libs: -L${libdir} -ltree-sitter-godot-resource 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /bindings/python/tests/test_binding.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | 3 | import tree_sitter, tree_sitter_godot_resource 4 | 5 | 6 | class TestLanguage(TestCase): 7 | def test_can_load_grammar(self): 8 | try: 9 | tree_sitter.Language(tree_sitter_godot_resource.language()) 10 | except Exception: 11 | self.fail("Error loading GodotResource grammar") 12 | -------------------------------------------------------------------------------- /bindings/swift/TreeSitterGodotResource/godot_resource.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_SITTER_GODOT_RESOURCE_H_ 2 | #define TREE_SITTER_GODOT_RESOURCE_H_ 3 | 4 | typedef struct TSLanguage TSLanguage; 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | const TSLanguage *tree_sitter_godot_resource(void); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif // TREE_SITTER_GODOT_RESOURCE_H_ 17 | -------------------------------------------------------------------------------- /bindings/go/binding.go: -------------------------------------------------------------------------------- 1 | package tree_sitter_godot_resource 2 | 3 | // #cgo CFLAGS: -std=c11 -fPIC 4 | // #include "../../src/parser.c" 5 | // // NOTE: if your language has an external scanner, add it here. 6 | // #include "../../src/scanner.c" 7 | import "C" 8 | 9 | import "unsafe" 10 | 11 | // Get the tree-sitter Language for this grammar. 12 | func Language() unsafe.Pointer { 13 | return unsafe.Pointer(C.tree_sitter_godot_resource()) 14 | } 15 | -------------------------------------------------------------------------------- /bindings/go/binding_test.go: -------------------------------------------------------------------------------- 1 | package tree_sitter_godot_resource_test 2 | 3 | import ( 4 | "testing" 5 | 6 | tree_sitter "github.com/tree-sitter/go-tree-sitter" 7 | tree_sitter_godot_resource "github.com/prestonknopp/tree-sitter-godot-resource/bindings/go" 8 | ) 9 | 10 | func TestCanLoadGrammar(t *testing.T) { 11 | language := tree_sitter.NewLanguage(tree_sitter_godot_resource.Language()) 12 | if language == nil { 13 | t.Errorf("Error loading GodotResource grammar") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/corpus/issues/issue-3.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Constructors accept type arguments #3 3 | ===================================== 4 | 5 | [resource] 6 | test_array = Array[int]([42, 76]) 7 | 8 | --- 9 | 10 | (resource 11 | (section 12 | (identifier) 13 | (property 14 | (path) 15 | (constructor 16 | (identifier) 17 | (identifier) 18 | (arguments 19 | (array 20 | (integer) 21 | (integer))))))) 22 | -------------------------------------------------------------------------------- /bindings/swift/TreeSitterGodotResourceTests/TreeSitterGodotResourceTests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import SwiftTreeSitter 3 | import TreeSitterGodotResource 4 | 5 | final class TreeSitterGodotResourceTests: XCTestCase { 6 | func testCanLoadGrammar() throws { 7 | let parser = Parser() 8 | let language = Language(language: tree_sitter_godot_resource()) 9 | XCTAssertNoThrow(try parser.setLanguage(language), 10 | "Error loading GodotResource grammar") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bindings/node/index.js: -------------------------------------------------------------------------------- 1 | const root = require("path").join(__dirname, "..", ".."); 2 | 3 | module.exports = 4 | typeof process.versions.bun === "string" 5 | // Support `bun build --compile` by being statically analyzable enough to find the .node file at build-time 6 | ? require(`../../prebuilds/${process.platform}-${process.arch}/tree-sitter-godot-resource.node`) 7 | : require("node-gyp-build")(root); 8 | 9 | try { 10 | module.exports.nodeTypeInfo = require("../../src/node-types.json"); 11 | } catch (_) {} 12 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'grammar.js' 7 | - 'corpus/**' 8 | workflow_dispatch: 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions/setup-node@v4 16 | with: 17 | node-version: lts/* 18 | - run: | 19 | node --version 20 | npm --version 21 | - run: npm ci --include=dev --include=optional --include=peer 22 | - run: npm test 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Rust artifacts 2 | target/ 3 | 4 | # Node artifacts 5 | build/ 6 | prebuilds/ 7 | node_modules/ 8 | 9 | # Swift artifacts 10 | .build/ 11 | 12 | # Go artifacts 13 | _obj/ 14 | 15 | # Python artifacts 16 | .venv/ 17 | dist/ 18 | *.egg-info 19 | *.whl 20 | 21 | # C artifacts 22 | *.a 23 | *.so 24 | *.so.* 25 | *.dylib 26 | *.dll 27 | *.pc 28 | parser.exp 29 | parser.lib 30 | parser.obj 31 | scanner.obj 32 | 33 | # Grammar volatiles 34 | *.wasm 35 | *.obj 36 | *.o 37 | 38 | # Archives 39 | *.tar.gz 40 | *.tgz 41 | *.zip 42 | -------------------------------------------------------------------------------- /bindings/nim/treesittergodotresource.nim: -------------------------------------------------------------------------------- 1 | # This module, i.e. the nim bindings, can be placed anywhere in your nim project 2 | # or kept in the bindings directory. 3 | # 4 | # However the following assumes that when compiling your project or main module that 5 | # "tree-sitter-godot-resource/" is accessible from the current working directory. 6 | {.passC: "-Itree-sitter-godot-resource/src".} 7 | {.compile: "tree-sitter-godot-resource/src/parser.c".} 8 | {.compile: "tree-sitter-godot-resource/src/scanner.c".} 9 | proc tree_sitter_godot_resource*(): pointer {.importc.} 10 | -------------------------------------------------------------------------------- /bindings/node/index.d.ts: -------------------------------------------------------------------------------- 1 | type BaseNode = { 2 | type: string; 3 | named: boolean; 4 | }; 5 | 6 | type ChildNode = { 7 | multiple: boolean; 8 | required: boolean; 9 | types: BaseNode[]; 10 | }; 11 | 12 | type NodeInfo = 13 | | (BaseNode & { 14 | subtypes: BaseNode[]; 15 | }) 16 | | (BaseNode & { 17 | fields: { [name: string]: ChildNode }; 18 | children: ChildNode[]; 19 | }); 20 | 21 | type Language = { 22 | name: string; 23 | language: unknown; 24 | nodeTypeInfo: NodeInfo[]; 25 | }; 26 | 27 | declare const language: Language; 28 | export = language; 29 | -------------------------------------------------------------------------------- /test/corpus/issues/issue-9.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Generic type arguments can accept call syntax #9 3 | ===================================== 4 | 5 | [node name="Node" type="Node"] 6 | property/0/index = Array[ExtResource("2_k17ep")]([SubResource("Resource_ji6et")]) 7 | 8 | --- 9 | 10 | (resource 11 | (section 12 | (identifier) 13 | (attribute (identifier) (string)) 14 | (attribute (identifier) (string)) 15 | (property (path) 16 | (constructor 17 | (identifier) 18 | (constructor (identifier) (arguments (string))) 19 | (arguments (array (constructor (identifier) (arguments (string))))) 20 | )))) -------------------------------------------------------------------------------- /bindings/node/binding.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef struct TSLanguage TSLanguage; 4 | 5 | extern "C" TSLanguage *tree_sitter_godot_resource(); 6 | 7 | // "tree-sitter", "language" hashed with BLAKE2 8 | const napi_type_tag LANGUAGE_TYPE_TAG = { 9 | 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16 10 | }; 11 | 12 | Napi::Object Init(Napi::Env env, Napi::Object exports) { 13 | exports["name"] = Napi::String::New(env, "godot_resource"); 14 | auto language = Napi::External::New(env, tree_sitter_godot_resource()); 15 | language.TypeTag(&LANGUAGE_TYPE_TAG); 16 | exports["language"] = language; 17 | return exports; 18 | } 19 | 20 | NODE_API_MODULE(tree_sitter_godot_resource_binding, Init) 21 | -------------------------------------------------------------------------------- /bindings/rust/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let src_dir = std::path::Path::new("src"); 3 | 4 | let mut c_config = cc::Build::new(); 5 | c_config.std("c11").include(src_dir); 6 | 7 | #[cfg(target_env = "msvc")] 8 | c_config.flag("-utf-8"); 9 | 10 | let parser_path = src_dir.join("parser.c"); 11 | c_config.file(&parser_path); 12 | println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); 13 | 14 | // NOTE: if your language uses an external scanner, uncomment this block: 15 | let scanner_path = src_dir.join("scanner.c"); 16 | c_config.file(&scanner_path); 17 | println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); 18 | 19 | c_config.compile("tree-sitter-godot-resource"); 20 | } 21 | -------------------------------------------------------------------------------- /test/corpus/issues/issue-4.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Constructors accept type arguments #4 3 | ===================================== 4 | 5 | [resource] 6 | test_array = Dictionary[int, String]({1: "first value",2: "second value",3: "etc"}) 7 | 8 | --- 9 | 10 | (resource 11 | (section 12 | (identifier) 13 | (property 14 | (path) 15 | (constructor 16 | (identifier) 17 | (identifier) 18 | (identifier) 19 | (arguments 20 | (dictionary 21 | (pair 22 | (integer) 23 | (string)) 24 | (pair 25 | (integer) 26 | (string)) 27 | (pair 28 | (integer) 29 | (string)))))))) -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | 6 | [*.{json,toml,yml,gyp}] 7 | indent_style = space 8 | indent_size = 2 9 | 10 | [*.js] 11 | indent_style = space 12 | indent_size = 2 13 | 14 | [*.scm] 15 | indent_style = space 16 | indent_size = 2 17 | 18 | [*.{c,cc,h}] 19 | indent_style = space 20 | indent_size = 4 21 | 22 | [*.rs] 23 | indent_style = space 24 | indent_size = 4 25 | 26 | [*.{py,pyi}] 27 | indent_style = space 28 | indent_size = 4 29 | 30 | [*.swift] 31 | indent_style = space 32 | indent_size = 4 33 | 34 | [*.go] 35 | indent_style = tab 36 | indent_size = 8 37 | 38 | [Makefile] 39 | indent_style = tab 40 | indent_size = 8 41 | 42 | [parser.c] 43 | indent_size = 2 44 | 45 | [{alloc,array,parser}.h] 46 | indent_size = 2 47 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "tree_sitter_godot_resource_binding", 5 | "dependencies": [ 6 | " 2 | 3 | typedef struct TSLanguage TSLanguage; 4 | 5 | TSLanguage *tree_sitter_godot_resource(void); 6 | 7 | static PyObject* _binding_language(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args)) { 8 | return PyCapsule_New(tree_sitter_godot_resource(), "tree_sitter.Language", NULL); 9 | } 10 | 11 | static PyMethodDef methods[] = { 12 | {"language", _binding_language, METH_NOARGS, 13 | "Get the tree-sitter language for this grammar."}, 14 | {NULL, NULL, 0, NULL} 15 | }; 16 | 17 | static struct PyModuleDef module = { 18 | .m_base = PyModuleDef_HEAD_INIT, 19 | .m_name = "_binding", 20 | .m_doc = NULL, 21 | .m_size = -1, 22 | .m_methods = methods 23 | }; 24 | 25 | PyMODINIT_FUNC PyInit__binding(void) { 26 | return PyModule_Create(&module); 27 | } 28 | -------------------------------------------------------------------------------- /tree-sitter.json: -------------------------------------------------------------------------------- 1 | { 2 | "grammars": [ 3 | { 4 | "name": "godot_resource", 5 | "camelcase": "GodotResource", 6 | "scope": "source.godot_resource", 7 | "file-types": [ 8 | ".tscn", 9 | ".tres", 10 | ".godot" 11 | ], 12 | "injection-regex": "^godot_resource$" 13 | } 14 | ], 15 | "metadata": { 16 | "version": "0.7.0", 17 | "license": "MIT", 18 | "description": "Grammar for the Godot game engine's resource format.", 19 | "authors": [ 20 | { 21 | "name": "Preston Knopp" 22 | } 23 | ], 24 | "links": { 25 | "repository": "https://github.com/PrestonKnopp/tree-sitter-godot-resource" 26 | } 27 | }, 28 | "bindings": { 29 | "c": true, 30 | "go": true, 31 | "node": true, 32 | "python": true, 33 | "rust": true, 34 | "swift": true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "tree-sitter-godot-resource" 7 | description = "Grammar for the Godot game engine's resource format." 8 | version = "0.7.0" 9 | keywords = ["incremental", "parsing", "tree-sitter", "godot-resource"] 10 | classifiers = [ 11 | "Intended Audience :: Developers", 12 | "Topic :: Software Development :: Compilers", 13 | "Topic :: Text Processing :: Linguistic", 14 | "Typing :: Typed", 15 | ] 16 | authors = [{ name = "Preston Knopp" }] 17 | requires-python = ">=3.9" 18 | license.text = "MIT" 19 | readme = "README.md" 20 | 21 | [project.urls] 22 | Homepage = "https://github.com/prestonknopp/tree-sitter-godot-resource" 23 | 24 | [project.optional-dependencies] 25 | core = ["tree-sitter~=0.22"] 26 | 27 | [tool.cibuildwheel] 28 | build = "cp39-*" 29 | build-frontend = "build" 30 | -------------------------------------------------------------------------------- /test/corpus/issues/issue-12.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Handle String Names #12 3 | ===================================== 4 | 5 | [resource] 6 | test_string_name = &"test stringname" 7 | test_dict = Dictionary[int, StringName]({1: &"first value",2: &"second value",3: &"with escaped quote\""}) 8 | test_string = "String with a literal newline and an 9 | &" 10 | --- 11 | 12 | (resource 13 | (section 14 | (identifier) 15 | (property 16 | (path) 17 | (string_name)) 18 | (property 19 | (path) 20 | (constructor 21 | (identifier) 22 | (identifier) 23 | (identifier) 24 | (arguments 25 | (dictionary 26 | (pair 27 | (integer) 28 | (string_name)) 29 | (pair 30 | (integer) 31 | (string_name)) 32 | (pair 33 | (integer) 34 | (string_name)))))) 35 | (property 36 | (path) 37 | (string)))) -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | 3 | # Generated source files 4 | src/*.json linguist-generated 5 | src/parser.c linguist-generated 6 | src/tree_sitter/* linguist-generated 7 | 8 | # C bindings 9 | bindings/c/* linguist-generated 10 | CMakeLists.txt linguist-generated 11 | Makefile linguist-generated 12 | 13 | # Rust bindings 14 | bindings/rust/* linguist-generated 15 | Cargo.toml linguist-generated 16 | Cargo.lock linguist-generated 17 | 18 | # Node.js bindings 19 | bindings/node/* linguist-generated 20 | binding.gyp linguist-generated 21 | package.json linguist-generated 22 | package-lock.json linguist-generated 23 | 24 | # Python bindings 25 | bindings/python/** linguist-generated 26 | setup.py linguist-generated 27 | pyproject.toml linguist-generated 28 | 29 | # Go bindings 30 | bindings/go/* linguist-generated 31 | go.mod linguist-generated 32 | go.sum linguist-generated 33 | 34 | # Swift bindings 35 | bindings/swift/** linguist-generated 36 | Package.swift linguist-generated 37 | Package.resolved linguist-generated 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Preston Knopp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/corpus/issues/issue-5.txt: -------------------------------------------------------------------------------- 1 | 2 | ===================================== 3 | Dictionaries can have any variant as a key #5 4 | ===================================== 5 | 6 | [resource] 7 | test_untyped_dict = { 8 | 1: "first value", 9 | { 1: 5.2 }: "second value", 10 | [0, 1, 2]: "third value", 11 | PackedStringArray("foo", "bar", "baz"): "fourth value" 12 | } 13 | 14 | --- 15 | 16 | (resource 17 | (section 18 | (identifier) 19 | (property 20 | (path) 21 | (dictionary 22 | (pair 23 | (integer) 24 | (string)) 25 | (pair 26 | (dictionary 27 | (pair 28 | (integer) 29 | (float))) 30 | (string)) 31 | (pair 32 | (array 33 | (integer) 34 | (integer) 35 | (integer)) 36 | (string)) 37 | (pair 38 | (constructor 39 | (identifier) 40 | (arguments 41 | (string) 42 | (string) 43 | (string))) 44 | (string)))))) -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "TreeSitterGodotResource", 6 | products: [ 7 | .library(name: "TreeSitterGodotResource", targets: ["TreeSitterGodotResource"]), 8 | ], 9 | dependencies: [ 10 | .package(url: "https://github.com/ChimeHQ/SwiftTreeSitter", from: "0.8.0"), 11 | ], 12 | targets: [ 13 | .target( 14 | name: "TreeSitterGodotResource", 15 | dependencies: [], 16 | path: ".", 17 | sources: [ 18 | "src/parser.c", 19 | "src/scanner.c", 20 | ], 21 | resources: [ 22 | .copy("queries") 23 | ], 24 | publicHeadersPath: "bindings/swift", 25 | cSettings: [.headerSearchPath("src")] 26 | ), 27 | .testTarget( 28 | name: "TreeSitterGodotResourceTests", 29 | dependencies: [ 30 | "SwiftTreeSitter", 31 | "TreeSitterGodotResource", 32 | ], 33 | path: "bindings/swift/TreeSitterGodotResourceTests" 34 | ) 35 | ], 36 | cLanguageStandard: .c11 37 | ) 38 | -------------------------------------------------------------------------------- /src/tree_sitter/alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_SITTER_ALLOC_H_ 2 | #define TREE_SITTER_ALLOC_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | // Allow clients to override allocation functions 13 | #ifdef TREE_SITTER_REUSE_ALLOCATOR 14 | 15 | extern void *(*ts_current_malloc)(size_t size); 16 | extern void *(*ts_current_calloc)(size_t count, size_t size); 17 | extern void *(*ts_current_realloc)(void *ptr, size_t size); 18 | extern void (*ts_current_free)(void *ptr); 19 | 20 | #ifndef ts_malloc 21 | #define ts_malloc ts_current_malloc 22 | #endif 23 | #ifndef ts_calloc 24 | #define ts_calloc ts_current_calloc 25 | #endif 26 | #ifndef ts_realloc 27 | #define ts_realloc ts_current_realloc 28 | #endif 29 | #ifndef ts_free 30 | #define ts_free ts_current_free 31 | #endif 32 | 33 | #else 34 | 35 | #ifndef ts_malloc 36 | #define ts_malloc malloc 37 | #endif 38 | #ifndef ts_calloc 39 | #define ts_calloc calloc 40 | #endif 41 | #ifndef ts_realloc 42 | #define ts_realloc realloc 43 | #endif 44 | #ifndef ts_free 45 | #define ts_free free 46 | #endif 47 | 48 | #endif 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif // TREE_SITTER_ALLOC_H_ 55 | -------------------------------------------------------------------------------- /test/corpus/resource.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Resource File 3 | ===================================== 4 | [gd_scene load_steps=10 format=2] 5 | 6 | [ext_resource path="path" type="type" id=1] 7 | 8 | [node] 9 | 10 | [node name="game"] 11 | __meta__ = { 12 | "_edit_lock_": true 13 | } 14 | 15 | [node parent="game/test"] 16 | script = ExtResource( 1 ) 17 | editor/display_folded = true 18 | float = 10000390.03230329 19 | bool = false 20 | str = "hello 21 | world \"okay\"" 22 | 23 | --- 24 | 25 | (resource 26 | (section (identifier) 27 | (attribute (identifier) (integer)) 28 | (attribute (identifier) (integer))) 29 | (section (identifier) 30 | (attribute (identifier) (string)) 31 | (attribute (identifier) (string)) 32 | (attribute (identifier) (integer))) 33 | (section (identifier)) 34 | (section (identifier) 35 | (attribute (identifier) (string)) 36 | (property (path) (dictionary 37 | (pair (string) (true))))) 38 | (section (identifier) 39 | (attribute (identifier) (string)) 40 | (property (path) (constructor 41 | (identifier) (arguments (integer)))) 42 | (property (path) (true)) 43 | (property (path) (float)) 44 | (property (path) (false)) 45 | (property (path) (string)))) 46 | -------------------------------------------------------------------------------- /bindings/python/tree_sitter_godot_resource/__init__.py: -------------------------------------------------------------------------------- 1 | """Grammar for the Godot game engine's resource format.""" 2 | 3 | from importlib.resources import files as _files 4 | 5 | from ._binding import language 6 | 7 | 8 | def _get_query(name, file): 9 | query = _files(f"{__package__}.queries") / file 10 | globals()[name] = query.read_text() 11 | return globals()[name] 12 | 13 | 14 | def __getattr__(name): 15 | # NOTE: uncomment these to include any queries that this grammar contains: 16 | 17 | # if name == "HIGHLIGHTS_QUERY": 18 | # return _get_query("HIGHLIGHTS_QUERY", "highlights.scm") 19 | # if name == "INJECTIONS_QUERY": 20 | # return _get_query("INJECTIONS_QUERY", "injections.scm") 21 | # if name == "LOCALS_QUERY": 22 | # return _get_query("LOCALS_QUERY", "locals.scm") 23 | # if name == "TAGS_QUERY": 24 | # return _get_query("TAGS_QUERY", "tags.scm") 25 | 26 | raise AttributeError(f"module {__name__!r} has no attribute {name!r}") 27 | 28 | 29 | __all__ = [ 30 | "language", 31 | # "HIGHLIGHTS_QUERY", 32 | # "INJECTIONS_QUERY", 33 | # "LOCALS_QUERY", 34 | # "TAGS_QUERY", 35 | ] 36 | 37 | 38 | def __dir__(): 39 | return sorted(__all__ + [ 40 | "__all__", "__builtins__", "__cached__", "__doc__", "__file__", 41 | "__loader__", "__name__", "__package__", "__path__", "__spec__", 42 | ]) 43 | -------------------------------------------------------------------------------- /src/scanner.c: -------------------------------------------------------------------------------- 1 | /* Author: Preston Knopp 2 | * Description: Parse multiline double quote strings without state 3 | */ 4 | #include 5 | #include 6 | 7 | // using wctype::iswspace 8 | 9 | enum TokenType { 10 | STRING 11 | }; 12 | 13 | bool tree_sitter_godot_resource_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) { 14 | 15 | if (!valid_symbols[STRING]) { 16 | return false; 17 | } 18 | 19 | while (iswspace(lexer->lookahead)) { 20 | lexer->advance(lexer, true); 21 | } 22 | 23 | if (lexer->lookahead != '"') { 24 | return false; 25 | } 26 | 27 | uint32_t last_char = '"'; 28 | lexer->advance(lexer, false); 29 | 30 | while (lexer->lookahead) { 31 | 32 | if (last_char != '\\' && lexer->lookahead == '"') { 33 | lexer->advance(lexer, false); 34 | lexer->result_symbol = STRING; 35 | return true; 36 | } 37 | 38 | last_char = lexer->lookahead; 39 | lexer->advance(lexer, false); 40 | } 41 | 42 | return false; 43 | } 44 | 45 | void *tree_sitter_godot_resource_external_scanner_create() { return NULL; } 46 | unsigned tree_sitter_godot_resource_external_scanner_serialize(void *payload, char *buffer) { return 0; } 47 | void tree_sitter_godot_resource_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {} 48 | void tree_sitter_godot_resource_external_scanner_destroy(void *payload) {} 49 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tree-sitter-godot-resource", 3 | "version": "0.7.0", 4 | "description": "Grammar for the Godot game engine's text resource format.", 5 | "repository": "https://github.com/prestonknopp/tree-sitter-godot-resource", 6 | "license": "MIT", 7 | "author": { 8 | "name": "Preston Knopp" 9 | }, 10 | "main": "bindings/node", 11 | "types": "bindings/node", 12 | "keywords": [ 13 | "incremental", 14 | "parsing", 15 | "tree-sitter", 16 | "godot", 17 | "tscn", 18 | "tres" 19 | ], 20 | "files": [ 21 | "grammar.js", 22 | "tree-sitter.json", 23 | "binding.gyp", 24 | "prebuilds/**", 25 | "bindings/node/*", 26 | "queries/*", 27 | "src/**", 28 | "*.wasm" 29 | ], 30 | "dependencies": { 31 | "node-addon-api": "^8.3.1", 32 | "node-gyp-build": "^4.8.4" 33 | }, 34 | "devDependencies": { 35 | "prebuildify": "^6.0.1", 36 | "prettier": "^3.5.3", 37 | "tree-sitter-cli": "^0.24.7" 38 | }, 39 | "peerDependencies": { 40 | "tree-sitter": "^0.21.1" 41 | }, 42 | "peerDependenciesMeta": { 43 | "tree-sitter": { 44 | "optional": true 45 | } 46 | }, 47 | "scripts": { 48 | "install": "node-gyp-build", 49 | "prebuild": "prebuildify --strip -t electron@34.5.5 -t electron@35.3.0 -t electron@36.2.0 -t v20.19.1 -t v22.15.0 -t v23.11.0 -t v24.0.1", 50 | "prestart": "tree-sitter build --wasm", 51 | "start": "tree-sitter playground", 52 | "versions": "node --version && npm --version && tree-sitter --version", 53 | "test": "tree-sitter test && node --test bindings/node/*_test.js", 54 | "generate": "tree-sitter generate", 55 | "genTest": "tree-sitter generate && npm test", 56 | "parse": "tree-sitter parse", 57 | "ts": "tree-sitter", 58 | "format": "prettier -w grammar.js package.json" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from os.path import isdir, join 2 | from platform import system 3 | 4 | from setuptools import Extension, find_packages, setup 5 | from setuptools.command.build import build 6 | from wheel.bdist_wheel import bdist_wheel 7 | 8 | 9 | class Build(build): 10 | def run(self): 11 | if isdir("queries"): 12 | dest = join(self.build_lib, "tree_sitter_godot_resource", "queries") 13 | self.copy_tree("queries", dest) 14 | super().run() 15 | 16 | 17 | class BdistWheel(bdist_wheel): 18 | def get_tag(self): 19 | python, abi, platform = super().get_tag() 20 | if python.startswith("cp"): 21 | python, abi = "cp39", "abi3" 22 | return python, abi, platform 23 | 24 | 25 | setup( 26 | packages=find_packages("bindings/python"), 27 | package_dir={"": "bindings/python"}, 28 | package_data={ 29 | "tree_sitter_godot_resource": ["*.pyi", "py.typed"], 30 | "tree_sitter_godot_resource.queries": ["*.scm"], 31 | }, 32 | ext_package="tree_sitter_godot_resource", 33 | ext_modules=[ 34 | Extension( 35 | name="_binding", 36 | sources=[ 37 | "bindings/python/tree_sitter_godot_resource/binding.c", 38 | "src/parser.c", 39 | # NOTE: if your language uses an external scanner, add it here. 40 | "src/scanner.c", 41 | ], 42 | extra_compile_args=[ 43 | "-std=c11", 44 | "-fvisibility=hidden", 45 | ] if system() != "Windows" else [ 46 | "/std:c11", 47 | "/utf-8", 48 | ], 49 | define_macros=[ 50 | ("Py_LIMITED_API", "0x03090000"), 51 | ("PY_SSIZE_T_CLEAN", None), 52 | ("TREE_SITTER_HIDE_SYMBOLS", None), 53 | ], 54 | include_dirs=["src"], 55 | py_limited_api=True, 56 | ) 57 | ], 58 | cmdclass={ 59 | "build": Build, 60 | "bdist_wheel": BdistWheel 61 | }, 62 | zip_safe=False 63 | ) 64 | -------------------------------------------------------------------------------- /bindings/rust/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate provides GodotResource language support for the [tree-sitter][] parsing library. 2 | //! 3 | //! Typically, you will use the [LANGUAGE][] constant to add this language to a 4 | //! tree-sitter [Parser][], and then use the parser to parse some code: 5 | //! 6 | //! ``` 7 | //! let code = r#" 8 | //! "#; 9 | //! let mut parser = tree_sitter::Parser::new(); 10 | //! let language = tree_sitter_godot_resource::LANGUAGE; 11 | //! parser 12 | //! .set_language(&language.into()) 13 | //! .expect("Error loading GodotResource parser"); 14 | //! let tree = parser.parse(code, None).unwrap(); 15 | //! assert!(!tree.root_node().has_error()); 16 | //! ``` 17 | //! 18 | //! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html 19 | //! [tree-sitter]: https://tree-sitter.github.io/ 20 | 21 | use tree_sitter_language::LanguageFn; 22 | 23 | extern "C" { 24 | fn tree_sitter_godot_resource() -> *const (); 25 | } 26 | 27 | /// The tree-sitter [`LanguageFn`][LanguageFn] for this grammar. 28 | /// 29 | /// [LanguageFn]: https://docs.rs/tree-sitter-language/*/tree_sitter_language/struct.LanguageFn.html 30 | pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_godot_resource) }; 31 | 32 | /// The content of the [`node-types.json`][] file for this grammar. 33 | /// 34 | /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types 35 | pub const NODE_TYPES: &str = include_str!("../../src/node-types.json"); 36 | 37 | // NOTE: uncomment these to include any queries that this grammar contains: 38 | 39 | // pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm"); 40 | // pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm"); 41 | // pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm"); 42 | // pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm"); 43 | 44 | #[cfg(test)] 45 | mod tests { 46 | #[test] 47 | fn test_can_load_grammar() { 48 | let mut parser = tree_sitter::Parser::new(); 49 | parser 50 | .set_language(&super::LANGUAGE.into()) 51 | .expect("Error loading GodotResource parser"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.github/workflows/build_publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will 2 | # - test tree sitter grammar 3 | # - upload build native binaries as an artifact for each major platform 4 | # - download artifacts for each major platform and bundle them to be published 5 | # to npm 6 | # when a new version tag is pushed to the master branch. 7 | name: Test Build Publish 8 | 9 | on: 10 | push: 11 | tags: [v*] 12 | 13 | jobs: 14 | 15 | build_native_binaries: 16 | strategy: 17 | matrix: 18 | # Use macos-14 for arm, however the artifact upload name conflicts with 19 | # macos-latest. There's probably a way to crossbuild for arm with 20 | # prebuildify. 21 | os: [macos-latest, ubuntu-latest, windows-latest] 22 | runs-on: ${{ matrix.os }} 23 | steps: 24 | - uses: actions/checkout@v4 25 | - uses: actions/setup-node@v4 26 | with: 27 | node-version: lts/* 28 | # Why is npm only occassionally installing peer dependencies? 29 | # I cannot get consistent peer dependency installs with the same command runs. 30 | # Should I always explicitly run npm i tree-sitter? The general consensus is yes. 31 | # But then, why does it install peer deps sometimes? 32 | - run: | 33 | node --version 34 | npm --version 35 | - run: npm ci --include=peer --include=optional --include=dev 36 | - run: npm i tree-sitter 37 | - run: npm run versions 38 | - run: npm test 39 | - run: npm run prebuild 40 | # upload-artifact@v4 requires each artifact name to be unique. 41 | - uses: actions/upload-artifact@v4 42 | with: 43 | name: prebuilds-${{ matrix.os }} 44 | path: prebuilds 45 | retention-days: 1 46 | 47 | 48 | publish_npm: 49 | needs: build_native_binaries 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v4 53 | - uses: actions/setup-node@v4 54 | with: 55 | node-version: lts/* 56 | # https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-nodejs-packages#publishing-packages-to-the-npm-registry 57 | # https://github.com/actions/setup-node/issues/342 58 | # This is required to publish to npm. 59 | registry-url: 'https://registry.npmjs.org' 60 | - run: | 61 | node --version 62 | npm --version 63 | - run: npm ci 64 | # Download all artifacts and merge into prebuilds dir. 65 | - uses: actions/download-artifact@v4 66 | with: 67 | path: prebuilds 68 | pattern: prebuilds-* 69 | merge-multiple: true 70 | - run: ls -R prebuilds 71 | - run: npm publish 72 | env: 73 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 74 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(tree-sitter-godot-resource 4 | VERSION "0.7.0" 5 | DESCRIPTION "Grammar for the Godot game engine's resource format." 6 | HOMEPAGE_URL "https://github.com/prestonknopp/tree-sitter-godot-resource" 7 | LANGUAGES C) 8 | 9 | option(BUILD_SHARED_LIBS "Build using shared libraries" ON) 10 | option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF) 11 | 12 | set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version") 13 | if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$") 14 | unset(TREE_SITTER_ABI_VERSION CACHE) 15 | message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer") 16 | endif() 17 | 18 | find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI") 19 | 20 | add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c" 21 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json" 22 | COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json 23 | --abi=${TREE_SITTER_ABI_VERSION} 24 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 25 | COMMENT "Generating parser.c") 26 | 27 | add_library(tree-sitter-godot-resource src/parser.c) 28 | if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c) 29 | target_sources(tree-sitter-godot-resource PRIVATE src/scanner.c) 30 | endif() 31 | target_include_directories(tree-sitter-godot-resource PRIVATE src) 32 | 33 | target_compile_definitions(tree-sitter-godot-resource PRIVATE 34 | $<$:TREE_SITTER_REUSE_ALLOCATOR> 35 | $<$:TREE_SITTER_DEBUG>) 36 | 37 | set_target_properties(tree-sitter-godot-resource 38 | PROPERTIES 39 | C_STANDARD 11 40 | POSITION_INDEPENDENT_CODE ON 41 | SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}" 42 | DEFINE_SYMBOL "") 43 | 44 | configure_file(bindings/c/tree-sitter-godot-resource.pc.in 45 | "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-godot-resource.pc" @ONLY) 46 | 47 | include(GNUInstallDirs) 48 | 49 | install(FILES bindings/c/tree-sitter-godot-resource.h 50 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tree_sitter") 51 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-godot-resource.pc" 52 | DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig") 53 | install(TARGETS tree-sitter-godot-resource 54 | LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") 55 | 56 | add_custom_target(ts-test "${TREE_SITTER_CLI}" test 57 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 58 | COMMENT "tree-sitter test") 59 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifeq ($(OS),Windows_NT) 2 | $(error Windows is not supported) 3 | endif 4 | 5 | LANGUAGE_NAME := tree-sitter-godot-resource 6 | HOMEPAGE_URL := https://github.com/prestonknopp/tree-sitter-godot-resource 7 | VERSION := 0.7.0 8 | 9 | # repository 10 | SRC_DIR := src 11 | 12 | TS ?= tree-sitter 13 | 14 | # install directory layout 15 | PREFIX ?= /usr/local 16 | INCLUDEDIR ?= $(PREFIX)/include 17 | LIBDIR ?= $(PREFIX)/lib 18 | PCLIBDIR ?= $(LIBDIR)/pkgconfig 19 | 20 | # source/object files 21 | PARSER := $(SRC_DIR)/parser.c 22 | EXTRAS := $(filter-out $(PARSER),$(wildcard $(SRC_DIR)/*.c)) 23 | OBJS := $(patsubst %.c,%.o,$(PARSER) $(EXTRAS)) 24 | 25 | # flags 26 | ARFLAGS ?= rcs 27 | override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC 28 | 29 | # ABI versioning 30 | SONAME_MAJOR = $(shell sed -n 's/\#define LANGUAGE_VERSION //p' $(PARSER)) 31 | SONAME_MINOR = $(word 1,$(subst ., ,$(VERSION))) 32 | 33 | # OS-specific bits 34 | ifeq ($(shell uname),Darwin) 35 | SOEXT = dylib 36 | SOEXTVER_MAJOR = $(SONAME_MAJOR).$(SOEXT) 37 | SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).$(SOEXT) 38 | LINKSHARED = -dynamiclib -Wl,-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SOEXTVER),-rpath,@executable_path/../Frameworks 39 | else 40 | SOEXT = so 41 | SOEXTVER_MAJOR = $(SOEXT).$(SONAME_MAJOR) 42 | SOEXTVER = $(SOEXT).$(SONAME_MAJOR).$(SONAME_MINOR) 43 | LINKSHARED = -shared -Wl,-soname,lib$(LANGUAGE_NAME).$(SOEXTVER) 44 | endif 45 | ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),) 46 | PCLIBDIR := $(PREFIX)/libdata/pkgconfig 47 | endif 48 | 49 | all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc 50 | 51 | lib$(LANGUAGE_NAME).a: $(OBJS) 52 | $(AR) $(ARFLAGS) $@ $^ 53 | 54 | lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS) 55 | $(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ 56 | ifneq ($(STRIP),) 57 | $(STRIP) $@ 58 | endif 59 | 60 | $(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in 61 | sed -e 's|@PROJECT_VERSION@|$(VERSION)|' \ 62 | -e 's|@CMAKE_INSTALL_LIBDIR@|$(LIBDIR:$(PREFIX)/%=%)|' \ 63 | -e 's|@CMAKE_INSTALL_INCLUDEDIR@|$(INCLUDEDIR:$(PREFIX)/%=%)|' \ 64 | -e 's|@PROJECT_DESCRIPTION@|$(DESCRIPTION)|' \ 65 | -e 's|@PROJECT_HOMEPAGE_URL@|$(HOMEPAGE_URL)|' \ 66 | -e 's|@CMAKE_INSTALL_PREFIX@|$(PREFIX)|' $< > $@ 67 | 68 | $(PARSER): $(SRC_DIR)/grammar.json 69 | $(TS) generate $^ 70 | 71 | install: all 72 | install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)' 73 | install -m644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h 74 | install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc 75 | install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a 76 | install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) 77 | ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) 78 | ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) 79 | 80 | uninstall: 81 | $(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \ 82 | '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \ 83 | '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \ 84 | '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \ 85 | '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \ 86 | '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc 87 | 88 | clean: 89 | $(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) 90 | 91 | test: 92 | $(TS) test 93 | 94 | .PHONY: all install uninstall clean test 95 | -------------------------------------------------------------------------------- /grammar.js: -------------------------------------------------------------------------------- 1 | module.exports = grammar({ 2 | name: "godot_resource", 3 | word: ($) => $._identifier, 4 | extras: ($) => [$.comment, /[\s\uFEFF\u2060\u200B]|\\\r?\n/], 5 | 6 | externals: ($) => [$.string], 7 | 8 | rules: { 9 | resource: ($) => seq(repeat($.property), repeat($.section)), 10 | 11 | // ----------------------------------------------------------------------------- 12 | // - Atoms - 13 | // ----------------------------------------------------------------------------- 14 | 15 | _identifier: ($) => /[a-zA-Z_][a-zA-Z_0-9]*/, 16 | identifier: ($) => $._identifier, 17 | comment: ($) => token(seq(";", /.*/)), 18 | 19 | true: ($) => "true", 20 | false: ($) => "false", 21 | null: ($) => "null", 22 | 23 | float: ($) => { 24 | const digits = repeat1(/-?[0-9]+_?/); 25 | const exponent = seq(/[eE][\+-]?/, digits); 26 | 27 | return token( 28 | choice( 29 | seq(digits, ".", optional(digits), optional(exponent)), 30 | seq(optional(digits), ".", digits, optional(exponent)), 31 | seq(digits, exponent), 32 | ), 33 | ); 34 | }, 35 | 36 | integer: ($) => 37 | token( 38 | choice( 39 | seq(choice("0x", "0X"), repeat1(/_?[A-Fa-f0-9]+/)), 40 | seq(choice("0o", "0O"), repeat1(/_?[0-7]+/)), 41 | seq(choice("0b", "0B"), repeat1(/_?[0-1]+/)), 42 | repeat1(/-?[0-9]+_?/), 43 | ), 44 | ), 45 | 46 | string_name: ($) => seq("&", alias($.string, "string")), 47 | 48 | // ----------------------------------------------------------------------------- 49 | // - Compound - 50 | // ----------------------------------------------------------------------------- 51 | 52 | _value: ($) => 53 | choice( 54 | $.float, 55 | $.integer, 56 | $.string, 57 | $.string_name, 58 | $.true, 59 | $.false, 60 | $.null, 61 | $.dictionary, 62 | $.array, 63 | $.constructor, 64 | $.identifier, 65 | ), 66 | 67 | // ----------------------------------------------------------------------------- 68 | // - Sections - 69 | // ----------------------------------------------------------------------------- 70 | 71 | // e.g. 72 | // [gd_scene load_steps=10 format=2] 73 | // [node name="main" type="Node"] 74 | section: ($) => 75 | seq( 76 | "[", 77 | $.identifier, 78 | optional($._attributes), 79 | "]", 80 | optional($._properties), 81 | ), 82 | 83 | // e.g. 84 | // name="main" 85 | // id=1 86 | _attributes: ($) => repeat1($.attribute), 87 | attribute: ($) => seq($.identifier, "=", $._value), 88 | 89 | // e.g. 90 | // script = ExtResource( 1 ) 91 | // 0/texture = ExtResource( 2 ) 92 | _properties: ($) => repeat1($.property), 93 | property: ($) => seq($.path, "=", $._value), 94 | path: ($) => /[a-zA-Z_0-9][a-zA-Z_:/0-9]*/, 95 | 96 | // ----------------------------------------------------------------------------- 97 | // - Data Structs - 98 | // ----------------------------------------------------------------------------- 99 | 100 | pair: ($) => seq($._value, ":", $._value), 101 | 102 | dictionary: ($) => seq("{", optional(commaSep1($.pair)), "}"), 103 | 104 | array: ($) => seq("[", optional(commaSep1($._value)), "]"), 105 | 106 | // ----------------------------------------------------------------------------- 107 | // - Constructor - 108 | // ----------------------------------------------------------------------------- 109 | 110 | arguments: ($) => 111 | seq("(", optional(commaSep1(choice($._value, $.pair))), ")"), 112 | 113 | // Generic type arguments are parsed as arbitrary values. 114 | // I haven't seen attributes, e.g. "Type.SubType", in the wild. Not sure if resources parse them. 115 | _type_args: ($) => seq("[", commaSep1($._value), "]"), 116 | constructor: ($) => 117 | prec.right(1, seq($.identifier, optional($._type_args), $.arguments)), 118 | }, // end rules 119 | }); 120 | 121 | function commaSep1(rule) { 122 | return sep1(rule, ","); 123 | } 124 | 125 | function sep1(rule, separator) { 126 | return seq(rule, repeat(seq(separator, rule))); 127 | } 128 | -------------------------------------------------------------------------------- /test/corpus/section.txt: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Lonely Section 3 | ===================================== 4 | 5 | [id] 6 | 7 | --- 8 | 9 | (resource 10 | (section (identifier))) 11 | 12 | ===================================== 13 | Section with Attributes 14 | ===================================== 15 | 16 | [id a=1 b="s"] 17 | 18 | --- 19 | 20 | (resource 21 | (section (identifier) 22 | (attribute (identifier) (integer)) 23 | (attribute (identifier) (string)))) 24 | 25 | ===================================== 26 | Section Properties 27 | ===================================== 28 | 29 | [id] 30 | a = 1 31 | b = 2 32 | 33 | --- 34 | 35 | (resource 36 | (section (identifier) 37 | (property (path) (integer)) 38 | (property (path) (integer)))) 39 | 40 | ===================================== 41 | Section with Attributes Properties 42 | ===================================== 43 | 44 | [id a=1 b="s"] 45 | a = 1 46 | b = 2 47 | 48 | --- 49 | 50 | (resource 51 | (section (identifier) 52 | (attribute (identifier) (integer)) 53 | (attribute (identifier) (string)) 54 | (property (path) (integer)) 55 | (property (path) (integer)))) 56 | 57 | ===================================== 58 | Dictionary Properties 59 | ===================================== 60 | 61 | [id] 62 | dict = {} 63 | dict = { 64 | "a": 1, 65 | "b": 2 66 | } 67 | 68 | --- 69 | 70 | (resource 71 | (section (identifier) 72 | (property (path) (dictionary)) 73 | (property (path) 74 | (dictionary 75 | (pair (string) (integer)) 76 | (pair (string) (integer)))))) 77 | 78 | ===================================== 79 | Sub Dictionary Properties 80 | ===================================== 81 | 82 | [id] 83 | dict = { 84 | "a": { 85 | "b": 1 86 | } 87 | } 88 | 89 | --- 90 | 91 | (resource 92 | (section (identifier) 93 | (property (path) 94 | (dictionary 95 | (pair 96 | (string) 97 | (dictionary 98 | (pair 99 | (string) 100 | (integer)))))))) 101 | 102 | ===================================== 103 | Indented Dictionary Properties 104 | ===================================== 105 | 106 | [id] 107 | dict = { 108 | "a": 1, 109 | "b": 2 110 | } 111 | 112 | --- 113 | 114 | (resource 115 | (section (identifier) 116 | (property (path) 117 | (dictionary 118 | (pair (string) (integer)) 119 | (pair (string) (integer)))))) 120 | 121 | ===================================== 122 | Section with String Attr and Prop 123 | ===================================== 124 | 125 | [id a="a/b"] 126 | dict = { 127 | "a": true 128 | } 129 | 130 | --- 131 | 132 | (resource 133 | (section (identifier) 134 | (attribute (identifier) (string)) 135 | (property (path) 136 | (dictionary 137 | (pair (string) (true)))))) 138 | 139 | ===================================== 140 | Constructor Property 141 | ===================================== 142 | 143 | [id a=1.0] 144 | a = Constructor( 1 ) 145 | 146 | --- 147 | 148 | (resource 149 | (section 150 | (identifier) 151 | (attribute (identifier) (float)) 152 | (property (path) 153 | (constructor (identifier) 154 | (arguments (integer)))))) 155 | 156 | ===================================== 157 | Constructor Generic Type Arguments 158 | ===================================== 159 | 160 | [id] 161 | b = Constructor[TypeArg1]() 162 | c = Constructor[TypeArg1, TypeArgC(1)]("value") 163 | 164 | --- 165 | 166 | (resource 167 | (section (identifier) 168 | (property (path) 169 | (constructor 170 | (identifier) 171 | (identifier) 172 | (arguments))) 173 | (property (path) 174 | (constructor 175 | (identifier) 176 | (identifier) 177 | (constructor 178 | (identifier) 179 | (arguments (integer))) 180 | (arguments (string)))))) 181 | 182 | ===================================== 183 | Underscore Property 184 | ===================================== 185 | 186 | [id] 187 | __dict__ = { 188 | "a": true 189 | } 190 | 191 | --- 192 | 193 | (resource 194 | (section (identifier) 195 | (property (path) 196 | (dictionary 197 | (pair (string) (true)))))) 198 | 199 | 200 | ===================================== 201 | Object Constructor Property 202 | ===================================== 203 | 204 | [id] 205 | testObject = Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":79,"unicode":0,"echo":false,"script":null) 206 | 207 | --- 208 | 209 | (resource 210 | (section 211 | (identifier) 212 | (property 213 | (path) 214 | (constructor 215 | (identifier) 216 | (arguments 217 | (identifier) 218 | (pair 219 | (string) 220 | (false)) 221 | (pair 222 | (string) 223 | (string)) 224 | (pair 225 | (string) 226 | (integer)) 227 | (pair 228 | (string) 229 | (false)) 230 | (pair 231 | (string) 232 | (false)) 233 | (pair 234 | (string) 235 | (false)) 236 | (pair 237 | (string) 238 | (false)) 239 | (pair 240 | (string) 241 | (false)) 242 | (pair 243 | (string) 244 | (false)) 245 | (pair 246 | (string) 247 | (integer)) 248 | (pair 249 | (string) 250 | (integer)) 251 | (pair 252 | (string) 253 | (false)) 254 | (pair 255 | (string) 256 | (null))))))) 257 | -------------------------------------------------------------------------------- /examples/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ { 12 | "base": "Reference", 13 | "class": "CellInfo", 14 | "language": "GDScript", 15 | "path": "res://farm/cell_info.gd" 16 | }, { 17 | "base": "Resource", 18 | "class": "CellOrientation", 19 | "language": "GDScript", 20 | "path": "res://farm/cell_orientation.gd" 21 | }, { 22 | "base": "Reference", 23 | "class": "CellVariant", 24 | "language": "GDScript", 25 | "path": "res://farm/cell_variant.gd" 26 | }, { 27 | "base": "Node", 28 | "class": "Component", 29 | "language": "GDScript", 30 | "path": "res://entities/Component.gd" 31 | }, { 32 | "base": "Node", 33 | "class": "ComponentRegistration", 34 | "language": "GDScript", 35 | "path": "res://scripts/ComponentRegistration.gd" 36 | }, { 37 | "base": "Node", 38 | "class": "HealthNode", 39 | "language": "GDScript", 40 | "path": "res://entities/health.gd" 41 | }, { 42 | "base": "Reference", 43 | "class": "InventoryItem", 44 | "language": "GDScript", 45 | "path": "res://entities/player/inventory/inventory_item.gd" 46 | }, { 47 | "base": "TileMap", 48 | "class": "LandMap", 49 | "language": "GDScript", 50 | "path": "res://farm/land_map.gd" 51 | }, { 52 | "base": "Resource", 53 | "class": "MatrixRule", 54 | "language": "GDScript", 55 | "path": "res://farm/resources/sources/MatrixRule.gd" 56 | }, { 57 | "base": "Resource", 58 | "class": "MatrixRuleSet", 59 | "language": "GDScript", 60 | "path": "res://farm/resources/sources/MatrixRuleSet.gd" 61 | }, { 62 | "base": "Node", 63 | "class": "NodeStateMachine", 64 | "language": "GDScript", 65 | "path": "res://scripts/NodeStateMachine.gd" 66 | }, { 67 | "base": "Node", 68 | "class": "PivotRotator", 69 | "language": "GDScript", 70 | "path": "res://entities/player/pivot_rotator.gd" 71 | }, { 72 | "base": "Node2D", 73 | "class": "Plant", 74 | "language": "GDScript", 75 | "path": "res://botany/Plant.gd" 76 | }, { 77 | "base": "Node", 78 | "class": "stc", 79 | "language": "GDScript", 80 | "path": "res://scripts/static.gd" 81 | } ] 82 | _global_script_class_icons={ 83 | "CellInfo": "", 84 | "CellOrientation": "", 85 | "CellVariant": "", 86 | "Component": "", 87 | "ComponentRegistration": "", 88 | "HealthNode": "", 89 | "InventoryItem": "", 90 | "LandMap": "", 91 | "MatrixRule": "", 92 | "MatrixRuleSet": "", 93 | "NodeStateMachine": "", 94 | "PivotRotator": "", 95 | "Plant": "", 96 | "stc": "" 97 | } 98 | 99 | [application] 100 | 101 | config/name="Farmer Shooter" 102 | run/main_scene="res://main.tscn" 103 | config/icon="res://icon.png" 104 | 105 | [debug] 106 | 107 | gdscript/warnings/enable=false 108 | gdscript/warnings/unused_variable=false 109 | gdscript/warnings/unused_class_variable=false 110 | gdscript/warnings/unused_argument=false 111 | gdscript/warnings/narrowing_conversion=false 112 | gdscript/warnings/unused_signal=false 113 | 114 | [display] 115 | 116 | window/size/height=576 117 | window/stretch/mode="2d" 118 | 119 | [importer_defaults] 120 | 121 | texture={ 122 | "compress/bptc_ldr": 0, 123 | "compress/hdr_mode": 0, 124 | "compress/lossy_quality": 0.7, 125 | "compress/mode": 0, 126 | "compress/normal_map": 0, 127 | "detect_3d": false, 128 | "flags/anisotropic": false, 129 | "flags/filter": false, 130 | "flags/mipmaps": false, 131 | "flags/repeat": 0, 132 | "flags/srgb": 2, 133 | "process/HDR_as_SRGB": false, 134 | "process/fix_alpha_border": true, 135 | "process/invert_color": false, 136 | "process/premult_alpha": false, 137 | "size_limit": 0, 138 | "stream": false, 139 | "svg/scale": 1.0 140 | } 141 | ogg_vorbis={ 142 | "loop": false, 143 | "loop_offset": 0 144 | } 145 | 146 | [input] 147 | 148 | movement_left={ 149 | "deadzone": 0.5, 150 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null) 151 | ] 152 | } 153 | movement_right={ 154 | "deadzone": 0.5, 155 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null) 156 | ] 157 | } 158 | movement_up={ 159 | "deadzone": 0.5, 160 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":44,"unicode":0,"echo":false,"script":null) 161 | ] 162 | } 163 | movement_down={ 164 | "deadzone": 0.5, 165 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":79,"unicode":0,"echo":false,"script":null) 166 | ] 167 | } 168 | inventory_left={ 169 | "deadzone": 0.5, 170 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":39,"unicode":0,"echo":false,"script":null) 171 | ] 172 | } 173 | inventory_right={ 174 | "deadzone": 0.5, 175 | "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":46,"unicode":0,"echo":false,"script":null) 176 | ] 177 | } 178 | action={ 179 | "deadzone": 0.5, 180 | "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null) 181 | ] 182 | } 183 | 184 | [layer_names] 185 | 186 | 2d_physics/layer_1="player" 187 | 2d_physics/layer_2="enemies" 188 | 2d_physics/layer_3="farms" 189 | 2d_physics/layer_4="pickups" 190 | 191 | [rendering] 192 | 193 | environment/default_environment="res://default_env.tres" 194 | -------------------------------------------------------------------------------- /src/tree_sitter/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_SITTER_PARSER_H_ 2 | #define TREE_SITTER_PARSER_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define ts_builtin_sym_error ((TSSymbol)-1) 13 | #define ts_builtin_sym_end 0 14 | #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 15 | 16 | #ifndef TREE_SITTER_API_H_ 17 | typedef uint16_t TSStateId; 18 | typedef uint16_t TSSymbol; 19 | typedef uint16_t TSFieldId; 20 | typedef struct TSLanguage TSLanguage; 21 | #endif 22 | 23 | typedef struct { 24 | TSFieldId field_id; 25 | uint8_t child_index; 26 | bool inherited; 27 | } TSFieldMapEntry; 28 | 29 | typedef struct { 30 | uint16_t index; 31 | uint16_t length; 32 | } TSFieldMapSlice; 33 | 34 | typedef struct { 35 | bool visible; 36 | bool named; 37 | bool supertype; 38 | } TSSymbolMetadata; 39 | 40 | typedef struct TSLexer TSLexer; 41 | 42 | struct TSLexer { 43 | int32_t lookahead; 44 | TSSymbol result_symbol; 45 | void (*advance)(TSLexer *, bool); 46 | void (*mark_end)(TSLexer *); 47 | uint32_t (*get_column)(TSLexer *); 48 | bool (*is_at_included_range_start)(const TSLexer *); 49 | bool (*eof)(const TSLexer *); 50 | void (*log)(const TSLexer *, const char *, ...); 51 | }; 52 | 53 | typedef enum { 54 | TSParseActionTypeShift, 55 | TSParseActionTypeReduce, 56 | TSParseActionTypeAccept, 57 | TSParseActionTypeRecover, 58 | } TSParseActionType; 59 | 60 | typedef union { 61 | struct { 62 | uint8_t type; 63 | TSStateId state; 64 | bool extra; 65 | bool repetition; 66 | } shift; 67 | struct { 68 | uint8_t type; 69 | uint8_t child_count; 70 | TSSymbol symbol; 71 | int16_t dynamic_precedence; 72 | uint16_t production_id; 73 | } reduce; 74 | uint8_t type; 75 | } TSParseAction; 76 | 77 | typedef struct { 78 | uint16_t lex_state; 79 | uint16_t external_lex_state; 80 | } TSLexMode; 81 | 82 | typedef union { 83 | TSParseAction action; 84 | struct { 85 | uint8_t count; 86 | bool reusable; 87 | } entry; 88 | } TSParseActionEntry; 89 | 90 | typedef struct { 91 | int32_t start; 92 | int32_t end; 93 | } TSCharacterRange; 94 | 95 | struct TSLanguage { 96 | uint32_t version; 97 | uint32_t symbol_count; 98 | uint32_t alias_count; 99 | uint32_t token_count; 100 | uint32_t external_token_count; 101 | uint32_t state_count; 102 | uint32_t large_state_count; 103 | uint32_t production_id_count; 104 | uint32_t field_count; 105 | uint16_t max_alias_sequence_length; 106 | const uint16_t *parse_table; 107 | const uint16_t *small_parse_table; 108 | const uint32_t *small_parse_table_map; 109 | const TSParseActionEntry *parse_actions; 110 | const char * const *symbol_names; 111 | const char * const *field_names; 112 | const TSFieldMapSlice *field_map_slices; 113 | const TSFieldMapEntry *field_map_entries; 114 | const TSSymbolMetadata *symbol_metadata; 115 | const TSSymbol *public_symbol_map; 116 | const uint16_t *alias_map; 117 | const TSSymbol *alias_sequences; 118 | const TSLexMode *lex_modes; 119 | bool (*lex_fn)(TSLexer *, TSStateId); 120 | bool (*keyword_lex_fn)(TSLexer *, TSStateId); 121 | TSSymbol keyword_capture_token; 122 | struct { 123 | const bool *states; 124 | const TSSymbol *symbol_map; 125 | void *(*create)(void); 126 | void (*destroy)(void *); 127 | bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); 128 | unsigned (*serialize)(void *, char *); 129 | void (*deserialize)(void *, const char *, unsigned); 130 | } external_scanner; 131 | const TSStateId *primary_state_ids; 132 | }; 133 | 134 | static inline bool set_contains(TSCharacterRange *ranges, uint32_t len, int32_t lookahead) { 135 | uint32_t index = 0; 136 | uint32_t size = len - index; 137 | while (size > 1) { 138 | uint32_t half_size = size / 2; 139 | uint32_t mid_index = index + half_size; 140 | TSCharacterRange *range = &ranges[mid_index]; 141 | if (lookahead >= range->start && lookahead <= range->end) { 142 | return true; 143 | } else if (lookahead > range->end) { 144 | index = mid_index; 145 | } 146 | size -= half_size; 147 | } 148 | TSCharacterRange *range = &ranges[index]; 149 | return (lookahead >= range->start && lookahead <= range->end); 150 | } 151 | 152 | /* 153 | * Lexer Macros 154 | */ 155 | 156 | #ifdef _MSC_VER 157 | #define UNUSED __pragma(warning(suppress : 4101)) 158 | #else 159 | #define UNUSED __attribute__((unused)) 160 | #endif 161 | 162 | #define START_LEXER() \ 163 | bool result = false; \ 164 | bool skip = false; \ 165 | UNUSED \ 166 | bool eof = false; \ 167 | int32_t lookahead; \ 168 | goto start; \ 169 | next_state: \ 170 | lexer->advance(lexer, skip); \ 171 | start: \ 172 | skip = false; \ 173 | lookahead = lexer->lookahead; 174 | 175 | #define ADVANCE(state_value) \ 176 | { \ 177 | state = state_value; \ 178 | goto next_state; \ 179 | } 180 | 181 | #define ADVANCE_MAP(...) \ 182 | { \ 183 | static const uint16_t map[] = { __VA_ARGS__ }; \ 184 | for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \ 185 | if (map[i] == lookahead) { \ 186 | state = map[i + 1]; \ 187 | goto next_state; \ 188 | } \ 189 | } \ 190 | } 191 | 192 | #define SKIP(state_value) \ 193 | { \ 194 | skip = true; \ 195 | state = state_value; \ 196 | goto next_state; \ 197 | } 198 | 199 | #define ACCEPT_TOKEN(symbol_value) \ 200 | result = true; \ 201 | lexer->result_symbol = symbol_value; \ 202 | lexer->mark_end(lexer); 203 | 204 | #define END_STATE() return result; 205 | 206 | /* 207 | * Parse Table Macros 208 | */ 209 | 210 | #define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT) 211 | 212 | #define STATE(id) id 213 | 214 | #define ACTIONS(id) id 215 | 216 | #define SHIFT(state_value) \ 217 | {{ \ 218 | .shift = { \ 219 | .type = TSParseActionTypeShift, \ 220 | .state = (state_value) \ 221 | } \ 222 | }} 223 | 224 | #define SHIFT_REPEAT(state_value) \ 225 | {{ \ 226 | .shift = { \ 227 | .type = TSParseActionTypeShift, \ 228 | .state = (state_value), \ 229 | .repetition = true \ 230 | } \ 231 | }} 232 | 233 | #define SHIFT_EXTRA() \ 234 | {{ \ 235 | .shift = { \ 236 | .type = TSParseActionTypeShift, \ 237 | .extra = true \ 238 | } \ 239 | }} 240 | 241 | #define REDUCE(symbol_name, children, precedence, prod_id) \ 242 | {{ \ 243 | .reduce = { \ 244 | .type = TSParseActionTypeReduce, \ 245 | .symbol = symbol_name, \ 246 | .child_count = children, \ 247 | .dynamic_precedence = precedence, \ 248 | .production_id = prod_id \ 249 | }, \ 250 | }} 251 | 252 | #define RECOVER() \ 253 | {{ \ 254 | .type = TSParseActionTypeRecover \ 255 | }} 256 | 257 | #define ACCEPT_INPUT() \ 258 | {{ \ 259 | .type = TSParseActionTypeAccept \ 260 | }} 261 | 262 | #ifdef __cplusplus 263 | } 264 | #endif 265 | 266 | #endif // TREE_SITTER_PARSER_H_ 267 | -------------------------------------------------------------------------------- /examples/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=10 format=2] 2 | 3 | [ext_resource path="res://scripts/NodeStateMachine.gd" type="Script" id=1] 4 | [ext_resource path="res://phases/farming_phase.gd" type="Script" id=2] 5 | [ext_resource path="res://phases/defending_phase.gd" type="Script" id=3] 6 | [ext_resource path="res://phases/spawner.gd" type="Script" id=4] 7 | [ext_resource path="res://entities/enemy/enemy.tscn" type="PackedScene" id=5] 8 | [ext_resource path="res://phases/upgrading_phase.gd" type="Script" id=6] 9 | [ext_resource path="res://farm/farm.tscn" type="PackedScene" id=7] 10 | [ext_resource path="res://entities/player/player.tscn" type="PackedScene" id=8] 11 | [ext_resource path="res://forest_ambiance.ogg" type="AudioStream" id=9] 12 | 13 | [node name="main" type="Node"] 14 | 15 | [node name="game" type="Node2D" parent="."] 16 | __meta__ = { 17 | "_edit_lock_": true 18 | } 19 | 20 | [node name="phases" type="Node" parent="game"] 21 | script = ExtResource( 1 ) 22 | starting_state = 0 23 | 24 | [node name="farming" type="Node" parent="game/phases"] 25 | editor/display_folded = true 26 | script = ExtResource( 2 ) 27 | 28 | [node name="farming_label" type="Label" parent="game/phases/farming"] 29 | visible = false 30 | anchor_left = 0.0 31 | anchor_top = 0.0 32 | anchor_right = 0.0 33 | anchor_bottom = 0.0 34 | margin_right = 63.0 35 | margin_bottom = 14.0 36 | rect_pivot_offset = Vector2( 0, 0 ) 37 | rect_clip_content = false 38 | mouse_filter = 2 39 | mouse_default_cursor_shape = 0 40 | size_flags_horizontal = 1 41 | size_flags_vertical = 4 42 | text = "farming" 43 | percent_visible = 1.0 44 | lines_skipped = 0 45 | max_lines_visible = -1 46 | 47 | [node name="ProgressBar" type="ProgressBar" parent="game/phases/farming"] 48 | visible = false 49 | anchor_left = 0.0 50 | anchor_top = 0.0 51 | anchor_right = 0.0 52 | anchor_bottom = 0.0 53 | margin_left = 1.0 54 | margin_top = 19.0 55 | margin_right = 237.0 56 | margin_bottom = 33.0 57 | rect_pivot_offset = Vector2( 0, 0 ) 58 | rect_clip_content = false 59 | mouse_filter = 0 60 | mouse_default_cursor_shape = 0 61 | size_flags_horizontal = 1 62 | size_flags_vertical = 0 63 | min_value = 0.0 64 | max_value = 5.0 65 | step = 0.0 66 | page = 0.0 67 | value = 0.0 68 | exp_edit = false 69 | rounded = false 70 | allow_greater = false 71 | allow_lesser = false 72 | percent_visible = true 73 | 74 | [node name="defending" type="Node" parent="game/phases"] 75 | editor/display_folded = true 76 | script = ExtResource( 3 ) 77 | 78 | [node name="defending_label" type="Label" parent="game/phases/defending"] 79 | visible = false 80 | anchor_left = 0.0 81 | anchor_top = 0.0 82 | anchor_right = 0.0 83 | anchor_bottom = 0.0 84 | margin_right = 40.0 85 | margin_bottom = 14.0 86 | rect_pivot_offset = Vector2( 0, 0 ) 87 | rect_clip_content = false 88 | mouse_filter = 2 89 | mouse_default_cursor_shape = 0 90 | size_flags_horizontal = 1 91 | size_flags_vertical = 4 92 | text = "defending" 93 | percent_visible = 1.0 94 | lines_skipped = 0 95 | max_lines_visible = -1 96 | 97 | [node name="spawner" type="Node" parent="game/phases/defending"] 98 | script = ExtResource( 4 ) 99 | count = 20 100 | over_time = 20.0 101 | enemy_scene = ExtResource( 5 ) 102 | 103 | [node name="spawn_timer" type="Timer" parent="game/phases/defending/spawner"] 104 | process_mode = 1 105 | wait_time = 1.0 106 | one_shot = true 107 | autostart = false 108 | 109 | [node name="upgrading" type="Node" parent="game/phases"] 110 | editor/display_folded = true 111 | script = ExtResource( 6 ) 112 | 113 | [node name="CanvasLayer" type="CanvasLayer" parent="game/phases/upgrading"] 114 | layer = 1 115 | offset = Vector2( 0, 0 ) 116 | rotation = 0.0 117 | scale = Vector2( 1, 1 ) 118 | transform = Transform2D( 1, 0, 0, 1, 0, 0 ) 119 | 120 | [node name="upgrading_label" type="Label" parent="game/phases/upgrading/CanvasLayer"] 121 | visible = false 122 | anchor_left = 0.0 123 | anchor_top = 0.0 124 | anchor_right = 0.0 125 | anchor_bottom = 0.0 126 | margin_right = 63.0 127 | margin_bottom = 14.0 128 | rect_pivot_offset = Vector2( 0, 0 ) 129 | rect_clip_content = false 130 | mouse_filter = 2 131 | mouse_default_cursor_shape = 0 132 | size_flags_horizontal = 1 133 | size_flags_vertical = 4 134 | text = "upgrading" 135 | percent_visible = 1.0 136 | lines_skipped = 0 137 | max_lines_visible = -1 138 | 139 | [node name="upgrade_dialog" type="AcceptDialog" parent="game/phases/upgrading/CanvasLayer"] 140 | visible = false 141 | anchor_left = 0.0 142 | anchor_top = 0.0 143 | anchor_right = 1.0 144 | anchor_bottom = 1.0 145 | margin_left = 20.0 146 | margin_top = 40.0 147 | margin_right = -20.0 148 | margin_bottom = -20.0 149 | rect_pivot_offset = Vector2( 0, 0 ) 150 | rect_clip_content = false 151 | mouse_filter = 0 152 | mouse_default_cursor_shape = 0 153 | size_flags_horizontal = 1 154 | size_flags_vertical = 1 155 | popup_exclusive = false 156 | window_title = "Upgrade" 157 | resizable = false 158 | dialog_hide_on_ok = true 159 | 160 | [node name="VBoxContainer" type="VBoxContainer" parent="game/phases/upgrading/CanvasLayer/upgrade_dialog"] 161 | anchor_left = 0.0 162 | anchor_top = 0.0 163 | anchor_right = 0.0 164 | anchor_bottom = 0.0 165 | margin_left = 8.0 166 | margin_top = 8.0 167 | margin_right = 976.0 168 | margin_bottom = 480.0 169 | rect_pivot_offset = Vector2( 0, 0 ) 170 | rect_clip_content = false 171 | mouse_filter = 1 172 | mouse_default_cursor_shape = 0 173 | size_flags_horizontal = 1 174 | size_flags_vertical = 1 175 | alignment = 0 176 | 177 | [node name="upgrade_plot_butt" type="Button" parent="game/phases/upgrading/CanvasLayer/upgrade_dialog/VBoxContainer"] 178 | anchor_left = 0.0 179 | anchor_top = 0.0 180 | anchor_right = 0.0 181 | anchor_bottom = 0.0 182 | margin_right = 968.0 183 | margin_bottom = 20.0 184 | rect_pivot_offset = Vector2( 0, 0 ) 185 | rect_clip_content = false 186 | focus_mode = 2 187 | mouse_filter = 0 188 | mouse_default_cursor_shape = 0 189 | size_flags_horizontal = 1 190 | size_flags_vertical = 1 191 | toggle_mode = false 192 | enabled_focus_mode = 2 193 | shortcut = null 194 | group = null 195 | text = "upgrade plot" 196 | flat = false 197 | align = 1 198 | 199 | [node name="buy_seeds_butt" type="Button" parent="game/phases/upgrading/CanvasLayer/upgrade_dialog/VBoxContainer"] 200 | anchor_left = 0.0 201 | anchor_top = 0.0 202 | anchor_right = 0.0 203 | anchor_bottom = 0.0 204 | margin_top = 24.0 205 | margin_right = 968.0 206 | margin_bottom = 44.0 207 | rect_pivot_offset = Vector2( 0, 0 ) 208 | rect_clip_content = false 209 | focus_mode = 2 210 | mouse_filter = 0 211 | mouse_default_cursor_shape = 0 212 | size_flags_horizontal = 1 213 | size_flags_vertical = 1 214 | toggle_mode = false 215 | enabled_focus_mode = 2 216 | shortcut = null 217 | group = null 218 | text = "buy seeds" 219 | flat = false 220 | align = 1 221 | 222 | [node name="farm" parent="game" instance=ExtResource( 7 )] 223 | 224 | [node name="player" parent="game" instance=ExtResource( 8 )] 225 | position = Vector2( 532.068, 267.483 ) 226 | 227 | [node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="game"] 228 | stream = ExtResource( 9 ) 229 | volume_db = 0.0 230 | pitch_scale = 1.0 231 | autoplay = true 232 | stream_paused = false 233 | mix_target = 0 234 | bus = "Master" 235 | 236 | [connection signal="entered" from="game/phases/farming" to="game/phases/farming/ProgressBar" method="show"] 237 | [connection signal="entered" from="game/phases/farming" to="game/phases/farming/farming_label" method="show"] 238 | [connection signal="exited" from="game/phases/farming" to="game/phases/farming/ProgressBar" method="hide"] 239 | [connection signal="exited" from="game/phases/farming" to="game/phases/farming/farming_label" method="hide"] 240 | [connection signal="entered" from="game/phases/defending" to="game/phases/defending/defending_label" method="show"] 241 | [connection signal="exited" from="game/phases/defending" to="game/phases/defending/defending_label" method="hide"] 242 | [connection signal="spawns_dead" from="game/phases/defending/spawner" to="game/phases/defending" method="_on_spawner_spawns_dead"] 243 | [connection signal="timeout" from="game/phases/defending/spawner/spawn_timer" to="game/phases/defending/spawner" method="_on_spawn_timer_timeout"] 244 | [connection signal="entered" from="game/phases/upgrading" to="game/phases/upgrading/CanvasLayer/upgrading_label" method="show"] 245 | [connection signal="entered" from="game/phases/upgrading" to="game/phases/upgrading/CanvasLayer/upgrade_dialog" method="popup_centered"] 246 | [connection signal="exited" from="game/phases/upgrading" to="game/phases/upgrading/CanvasLayer/upgrading_label" method="hide"] 247 | [connection signal="confirmed" from="game/phases/upgrading/CanvasLayer/upgrade_dialog" to="game/phases/upgrading" method="_on_AcceptDialog_confirmed"] 248 | [connection signal="pressed" from="game/phases/upgrading/CanvasLayer/upgrade_dialog/VBoxContainer/upgrade_plot_butt" to="game/phases/upgrading" method="_on_upgrade_plot_butt_pressed"] 249 | [connection signal="pressed" from="game/phases/upgrading/CanvasLayer/upgrade_dialog/VBoxContainer/upgrade_plot_butt" to="game/farm" method="upgrade_plot"] 250 | [connection signal="pressed" from="game/phases/upgrading/CanvasLayer/upgrade_dialog/VBoxContainer/buy_seeds_butt" to="game/phases/upgrading" method="_on_buy_seeds_butt_pressed"] 251 | -------------------------------------------------------------------------------- /src/node-types.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "arguments", 4 | "named": true, 5 | "fields": {}, 6 | "children": { 7 | "multiple": true, 8 | "required": false, 9 | "types": [ 10 | { 11 | "type": "array", 12 | "named": true 13 | }, 14 | { 15 | "type": "constructor", 16 | "named": true 17 | }, 18 | { 19 | "type": "dictionary", 20 | "named": true 21 | }, 22 | { 23 | "type": "false", 24 | "named": true 25 | }, 26 | { 27 | "type": "float", 28 | "named": true 29 | }, 30 | { 31 | "type": "identifier", 32 | "named": true 33 | }, 34 | { 35 | "type": "integer", 36 | "named": true 37 | }, 38 | { 39 | "type": "null", 40 | "named": true 41 | }, 42 | { 43 | "type": "pair", 44 | "named": true 45 | }, 46 | { 47 | "type": "string", 48 | "named": true 49 | }, 50 | { 51 | "type": "string_name", 52 | "named": true 53 | }, 54 | { 55 | "type": "true", 56 | "named": true 57 | } 58 | ] 59 | } 60 | }, 61 | { 62 | "type": "array", 63 | "named": true, 64 | "fields": {}, 65 | "children": { 66 | "multiple": true, 67 | "required": false, 68 | "types": [ 69 | { 70 | "type": "array", 71 | "named": true 72 | }, 73 | { 74 | "type": "constructor", 75 | "named": true 76 | }, 77 | { 78 | "type": "dictionary", 79 | "named": true 80 | }, 81 | { 82 | "type": "false", 83 | "named": true 84 | }, 85 | { 86 | "type": "float", 87 | "named": true 88 | }, 89 | { 90 | "type": "identifier", 91 | "named": true 92 | }, 93 | { 94 | "type": "integer", 95 | "named": true 96 | }, 97 | { 98 | "type": "null", 99 | "named": true 100 | }, 101 | { 102 | "type": "string", 103 | "named": true 104 | }, 105 | { 106 | "type": "string_name", 107 | "named": true 108 | }, 109 | { 110 | "type": "true", 111 | "named": true 112 | } 113 | ] 114 | } 115 | }, 116 | { 117 | "type": "attribute", 118 | "named": true, 119 | "fields": {}, 120 | "children": { 121 | "multiple": true, 122 | "required": true, 123 | "types": [ 124 | { 125 | "type": "array", 126 | "named": true 127 | }, 128 | { 129 | "type": "constructor", 130 | "named": true 131 | }, 132 | { 133 | "type": "dictionary", 134 | "named": true 135 | }, 136 | { 137 | "type": "false", 138 | "named": true 139 | }, 140 | { 141 | "type": "float", 142 | "named": true 143 | }, 144 | { 145 | "type": "identifier", 146 | "named": true 147 | }, 148 | { 149 | "type": "integer", 150 | "named": true 151 | }, 152 | { 153 | "type": "null", 154 | "named": true 155 | }, 156 | { 157 | "type": "string", 158 | "named": true 159 | }, 160 | { 161 | "type": "string_name", 162 | "named": true 163 | }, 164 | { 165 | "type": "true", 166 | "named": true 167 | } 168 | ] 169 | } 170 | }, 171 | { 172 | "type": "constructor", 173 | "named": true, 174 | "fields": {}, 175 | "children": { 176 | "multiple": true, 177 | "required": true, 178 | "types": [ 179 | { 180 | "type": "arguments", 181 | "named": true 182 | }, 183 | { 184 | "type": "array", 185 | "named": true 186 | }, 187 | { 188 | "type": "constructor", 189 | "named": true 190 | }, 191 | { 192 | "type": "dictionary", 193 | "named": true 194 | }, 195 | { 196 | "type": "false", 197 | "named": true 198 | }, 199 | { 200 | "type": "float", 201 | "named": true 202 | }, 203 | { 204 | "type": "identifier", 205 | "named": true 206 | }, 207 | { 208 | "type": "integer", 209 | "named": true 210 | }, 211 | { 212 | "type": "null", 213 | "named": true 214 | }, 215 | { 216 | "type": "string", 217 | "named": true 218 | }, 219 | { 220 | "type": "string_name", 221 | "named": true 222 | }, 223 | { 224 | "type": "true", 225 | "named": true 226 | } 227 | ] 228 | } 229 | }, 230 | { 231 | "type": "dictionary", 232 | "named": true, 233 | "fields": {}, 234 | "children": { 235 | "multiple": true, 236 | "required": false, 237 | "types": [ 238 | { 239 | "type": "pair", 240 | "named": true 241 | } 242 | ] 243 | } 244 | }, 245 | { 246 | "type": "identifier", 247 | "named": true, 248 | "fields": {} 249 | }, 250 | { 251 | "type": "pair", 252 | "named": true, 253 | "fields": {}, 254 | "children": { 255 | "multiple": true, 256 | "required": true, 257 | "types": [ 258 | { 259 | "type": "array", 260 | "named": true 261 | }, 262 | { 263 | "type": "constructor", 264 | "named": true 265 | }, 266 | { 267 | "type": "dictionary", 268 | "named": true 269 | }, 270 | { 271 | "type": "false", 272 | "named": true 273 | }, 274 | { 275 | "type": "float", 276 | "named": true 277 | }, 278 | { 279 | "type": "identifier", 280 | "named": true 281 | }, 282 | { 283 | "type": "integer", 284 | "named": true 285 | }, 286 | { 287 | "type": "null", 288 | "named": true 289 | }, 290 | { 291 | "type": "string", 292 | "named": true 293 | }, 294 | { 295 | "type": "string_name", 296 | "named": true 297 | }, 298 | { 299 | "type": "true", 300 | "named": true 301 | } 302 | ] 303 | } 304 | }, 305 | { 306 | "type": "property", 307 | "named": true, 308 | "fields": {}, 309 | "children": { 310 | "multiple": true, 311 | "required": true, 312 | "types": [ 313 | { 314 | "type": "array", 315 | "named": true 316 | }, 317 | { 318 | "type": "constructor", 319 | "named": true 320 | }, 321 | { 322 | "type": "dictionary", 323 | "named": true 324 | }, 325 | { 326 | "type": "false", 327 | "named": true 328 | }, 329 | { 330 | "type": "float", 331 | "named": true 332 | }, 333 | { 334 | "type": "identifier", 335 | "named": true 336 | }, 337 | { 338 | "type": "integer", 339 | "named": true 340 | }, 341 | { 342 | "type": "null", 343 | "named": true 344 | }, 345 | { 346 | "type": "path", 347 | "named": true 348 | }, 349 | { 350 | "type": "string", 351 | "named": true 352 | }, 353 | { 354 | "type": "string_name", 355 | "named": true 356 | }, 357 | { 358 | "type": "true", 359 | "named": true 360 | } 361 | ] 362 | } 363 | }, 364 | { 365 | "type": "resource", 366 | "named": true, 367 | "root": true, 368 | "fields": {}, 369 | "children": { 370 | "multiple": true, 371 | "required": false, 372 | "types": [ 373 | { 374 | "type": "property", 375 | "named": true 376 | }, 377 | { 378 | "type": "section", 379 | "named": true 380 | } 381 | ] 382 | } 383 | }, 384 | { 385 | "type": "section", 386 | "named": true, 387 | "fields": {}, 388 | "children": { 389 | "multiple": true, 390 | "required": true, 391 | "types": [ 392 | { 393 | "type": "attribute", 394 | "named": true 395 | }, 396 | { 397 | "type": "identifier", 398 | "named": true 399 | }, 400 | { 401 | "type": "property", 402 | "named": true 403 | } 404 | ] 405 | } 406 | }, 407 | { 408 | "type": "string_name", 409 | "named": true, 410 | "fields": {} 411 | }, 412 | { 413 | "type": "&", 414 | "named": false 415 | }, 416 | { 417 | "type": "(", 418 | "named": false 419 | }, 420 | { 421 | "type": ")", 422 | "named": false 423 | }, 424 | { 425 | "type": ",", 426 | "named": false 427 | }, 428 | { 429 | "type": ":", 430 | "named": false 431 | }, 432 | { 433 | "type": "=", 434 | "named": false 435 | }, 436 | { 437 | "type": "[", 438 | "named": false 439 | }, 440 | { 441 | "type": "]", 442 | "named": false 443 | }, 444 | { 445 | "type": "comment", 446 | "named": true 447 | }, 448 | { 449 | "type": "false", 450 | "named": true 451 | }, 452 | { 453 | "type": "float", 454 | "named": true 455 | }, 456 | { 457 | "type": "integer", 458 | "named": true 459 | }, 460 | { 461 | "type": "null", 462 | "named": true 463 | }, 464 | { 465 | "type": "path", 466 | "named": true 467 | }, 468 | { 469 | "type": "string", 470 | "named": true 471 | }, 472 | { 473 | "type": "string", 474 | "named": false 475 | }, 476 | { 477 | "type": "true", 478 | "named": true 479 | }, 480 | { 481 | "type": "{", 482 | "named": false 483 | }, 484 | { 485 | "type": "}", 486 | "named": false 487 | } 488 | ] -------------------------------------------------------------------------------- /src/tree_sitter/array.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_SITTER_ARRAY_H_ 2 | #define TREE_SITTER_ARRAY_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "./alloc.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef _MSC_VER 17 | #pragma warning(push) 18 | #pragma warning(disable : 4101) 19 | #elif defined(__GNUC__) || defined(__clang__) 20 | #pragma GCC diagnostic push 21 | #pragma GCC diagnostic ignored "-Wunused-variable" 22 | #endif 23 | 24 | #define Array(T) \ 25 | struct { \ 26 | T *contents; \ 27 | uint32_t size; \ 28 | uint32_t capacity; \ 29 | } 30 | 31 | /// Initialize an array. 32 | #define array_init(self) \ 33 | ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL) 34 | 35 | /// Create an empty array. 36 | #define array_new() \ 37 | { NULL, 0, 0 } 38 | 39 | /// Get a pointer to the element at a given `index` in the array. 40 | #define array_get(self, _index) \ 41 | (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index]) 42 | 43 | /// Get a pointer to the first element in the array. 44 | #define array_front(self) array_get(self, 0) 45 | 46 | /// Get a pointer to the last element in the array. 47 | #define array_back(self) array_get(self, (self)->size - 1) 48 | 49 | /// Clear the array, setting its size to zero. Note that this does not free any 50 | /// memory allocated for the array's contents. 51 | #define array_clear(self) ((self)->size = 0) 52 | 53 | /// Reserve `new_capacity` elements of space in the array. If `new_capacity` is 54 | /// less than the array's current capacity, this function has no effect. 55 | #define array_reserve(self, new_capacity) \ 56 | _array__reserve((Array *)(self), array_elem_size(self), new_capacity) 57 | 58 | /// Free any memory allocated for this array. Note that this does not free any 59 | /// memory allocated for the array's contents. 60 | #define array_delete(self) _array__delete((Array *)(self)) 61 | 62 | /// Push a new `element` onto the end of the array. 63 | #define array_push(self, element) \ 64 | (_array__grow((Array *)(self), 1, array_elem_size(self)), \ 65 | (self)->contents[(self)->size++] = (element)) 66 | 67 | /// Increase the array's size by `count` elements. 68 | /// New elements are zero-initialized. 69 | #define array_grow_by(self, count) \ 70 | do { \ 71 | if ((count) == 0) break; \ 72 | _array__grow((Array *)(self), count, array_elem_size(self)); \ 73 | memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \ 74 | (self)->size += (count); \ 75 | } while (0) 76 | 77 | /// Append all elements from one array to the end of another. 78 | #define array_push_all(self, other) \ 79 | array_extend((self), (other)->size, (other)->contents) 80 | 81 | /// Append `count` elements to the end of the array, reading their values from the 82 | /// `contents` pointer. 83 | #define array_extend(self, count, contents) \ 84 | _array__splice( \ 85 | (Array *)(self), array_elem_size(self), (self)->size, \ 86 | 0, count, contents \ 87 | ) 88 | 89 | /// Remove `old_count` elements from the array starting at the given `index`. At 90 | /// the same index, insert `new_count` new elements, reading their values from the 91 | /// `new_contents` pointer. 92 | #define array_splice(self, _index, old_count, new_count, new_contents) \ 93 | _array__splice( \ 94 | (Array *)(self), array_elem_size(self), _index, \ 95 | old_count, new_count, new_contents \ 96 | ) 97 | 98 | /// Insert one `element` into the array at the given `index`. 99 | #define array_insert(self, _index, element) \ 100 | _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element)) 101 | 102 | /// Remove one element from the array at the given `index`. 103 | #define array_erase(self, _index) \ 104 | _array__erase((Array *)(self), array_elem_size(self), _index) 105 | 106 | /// Pop the last element off the array, returning the element by value. 107 | #define array_pop(self) ((self)->contents[--(self)->size]) 108 | 109 | /// Assign the contents of one array to another, reallocating if necessary. 110 | #define array_assign(self, other) \ 111 | _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self)) 112 | 113 | /// Swap one array with another 114 | #define array_swap(self, other) \ 115 | _array__swap((Array *)(self), (Array *)(other)) 116 | 117 | /// Get the size of the array contents 118 | #define array_elem_size(self) (sizeof *(self)->contents) 119 | 120 | /// Search a sorted array for a given `needle` value, using the given `compare` 121 | /// callback to determine the order. 122 | /// 123 | /// If an existing element is found to be equal to `needle`, then the `index` 124 | /// out-parameter is set to the existing value's index, and the `exists` 125 | /// out-parameter is set to true. Otherwise, `index` is set to an index where 126 | /// `needle` should be inserted in order to preserve the sorting, and `exists` 127 | /// is set to false. 128 | #define array_search_sorted_with(self, compare, needle, _index, _exists) \ 129 | _array__search_sorted(self, 0, compare, , needle, _index, _exists) 130 | 131 | /// Search a sorted array for a given `needle` value, using integer comparisons 132 | /// of a given struct field (specified with a leading dot) to determine the order. 133 | /// 134 | /// See also `array_search_sorted_with`. 135 | #define array_search_sorted_by(self, field, needle, _index, _exists) \ 136 | _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists) 137 | 138 | /// Insert a given `value` into a sorted array, using the given `compare` 139 | /// callback to determine the order. 140 | #define array_insert_sorted_with(self, compare, value) \ 141 | do { \ 142 | unsigned _index, _exists; \ 143 | array_search_sorted_with(self, compare, &(value), &_index, &_exists); \ 144 | if (!_exists) array_insert(self, _index, value); \ 145 | } while (0) 146 | 147 | /// Insert a given `value` into a sorted array, using integer comparisons of 148 | /// a given struct field (specified with a leading dot) to determine the order. 149 | /// 150 | /// See also `array_search_sorted_by`. 151 | #define array_insert_sorted_by(self, field, value) \ 152 | do { \ 153 | unsigned _index, _exists; \ 154 | array_search_sorted_by(self, field, (value) field, &_index, &_exists); \ 155 | if (!_exists) array_insert(self, _index, value); \ 156 | } while (0) 157 | 158 | // Private 159 | 160 | typedef Array(void) Array; 161 | 162 | /// This is not what you're looking for, see `array_delete`. 163 | static inline void _array__delete(Array *self) { 164 | if (self->contents) { 165 | ts_free(self->contents); 166 | self->contents = NULL; 167 | self->size = 0; 168 | self->capacity = 0; 169 | } 170 | } 171 | 172 | /// This is not what you're looking for, see `array_erase`. 173 | static inline void _array__erase(Array *self, size_t element_size, 174 | uint32_t index) { 175 | assert(index < self->size); 176 | char *contents = (char *)self->contents; 177 | memmove(contents + index * element_size, contents + (index + 1) * element_size, 178 | (self->size - index - 1) * element_size); 179 | self->size--; 180 | } 181 | 182 | /// This is not what you're looking for, see `array_reserve`. 183 | static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) { 184 | if (new_capacity > self->capacity) { 185 | if (self->contents) { 186 | self->contents = ts_realloc(self->contents, new_capacity * element_size); 187 | } else { 188 | self->contents = ts_malloc(new_capacity * element_size); 189 | } 190 | self->capacity = new_capacity; 191 | } 192 | } 193 | 194 | /// This is not what you're looking for, see `array_assign`. 195 | static inline void _array__assign(Array *self, const Array *other, size_t element_size) { 196 | _array__reserve(self, element_size, other->size); 197 | self->size = other->size; 198 | memcpy(self->contents, other->contents, self->size * element_size); 199 | } 200 | 201 | /// This is not what you're looking for, see `array_swap`. 202 | static inline void _array__swap(Array *self, Array *other) { 203 | Array swap = *other; 204 | *other = *self; 205 | *self = swap; 206 | } 207 | 208 | /// This is not what you're looking for, see `array_push` or `array_grow_by`. 209 | static inline void _array__grow(Array *self, uint32_t count, size_t element_size) { 210 | uint32_t new_size = self->size + count; 211 | if (new_size > self->capacity) { 212 | uint32_t new_capacity = self->capacity * 2; 213 | if (new_capacity < 8) new_capacity = 8; 214 | if (new_capacity < new_size) new_capacity = new_size; 215 | _array__reserve(self, element_size, new_capacity); 216 | } 217 | } 218 | 219 | /// This is not what you're looking for, see `array_splice`. 220 | static inline void _array__splice(Array *self, size_t element_size, 221 | uint32_t index, uint32_t old_count, 222 | uint32_t new_count, const void *elements) { 223 | uint32_t new_size = self->size + new_count - old_count; 224 | uint32_t old_end = index + old_count; 225 | uint32_t new_end = index + new_count; 226 | assert(old_end <= self->size); 227 | 228 | _array__reserve(self, element_size, new_size); 229 | 230 | char *contents = (char *)self->contents; 231 | if (self->size > old_end) { 232 | memmove( 233 | contents + new_end * element_size, 234 | contents + old_end * element_size, 235 | (self->size - old_end) * element_size 236 | ); 237 | } 238 | if (new_count > 0) { 239 | if (elements) { 240 | memcpy( 241 | (contents + index * element_size), 242 | elements, 243 | new_count * element_size 244 | ); 245 | } else { 246 | memset( 247 | (contents + index * element_size), 248 | 0, 249 | new_count * element_size 250 | ); 251 | } 252 | } 253 | self->size += new_count - old_count; 254 | } 255 | 256 | /// A binary search routine, based on Rust's `std::slice::binary_search_by`. 257 | /// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`. 258 | #define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \ 259 | do { \ 260 | *(_index) = start; \ 261 | *(_exists) = false; \ 262 | uint32_t size = (self)->size - *(_index); \ 263 | if (size == 0) break; \ 264 | int comparison; \ 265 | while (size > 1) { \ 266 | uint32_t half_size = size / 2; \ 267 | uint32_t mid_index = *(_index) + half_size; \ 268 | comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \ 269 | if (comparison <= 0) *(_index) = mid_index; \ 270 | size -= half_size; \ 271 | } \ 272 | comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \ 273 | if (comparison == 0) *(_exists) = true; \ 274 | else if (comparison < 0) *(_index) += 1; \ 275 | } while (0) 276 | 277 | /// Helper macro for the `_sorted_by` routines below. This takes the left (existing) 278 | /// parameter by reference in order to work with the generic sorting function above. 279 | #define _compare_int(a, b) ((int)*(a) - (int)(b)) 280 | 281 | #ifdef _MSC_VER 282 | #pragma warning(pop) 283 | #elif defined(__GNUC__) || defined(__clang__) 284 | #pragma GCC diagnostic pop 285 | #endif 286 | 287 | #ifdef __cplusplus 288 | } 289 | #endif 290 | 291 | #endif // TREE_SITTER_ARRAY_H_ 292 | -------------------------------------------------------------------------------- /src/grammar.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json", 3 | "name": "godot_resource", 4 | "word": "_identifier", 5 | "rules": { 6 | "resource": { 7 | "type": "SEQ", 8 | "members": [ 9 | { 10 | "type": "REPEAT", 11 | "content": { 12 | "type": "SYMBOL", 13 | "name": "property" 14 | } 15 | }, 16 | { 17 | "type": "REPEAT", 18 | "content": { 19 | "type": "SYMBOL", 20 | "name": "section" 21 | } 22 | } 23 | ] 24 | }, 25 | "_identifier": { 26 | "type": "PATTERN", 27 | "value": "[a-zA-Z_][a-zA-Z_0-9]*" 28 | }, 29 | "identifier": { 30 | "type": "SYMBOL", 31 | "name": "_identifier" 32 | }, 33 | "comment": { 34 | "type": "TOKEN", 35 | "content": { 36 | "type": "SEQ", 37 | "members": [ 38 | { 39 | "type": "STRING", 40 | "value": ";" 41 | }, 42 | { 43 | "type": "PATTERN", 44 | "value": ".*" 45 | } 46 | ] 47 | } 48 | }, 49 | "true": { 50 | "type": "STRING", 51 | "value": "true" 52 | }, 53 | "false": { 54 | "type": "STRING", 55 | "value": "false" 56 | }, 57 | "null": { 58 | "type": "STRING", 59 | "value": "null" 60 | }, 61 | "float": { 62 | "type": "TOKEN", 63 | "content": { 64 | "type": "CHOICE", 65 | "members": [ 66 | { 67 | "type": "SEQ", 68 | "members": [ 69 | { 70 | "type": "REPEAT1", 71 | "content": { 72 | "type": "PATTERN", 73 | "value": "-?[0-9]+_?" 74 | } 75 | }, 76 | { 77 | "type": "STRING", 78 | "value": "." 79 | }, 80 | { 81 | "type": "CHOICE", 82 | "members": [ 83 | { 84 | "type": "REPEAT1", 85 | "content": { 86 | "type": "PATTERN", 87 | "value": "-?[0-9]+_?" 88 | } 89 | }, 90 | { 91 | "type": "BLANK" 92 | } 93 | ] 94 | }, 95 | { 96 | "type": "CHOICE", 97 | "members": [ 98 | { 99 | "type": "SEQ", 100 | "members": [ 101 | { 102 | "type": "PATTERN", 103 | "value": "[eE][\\+-]?" 104 | }, 105 | { 106 | "type": "REPEAT1", 107 | "content": { 108 | "type": "PATTERN", 109 | "value": "-?[0-9]+_?" 110 | } 111 | } 112 | ] 113 | }, 114 | { 115 | "type": "BLANK" 116 | } 117 | ] 118 | } 119 | ] 120 | }, 121 | { 122 | "type": "SEQ", 123 | "members": [ 124 | { 125 | "type": "CHOICE", 126 | "members": [ 127 | { 128 | "type": "REPEAT1", 129 | "content": { 130 | "type": "PATTERN", 131 | "value": "-?[0-9]+_?" 132 | } 133 | }, 134 | { 135 | "type": "BLANK" 136 | } 137 | ] 138 | }, 139 | { 140 | "type": "STRING", 141 | "value": "." 142 | }, 143 | { 144 | "type": "REPEAT1", 145 | "content": { 146 | "type": "PATTERN", 147 | "value": "-?[0-9]+_?" 148 | } 149 | }, 150 | { 151 | "type": "CHOICE", 152 | "members": [ 153 | { 154 | "type": "SEQ", 155 | "members": [ 156 | { 157 | "type": "PATTERN", 158 | "value": "[eE][\\+-]?" 159 | }, 160 | { 161 | "type": "REPEAT1", 162 | "content": { 163 | "type": "PATTERN", 164 | "value": "-?[0-9]+_?" 165 | } 166 | } 167 | ] 168 | }, 169 | { 170 | "type": "BLANK" 171 | } 172 | ] 173 | } 174 | ] 175 | }, 176 | { 177 | "type": "SEQ", 178 | "members": [ 179 | { 180 | "type": "REPEAT1", 181 | "content": { 182 | "type": "PATTERN", 183 | "value": "-?[0-9]+_?" 184 | } 185 | }, 186 | { 187 | "type": "SEQ", 188 | "members": [ 189 | { 190 | "type": "PATTERN", 191 | "value": "[eE][\\+-]?" 192 | }, 193 | { 194 | "type": "REPEAT1", 195 | "content": { 196 | "type": "PATTERN", 197 | "value": "-?[0-9]+_?" 198 | } 199 | } 200 | ] 201 | } 202 | ] 203 | } 204 | ] 205 | } 206 | }, 207 | "integer": { 208 | "type": "TOKEN", 209 | "content": { 210 | "type": "CHOICE", 211 | "members": [ 212 | { 213 | "type": "SEQ", 214 | "members": [ 215 | { 216 | "type": "CHOICE", 217 | "members": [ 218 | { 219 | "type": "STRING", 220 | "value": "0x" 221 | }, 222 | { 223 | "type": "STRING", 224 | "value": "0X" 225 | } 226 | ] 227 | }, 228 | { 229 | "type": "REPEAT1", 230 | "content": { 231 | "type": "PATTERN", 232 | "value": "_?[A-Fa-f0-9]+" 233 | } 234 | } 235 | ] 236 | }, 237 | { 238 | "type": "SEQ", 239 | "members": [ 240 | { 241 | "type": "CHOICE", 242 | "members": [ 243 | { 244 | "type": "STRING", 245 | "value": "0o" 246 | }, 247 | { 248 | "type": "STRING", 249 | "value": "0O" 250 | } 251 | ] 252 | }, 253 | { 254 | "type": "REPEAT1", 255 | "content": { 256 | "type": "PATTERN", 257 | "value": "_?[0-7]+" 258 | } 259 | } 260 | ] 261 | }, 262 | { 263 | "type": "SEQ", 264 | "members": [ 265 | { 266 | "type": "CHOICE", 267 | "members": [ 268 | { 269 | "type": "STRING", 270 | "value": "0b" 271 | }, 272 | { 273 | "type": "STRING", 274 | "value": "0B" 275 | } 276 | ] 277 | }, 278 | { 279 | "type": "REPEAT1", 280 | "content": { 281 | "type": "PATTERN", 282 | "value": "_?[0-1]+" 283 | } 284 | } 285 | ] 286 | }, 287 | { 288 | "type": "REPEAT1", 289 | "content": { 290 | "type": "PATTERN", 291 | "value": "-?[0-9]+_?" 292 | } 293 | } 294 | ] 295 | } 296 | }, 297 | "string_name": { 298 | "type": "SEQ", 299 | "members": [ 300 | { 301 | "type": "STRING", 302 | "value": "&" 303 | }, 304 | { 305 | "type": "ALIAS", 306 | "content": { 307 | "type": "SYMBOL", 308 | "name": "string" 309 | }, 310 | "named": false, 311 | "value": "string" 312 | } 313 | ] 314 | }, 315 | "_value": { 316 | "type": "CHOICE", 317 | "members": [ 318 | { 319 | "type": "SYMBOL", 320 | "name": "float" 321 | }, 322 | { 323 | "type": "SYMBOL", 324 | "name": "integer" 325 | }, 326 | { 327 | "type": "SYMBOL", 328 | "name": "string" 329 | }, 330 | { 331 | "type": "SYMBOL", 332 | "name": "string_name" 333 | }, 334 | { 335 | "type": "SYMBOL", 336 | "name": "true" 337 | }, 338 | { 339 | "type": "SYMBOL", 340 | "name": "false" 341 | }, 342 | { 343 | "type": "SYMBOL", 344 | "name": "null" 345 | }, 346 | { 347 | "type": "SYMBOL", 348 | "name": "dictionary" 349 | }, 350 | { 351 | "type": "SYMBOL", 352 | "name": "array" 353 | }, 354 | { 355 | "type": "SYMBOL", 356 | "name": "constructor" 357 | }, 358 | { 359 | "type": "SYMBOL", 360 | "name": "identifier" 361 | } 362 | ] 363 | }, 364 | "section": { 365 | "type": "SEQ", 366 | "members": [ 367 | { 368 | "type": "STRING", 369 | "value": "[" 370 | }, 371 | { 372 | "type": "SYMBOL", 373 | "name": "identifier" 374 | }, 375 | { 376 | "type": "CHOICE", 377 | "members": [ 378 | { 379 | "type": "SYMBOL", 380 | "name": "_attributes" 381 | }, 382 | { 383 | "type": "BLANK" 384 | } 385 | ] 386 | }, 387 | { 388 | "type": "STRING", 389 | "value": "]" 390 | }, 391 | { 392 | "type": "CHOICE", 393 | "members": [ 394 | { 395 | "type": "SYMBOL", 396 | "name": "_properties" 397 | }, 398 | { 399 | "type": "BLANK" 400 | } 401 | ] 402 | } 403 | ] 404 | }, 405 | "_attributes": { 406 | "type": "REPEAT1", 407 | "content": { 408 | "type": "SYMBOL", 409 | "name": "attribute" 410 | } 411 | }, 412 | "attribute": { 413 | "type": "SEQ", 414 | "members": [ 415 | { 416 | "type": "SYMBOL", 417 | "name": "identifier" 418 | }, 419 | { 420 | "type": "STRING", 421 | "value": "=" 422 | }, 423 | { 424 | "type": "SYMBOL", 425 | "name": "_value" 426 | } 427 | ] 428 | }, 429 | "_properties": { 430 | "type": "REPEAT1", 431 | "content": { 432 | "type": "SYMBOL", 433 | "name": "property" 434 | } 435 | }, 436 | "property": { 437 | "type": "SEQ", 438 | "members": [ 439 | { 440 | "type": "SYMBOL", 441 | "name": "path" 442 | }, 443 | { 444 | "type": "STRING", 445 | "value": "=" 446 | }, 447 | { 448 | "type": "SYMBOL", 449 | "name": "_value" 450 | } 451 | ] 452 | }, 453 | "path": { 454 | "type": "PATTERN", 455 | "value": "[a-zA-Z_0-9][a-zA-Z_:/0-9]*" 456 | }, 457 | "pair": { 458 | "type": "SEQ", 459 | "members": [ 460 | { 461 | "type": "SYMBOL", 462 | "name": "_value" 463 | }, 464 | { 465 | "type": "STRING", 466 | "value": ":" 467 | }, 468 | { 469 | "type": "SYMBOL", 470 | "name": "_value" 471 | } 472 | ] 473 | }, 474 | "dictionary": { 475 | "type": "SEQ", 476 | "members": [ 477 | { 478 | "type": "STRING", 479 | "value": "{" 480 | }, 481 | { 482 | "type": "CHOICE", 483 | "members": [ 484 | { 485 | "type": "SEQ", 486 | "members": [ 487 | { 488 | "type": "SYMBOL", 489 | "name": "pair" 490 | }, 491 | { 492 | "type": "REPEAT", 493 | "content": { 494 | "type": "SEQ", 495 | "members": [ 496 | { 497 | "type": "STRING", 498 | "value": "," 499 | }, 500 | { 501 | "type": "SYMBOL", 502 | "name": "pair" 503 | } 504 | ] 505 | } 506 | } 507 | ] 508 | }, 509 | { 510 | "type": "BLANK" 511 | } 512 | ] 513 | }, 514 | { 515 | "type": "STRING", 516 | "value": "}" 517 | } 518 | ] 519 | }, 520 | "array": { 521 | "type": "SEQ", 522 | "members": [ 523 | { 524 | "type": "STRING", 525 | "value": "[" 526 | }, 527 | { 528 | "type": "CHOICE", 529 | "members": [ 530 | { 531 | "type": "SEQ", 532 | "members": [ 533 | { 534 | "type": "SYMBOL", 535 | "name": "_value" 536 | }, 537 | { 538 | "type": "REPEAT", 539 | "content": { 540 | "type": "SEQ", 541 | "members": [ 542 | { 543 | "type": "STRING", 544 | "value": "," 545 | }, 546 | { 547 | "type": "SYMBOL", 548 | "name": "_value" 549 | } 550 | ] 551 | } 552 | } 553 | ] 554 | }, 555 | { 556 | "type": "BLANK" 557 | } 558 | ] 559 | }, 560 | { 561 | "type": "STRING", 562 | "value": "]" 563 | } 564 | ] 565 | }, 566 | "arguments": { 567 | "type": "SEQ", 568 | "members": [ 569 | { 570 | "type": "STRING", 571 | "value": "(" 572 | }, 573 | { 574 | "type": "CHOICE", 575 | "members": [ 576 | { 577 | "type": "SEQ", 578 | "members": [ 579 | { 580 | "type": "CHOICE", 581 | "members": [ 582 | { 583 | "type": "SYMBOL", 584 | "name": "_value" 585 | }, 586 | { 587 | "type": "SYMBOL", 588 | "name": "pair" 589 | } 590 | ] 591 | }, 592 | { 593 | "type": "REPEAT", 594 | "content": { 595 | "type": "SEQ", 596 | "members": [ 597 | { 598 | "type": "STRING", 599 | "value": "," 600 | }, 601 | { 602 | "type": "CHOICE", 603 | "members": [ 604 | { 605 | "type": "SYMBOL", 606 | "name": "_value" 607 | }, 608 | { 609 | "type": "SYMBOL", 610 | "name": "pair" 611 | } 612 | ] 613 | } 614 | ] 615 | } 616 | } 617 | ] 618 | }, 619 | { 620 | "type": "BLANK" 621 | } 622 | ] 623 | }, 624 | { 625 | "type": "STRING", 626 | "value": ")" 627 | } 628 | ] 629 | }, 630 | "_type_args": { 631 | "type": "SEQ", 632 | "members": [ 633 | { 634 | "type": "STRING", 635 | "value": "[" 636 | }, 637 | { 638 | "type": "SEQ", 639 | "members": [ 640 | { 641 | "type": "SYMBOL", 642 | "name": "_value" 643 | }, 644 | { 645 | "type": "REPEAT", 646 | "content": { 647 | "type": "SEQ", 648 | "members": [ 649 | { 650 | "type": "STRING", 651 | "value": "," 652 | }, 653 | { 654 | "type": "SYMBOL", 655 | "name": "_value" 656 | } 657 | ] 658 | } 659 | } 660 | ] 661 | }, 662 | { 663 | "type": "STRING", 664 | "value": "]" 665 | } 666 | ] 667 | }, 668 | "constructor": { 669 | "type": "PREC_RIGHT", 670 | "value": 1, 671 | "content": { 672 | "type": "SEQ", 673 | "members": [ 674 | { 675 | "type": "SYMBOL", 676 | "name": "identifier" 677 | }, 678 | { 679 | "type": "CHOICE", 680 | "members": [ 681 | { 682 | "type": "SYMBOL", 683 | "name": "_type_args" 684 | }, 685 | { 686 | "type": "BLANK" 687 | } 688 | ] 689 | }, 690 | { 691 | "type": "SYMBOL", 692 | "name": "arguments" 693 | } 694 | ] 695 | } 696 | } 697 | }, 698 | "extras": [ 699 | { 700 | "type": "SYMBOL", 701 | "name": "comment" 702 | }, 703 | { 704 | "type": "PATTERN", 705 | "value": "[\\s\\uFEFF\\u2060\\u200B]|\\\\\\r?\\n" 706 | } 707 | ], 708 | "conflicts": [], 709 | "precedences": [], 710 | "externals": [ 711 | { 712 | "type": "SYMBOL", 713 | "name": "string" 714 | } 715 | ], 716 | "inline": [], 717 | "supertypes": [] 718 | } 719 | -------------------------------------------------------------------------------- /src/parser.c: -------------------------------------------------------------------------------- 1 | #include "tree_sitter/parser.h" 2 | 3 | #if defined(__GNUC__) || defined(__clang__) 4 | #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 5 | #endif 6 | 7 | #define LANGUAGE_VERSION 14 8 | #define STATE_COUNT 93 9 | #define LARGE_STATE_COUNT 2 10 | #define SYMBOL_COUNT 40 11 | #define ALIAS_COUNT 1 12 | #define TOKEN_COUNT 20 13 | #define EXTERNAL_TOKEN_COUNT 1 14 | #define FIELD_COUNT 0 15 | #define MAX_ALIAS_SEQUENCE_LENGTH 5 16 | #define PRODUCTION_ID_COUNT 2 17 | 18 | enum ts_symbol_identifiers { 19 | sym__identifier = 1, 20 | sym_comment = 2, 21 | sym_true = 3, 22 | sym_false = 4, 23 | sym_null = 5, 24 | sym_float = 6, 25 | sym_integer = 7, 26 | anon_sym_AMP = 8, 27 | anon_sym_LBRACK = 9, 28 | anon_sym_RBRACK = 10, 29 | anon_sym_EQ = 11, 30 | sym_path = 12, 31 | anon_sym_COLON = 13, 32 | anon_sym_LBRACE = 14, 33 | anon_sym_COMMA = 15, 34 | anon_sym_RBRACE = 16, 35 | anon_sym_LPAREN = 17, 36 | anon_sym_RPAREN = 18, 37 | sym_string = 19, 38 | sym_resource = 20, 39 | sym_identifier = 21, 40 | sym_string_name = 22, 41 | sym__value = 23, 42 | sym_section = 24, 43 | aux_sym__attributes = 25, 44 | sym_attribute = 26, 45 | aux_sym__properties = 27, 46 | sym_property = 28, 47 | sym_pair = 29, 48 | sym_dictionary = 30, 49 | sym_array = 31, 50 | sym_arguments = 32, 51 | sym__type_args = 33, 52 | sym_constructor = 34, 53 | aux_sym_resource_repeat1 = 35, 54 | aux_sym_resource_repeat2 = 36, 55 | aux_sym_dictionary_repeat1 = 37, 56 | aux_sym_array_repeat1 = 38, 57 | aux_sym_arguments_repeat1 = 39, 58 | anon_alias_sym_string = 40, 59 | }; 60 | 61 | static const char * const ts_symbol_names[] = { 62 | [ts_builtin_sym_end] = "end", 63 | [sym__identifier] = "_identifier", 64 | [sym_comment] = "comment", 65 | [sym_true] = "true", 66 | [sym_false] = "false", 67 | [sym_null] = "null", 68 | [sym_float] = "float", 69 | [sym_integer] = "integer", 70 | [anon_sym_AMP] = "&", 71 | [anon_sym_LBRACK] = "[", 72 | [anon_sym_RBRACK] = "]", 73 | [anon_sym_EQ] = "=", 74 | [sym_path] = "path", 75 | [anon_sym_COLON] = ":", 76 | [anon_sym_LBRACE] = "{", 77 | [anon_sym_COMMA] = ",", 78 | [anon_sym_RBRACE] = "}", 79 | [anon_sym_LPAREN] = "(", 80 | [anon_sym_RPAREN] = ")", 81 | [sym_string] = "string", 82 | [sym_resource] = "resource", 83 | [sym_identifier] = "identifier", 84 | [sym_string_name] = "string_name", 85 | [sym__value] = "_value", 86 | [sym_section] = "section", 87 | [aux_sym__attributes] = "_attributes", 88 | [sym_attribute] = "attribute", 89 | [aux_sym__properties] = "_properties", 90 | [sym_property] = "property", 91 | [sym_pair] = "pair", 92 | [sym_dictionary] = "dictionary", 93 | [sym_array] = "array", 94 | [sym_arguments] = "arguments", 95 | [sym__type_args] = "_type_args", 96 | [sym_constructor] = "constructor", 97 | [aux_sym_resource_repeat1] = "resource_repeat1", 98 | [aux_sym_resource_repeat2] = "resource_repeat2", 99 | [aux_sym_dictionary_repeat1] = "dictionary_repeat1", 100 | [aux_sym_array_repeat1] = "array_repeat1", 101 | [aux_sym_arguments_repeat1] = "arguments_repeat1", 102 | [anon_alias_sym_string] = "string", 103 | }; 104 | 105 | static const TSSymbol ts_symbol_map[] = { 106 | [ts_builtin_sym_end] = ts_builtin_sym_end, 107 | [sym__identifier] = sym__identifier, 108 | [sym_comment] = sym_comment, 109 | [sym_true] = sym_true, 110 | [sym_false] = sym_false, 111 | [sym_null] = sym_null, 112 | [sym_float] = sym_float, 113 | [sym_integer] = sym_integer, 114 | [anon_sym_AMP] = anon_sym_AMP, 115 | [anon_sym_LBRACK] = anon_sym_LBRACK, 116 | [anon_sym_RBRACK] = anon_sym_RBRACK, 117 | [anon_sym_EQ] = anon_sym_EQ, 118 | [sym_path] = sym_path, 119 | [anon_sym_COLON] = anon_sym_COLON, 120 | [anon_sym_LBRACE] = anon_sym_LBRACE, 121 | [anon_sym_COMMA] = anon_sym_COMMA, 122 | [anon_sym_RBRACE] = anon_sym_RBRACE, 123 | [anon_sym_LPAREN] = anon_sym_LPAREN, 124 | [anon_sym_RPAREN] = anon_sym_RPAREN, 125 | [sym_string] = sym_string, 126 | [sym_resource] = sym_resource, 127 | [sym_identifier] = sym_identifier, 128 | [sym_string_name] = sym_string_name, 129 | [sym__value] = sym__value, 130 | [sym_section] = sym_section, 131 | [aux_sym__attributes] = aux_sym__attributes, 132 | [sym_attribute] = sym_attribute, 133 | [aux_sym__properties] = aux_sym__properties, 134 | [sym_property] = sym_property, 135 | [sym_pair] = sym_pair, 136 | [sym_dictionary] = sym_dictionary, 137 | [sym_array] = sym_array, 138 | [sym_arguments] = sym_arguments, 139 | [sym__type_args] = sym__type_args, 140 | [sym_constructor] = sym_constructor, 141 | [aux_sym_resource_repeat1] = aux_sym_resource_repeat1, 142 | [aux_sym_resource_repeat2] = aux_sym_resource_repeat2, 143 | [aux_sym_dictionary_repeat1] = aux_sym_dictionary_repeat1, 144 | [aux_sym_array_repeat1] = aux_sym_array_repeat1, 145 | [aux_sym_arguments_repeat1] = aux_sym_arguments_repeat1, 146 | [anon_alias_sym_string] = anon_alias_sym_string, 147 | }; 148 | 149 | static const TSSymbolMetadata ts_symbol_metadata[] = { 150 | [ts_builtin_sym_end] = { 151 | .visible = false, 152 | .named = true, 153 | }, 154 | [sym__identifier] = { 155 | .visible = false, 156 | .named = true, 157 | }, 158 | [sym_comment] = { 159 | .visible = true, 160 | .named = true, 161 | }, 162 | [sym_true] = { 163 | .visible = true, 164 | .named = true, 165 | }, 166 | [sym_false] = { 167 | .visible = true, 168 | .named = true, 169 | }, 170 | [sym_null] = { 171 | .visible = true, 172 | .named = true, 173 | }, 174 | [sym_float] = { 175 | .visible = true, 176 | .named = true, 177 | }, 178 | [sym_integer] = { 179 | .visible = true, 180 | .named = true, 181 | }, 182 | [anon_sym_AMP] = { 183 | .visible = true, 184 | .named = false, 185 | }, 186 | [anon_sym_LBRACK] = { 187 | .visible = true, 188 | .named = false, 189 | }, 190 | [anon_sym_RBRACK] = { 191 | .visible = true, 192 | .named = false, 193 | }, 194 | [anon_sym_EQ] = { 195 | .visible = true, 196 | .named = false, 197 | }, 198 | [sym_path] = { 199 | .visible = true, 200 | .named = true, 201 | }, 202 | [anon_sym_COLON] = { 203 | .visible = true, 204 | .named = false, 205 | }, 206 | [anon_sym_LBRACE] = { 207 | .visible = true, 208 | .named = false, 209 | }, 210 | [anon_sym_COMMA] = { 211 | .visible = true, 212 | .named = false, 213 | }, 214 | [anon_sym_RBRACE] = { 215 | .visible = true, 216 | .named = false, 217 | }, 218 | [anon_sym_LPAREN] = { 219 | .visible = true, 220 | .named = false, 221 | }, 222 | [anon_sym_RPAREN] = { 223 | .visible = true, 224 | .named = false, 225 | }, 226 | [sym_string] = { 227 | .visible = true, 228 | .named = true, 229 | }, 230 | [sym_resource] = { 231 | .visible = true, 232 | .named = true, 233 | }, 234 | [sym_identifier] = { 235 | .visible = true, 236 | .named = true, 237 | }, 238 | [sym_string_name] = { 239 | .visible = true, 240 | .named = true, 241 | }, 242 | [sym__value] = { 243 | .visible = false, 244 | .named = true, 245 | }, 246 | [sym_section] = { 247 | .visible = true, 248 | .named = true, 249 | }, 250 | [aux_sym__attributes] = { 251 | .visible = false, 252 | .named = false, 253 | }, 254 | [sym_attribute] = { 255 | .visible = true, 256 | .named = true, 257 | }, 258 | [aux_sym__properties] = { 259 | .visible = false, 260 | .named = false, 261 | }, 262 | [sym_property] = { 263 | .visible = true, 264 | .named = true, 265 | }, 266 | [sym_pair] = { 267 | .visible = true, 268 | .named = true, 269 | }, 270 | [sym_dictionary] = { 271 | .visible = true, 272 | .named = true, 273 | }, 274 | [sym_array] = { 275 | .visible = true, 276 | .named = true, 277 | }, 278 | [sym_arguments] = { 279 | .visible = true, 280 | .named = true, 281 | }, 282 | [sym__type_args] = { 283 | .visible = false, 284 | .named = true, 285 | }, 286 | [sym_constructor] = { 287 | .visible = true, 288 | .named = true, 289 | }, 290 | [aux_sym_resource_repeat1] = { 291 | .visible = false, 292 | .named = false, 293 | }, 294 | [aux_sym_resource_repeat2] = { 295 | .visible = false, 296 | .named = false, 297 | }, 298 | [aux_sym_dictionary_repeat1] = { 299 | .visible = false, 300 | .named = false, 301 | }, 302 | [aux_sym_array_repeat1] = { 303 | .visible = false, 304 | .named = false, 305 | }, 306 | [aux_sym_arguments_repeat1] = { 307 | .visible = false, 308 | .named = false, 309 | }, 310 | [anon_alias_sym_string] = { 311 | .visible = true, 312 | .named = false, 313 | }, 314 | }; 315 | 316 | static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { 317 | [0] = {0}, 318 | [1] = { 319 | [1] = anon_alias_sym_string, 320 | }, 321 | }; 322 | 323 | static const uint16_t ts_non_terminal_alias_map[] = { 324 | 0, 325 | }; 326 | 327 | static const TSStateId ts_primary_state_ids[STATE_COUNT] = { 328 | [0] = 0, 329 | [1] = 1, 330 | [2] = 2, 331 | [3] = 3, 332 | [4] = 2, 333 | [5] = 3, 334 | [6] = 6, 335 | [7] = 7, 336 | [8] = 8, 337 | [9] = 6, 338 | [10] = 10, 339 | [11] = 11, 340 | [12] = 12, 341 | [13] = 13, 342 | [14] = 14, 343 | [15] = 15, 344 | [16] = 16, 345 | [17] = 17, 346 | [18] = 18, 347 | [19] = 19, 348 | [20] = 20, 349 | [21] = 21, 350 | [22] = 22, 351 | [23] = 23, 352 | [24] = 24, 353 | [25] = 25, 354 | [26] = 26, 355 | [27] = 27, 356 | [28] = 28, 357 | [29] = 29, 358 | [30] = 15, 359 | [31] = 31, 360 | [32] = 32, 361 | [33] = 33, 362 | [34] = 34, 363 | [35] = 35, 364 | [36] = 36, 365 | [37] = 37, 366 | [38] = 38, 367 | [39] = 39, 368 | [40] = 40, 369 | [41] = 41, 370 | [42] = 16, 371 | [43] = 43, 372 | [44] = 44, 373 | [45] = 44, 374 | [46] = 46, 375 | [47] = 47, 376 | [48] = 48, 377 | [49] = 49, 378 | [50] = 50, 379 | [51] = 51, 380 | [52] = 52, 381 | [53] = 53, 382 | [54] = 47, 383 | [55] = 55, 384 | [56] = 56, 385 | [57] = 57, 386 | [58] = 58, 387 | [59] = 59, 388 | [60] = 53, 389 | [61] = 58, 390 | [62] = 62, 391 | [63] = 56, 392 | [64] = 59, 393 | [65] = 46, 394 | [66] = 27, 395 | [67] = 67, 396 | [68] = 21, 397 | [69] = 18, 398 | [70] = 23, 399 | [71] = 26, 400 | [72] = 17, 401 | [73] = 28, 402 | [74] = 25, 403 | [75] = 75, 404 | [76] = 76, 405 | [77] = 77, 406 | [78] = 78, 407 | [79] = 79, 408 | [80] = 75, 409 | [81] = 24, 410 | [82] = 19, 411 | [83] = 20, 412 | [84] = 22, 413 | [85] = 85, 414 | [86] = 86, 415 | [87] = 87, 416 | [88] = 87, 417 | [89] = 89, 418 | [90] = 90, 419 | [91] = 91, 420 | [92] = 92, 421 | }; 422 | 423 | static bool ts_lex(TSLexer *lexer, TSStateId state) { 424 | START_LEXER(); 425 | eof = lexer->eof(lexer); 426 | switch (state) { 427 | case 0: 428 | if (eof) ADVANCE(18); 429 | ADVANCE_MAP( 430 | '&', 31, 431 | '(', 40, 432 | ')', 41, 433 | ',', 38, 434 | '-', 9, 435 | '.', 2, 436 | '0', 25, 437 | ':', 36, 438 | ';', 20, 439 | '=', 34, 440 | '[', 32, 441 | ); 442 | if (lookahead == '\\') SKIP(14); 443 | if (lookahead == ']') ADVANCE(33); 444 | if (lookahead == '{') ADVANCE(37); 445 | if (lookahead == '}') ADVANCE(39); 446 | if (('\t' <= lookahead && lookahead <= '\r') || 447 | lookahead == ' ' || 448 | lookahead == 0x200b || 449 | lookahead == 0x2060 || 450 | lookahead == 0xfeff) SKIP(0); 451 | if (('1' <= lookahead && lookahead <= '9')) ADVANCE(26); 452 | if (('A' <= lookahead && lookahead <= 'Z') || 453 | lookahead == '_' || 454 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(19); 455 | END_STATE(); 456 | case 1: 457 | if (lookahead == '+') ADVANCE(3); 458 | if (lookahead == '-') ADVANCE(3); 459 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(23); 460 | END_STATE(); 461 | case 2: 462 | if (lookahead == '-') ADVANCE(10); 463 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(21); 464 | END_STATE(); 465 | case 3: 466 | if (lookahead == '-') ADVANCE(11); 467 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(23); 468 | END_STATE(); 469 | case 4: 470 | if (lookahead == '_') ADVANCE(7); 471 | if (lookahead == '0' || 472 | lookahead == '1') ADVANCE(28); 473 | END_STATE(); 474 | case 5: 475 | if (lookahead == '_') ADVANCE(8); 476 | if (('0' <= lookahead && lookahead <= '7')) ADVANCE(29); 477 | END_STATE(); 478 | case 6: 479 | if (lookahead == '_') ADVANCE(12); 480 | if (('0' <= lookahead && lookahead <= '9') || 481 | ('A' <= lookahead && lookahead <= 'F') || 482 | ('a' <= lookahead && lookahead <= 'f')) ADVANCE(30); 483 | END_STATE(); 484 | case 7: 485 | if (lookahead == '0' || 486 | lookahead == '1') ADVANCE(28); 487 | END_STATE(); 488 | case 8: 489 | if (('0' <= lookahead && lookahead <= '7')) ADVANCE(29); 490 | END_STATE(); 491 | case 9: 492 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(26); 493 | END_STATE(); 494 | case 10: 495 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(21); 496 | END_STATE(); 497 | case 11: 498 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(23); 499 | END_STATE(); 500 | case 12: 501 | if (('0' <= lookahead && lookahead <= '9') || 502 | ('A' <= lookahead && lookahead <= 'F') || 503 | ('a' <= lookahead && lookahead <= 'f')) ADVANCE(30); 504 | END_STATE(); 505 | case 13: 506 | if (eof) ADVANCE(18); 507 | if (lookahead == '\n') SKIP(0); 508 | END_STATE(); 509 | case 14: 510 | if (eof) ADVANCE(18); 511 | if (lookahead == '\n') SKIP(0); 512 | if (lookahead == '\r') SKIP(13); 513 | END_STATE(); 514 | case 15: 515 | if (eof) ADVANCE(18); 516 | if (lookahead == '\n') SKIP(17); 517 | END_STATE(); 518 | case 16: 519 | if (eof) ADVANCE(18); 520 | if (lookahead == '\n') SKIP(17); 521 | if (lookahead == '\r') SKIP(15); 522 | END_STATE(); 523 | case 17: 524 | if (eof) ADVANCE(18); 525 | if (lookahead == '(') ADVANCE(40); 526 | if (lookahead == ')') ADVANCE(41); 527 | if (lookahead == ',') ADVANCE(38); 528 | if (lookahead == ':') ADVANCE(36); 529 | if (lookahead == ';') ADVANCE(20); 530 | if (lookahead == '[') ADVANCE(32); 531 | if (lookahead == '\\') SKIP(16); 532 | if (lookahead == ']') ADVANCE(33); 533 | if (lookahead == '}') ADVANCE(39); 534 | if (('\t' <= lookahead && lookahead <= '\r') || 535 | lookahead == ' ' || 536 | lookahead == 0x200b || 537 | lookahead == 0x2060 || 538 | lookahead == 0xfeff) SKIP(17); 539 | if (('0' <= lookahead && lookahead <= '9') || 540 | ('A' <= lookahead && lookahead <= 'Z') || 541 | lookahead == '_' || 542 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); 543 | END_STATE(); 544 | case 18: 545 | ACCEPT_TOKEN(ts_builtin_sym_end); 546 | END_STATE(); 547 | case 19: 548 | ACCEPT_TOKEN(sym__identifier); 549 | if (('0' <= lookahead && lookahead <= '9') || 550 | ('A' <= lookahead && lookahead <= 'Z') || 551 | lookahead == '_' || 552 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(19); 553 | END_STATE(); 554 | case 20: 555 | ACCEPT_TOKEN(sym_comment); 556 | if (lookahead != 0 && 557 | lookahead != '\n') ADVANCE(20); 558 | END_STATE(); 559 | case 21: 560 | ACCEPT_TOKEN(sym_float); 561 | if (lookahead == '-') ADVANCE(10); 562 | if (lookahead == '_') ADVANCE(22); 563 | if (lookahead == 'E' || 564 | lookahead == 'e') ADVANCE(1); 565 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(21); 566 | END_STATE(); 567 | case 22: 568 | ACCEPT_TOKEN(sym_float); 569 | if (lookahead == '-') ADVANCE(10); 570 | if (lookahead == 'E' || 571 | lookahead == 'e') ADVANCE(1); 572 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(21); 573 | END_STATE(); 574 | case 23: 575 | ACCEPT_TOKEN(sym_float); 576 | if (lookahead == '-') ADVANCE(11); 577 | if (lookahead == '_') ADVANCE(24); 578 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(23); 579 | END_STATE(); 580 | case 24: 581 | ACCEPT_TOKEN(sym_float); 582 | if (lookahead == '-') ADVANCE(11); 583 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(23); 584 | END_STATE(); 585 | case 25: 586 | ACCEPT_TOKEN(sym_integer); 587 | ADVANCE_MAP( 588 | '-', 9, 589 | '.', 22, 590 | '_', 27, 591 | 'B', 4, 592 | 'b', 4, 593 | 'E', 1, 594 | 'e', 1, 595 | 'O', 5, 596 | 'o', 5, 597 | 'X', 6, 598 | 'x', 6, 599 | ); 600 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(26); 601 | END_STATE(); 602 | case 26: 603 | ACCEPT_TOKEN(sym_integer); 604 | if (lookahead == '-') ADVANCE(9); 605 | if (lookahead == '.') ADVANCE(22); 606 | if (lookahead == '_') ADVANCE(27); 607 | if (lookahead == 'E' || 608 | lookahead == 'e') ADVANCE(1); 609 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(26); 610 | END_STATE(); 611 | case 27: 612 | ACCEPT_TOKEN(sym_integer); 613 | if (lookahead == '-') ADVANCE(9); 614 | if (lookahead == '.') ADVANCE(22); 615 | if (lookahead == 'E' || 616 | lookahead == 'e') ADVANCE(1); 617 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(26); 618 | END_STATE(); 619 | case 28: 620 | ACCEPT_TOKEN(sym_integer); 621 | if (lookahead == '_') ADVANCE(7); 622 | if (lookahead == '0' || 623 | lookahead == '1') ADVANCE(28); 624 | END_STATE(); 625 | case 29: 626 | ACCEPT_TOKEN(sym_integer); 627 | if (lookahead == '_') ADVANCE(8); 628 | if (('0' <= lookahead && lookahead <= '7')) ADVANCE(29); 629 | END_STATE(); 630 | case 30: 631 | ACCEPT_TOKEN(sym_integer); 632 | if (lookahead == '_') ADVANCE(12); 633 | if (('0' <= lookahead && lookahead <= '9') || 634 | ('A' <= lookahead && lookahead <= 'F') || 635 | ('a' <= lookahead && lookahead <= 'f')) ADVANCE(30); 636 | END_STATE(); 637 | case 31: 638 | ACCEPT_TOKEN(anon_sym_AMP); 639 | END_STATE(); 640 | case 32: 641 | ACCEPT_TOKEN(anon_sym_LBRACK); 642 | END_STATE(); 643 | case 33: 644 | ACCEPT_TOKEN(anon_sym_RBRACK); 645 | END_STATE(); 646 | case 34: 647 | ACCEPT_TOKEN(anon_sym_EQ); 648 | END_STATE(); 649 | case 35: 650 | ACCEPT_TOKEN(sym_path); 651 | if (('/' <= lookahead && lookahead <= ':') || 652 | ('A' <= lookahead && lookahead <= 'Z') || 653 | lookahead == '_' || 654 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(35); 655 | END_STATE(); 656 | case 36: 657 | ACCEPT_TOKEN(anon_sym_COLON); 658 | END_STATE(); 659 | case 37: 660 | ACCEPT_TOKEN(anon_sym_LBRACE); 661 | END_STATE(); 662 | case 38: 663 | ACCEPT_TOKEN(anon_sym_COMMA); 664 | END_STATE(); 665 | case 39: 666 | ACCEPT_TOKEN(anon_sym_RBRACE); 667 | END_STATE(); 668 | case 40: 669 | ACCEPT_TOKEN(anon_sym_LPAREN); 670 | END_STATE(); 671 | case 41: 672 | ACCEPT_TOKEN(anon_sym_RPAREN); 673 | END_STATE(); 674 | default: 675 | return false; 676 | } 677 | } 678 | 679 | static bool ts_lex_keywords(TSLexer *lexer, TSStateId state) { 680 | START_LEXER(); 681 | eof = lexer->eof(lexer); 682 | switch (state) { 683 | case 0: 684 | if (lookahead == '\\') SKIP(1); 685 | if (lookahead == 'f') ADVANCE(2); 686 | if (lookahead == 'n') ADVANCE(3); 687 | if (lookahead == 't') ADVANCE(4); 688 | if (('\t' <= lookahead && lookahead <= '\r') || 689 | lookahead == ' ' || 690 | lookahead == 0x200b || 691 | lookahead == 0x2060 || 692 | lookahead == 0xfeff) SKIP(0); 693 | END_STATE(); 694 | case 1: 695 | if (lookahead == '\n') SKIP(0); 696 | if (lookahead == '\r') SKIP(5); 697 | END_STATE(); 698 | case 2: 699 | if (lookahead == 'a') ADVANCE(6); 700 | END_STATE(); 701 | case 3: 702 | if (lookahead == 'u') ADVANCE(7); 703 | END_STATE(); 704 | case 4: 705 | if (lookahead == 'r') ADVANCE(8); 706 | END_STATE(); 707 | case 5: 708 | if (lookahead == '\n') SKIP(0); 709 | END_STATE(); 710 | case 6: 711 | if (lookahead == 'l') ADVANCE(9); 712 | END_STATE(); 713 | case 7: 714 | if (lookahead == 'l') ADVANCE(10); 715 | END_STATE(); 716 | case 8: 717 | if (lookahead == 'u') ADVANCE(11); 718 | END_STATE(); 719 | case 9: 720 | if (lookahead == 's') ADVANCE(12); 721 | END_STATE(); 722 | case 10: 723 | if (lookahead == 'l') ADVANCE(13); 724 | END_STATE(); 725 | case 11: 726 | if (lookahead == 'e') ADVANCE(14); 727 | END_STATE(); 728 | case 12: 729 | if (lookahead == 'e') ADVANCE(15); 730 | END_STATE(); 731 | case 13: 732 | ACCEPT_TOKEN(sym_null); 733 | END_STATE(); 734 | case 14: 735 | ACCEPT_TOKEN(sym_true); 736 | END_STATE(); 737 | case 15: 738 | ACCEPT_TOKEN(sym_false); 739 | END_STATE(); 740 | default: 741 | return false; 742 | } 743 | } 744 | 745 | static const TSLexMode ts_lex_modes[STATE_COUNT] = { 746 | [0] = {.lex_state = 0, .external_lex_state = 1}, 747 | [1] = {.lex_state = 17}, 748 | [2] = {.lex_state = 0, .external_lex_state = 1}, 749 | [3] = {.lex_state = 0, .external_lex_state = 1}, 750 | [4] = {.lex_state = 0, .external_lex_state = 1}, 751 | [5] = {.lex_state = 0, .external_lex_state = 1}, 752 | [6] = {.lex_state = 0, .external_lex_state = 1}, 753 | [7] = {.lex_state = 0, .external_lex_state = 1}, 754 | [8] = {.lex_state = 0, .external_lex_state = 1}, 755 | [9] = {.lex_state = 0, .external_lex_state = 1}, 756 | [10] = {.lex_state = 0, .external_lex_state = 1}, 757 | [11] = {.lex_state = 0, .external_lex_state = 1}, 758 | [12] = {.lex_state = 0, .external_lex_state = 1}, 759 | [13] = {.lex_state = 0, .external_lex_state = 1}, 760 | [14] = {.lex_state = 0, .external_lex_state = 1}, 761 | [15] = {.lex_state = 17}, 762 | [16] = {.lex_state = 0}, 763 | [17] = {.lex_state = 17}, 764 | [18] = {.lex_state = 17}, 765 | [19] = {.lex_state = 17}, 766 | [20] = {.lex_state = 17}, 767 | [21] = {.lex_state = 17}, 768 | [22] = {.lex_state = 17}, 769 | [23] = {.lex_state = 17}, 770 | [24] = {.lex_state = 17}, 771 | [25] = {.lex_state = 17}, 772 | [26] = {.lex_state = 17}, 773 | [27] = {.lex_state = 17}, 774 | [28] = {.lex_state = 17}, 775 | [29] = {.lex_state = 17}, 776 | [30] = {.lex_state = 0}, 777 | [31] = {.lex_state = 17}, 778 | [32] = {.lex_state = 17}, 779 | [33] = {.lex_state = 0}, 780 | [34] = {.lex_state = 0}, 781 | [35] = {.lex_state = 17}, 782 | [36] = {.lex_state = 17}, 783 | [37] = {.lex_state = 0}, 784 | [38] = {.lex_state = 17}, 785 | [39] = {.lex_state = 17}, 786 | [40] = {.lex_state = 0}, 787 | [41] = {.lex_state = 0}, 788 | [42] = {.lex_state = 17}, 789 | [43] = {.lex_state = 0}, 790 | [44] = {.lex_state = 0}, 791 | [45] = {.lex_state = 0}, 792 | [46] = {.lex_state = 0}, 793 | [47] = {.lex_state = 0}, 794 | [48] = {.lex_state = 0}, 795 | [49] = {.lex_state = 0}, 796 | [50] = {.lex_state = 17}, 797 | [51] = {.lex_state = 0}, 798 | [52] = {.lex_state = 0}, 799 | [53] = {.lex_state = 0}, 800 | [54] = {.lex_state = 0}, 801 | [55] = {.lex_state = 0}, 802 | [56] = {.lex_state = 0}, 803 | [57] = {.lex_state = 0}, 804 | [58] = {.lex_state = 0}, 805 | [59] = {.lex_state = 0}, 806 | [60] = {.lex_state = 0}, 807 | [61] = {.lex_state = 0}, 808 | [62] = {.lex_state = 0}, 809 | [63] = {.lex_state = 0}, 810 | [64] = {.lex_state = 0}, 811 | [65] = {.lex_state = 0}, 812 | [66] = {.lex_state = 0}, 813 | [67] = {.lex_state = 0}, 814 | [68] = {.lex_state = 0}, 815 | [69] = {.lex_state = 0}, 816 | [70] = {.lex_state = 0}, 817 | [71] = {.lex_state = 0}, 818 | [72] = {.lex_state = 0}, 819 | [73] = {.lex_state = 0}, 820 | [74] = {.lex_state = 0}, 821 | [75] = {.lex_state = 0}, 822 | [76] = {.lex_state = 0}, 823 | [77] = {.lex_state = 0}, 824 | [78] = {.lex_state = 0}, 825 | [79] = {.lex_state = 0}, 826 | [80] = {.lex_state = 0}, 827 | [81] = {.lex_state = 0}, 828 | [82] = {.lex_state = 0}, 829 | [83] = {.lex_state = 0}, 830 | [84] = {.lex_state = 0}, 831 | [85] = {.lex_state = 0}, 832 | [86] = {.lex_state = 0}, 833 | [87] = {.lex_state = 0, .external_lex_state = 1}, 834 | [88] = {.lex_state = 0, .external_lex_state = 1}, 835 | [89] = {.lex_state = 0}, 836 | [90] = {.lex_state = 0}, 837 | [91] = {.lex_state = 0}, 838 | [92] = {.lex_state = 0}, 839 | }; 840 | 841 | static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { 842 | [0] = { 843 | [ts_builtin_sym_end] = ACTIONS(1), 844 | [sym__identifier] = ACTIONS(1), 845 | [sym_comment] = ACTIONS(3), 846 | [sym_true] = ACTIONS(1), 847 | [sym_false] = ACTIONS(1), 848 | [sym_null] = ACTIONS(1), 849 | [sym_float] = ACTIONS(1), 850 | [sym_integer] = ACTIONS(1), 851 | [anon_sym_AMP] = ACTIONS(1), 852 | [anon_sym_LBRACK] = ACTIONS(1), 853 | [anon_sym_RBRACK] = ACTIONS(1), 854 | [anon_sym_EQ] = ACTIONS(1), 855 | [anon_sym_COLON] = ACTIONS(1), 856 | [anon_sym_LBRACE] = ACTIONS(1), 857 | [anon_sym_COMMA] = ACTIONS(1), 858 | [anon_sym_RBRACE] = ACTIONS(1), 859 | [anon_sym_LPAREN] = ACTIONS(1), 860 | [anon_sym_RPAREN] = ACTIONS(1), 861 | [sym_string] = ACTIONS(1), 862 | }, 863 | [1] = { 864 | [sym_resource] = STATE(92), 865 | [sym_section] = STATE(41), 866 | [sym_property] = STATE(29), 867 | [aux_sym_resource_repeat1] = STATE(29), 868 | [aux_sym_resource_repeat2] = STATE(41), 869 | [ts_builtin_sym_end] = ACTIONS(5), 870 | [sym_comment] = ACTIONS(3), 871 | [anon_sym_LBRACK] = ACTIONS(7), 872 | [sym_path] = ACTIONS(9), 873 | }, 874 | }; 875 | 876 | static const uint16_t ts_small_parse_table[] = { 877 | [0] = 11, 878 | ACTIONS(3), 1, 879 | sym_comment, 880 | ACTIONS(11), 1, 881 | sym__identifier, 882 | ACTIONS(17), 1, 883 | anon_sym_AMP, 884 | ACTIONS(19), 1, 885 | anon_sym_LBRACK, 886 | ACTIONS(21), 1, 887 | anon_sym_LBRACE, 888 | ACTIONS(23), 1, 889 | anon_sym_RPAREN, 890 | STATE(15), 1, 891 | sym_identifier, 892 | STATE(46), 1, 893 | sym_pair, 894 | ACTIONS(15), 2, 895 | sym_string, 896 | sym_float, 897 | ACTIONS(13), 4, 898 | sym_true, 899 | sym_false, 900 | sym_null, 901 | sym_integer, 902 | STATE(44), 5, 903 | sym_string_name, 904 | sym__value, 905 | sym_dictionary, 906 | sym_array, 907 | sym_constructor, 908 | [42] = 11, 909 | ACTIONS(3), 1, 910 | sym_comment, 911 | ACTIONS(11), 1, 912 | sym__identifier, 913 | ACTIONS(17), 1, 914 | anon_sym_AMP, 915 | ACTIONS(19), 1, 916 | anon_sym_LBRACK, 917 | ACTIONS(21), 1, 918 | anon_sym_LBRACE, 919 | ACTIONS(29), 1, 920 | anon_sym_RBRACE, 921 | STATE(15), 1, 922 | sym_identifier, 923 | STATE(58), 1, 924 | sym_pair, 925 | ACTIONS(27), 2, 926 | sym_string, 927 | sym_float, 928 | ACTIONS(25), 4, 929 | sym_true, 930 | sym_false, 931 | sym_null, 932 | sym_integer, 933 | STATE(85), 5, 934 | sym_string_name, 935 | sym__value, 936 | sym_dictionary, 937 | sym_array, 938 | sym_constructor, 939 | [84] = 11, 940 | ACTIONS(3), 1, 941 | sym_comment, 942 | ACTIONS(11), 1, 943 | sym__identifier, 944 | ACTIONS(17), 1, 945 | anon_sym_AMP, 946 | ACTIONS(19), 1, 947 | anon_sym_LBRACK, 948 | ACTIONS(21), 1, 949 | anon_sym_LBRACE, 950 | ACTIONS(35), 1, 951 | anon_sym_RPAREN, 952 | STATE(15), 1, 953 | sym_identifier, 954 | STATE(65), 1, 955 | sym_pair, 956 | ACTIONS(33), 2, 957 | sym_string, 958 | sym_float, 959 | ACTIONS(31), 4, 960 | sym_true, 961 | sym_false, 962 | sym_null, 963 | sym_integer, 964 | STATE(45), 5, 965 | sym_string_name, 966 | sym__value, 967 | sym_dictionary, 968 | sym_array, 969 | sym_constructor, 970 | [126] = 11, 971 | ACTIONS(3), 1, 972 | sym_comment, 973 | ACTIONS(11), 1, 974 | sym__identifier, 975 | ACTIONS(17), 1, 976 | anon_sym_AMP, 977 | ACTIONS(19), 1, 978 | anon_sym_LBRACK, 979 | ACTIONS(21), 1, 980 | anon_sym_LBRACE, 981 | ACTIONS(37), 1, 982 | anon_sym_RBRACE, 983 | STATE(15), 1, 984 | sym_identifier, 985 | STATE(61), 1, 986 | sym_pair, 987 | ACTIONS(27), 2, 988 | sym_string, 989 | sym_float, 990 | ACTIONS(25), 4, 991 | sym_true, 992 | sym_false, 993 | sym_null, 994 | sym_integer, 995 | STATE(85), 5, 996 | sym_string_name, 997 | sym__value, 998 | sym_dictionary, 999 | sym_array, 1000 | sym_constructor, 1001 | [168] = 10, 1002 | ACTIONS(3), 1, 1003 | sym_comment, 1004 | ACTIONS(11), 1, 1005 | sym__identifier, 1006 | ACTIONS(17), 1, 1007 | anon_sym_AMP, 1008 | ACTIONS(19), 1, 1009 | anon_sym_LBRACK, 1010 | ACTIONS(21), 1, 1011 | anon_sym_LBRACE, 1012 | ACTIONS(43), 1, 1013 | anon_sym_RBRACK, 1014 | STATE(15), 1, 1015 | sym_identifier, 1016 | ACTIONS(41), 2, 1017 | sym_string, 1018 | sym_float, 1019 | ACTIONS(39), 4, 1020 | sym_true, 1021 | sym_false, 1022 | sym_null, 1023 | sym_integer, 1024 | STATE(53), 5, 1025 | sym_string_name, 1026 | sym__value, 1027 | sym_dictionary, 1028 | sym_array, 1029 | sym_constructor, 1030 | [207] = 10, 1031 | ACTIONS(3), 1, 1032 | sym_comment, 1033 | ACTIONS(11), 1, 1034 | sym__identifier, 1035 | ACTIONS(17), 1, 1036 | anon_sym_AMP, 1037 | ACTIONS(19), 1, 1038 | anon_sym_LBRACK, 1039 | ACTIONS(21), 1, 1040 | anon_sym_LBRACE, 1041 | STATE(15), 1, 1042 | sym_identifier, 1043 | STATE(79), 1, 1044 | sym_pair, 1045 | ACTIONS(27), 2, 1046 | sym_string, 1047 | sym_float, 1048 | ACTIONS(25), 4, 1049 | sym_true, 1050 | sym_false, 1051 | sym_null, 1052 | sym_integer, 1053 | STATE(85), 5, 1054 | sym_string_name, 1055 | sym__value, 1056 | sym_dictionary, 1057 | sym_array, 1058 | sym_constructor, 1059 | [246] = 10, 1060 | ACTIONS(3), 1, 1061 | sym_comment, 1062 | ACTIONS(11), 1, 1063 | sym__identifier, 1064 | ACTIONS(17), 1, 1065 | anon_sym_AMP, 1066 | ACTIONS(19), 1, 1067 | anon_sym_LBRACK, 1068 | ACTIONS(21), 1, 1069 | anon_sym_LBRACE, 1070 | STATE(15), 1, 1071 | sym_identifier, 1072 | STATE(76), 1, 1073 | sym_pair, 1074 | ACTIONS(47), 2, 1075 | sym_string, 1076 | sym_float, 1077 | ACTIONS(45), 4, 1078 | sym_true, 1079 | sym_false, 1080 | sym_null, 1081 | sym_integer, 1082 | STATE(55), 5, 1083 | sym_string_name, 1084 | sym__value, 1085 | sym_dictionary, 1086 | sym_array, 1087 | sym_constructor, 1088 | [285] = 10, 1089 | ACTIONS(3), 1, 1090 | sym_comment, 1091 | ACTIONS(11), 1, 1092 | sym__identifier, 1093 | ACTIONS(17), 1, 1094 | anon_sym_AMP, 1095 | ACTIONS(19), 1, 1096 | anon_sym_LBRACK, 1097 | ACTIONS(21), 1, 1098 | anon_sym_LBRACE, 1099 | ACTIONS(53), 1, 1100 | anon_sym_RBRACK, 1101 | STATE(15), 1, 1102 | sym_identifier, 1103 | ACTIONS(51), 2, 1104 | sym_string, 1105 | sym_float, 1106 | ACTIONS(49), 4, 1107 | sym_true, 1108 | sym_false, 1109 | sym_null, 1110 | sym_integer, 1111 | STATE(60), 5, 1112 | sym_string_name, 1113 | sym__value, 1114 | sym_dictionary, 1115 | sym_array, 1116 | sym_constructor, 1117 | [324] = 9, 1118 | ACTIONS(3), 1, 1119 | sym_comment, 1120 | ACTIONS(11), 1, 1121 | sym__identifier, 1122 | ACTIONS(17), 1, 1123 | anon_sym_AMP, 1124 | ACTIONS(19), 1, 1125 | anon_sym_LBRACK, 1126 | ACTIONS(21), 1, 1127 | anon_sym_LBRACE, 1128 | STATE(15), 1, 1129 | sym_identifier, 1130 | ACTIONS(57), 2, 1131 | sym_string, 1132 | sym_float, 1133 | ACTIONS(55), 4, 1134 | sym_true, 1135 | sym_false, 1136 | sym_null, 1137 | sym_integer, 1138 | STATE(49), 5, 1139 | sym_string_name, 1140 | sym__value, 1141 | sym_dictionary, 1142 | sym_array, 1143 | sym_constructor, 1144 | [360] = 9, 1145 | ACTIONS(3), 1, 1146 | sym_comment, 1147 | ACTIONS(11), 1, 1148 | sym__identifier, 1149 | ACTIONS(17), 1, 1150 | anon_sym_AMP, 1151 | ACTIONS(19), 1, 1152 | anon_sym_LBRACK, 1153 | ACTIONS(21), 1, 1154 | anon_sym_LBRACE, 1155 | STATE(15), 1, 1156 | sym_identifier, 1157 | ACTIONS(61), 2, 1158 | sym_string, 1159 | sym_float, 1160 | ACTIONS(59), 4, 1161 | sym_true, 1162 | sym_false, 1163 | sym_null, 1164 | sym_integer, 1165 | STATE(62), 5, 1166 | sym_string_name, 1167 | sym__value, 1168 | sym_dictionary, 1169 | sym_array, 1170 | sym_constructor, 1171 | [396] = 9, 1172 | ACTIONS(3), 1, 1173 | sym_comment, 1174 | ACTIONS(17), 1, 1175 | anon_sym_AMP, 1176 | ACTIONS(19), 1, 1177 | anon_sym_LBRACK, 1178 | ACTIONS(21), 1, 1179 | anon_sym_LBRACE, 1180 | ACTIONS(63), 1, 1181 | sym__identifier, 1182 | STATE(15), 1, 1183 | sym_identifier, 1184 | ACTIONS(67), 2, 1185 | sym_string, 1186 | sym_float, 1187 | ACTIONS(65), 4, 1188 | sym_true, 1189 | sym_false, 1190 | sym_null, 1191 | sym_integer, 1192 | STATE(50), 5, 1193 | sym_string_name, 1194 | sym__value, 1195 | sym_dictionary, 1196 | sym_array, 1197 | sym_constructor, 1198 | [432] = 9, 1199 | ACTIONS(3), 1, 1200 | sym_comment, 1201 | ACTIONS(11), 1, 1202 | sym__identifier, 1203 | ACTIONS(17), 1, 1204 | anon_sym_AMP, 1205 | ACTIONS(19), 1, 1206 | anon_sym_LBRACK, 1207 | ACTIONS(21), 1, 1208 | anon_sym_LBRACE, 1209 | STATE(15), 1, 1210 | sym_identifier, 1211 | ACTIONS(71), 2, 1212 | sym_string, 1213 | sym_float, 1214 | ACTIONS(69), 4, 1215 | sym_true, 1216 | sym_false, 1217 | sym_null, 1218 | sym_integer, 1219 | STATE(67), 5, 1220 | sym_string_name, 1221 | sym__value, 1222 | sym_dictionary, 1223 | sym_array, 1224 | sym_constructor, 1225 | [468] = 9, 1226 | ACTIONS(3), 1, 1227 | sym_comment, 1228 | ACTIONS(11), 1, 1229 | sym__identifier, 1230 | ACTIONS(77), 1, 1231 | anon_sym_AMP, 1232 | ACTIONS(79), 1, 1233 | anon_sym_LBRACK, 1234 | ACTIONS(81), 1, 1235 | anon_sym_LBRACE, 1236 | STATE(30), 1, 1237 | sym_identifier, 1238 | ACTIONS(75), 2, 1239 | sym_string, 1240 | sym_float, 1241 | ACTIONS(73), 4, 1242 | sym_true, 1243 | sym_false, 1244 | sym_null, 1245 | sym_integer, 1246 | STATE(78), 5, 1247 | sym_string_name, 1248 | sym__value, 1249 | sym_dictionary, 1250 | sym_array, 1251 | sym_constructor, 1252 | [504] = 6, 1253 | ACTIONS(3), 1, 1254 | sym_comment, 1255 | ACTIONS(85), 1, 1256 | anon_sym_LBRACK, 1257 | ACTIONS(87), 1, 1258 | anon_sym_LPAREN, 1259 | STATE(22), 1, 1260 | sym_arguments, 1261 | STATE(75), 1, 1262 | sym__type_args, 1263 | ACTIONS(83), 7, 1264 | ts_builtin_sym_end, 1265 | anon_sym_RBRACK, 1266 | sym_path, 1267 | anon_sym_COLON, 1268 | anon_sym_COMMA, 1269 | anon_sym_RBRACE, 1270 | anon_sym_RPAREN, 1271 | [529] = 2, 1272 | ACTIONS(3), 1, 1273 | sym_comment, 1274 | ACTIONS(89), 9, 1275 | sym__identifier, 1276 | anon_sym_LBRACK, 1277 | anon_sym_RBRACK, 1278 | anon_sym_EQ, 1279 | anon_sym_COLON, 1280 | anon_sym_COMMA, 1281 | anon_sym_RBRACE, 1282 | anon_sym_LPAREN, 1283 | anon_sym_RPAREN, 1284 | [544] = 2, 1285 | ACTIONS(3), 1, 1286 | sym_comment, 1287 | ACTIONS(91), 8, 1288 | ts_builtin_sym_end, 1289 | anon_sym_LBRACK, 1290 | anon_sym_RBRACK, 1291 | sym_path, 1292 | anon_sym_COLON, 1293 | anon_sym_COMMA, 1294 | anon_sym_RBRACE, 1295 | anon_sym_RPAREN, 1296 | [558] = 2, 1297 | ACTIONS(3), 1, 1298 | sym_comment, 1299 | ACTIONS(93), 8, 1300 | ts_builtin_sym_end, 1301 | anon_sym_LBRACK, 1302 | anon_sym_RBRACK, 1303 | sym_path, 1304 | anon_sym_COLON, 1305 | anon_sym_COMMA, 1306 | anon_sym_RBRACE, 1307 | anon_sym_RPAREN, 1308 | [572] = 2, 1309 | ACTIONS(3), 1, 1310 | sym_comment, 1311 | ACTIONS(95), 8, 1312 | ts_builtin_sym_end, 1313 | anon_sym_LBRACK, 1314 | anon_sym_RBRACK, 1315 | sym_path, 1316 | anon_sym_COLON, 1317 | anon_sym_COMMA, 1318 | anon_sym_RBRACE, 1319 | anon_sym_RPAREN, 1320 | [586] = 2, 1321 | ACTIONS(3), 1, 1322 | sym_comment, 1323 | ACTIONS(97), 8, 1324 | ts_builtin_sym_end, 1325 | anon_sym_LBRACK, 1326 | anon_sym_RBRACK, 1327 | sym_path, 1328 | anon_sym_COLON, 1329 | anon_sym_COMMA, 1330 | anon_sym_RBRACE, 1331 | anon_sym_RPAREN, 1332 | [600] = 2, 1333 | ACTIONS(3), 1, 1334 | sym_comment, 1335 | ACTIONS(99), 8, 1336 | ts_builtin_sym_end, 1337 | anon_sym_LBRACK, 1338 | anon_sym_RBRACK, 1339 | sym_path, 1340 | anon_sym_COLON, 1341 | anon_sym_COMMA, 1342 | anon_sym_RBRACE, 1343 | anon_sym_RPAREN, 1344 | [614] = 2, 1345 | ACTIONS(3), 1, 1346 | sym_comment, 1347 | ACTIONS(101), 8, 1348 | ts_builtin_sym_end, 1349 | anon_sym_LBRACK, 1350 | anon_sym_RBRACK, 1351 | sym_path, 1352 | anon_sym_COLON, 1353 | anon_sym_COMMA, 1354 | anon_sym_RBRACE, 1355 | anon_sym_RPAREN, 1356 | [628] = 2, 1357 | ACTIONS(3), 1, 1358 | sym_comment, 1359 | ACTIONS(103), 8, 1360 | ts_builtin_sym_end, 1361 | anon_sym_LBRACK, 1362 | anon_sym_RBRACK, 1363 | sym_path, 1364 | anon_sym_COLON, 1365 | anon_sym_COMMA, 1366 | anon_sym_RBRACE, 1367 | anon_sym_RPAREN, 1368 | [642] = 2, 1369 | ACTIONS(3), 1, 1370 | sym_comment, 1371 | ACTIONS(105), 8, 1372 | ts_builtin_sym_end, 1373 | anon_sym_LBRACK, 1374 | anon_sym_RBRACK, 1375 | sym_path, 1376 | anon_sym_COLON, 1377 | anon_sym_COMMA, 1378 | anon_sym_RBRACE, 1379 | anon_sym_RPAREN, 1380 | [656] = 2, 1381 | ACTIONS(3), 1, 1382 | sym_comment, 1383 | ACTIONS(107), 8, 1384 | ts_builtin_sym_end, 1385 | anon_sym_LBRACK, 1386 | anon_sym_RBRACK, 1387 | sym_path, 1388 | anon_sym_COLON, 1389 | anon_sym_COMMA, 1390 | anon_sym_RBRACE, 1391 | anon_sym_RPAREN, 1392 | [670] = 2, 1393 | ACTIONS(3), 1, 1394 | sym_comment, 1395 | ACTIONS(109), 8, 1396 | ts_builtin_sym_end, 1397 | anon_sym_LBRACK, 1398 | anon_sym_RBRACK, 1399 | sym_path, 1400 | anon_sym_COLON, 1401 | anon_sym_COMMA, 1402 | anon_sym_RBRACE, 1403 | anon_sym_RPAREN, 1404 | [684] = 2, 1405 | ACTIONS(3), 1, 1406 | sym_comment, 1407 | ACTIONS(111), 8, 1408 | ts_builtin_sym_end, 1409 | anon_sym_LBRACK, 1410 | anon_sym_RBRACK, 1411 | sym_path, 1412 | anon_sym_COLON, 1413 | anon_sym_COMMA, 1414 | anon_sym_RBRACE, 1415 | anon_sym_RPAREN, 1416 | [698] = 2, 1417 | ACTIONS(3), 1, 1418 | sym_comment, 1419 | ACTIONS(113), 8, 1420 | ts_builtin_sym_end, 1421 | anon_sym_LBRACK, 1422 | anon_sym_RBRACK, 1423 | sym_path, 1424 | anon_sym_COLON, 1425 | anon_sym_COMMA, 1426 | anon_sym_RBRACE, 1427 | anon_sym_RPAREN, 1428 | [712] = 6, 1429 | ACTIONS(3), 1, 1430 | sym_comment, 1431 | ACTIONS(7), 1, 1432 | anon_sym_LBRACK, 1433 | ACTIONS(9), 1, 1434 | sym_path, 1435 | ACTIONS(115), 1, 1436 | ts_builtin_sym_end, 1437 | STATE(36), 2, 1438 | sym_property, 1439 | aux_sym_resource_repeat1, 1440 | STATE(43), 2, 1441 | sym_section, 1442 | aux_sym_resource_repeat2, 1443 | [733] = 6, 1444 | ACTIONS(3), 1, 1445 | sym_comment, 1446 | ACTIONS(85), 1, 1447 | anon_sym_LBRACK, 1448 | ACTIONS(117), 1, 1449 | anon_sym_LPAREN, 1450 | STATE(80), 1, 1451 | sym__type_args, 1452 | STATE(84), 1, 1453 | sym_arguments, 1454 | ACTIONS(83), 2, 1455 | sym__identifier, 1456 | anon_sym_RBRACK, 1457 | [753] = 4, 1458 | ACTIONS(3), 1, 1459 | sym_comment, 1460 | ACTIONS(9), 1, 1461 | sym_path, 1462 | ACTIONS(119), 2, 1463 | ts_builtin_sym_end, 1464 | anon_sym_LBRACK, 1465 | STATE(39), 2, 1466 | aux_sym__properties, 1467 | sym_property, 1468 | [768] = 4, 1469 | ACTIONS(3), 1, 1470 | sym_comment, 1471 | ACTIONS(9), 1, 1472 | sym_path, 1473 | ACTIONS(121), 2, 1474 | ts_builtin_sym_end, 1475 | anon_sym_LBRACK, 1476 | STATE(35), 2, 1477 | aux_sym__properties, 1478 | sym_property, 1479 | [783] = 5, 1480 | ACTIONS(3), 1, 1481 | sym_comment, 1482 | ACTIONS(123), 1, 1483 | sym__identifier, 1484 | ACTIONS(125), 1, 1485 | anon_sym_RBRACK, 1486 | STATE(91), 1, 1487 | sym_identifier, 1488 | STATE(37), 2, 1489 | aux_sym__attributes, 1490 | sym_attribute, 1491 | [800] = 5, 1492 | ACTIONS(3), 1, 1493 | sym_comment, 1494 | ACTIONS(123), 1, 1495 | sym__identifier, 1496 | ACTIONS(127), 1, 1497 | anon_sym_RBRACK, 1498 | STATE(91), 1, 1499 | sym_identifier, 1500 | STATE(33), 2, 1501 | aux_sym__attributes, 1502 | sym_attribute, 1503 | [817] = 4, 1504 | ACTIONS(3), 1, 1505 | sym_comment, 1506 | ACTIONS(131), 1, 1507 | sym_path, 1508 | ACTIONS(129), 2, 1509 | ts_builtin_sym_end, 1510 | anon_sym_LBRACK, 1511 | STATE(35), 2, 1512 | aux_sym__properties, 1513 | sym_property, 1514 | [832] = 4, 1515 | ACTIONS(3), 1, 1516 | sym_comment, 1517 | ACTIONS(136), 1, 1518 | sym_path, 1519 | ACTIONS(134), 2, 1520 | ts_builtin_sym_end, 1521 | anon_sym_LBRACK, 1522 | STATE(36), 2, 1523 | sym_property, 1524 | aux_sym_resource_repeat1, 1525 | [847] = 5, 1526 | ACTIONS(3), 1, 1527 | sym_comment, 1528 | ACTIONS(139), 1, 1529 | sym__identifier, 1530 | ACTIONS(142), 1, 1531 | anon_sym_RBRACK, 1532 | STATE(91), 1, 1533 | sym_identifier, 1534 | STATE(37), 2, 1535 | aux_sym__attributes, 1536 | sym_attribute, 1537 | [864] = 4, 1538 | ACTIONS(3), 1, 1539 | sym_comment, 1540 | ACTIONS(9), 1, 1541 | sym_path, 1542 | ACTIONS(144), 2, 1543 | ts_builtin_sym_end, 1544 | anon_sym_LBRACK, 1545 | STATE(32), 2, 1546 | aux_sym__properties, 1547 | sym_property, 1548 | [879] = 4, 1549 | ACTIONS(3), 1, 1550 | sym_comment, 1551 | ACTIONS(9), 1, 1552 | sym_path, 1553 | ACTIONS(144), 2, 1554 | ts_builtin_sym_end, 1555 | anon_sym_LBRACK, 1556 | STATE(35), 2, 1557 | aux_sym__properties, 1558 | sym_property, 1559 | [894] = 4, 1560 | ACTIONS(3), 1, 1561 | sym_comment, 1562 | ACTIONS(146), 1, 1563 | ts_builtin_sym_end, 1564 | ACTIONS(148), 1, 1565 | anon_sym_LBRACK, 1566 | STATE(40), 2, 1567 | sym_section, 1568 | aux_sym_resource_repeat2, 1569 | [908] = 4, 1570 | ACTIONS(3), 1, 1571 | sym_comment, 1572 | ACTIONS(7), 1, 1573 | anon_sym_LBRACK, 1574 | ACTIONS(115), 1, 1575 | ts_builtin_sym_end, 1576 | STATE(40), 2, 1577 | sym_section, 1578 | aux_sym_resource_repeat2, 1579 | [922] = 2, 1580 | ACTIONS(3), 1, 1581 | sym_comment, 1582 | ACTIONS(89), 4, 1583 | ts_builtin_sym_end, 1584 | anon_sym_LBRACK, 1585 | sym_path, 1586 | anon_sym_LPAREN, 1587 | [932] = 4, 1588 | ACTIONS(3), 1, 1589 | sym_comment, 1590 | ACTIONS(7), 1, 1591 | anon_sym_LBRACK, 1592 | ACTIONS(151), 1, 1593 | ts_builtin_sym_end, 1594 | STATE(40), 2, 1595 | sym_section, 1596 | aux_sym_resource_repeat2, 1597 | [946] = 5, 1598 | ACTIONS(3), 1, 1599 | sym_comment, 1600 | ACTIONS(153), 1, 1601 | anon_sym_COLON, 1602 | ACTIONS(155), 1, 1603 | anon_sym_COMMA, 1604 | ACTIONS(157), 1, 1605 | anon_sym_RPAREN, 1606 | STATE(54), 1, 1607 | aux_sym_arguments_repeat1, 1608 | [962] = 5, 1609 | ACTIONS(3), 1, 1610 | sym_comment, 1611 | ACTIONS(153), 1, 1612 | anon_sym_COLON, 1613 | ACTIONS(155), 1, 1614 | anon_sym_COMMA, 1615 | ACTIONS(159), 1, 1616 | anon_sym_RPAREN, 1617 | STATE(47), 1, 1618 | aux_sym_arguments_repeat1, 1619 | [978] = 4, 1620 | ACTIONS(3), 1, 1621 | sym_comment, 1622 | ACTIONS(155), 1, 1623 | anon_sym_COMMA, 1624 | ACTIONS(157), 1, 1625 | anon_sym_RPAREN, 1626 | STATE(54), 1, 1627 | aux_sym_arguments_repeat1, 1628 | [991] = 4, 1629 | ACTIONS(3), 1, 1630 | sym_comment, 1631 | ACTIONS(155), 1, 1632 | anon_sym_COMMA, 1633 | ACTIONS(161), 1, 1634 | anon_sym_RPAREN, 1635 | STATE(57), 1, 1636 | aux_sym_arguments_repeat1, 1637 | [1004] = 4, 1638 | ACTIONS(3), 1, 1639 | sym_comment, 1640 | ACTIONS(163), 1, 1641 | anon_sym_RBRACK, 1642 | ACTIONS(165), 1, 1643 | anon_sym_COMMA, 1644 | STATE(48), 1, 1645 | aux_sym_array_repeat1, 1646 | [1017] = 2, 1647 | ACTIONS(3), 1, 1648 | sym_comment, 1649 | ACTIONS(168), 3, 1650 | anon_sym_COMMA, 1651 | anon_sym_RBRACE, 1652 | anon_sym_RPAREN, 1653 | [1026] = 2, 1654 | ACTIONS(3), 1, 1655 | sym_comment, 1656 | ACTIONS(170), 3, 1657 | ts_builtin_sym_end, 1658 | anon_sym_LBRACK, 1659 | sym_path, 1660 | [1035] = 4, 1661 | ACTIONS(3), 1, 1662 | sym_comment, 1663 | ACTIONS(172), 1, 1664 | anon_sym_COMMA, 1665 | ACTIONS(175), 1, 1666 | anon_sym_RBRACE, 1667 | STATE(51), 1, 1668 | aux_sym_dictionary_repeat1, 1669 | [1048] = 4, 1670 | ACTIONS(3), 1, 1671 | sym_comment, 1672 | ACTIONS(177), 1, 1673 | anon_sym_RBRACK, 1674 | ACTIONS(179), 1, 1675 | anon_sym_COMMA, 1676 | STATE(48), 1, 1677 | aux_sym_array_repeat1, 1678 | [1061] = 4, 1679 | ACTIONS(3), 1, 1680 | sym_comment, 1681 | ACTIONS(179), 1, 1682 | anon_sym_COMMA, 1683 | ACTIONS(181), 1, 1684 | anon_sym_RBRACK, 1685 | STATE(56), 1, 1686 | aux_sym_array_repeat1, 1687 | [1074] = 4, 1688 | ACTIONS(3), 1, 1689 | sym_comment, 1690 | ACTIONS(155), 1, 1691 | anon_sym_COMMA, 1692 | ACTIONS(183), 1, 1693 | anon_sym_RPAREN, 1694 | STATE(57), 1, 1695 | aux_sym_arguments_repeat1, 1696 | [1087] = 3, 1697 | ACTIONS(3), 1, 1698 | sym_comment, 1699 | ACTIONS(153), 1, 1700 | anon_sym_COLON, 1701 | ACTIONS(185), 2, 1702 | anon_sym_COMMA, 1703 | anon_sym_RPAREN, 1704 | [1098] = 4, 1705 | ACTIONS(3), 1, 1706 | sym_comment, 1707 | ACTIONS(179), 1, 1708 | anon_sym_COMMA, 1709 | ACTIONS(187), 1, 1710 | anon_sym_RBRACK, 1711 | STATE(48), 1, 1712 | aux_sym_array_repeat1, 1713 | [1111] = 4, 1714 | ACTIONS(3), 1, 1715 | sym_comment, 1716 | ACTIONS(185), 1, 1717 | anon_sym_RPAREN, 1718 | ACTIONS(189), 1, 1719 | anon_sym_COMMA, 1720 | STATE(57), 1, 1721 | aux_sym_arguments_repeat1, 1722 | [1124] = 4, 1723 | ACTIONS(3), 1, 1724 | sym_comment, 1725 | ACTIONS(192), 1, 1726 | anon_sym_COMMA, 1727 | ACTIONS(194), 1, 1728 | anon_sym_RBRACE, 1729 | STATE(59), 1, 1730 | aux_sym_dictionary_repeat1, 1731 | [1137] = 4, 1732 | ACTIONS(3), 1, 1733 | sym_comment, 1734 | ACTIONS(192), 1, 1735 | anon_sym_COMMA, 1736 | ACTIONS(196), 1, 1737 | anon_sym_RBRACE, 1738 | STATE(51), 1, 1739 | aux_sym_dictionary_repeat1, 1740 | [1150] = 4, 1741 | ACTIONS(3), 1, 1742 | sym_comment, 1743 | ACTIONS(179), 1, 1744 | anon_sym_COMMA, 1745 | ACTIONS(198), 1, 1746 | anon_sym_RBRACK, 1747 | STATE(63), 1, 1748 | aux_sym_array_repeat1, 1749 | [1163] = 4, 1750 | ACTIONS(3), 1, 1751 | sym_comment, 1752 | ACTIONS(192), 1, 1753 | anon_sym_COMMA, 1754 | ACTIONS(200), 1, 1755 | anon_sym_RBRACE, 1756 | STATE(64), 1, 1757 | aux_sym_dictionary_repeat1, 1758 | [1176] = 4, 1759 | ACTIONS(3), 1, 1760 | sym_comment, 1761 | ACTIONS(179), 1, 1762 | anon_sym_COMMA, 1763 | ACTIONS(202), 1, 1764 | anon_sym_RBRACK, 1765 | STATE(52), 1, 1766 | aux_sym_array_repeat1, 1767 | [1189] = 4, 1768 | ACTIONS(3), 1, 1769 | sym_comment, 1770 | ACTIONS(179), 1, 1771 | anon_sym_COMMA, 1772 | ACTIONS(204), 1, 1773 | anon_sym_RBRACK, 1774 | STATE(48), 1, 1775 | aux_sym_array_repeat1, 1776 | [1202] = 4, 1777 | ACTIONS(3), 1, 1778 | sym_comment, 1779 | ACTIONS(192), 1, 1780 | anon_sym_COMMA, 1781 | ACTIONS(206), 1, 1782 | anon_sym_RBRACE, 1783 | STATE(51), 1, 1784 | aux_sym_dictionary_repeat1, 1785 | [1215] = 4, 1786 | ACTIONS(3), 1, 1787 | sym_comment, 1788 | ACTIONS(155), 1, 1789 | anon_sym_COMMA, 1790 | ACTIONS(159), 1, 1791 | anon_sym_RPAREN, 1792 | STATE(47), 1, 1793 | aux_sym_arguments_repeat1, 1794 | [1228] = 2, 1795 | ACTIONS(3), 1, 1796 | sym_comment, 1797 | ACTIONS(111), 2, 1798 | sym__identifier, 1799 | anon_sym_RBRACK, 1800 | [1236] = 2, 1801 | ACTIONS(3), 1, 1802 | sym_comment, 1803 | ACTIONS(163), 2, 1804 | anon_sym_RBRACK, 1805 | anon_sym_COMMA, 1806 | [1244] = 2, 1807 | ACTIONS(3), 1, 1808 | sym_comment, 1809 | ACTIONS(99), 2, 1810 | sym__identifier, 1811 | anon_sym_RBRACK, 1812 | [1252] = 2, 1813 | ACTIONS(3), 1, 1814 | sym_comment, 1815 | ACTIONS(93), 2, 1816 | sym__identifier, 1817 | anon_sym_RBRACK, 1818 | [1260] = 2, 1819 | ACTIONS(3), 1, 1820 | sym_comment, 1821 | ACTIONS(103), 2, 1822 | sym__identifier, 1823 | anon_sym_RBRACK, 1824 | [1268] = 2, 1825 | ACTIONS(3), 1, 1826 | sym_comment, 1827 | ACTIONS(109), 2, 1828 | sym__identifier, 1829 | anon_sym_RBRACK, 1830 | [1276] = 2, 1831 | ACTIONS(3), 1, 1832 | sym_comment, 1833 | ACTIONS(91), 2, 1834 | sym__identifier, 1835 | anon_sym_RBRACK, 1836 | [1284] = 2, 1837 | ACTIONS(3), 1, 1838 | sym_comment, 1839 | ACTIONS(113), 2, 1840 | sym__identifier, 1841 | anon_sym_RBRACK, 1842 | [1292] = 2, 1843 | ACTIONS(3), 1, 1844 | sym_comment, 1845 | ACTIONS(107), 2, 1846 | sym__identifier, 1847 | anon_sym_RBRACK, 1848 | [1300] = 3, 1849 | ACTIONS(3), 1, 1850 | sym_comment, 1851 | ACTIONS(87), 1, 1852 | anon_sym_LPAREN, 1853 | STATE(26), 1, 1854 | sym_arguments, 1855 | [1310] = 2, 1856 | ACTIONS(3), 1, 1857 | sym_comment, 1858 | ACTIONS(185), 2, 1859 | anon_sym_COMMA, 1860 | anon_sym_RPAREN, 1861 | [1318] = 3, 1862 | ACTIONS(3), 1, 1863 | sym_comment, 1864 | ACTIONS(123), 1, 1865 | sym__identifier, 1866 | STATE(34), 1, 1867 | sym_identifier, 1868 | [1328] = 2, 1869 | ACTIONS(3), 1, 1870 | sym_comment, 1871 | ACTIONS(208), 2, 1872 | sym__identifier, 1873 | anon_sym_RBRACK, 1874 | [1336] = 2, 1875 | ACTIONS(3), 1, 1876 | sym_comment, 1877 | ACTIONS(175), 2, 1878 | anon_sym_COMMA, 1879 | anon_sym_RBRACE, 1880 | [1344] = 3, 1881 | ACTIONS(3), 1, 1882 | sym_comment, 1883 | ACTIONS(117), 1, 1884 | anon_sym_LPAREN, 1885 | STATE(71), 1, 1886 | sym_arguments, 1887 | [1354] = 2, 1888 | ACTIONS(3), 1, 1889 | sym_comment, 1890 | ACTIONS(105), 2, 1891 | sym__identifier, 1892 | anon_sym_RBRACK, 1893 | [1362] = 2, 1894 | ACTIONS(3), 1, 1895 | sym_comment, 1896 | ACTIONS(95), 2, 1897 | sym__identifier, 1898 | anon_sym_RBRACK, 1899 | [1370] = 2, 1900 | ACTIONS(3), 1, 1901 | sym_comment, 1902 | ACTIONS(97), 2, 1903 | sym__identifier, 1904 | anon_sym_RBRACK, 1905 | [1378] = 2, 1906 | ACTIONS(3), 1, 1907 | sym_comment, 1908 | ACTIONS(101), 2, 1909 | sym__identifier, 1910 | anon_sym_RBRACK, 1911 | [1386] = 2, 1912 | ACTIONS(3), 1, 1913 | sym_comment, 1914 | ACTIONS(153), 1, 1915 | anon_sym_COLON, 1916 | [1393] = 2, 1917 | ACTIONS(3), 1, 1918 | sym_comment, 1919 | ACTIONS(210), 1, 1920 | anon_sym_LPAREN, 1921 | [1400] = 2, 1922 | ACTIONS(3), 1, 1923 | sym_comment, 1924 | ACTIONS(212), 1, 1925 | sym_string, 1926 | [1407] = 2, 1927 | ACTIONS(3), 1, 1928 | sym_comment, 1929 | ACTIONS(214), 1, 1930 | sym_string, 1931 | [1414] = 2, 1932 | ACTIONS(3), 1, 1933 | sym_comment, 1934 | ACTIONS(216), 1, 1935 | anon_sym_LPAREN, 1936 | [1421] = 2, 1937 | ACTIONS(3), 1, 1938 | sym_comment, 1939 | ACTIONS(218), 1, 1940 | anon_sym_EQ, 1941 | [1428] = 2, 1942 | ACTIONS(3), 1, 1943 | sym_comment, 1944 | ACTIONS(220), 1, 1945 | anon_sym_EQ, 1946 | [1435] = 2, 1947 | ACTIONS(3), 1, 1948 | sym_comment, 1949 | ACTIONS(222), 1, 1950 | ts_builtin_sym_end, 1951 | }; 1952 | 1953 | static const uint32_t ts_small_parse_table_map[] = { 1954 | [SMALL_STATE(2)] = 0, 1955 | [SMALL_STATE(3)] = 42, 1956 | [SMALL_STATE(4)] = 84, 1957 | [SMALL_STATE(5)] = 126, 1958 | [SMALL_STATE(6)] = 168, 1959 | [SMALL_STATE(7)] = 207, 1960 | [SMALL_STATE(8)] = 246, 1961 | [SMALL_STATE(9)] = 285, 1962 | [SMALL_STATE(10)] = 324, 1963 | [SMALL_STATE(11)] = 360, 1964 | [SMALL_STATE(12)] = 396, 1965 | [SMALL_STATE(13)] = 432, 1966 | [SMALL_STATE(14)] = 468, 1967 | [SMALL_STATE(15)] = 504, 1968 | [SMALL_STATE(16)] = 529, 1969 | [SMALL_STATE(17)] = 544, 1970 | [SMALL_STATE(18)] = 558, 1971 | [SMALL_STATE(19)] = 572, 1972 | [SMALL_STATE(20)] = 586, 1973 | [SMALL_STATE(21)] = 600, 1974 | [SMALL_STATE(22)] = 614, 1975 | [SMALL_STATE(23)] = 628, 1976 | [SMALL_STATE(24)] = 642, 1977 | [SMALL_STATE(25)] = 656, 1978 | [SMALL_STATE(26)] = 670, 1979 | [SMALL_STATE(27)] = 684, 1980 | [SMALL_STATE(28)] = 698, 1981 | [SMALL_STATE(29)] = 712, 1982 | [SMALL_STATE(30)] = 733, 1983 | [SMALL_STATE(31)] = 753, 1984 | [SMALL_STATE(32)] = 768, 1985 | [SMALL_STATE(33)] = 783, 1986 | [SMALL_STATE(34)] = 800, 1987 | [SMALL_STATE(35)] = 817, 1988 | [SMALL_STATE(36)] = 832, 1989 | [SMALL_STATE(37)] = 847, 1990 | [SMALL_STATE(38)] = 864, 1991 | [SMALL_STATE(39)] = 879, 1992 | [SMALL_STATE(40)] = 894, 1993 | [SMALL_STATE(41)] = 908, 1994 | [SMALL_STATE(42)] = 922, 1995 | [SMALL_STATE(43)] = 932, 1996 | [SMALL_STATE(44)] = 946, 1997 | [SMALL_STATE(45)] = 962, 1998 | [SMALL_STATE(46)] = 978, 1999 | [SMALL_STATE(47)] = 991, 2000 | [SMALL_STATE(48)] = 1004, 2001 | [SMALL_STATE(49)] = 1017, 2002 | [SMALL_STATE(50)] = 1026, 2003 | [SMALL_STATE(51)] = 1035, 2004 | [SMALL_STATE(52)] = 1048, 2005 | [SMALL_STATE(53)] = 1061, 2006 | [SMALL_STATE(54)] = 1074, 2007 | [SMALL_STATE(55)] = 1087, 2008 | [SMALL_STATE(56)] = 1098, 2009 | [SMALL_STATE(57)] = 1111, 2010 | [SMALL_STATE(58)] = 1124, 2011 | [SMALL_STATE(59)] = 1137, 2012 | [SMALL_STATE(60)] = 1150, 2013 | [SMALL_STATE(61)] = 1163, 2014 | [SMALL_STATE(62)] = 1176, 2015 | [SMALL_STATE(63)] = 1189, 2016 | [SMALL_STATE(64)] = 1202, 2017 | [SMALL_STATE(65)] = 1215, 2018 | [SMALL_STATE(66)] = 1228, 2019 | [SMALL_STATE(67)] = 1236, 2020 | [SMALL_STATE(68)] = 1244, 2021 | [SMALL_STATE(69)] = 1252, 2022 | [SMALL_STATE(70)] = 1260, 2023 | [SMALL_STATE(71)] = 1268, 2024 | [SMALL_STATE(72)] = 1276, 2025 | [SMALL_STATE(73)] = 1284, 2026 | [SMALL_STATE(74)] = 1292, 2027 | [SMALL_STATE(75)] = 1300, 2028 | [SMALL_STATE(76)] = 1310, 2029 | [SMALL_STATE(77)] = 1318, 2030 | [SMALL_STATE(78)] = 1328, 2031 | [SMALL_STATE(79)] = 1336, 2032 | [SMALL_STATE(80)] = 1344, 2033 | [SMALL_STATE(81)] = 1354, 2034 | [SMALL_STATE(82)] = 1362, 2035 | [SMALL_STATE(83)] = 1370, 2036 | [SMALL_STATE(84)] = 1378, 2037 | [SMALL_STATE(85)] = 1386, 2038 | [SMALL_STATE(86)] = 1393, 2039 | [SMALL_STATE(87)] = 1400, 2040 | [SMALL_STATE(88)] = 1407, 2041 | [SMALL_STATE(89)] = 1414, 2042 | [SMALL_STATE(90)] = 1421, 2043 | [SMALL_STATE(91)] = 1428, 2044 | [SMALL_STATE(92)] = 1435, 2045 | }; 2046 | 2047 | static const TSParseActionEntry ts_parse_actions[] = { 2048 | [0] = {.entry = {.count = 0, .reusable = false}}, 2049 | [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), 2050 | [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(), 2051 | [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_resource, 0, 0, 0), 2052 | [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(77), 2053 | [9] = {.entry = {.count = 1, .reusable = true}}, SHIFT(90), 2054 | [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), 2055 | [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(44), 2056 | [15] = {.entry = {.count = 1, .reusable = true}}, SHIFT(44), 2057 | [17] = {.entry = {.count = 1, .reusable = true}}, SHIFT(88), 2058 | [19] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6), 2059 | [21] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3), 2060 | [23] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), 2061 | [25] = {.entry = {.count = 1, .reusable = false}}, SHIFT(85), 2062 | [27] = {.entry = {.count = 1, .reusable = true}}, SHIFT(85), 2063 | [29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(20), 2064 | [31] = {.entry = {.count = 1, .reusable = false}}, SHIFT(45), 2065 | [33] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), 2066 | [35] = {.entry = {.count = 1, .reusable = true}}, SHIFT(70), 2067 | [37] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83), 2068 | [39] = {.entry = {.count = 1, .reusable = false}}, SHIFT(53), 2069 | [41] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53), 2070 | [43] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), 2071 | [45] = {.entry = {.count = 1, .reusable = false}}, SHIFT(55), 2072 | [47] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), 2073 | [49] = {.entry = {.count = 1, .reusable = false}}, SHIFT(60), 2074 | [51] = {.entry = {.count = 1, .reusable = true}}, SHIFT(60), 2075 | [53] = {.entry = {.count = 1, .reusable = true}}, SHIFT(82), 2076 | [55] = {.entry = {.count = 1, .reusable = false}}, SHIFT(49), 2077 | [57] = {.entry = {.count = 1, .reusable = true}}, SHIFT(49), 2078 | [59] = {.entry = {.count = 1, .reusable = false}}, SHIFT(62), 2079 | [61] = {.entry = {.count = 1, .reusable = true}}, SHIFT(62), 2080 | [63] = {.entry = {.count = 1, .reusable = false}}, SHIFT(42), 2081 | [65] = {.entry = {.count = 1, .reusable = false}}, SHIFT(50), 2082 | [67] = {.entry = {.count = 1, .reusable = true}}, SHIFT(50), 2083 | [69] = {.entry = {.count = 1, .reusable = false}}, SHIFT(67), 2084 | [71] = {.entry = {.count = 1, .reusable = true}}, SHIFT(67), 2085 | [73] = {.entry = {.count = 1, .reusable = false}}, SHIFT(78), 2086 | [75] = {.entry = {.count = 1, .reusable = true}}, SHIFT(78), 2087 | [77] = {.entry = {.count = 1, .reusable = true}}, SHIFT(87), 2088 | [79] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9), 2089 | [81] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5), 2090 | [83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__value, 1, 0, 0), 2091 | [85] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), 2092 | [87] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), 2093 | [89] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_identifier, 1, 0, 0), 2094 | [91] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 4, 0, 0), 2095 | [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dictionary, 3, 0, 0), 2096 | [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 2, 0, 0), 2097 | [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dictionary, 2, 0, 0), 2098 | [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array, 3, 0, 0), 2099 | [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_constructor, 2, 0, 0), 2100 | [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 2, 0, 0), 2101 | [105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_string_name, 2, 0, 1), 2102 | [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 3, 0, 0), 2103 | [109] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_constructor, 3, 0, 0), 2104 | [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_arguments, 4, 0, 0), 2105 | [113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_dictionary, 4, 0, 0), 2106 | [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_resource, 1, 0, 0), 2107 | [117] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), 2108 | [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_section, 3, 0, 0), 2109 | [121] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_section, 5, 0, 0), 2110 | [123] = {.entry = {.count = 1, .reusable = true}}, SHIFT(16), 2111 | [125] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), 2112 | [127] = {.entry = {.count = 1, .reusable = true}}, SHIFT(31), 2113 | [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__properties, 2, 0, 0), 2114 | [131] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__properties, 2, 0, 0), SHIFT_REPEAT(90), 2115 | [134] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_resource_repeat1, 2, 0, 0), 2116 | [136] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_resource_repeat1, 2, 0, 0), SHIFT_REPEAT(90), 2117 | [139] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym__attributes, 2, 0, 0), SHIFT_REPEAT(16), 2118 | [142] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym__attributes, 2, 0, 0), 2119 | [144] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_section, 4, 0, 0), 2120 | [146] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_resource_repeat2, 2, 0, 0), 2121 | [148] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_resource_repeat2, 2, 0, 0), SHIFT_REPEAT(77), 2122 | [151] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_resource, 2, 0, 0), 2123 | [153] = {.entry = {.count = 1, .reusable = true}}, SHIFT(10), 2124 | [155] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), 2125 | [157] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), 2126 | [159] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), 2127 | [161] = {.entry = {.count = 1, .reusable = true}}, SHIFT(66), 2128 | [163] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2, 0, 0), 2129 | [165] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_array_repeat1, 2, 0, 0), SHIFT_REPEAT(13), 2130 | [168] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_pair, 3, 0, 0), 2131 | [170] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_property, 3, 0, 0), 2132 | [172] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_dictionary_repeat1, 2, 0, 0), SHIFT_REPEAT(7), 2133 | [175] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_dictionary_repeat1, 2, 0, 0), 2134 | [177] = {.entry = {.count = 1, .reusable = true}}, SHIFT(89), 2135 | [179] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13), 2136 | [181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(21), 2137 | [183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), 2138 | [185] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_arguments_repeat1, 2, 0, 0), 2139 | [187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17), 2140 | [189] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_arguments_repeat1, 2, 0, 0), SHIFT_REPEAT(8), 2141 | [192] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), 2142 | [194] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18), 2143 | [196] = {.entry = {.count = 1, .reusable = true}}, SHIFT(28), 2144 | [198] = {.entry = {.count = 1, .reusable = true}}, SHIFT(68), 2145 | [200] = {.entry = {.count = 1, .reusable = true}}, SHIFT(69), 2146 | [202] = {.entry = {.count = 1, .reusable = true}}, SHIFT(86), 2147 | [204] = {.entry = {.count = 1, .reusable = true}}, SHIFT(72), 2148 | [206] = {.entry = {.count = 1, .reusable = true}}, SHIFT(73), 2149 | [208] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_attribute, 3, 0, 0), 2150 | [210] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__type_args, 3, 0, 0), 2151 | [212] = {.entry = {.count = 1, .reusable = true}}, SHIFT(81), 2152 | [214] = {.entry = {.count = 1, .reusable = true}}, SHIFT(24), 2153 | [216] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__type_args, 4, 0, 0), 2154 | [218] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), 2155 | [220] = {.entry = {.count = 1, .reusable = true}}, SHIFT(14), 2156 | [222] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), 2157 | }; 2158 | 2159 | enum ts_external_scanner_symbol_identifiers { 2160 | ts_external_token_string = 0, 2161 | }; 2162 | 2163 | static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { 2164 | [ts_external_token_string] = sym_string, 2165 | }; 2166 | 2167 | static const bool ts_external_scanner_states[2][EXTERNAL_TOKEN_COUNT] = { 2168 | [1] = { 2169 | [ts_external_token_string] = true, 2170 | }, 2171 | }; 2172 | 2173 | #ifdef __cplusplus 2174 | extern "C" { 2175 | #endif 2176 | void *tree_sitter_godot_resource_external_scanner_create(void); 2177 | void tree_sitter_godot_resource_external_scanner_destroy(void *); 2178 | bool tree_sitter_godot_resource_external_scanner_scan(void *, TSLexer *, const bool *); 2179 | unsigned tree_sitter_godot_resource_external_scanner_serialize(void *, char *); 2180 | void tree_sitter_godot_resource_external_scanner_deserialize(void *, const char *, unsigned); 2181 | 2182 | #ifdef TREE_SITTER_HIDE_SYMBOLS 2183 | #define TS_PUBLIC 2184 | #elif defined(_WIN32) 2185 | #define TS_PUBLIC __declspec(dllexport) 2186 | #else 2187 | #define TS_PUBLIC __attribute__((visibility("default"))) 2188 | #endif 2189 | 2190 | TS_PUBLIC const TSLanguage *tree_sitter_godot_resource(void) { 2191 | static const TSLanguage language = { 2192 | .version = LANGUAGE_VERSION, 2193 | .symbol_count = SYMBOL_COUNT, 2194 | .alias_count = ALIAS_COUNT, 2195 | .token_count = TOKEN_COUNT, 2196 | .external_token_count = EXTERNAL_TOKEN_COUNT, 2197 | .state_count = STATE_COUNT, 2198 | .large_state_count = LARGE_STATE_COUNT, 2199 | .production_id_count = PRODUCTION_ID_COUNT, 2200 | .field_count = FIELD_COUNT, 2201 | .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, 2202 | .parse_table = &ts_parse_table[0][0], 2203 | .small_parse_table = ts_small_parse_table, 2204 | .small_parse_table_map = ts_small_parse_table_map, 2205 | .parse_actions = ts_parse_actions, 2206 | .symbol_names = ts_symbol_names, 2207 | .symbol_metadata = ts_symbol_metadata, 2208 | .public_symbol_map = ts_symbol_map, 2209 | .alias_map = ts_non_terminal_alias_map, 2210 | .alias_sequences = &ts_alias_sequences[0][0], 2211 | .lex_modes = ts_lex_modes, 2212 | .lex_fn = ts_lex, 2213 | .keyword_lex_fn = ts_lex_keywords, 2214 | .keyword_capture_token = sym__identifier, 2215 | .external_scanner = { 2216 | &ts_external_scanner_states[0][0], 2217 | ts_external_scanner_symbol_map, 2218 | tree_sitter_godot_resource_external_scanner_create, 2219 | tree_sitter_godot_resource_external_scanner_destroy, 2220 | tree_sitter_godot_resource_external_scanner_scan, 2221 | tree_sitter_godot_resource_external_scanner_serialize, 2222 | tree_sitter_godot_resource_external_scanner_deserialize, 2223 | }, 2224 | .primary_state_ids = ts_primary_state_ids, 2225 | }; 2226 | return &language; 2227 | } 2228 | #ifdef __cplusplus 2229 | } 2230 | #endif 2231 | --------------------------------------------------------------------------------