Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
feat(lang): add Chialisp support with a first-party tree-sitter grammar
Martin Vogel706bb2ce81da
diff --git a/.gitattributes b/.gitattributesindex a76ea0bd6..1b2d4fb75 100644--- a/.gitattributes+++ b/.gitattributes@@ -11,3 +11,7 @@ internal/cbm/vendored/grammars/**/scanner.c linguist-generated=true diff=false# the git hooks are extensionless and need explicit entries. (#1272)scripts/git-hooks/commit-msg text eol=lfscripts/hooks/pre-commit text eol=lf++# Chialisp grammar corpus: one case asserts CRLF comment termination, so this+# file must keep its exact bytes on every platform (no eol conversion). (#919)+tools/tree-sitter-chialisp/test/corpus/comments.txt -textdiff --git a/README.md b/README.mdindex 4744d135c..bc1d0b0d2 100644--- a/README.md+++ b/README.md@@ -4,7 +4,7 @@[](LICENSE)[](https://github.com/DeusData/codebase-memory-mcp/actions/workflows/dry-run.yml)[](https://github.com/DeusData/codebase-memory-mcp)-[](https://github.com/DeusData/codebase-memory-mcp)+[](https://github.com/DeusData/codebase-memory-mcp)[](#hybrid-lsp)[](https://github.com/DeusData/codebase-memory-mcp)[](https://github.com/DeusData/codebase-memory-mcp)@@ -16,7 +16,7 @@**The fastest and most efficient code intelligence engine for AI coding agents.** Full-indexes an average repository in milliseconds, the Linux kernel (28M LOC, 75K files) in 3 minutes. Answers structural queries in under 1ms. Ships as a native executable with a small verified runtime-asset set for macOS, Linux, and Windows — download, run `install`, done.-High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 161 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No language runtime, hosted service, or API key. Plug and play across 45 supported automatic/conditional client surfaces.+High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 162 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No language runtime, hosted service, or API key. Plug and play across 45 supported automatic/conditional client surfaces.> **Research** — The design and benchmarks behind this project are described in the preprint [*Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP*](https://arxiv.org/abs/2603.27277) (arXiv:2603.27277). Evaluated across 31 real-world repositories: 83% answer quality, 10× fewer tokens, 2.1× fewer tool calls vs. file-by-file exploration.@@ -32,7 +32,7 @@ High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-si- **Extreme indexing speed** — Linux kernel (28M LOC, 75K files) in 3 minutes. RAM-first pipeline: LZ4 compression, in-memory SQLite, fused Aho-Corasick pattern matching. Memory released after indexing.- **Plug and play** — native executable plus authenticated release-owned assets for macOS (arm64/amd64), Linux (arm64/amd64), and Windows (amd64). The native install needs no Docker, language runtime, or API keys. Download → `install` → restart agent → done.-- **161 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.+- **162 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.- **120x fewer tokens** — 5 structural queries: ~3,400 tokens vs ~412,000 via file-by-file search. One graph query replaces dozens of grep/read cycles.- **45 supported automatic/conditional client surfaces** — `install` configures detected clients and safely activates conditional clients only when their documented platform, marker, or explicit existing config path is present. See [Multi-Agent Support](#multi-agent-support) for the complete matrix and manual/UI-only boundaries.- **Built-in graph visualization** — 3D interactive UI at `localhost:9749`, served from the binary itself.@@ -796,14 +796,14 @@ codebase-memory-mcp ships a **lightweight C implementation of language type-reso**Two-layer architecture:**-1. **Tree-sitter pass** — fast, syntactic, runs for every one of the 161 languages. Extracts definitions, calls, imports.+1. **Tree-sitter pass** — fast, syntactic, runs for every one of the 162 languages. Extracts definitions, calls, imports.2. **Hybrid LSP pass** — type-aware, runs above the tree-sitter pass per-language. Refines call edges using the import graph plus a per-file or pre-built cross-file definition registry. Languages without a Hybrid LSP pass yet fall back to textual resolution, so you always get *some* answer.The result is a knowledge graph accurate enough to drive `trace_path` across packages, inheritance hierarchies, and stdlib calls — without paying for a language server process per project.## Language Support-161 languages, all parsed via vendored tree-sitter grammars compiled into the binary. Benchmarked against 64 real open-source repositories (78 to 49K nodes):+162 languages, all parsed via vendored tree-sitter grammars compiled into the binary. Benchmarked against 64 real open-source repositories (78 to 49K nodes):| Tier | Score | Languages ||------|-------|-----------|@@ -829,7 +829,7 @@ src/traces/ Runtime trace ingestionui/ Local HTTP server + verified external 3D-UI asset packfoundation/ Platform abstractions (threads, filesystem, logging, memory)-internal/cbm/ Vendored tree-sitter grammars (161 languages) + AST extraction engine+internal/cbm/ Vendored tree-sitter grammars (162 languages) + AST extraction engine```## Securitydiff --git a/THIRD_PARTY.md b/THIRD_PARTY.mdindex d148f9f65..fdcb0d5e4 100644--- a/THIRD_PARTY.md+++ b/THIRD_PARTY.md@@ -52,9 +52,15 @@ License summary:- `clojure` ([sogaiu/tree-sitter-clojure](https://github.com/sogaiu/tree-sitter-clojure)) is **CC0-1.0**;`fennel` is **CC0-1.0**; `jinja2` and `just` are **Apache-2.0**;`pine` is **ISC** (declared by its upstream).-- The grammars authored in-house for this project (`cobol`, `form`, `janet`,- `magma`, `protobuf`, `wolfram`) are **MIT** under the project's own license,- (c) DeusData. Seven further grammars (`arkts`, `assembly`, `cfml`,+- The grammars authored in-house for this project (`chialisp`, `cobol`, `form`,+ `janet`, `magma`, `protobuf`, `wolfram`) are **MIT** under the project's own+ license, (c) DeusData. Each ships the repository's own LICENSE, byte-identical+ to the root copy; they carry no third-party copyright because there is no+ third party. `chialisp` is a generic s-expression grammar for the Chia+ smart-coin language, written for this project because no usable public+ grammar exists; its source and corpus tests live in+ `tools/tree-sitter-chialisp/`.+- Seven further grammars (`arkts`, `assembly`, `cfml`,`cfscript`, `dotenv`, `pine`, `qml`) are self-maintained forks that retaintheir original upstream authors' licenses — see the manifest for per-grammarprovenance. `arkts` is a first-party derivative ofdiff --git a/docs/index.html b/docs/index.htmlindex ac5ecb81f..56496d5d8 100644--- a/docs/index.html+++ b/docs/index.html@@ -4,7 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>codebase-memory-mcp — Code Intelligence Knowledge Graph for AI Coding Agents</title>- <meta name="description" content="codebase-memory-mcp is an open-source MCP server that indexes any codebase into a persistent knowledge graph so AI coding agents answer structural questions with ~120x fewer tokens. 161 languages, Hybrid LSP type resolution, local semantic vector search, code-clone detection, sub-1ms queries, Linux kernel indexed in 3 minutes. Native executable with verified assets and no language runtime. One command configures 45 automatic/conditional client surfaces.">+ <meta name="description" content="codebase-memory-mcp is an open-source MCP server that indexes any codebase into a persistent knowledge graph so AI coding agents answer structural questions with ~120x fewer tokens. 162 languages, Hybrid LSP type resolution, local semantic vector search, code-clone detection, sub-1ms queries, Linux kernel indexed in 3 minutes. Native executable with verified assets and no language runtime. One command configures 45 automatic/conditional client surfaces."><meta name="keywords" content="MCP server, code intelligence, knowledge graph, tree-sitter, Hybrid LSP, semantic code search, code embeddings, code clone detection, cross-repo analysis, data-flow analysis, Claude Code, Codex CLI, Gemini CLI, Cursor, Zed, code exploration, token reduction, call graph, dead code detection"><meta name="author" content="DeusData"><meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">@@ -12,7 +12,7 @@<!-- Open Graph --><meta property="og:title" content="codebase-memory-mcp — Code Intelligence Knowledge Graph for AI Coding Agents">- <meta property="og:description" content="Index any codebase into a persistent knowledge graph. AI agents answer structural questions with ~120x fewer tokens. 161 languages, Hybrid LSP, sub-1ms queries, native executable with verified assets.">+ <meta property="og:description" content="Index any codebase into a persistent knowledge graph. AI agents answer structural questions with ~120x fewer tokens. 162 languages, Hybrid LSP, sub-1ms queries, native executable with verified assets."><meta property="og:type" content="website"><meta property="og:url" content="https://deusdata.github.io/codebase-memory-mcp/"><meta property="og:image" content="https://deusdata.github.io/codebase-memory-mcp/graph-ui-screenshot.png">@@ -24,7 +24,7 @@<!-- Twitter Card --><meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="codebase-memory-mcp — Code Intelligence for AI Coding Agents">- <meta name="twitter:description" content="Index any codebase into a knowledge graph. ~120x fewer tokens for AI code exploration. 161 languages, Hybrid LSP, sub-1ms queries, native executable with verified assets.">+ <meta name="twitter:description" content="Index any codebase into a knowledge graph. ~120x fewer tokens for AI code exploration. 162 languages, Hybrid LSP, sub-1ms queries, native executable with verified assets."><meta name="twitter:image" content="https://deusdata.github.io/codebase-memory-mcp/graph-ui-screenshot.png"><link rel="canonical" href="https://deusdata.github.io/codebase-memory-mcp/">@@ -41,7 +41,7 @@"applicationSubCategory": "Model Context Protocol (MCP) server","operatingSystem": "macOS, Linux, Windows","softwareVersion": "0.8.1",- "description": "An open-source MCP server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links, so AI coding agents answer structural questions with roughly 120x fewer tokens than file-by-file search. Parses 161 languages via tree-sitter with Hybrid LSP semantic type resolution for 9 language families. Ships as a native executable with authenticated release-owned assets; the native install needs no language runtime.",+ "description": "An open-source MCP server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links, so AI coding agents answer structural questions with roughly 120x fewer tokens than file-by-file search. Parses 162 languages via tree-sitter with Hybrid LSP semantic type resolution for 9 language families. Ships as a native executable with authenticated release-owned assets; the native install needs no language runtime.","url": "https://deusdata.github.io/codebase-memory-mcp/","downloadUrl": "https://github.com/DeusData/codebase-memory-mcp/releases/latest","codeRepository": "https://github.com/DeusData/codebase-memory-mcp",@@ -125,7 +125,7 @@"name": "What is codebase-memory-mcp?","acceptedAnswer": {"@type": "Answer",- "text": "codebase-memory-mcp is an open-source Model Context Protocol (MCP) server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. AI coding agents query that graph instead of reading files one by one, answering structural questions with roughly 120x fewer tokens. It parses 161 languages and ships as a native executable with authenticated release-owned assets; the native install needs no language runtime."+ "text": "codebase-memory-mcp is an open-source Model Context Protocol (MCP) server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. AI coding agents query that graph instead of reading files one by one, answering structural questions with roughly 120x fewer tokens. It parses 162 languages and ships as a native executable with authenticated release-owned assets; the native install needs no language runtime."}},{@@ -141,7 +141,7 @@"name": "Which programming languages does codebase-memory-mcp support?","acceptedAnswer": {"@type": "Answer",- "text": "It supports 161 languages through vendored tree-sitter grammars compiled into the binary, including Python, Go, JavaScript, TypeScript, Rust, Java, C, C++, C#, PHP, Ruby, Kotlin, Swift, and many more. Nine language families — Python, TypeScript/JavaScript, PHP, C#, Go, C/C++, Java, Kotlin, and Rust — additionally get Hybrid LSP semantic type resolution."+ "text": "It supports 162 languages through vendored tree-sitter grammars compiled into the binary, including Python, Go, JavaScript, TypeScript, Rust, Java, C, C++, C#, PHP, Ruby, Kotlin, Swift, and many more. Nine language families — Python, TypeScript/JavaScript, PHP, C#, Go, C/C++, Java, Kotlin, and Rust — additionally get Hybrid LSP semantic type resolution."}},{@@ -444,7 +444,7 @@The fastest, most efficient code intelligence engine for AI coding agents. It indexes anyrepository into a persistent knowledge graph — full-indexing an average repo in seconds and theLinux kernel in 3 minutes — so your agent answers structural questions with ~120x fewer tokens.- Tree-sitter parsing across 161 languages, Hybrid LSP type resolution, native executable with verified assets.+ Tree-sitter parsing across 162 languages, Hybrid LSP type resolution, native executable with verified assets.</p><div><div class="stat"><div class="number">~120x</div><div class="label">fewer tokens</div></div>@@ -483,7 +483,7 @@Protocol (MCP)</a> server that indexes a codebase into a persistent knowledge graph of functions,classes, call chains, HTTP routes, and cross-service links. Instead of reading files one at a time,an AI coding agent queries the graph — answering structural questions with roughly 120x fewer- tokens. It parses 161 languages and ships as a native executable with authenticated release-owned assets;+ tokens. It parses 162 languages and ships as a native executable with authenticated release-owned assets;the native install needs no language runtime.</p><p class="muted">@@ -606,7 +606,7 @@</tbody></table><p class="muted">- The two-layer pipeline runs a fast syntactic tree-sitter pass for every one of the 161 languages,+ The two-layer pipeline runs a fast syntactic tree-sitter pass for every one of the 162 languages,then a type-aware Hybrid LSP pass on top for the families above. Languages without a Hybrid LSP passyet fall back to textual resolution, so you always get an answer.</p>@@ -699,7 +699,7 @@<h2>Features</h2><div class="features"><div class="feature">- <h3>161 languages</h3>+ <h3>162 languages</h3><p>Python, Go, JS, TS, TSX, Rust, Java, C++, C#, C, PHP, Ruby, Kotlin, Scala, Zig, Elixir, Haskell, OCaml, Swift, Dart, Lean 4, and many more via vendored tree-sitter grammars compiled into the binary.</p></div><div class="feature">diff --git a/docs/llms.txt b/docs/llms.txtindex 270d4875a..f3c23970b 100644--- a/docs/llms.txt+++ b/docs/llms.txt@@ -1,6 +1,6 @@# codebase-memory-mcp-> An open-source Model Context Protocol (MCP) server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. AI coding agents query the graph instead of reading files one by one, answering structural questions with roughly 120x fewer tokens (~3,400 vs ~412,000 across five structural queries). Parses 161 languages via vendored tree-sitter grammars, with Hybrid LSP semantic type resolution for Python, TypeScript/JavaScript, PHP, C#, Go, C/C++, Java, Kotlin, and Rust. It also generates semantic graph edges (SEMANTICALLY_RELATED for vocabulary-mismatch matches, SIMILAR_TO for near-clone detection) and supports semantic vector search via bundled nomic-embed-code embeddings compiled into the native executable — no API key, no Ollama, no Docker. Ships a native executable with an authenticated integration asset; the UI variant adds one content-addressed frontend pack. All processing is local — the embeddings run on-device; there is no embedded LLM and no API key.+> An open-source Model Context Protocol (MCP) server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. AI coding agents query the graph instead of reading files one by one, answering structural questions with roughly 120x fewer tokens (~3,400 vs ~412,000 across five structural queries). Parses 162 languages via vendored tree-sitter grammars, with Hybrid LSP semantic type resolution for Python, TypeScript/JavaScript, PHP, C#, Go, C/C++, Java, Kotlin, and Rust. It also generates semantic graph edges (SEMANTICALLY_RELATED for vocabulary-mismatch matches, SIMILAR_TO for near-clone detection) and supports semantic vector search via bundled nomic-embed-code embeddings compiled into the native executable — no API key, no Ollama, no Docker. Ships a native executable with an authenticated integration asset; the UI variant adds one content-addressed frontend pack. All processing is local — the embeddings run on-device; there is no embedded LLM and no API key.## Key factsdiff --git a/internal/cbm/cbm.h b/internal/cbm/cbm.hindex ac187406e..7076015ac 100644--- a/internal/cbm/cbm.h+++ b/internal/cbm/cbm.h@@ -174,8 +174,9 @@ typedef enum {CBM_LANG_OBJECTSCRIPT_UDL, // InterSystems ObjectScript UDL (.cls class files)CBM_LANG_OBJECTSCRIPT_ROUTINE, // InterSystems ObjectScript routine (.mac/.int/.rtn/.inc)CBM_LANG_OBJECTSCRIPT_EXPORT, // InterSystems Studio Export XML (<Export generator="Cache">)- CBM_LANG_ARKTS, // ArkTS (HarmonyOS/OpenHarmony .ets — TypeScript superset + ArkUI)- CBM_LANG_PLSQL, // Oracle PL/SQL+ CBM_LANG_ARKTS, // ArkTS (HarmonyOS/OpenHarmony .ets — TypeScript superset + ArkUI)+ CBM_LANG_PLSQL, // Oracle PL/SQL+ CBM_LANG_CHIALISP, // Chialisp (.clsp/.clib/.clinc — Chia smart-coin s-expression language)CBM_LANG_COUNT} CBMLanguage;diff --git a/internal/cbm/extract_calls.c b/internal/cbm/extract_calls.cindex abfe21140..58c0c27d6 100644--- a/internal/cbm/extract_calls.c+++ b/internal/cbm/extract_calls.c@@ -735,7 +735,94 @@ static bool call_node_is_definition_container(CBMLanguage lang, TSNode node, con// Lisp dialects: a call is a list (`list` / `list_lit`) whose head (first named// child) is the function symbol (`symbol` / `sym_lit`). Generic field/first-child// extraction misses it because the head is not an `identifier` node.-static char *extract_lisp_callee(CBMArena *a, TSNode node, const char *source, const char *nk) {+/* Chialisp: a head atom that is a CLVM primitive/opcode, or a Chialisp+ * syntax/binding/def keyword, is NOT a call — emit no CALLS edge. Sourced from+ * the clvm_tools_rs keyword set and the clvm_rs operator set. The def and+ * include heads are here too so `(defun ...)`/`(include ...)` never mint a+ * phantom call to their own keyword. `export` and `namespace` are in THIS set+ * even though they are deliberately NOT definition heads: `(export foo)` names+ * a function already defined in the same file, so it is neither a call nor a+ * second definition of it. Real helpers that merely look primitive —+ * sha256tree, the curry helpers — are deliberately absent, so they pass through+ * and resolve normally. */+static bool chialisp_head_is_not_call(const char *t) {+ if (!t) {+ return true;+ }+ static const char *filtered[] = {+ /* --- CLVM primitives (VM ops) --- */+ "q", "a", "i", "c", "f", "r", "l", "x", "=", ">s", "sha256", "substr", "strlen", "concat",+ "+", "-", "*", "/", "divmod", ">", "ash", "lsh", "logand", "logior", "logxor", "lognot",+ "point_add", "pubkey_for_exp", "not", "any", "all", "softfork", "coinid", "g1_subtract",+ "g1_multiply", "g1_negate", "g2_add", "g2_subtract", "g2_multiply", "g2_negate", "g1_map",+ "g2_map", "bls_pairing_identity", "bls_verify", "modpow", "%", "secp256k1_verify",+ "secp256r1_verify", "keccak256",+ /* --- Chialisp syntax / binding / intrinsics (not calls or defs) --- */+ "quote", "qq", "unquote", "&rest", "let", "let*", "assign", "assign-inline",+ "assign-lambda", "lambda", "mod", "if", "list", "com", "opt", "@", "@*env*", "print",+ /* --- def / export / include heads (never a call) --- */+ "defun", "defun-inline", "defmacro", "defmac", "defconstant", "defconst", "namespace",+ "export", "embed-file", "compile-file", "include", NULL};+ for (int i = 0; filtered[i]; i++) {+ if (strcmp(t, filtered[i]) == 0) {+ return true;+ }+ }+ return false;+}++/* True when `node` (a `list`) sits in a BINDER position rather than an+ * application position: a `(defun NAME (params) ...)` parameter list, a+ * `(mod (ARGS) ...)` curried-argument list, a `(lambda (x) ...)` parameter+ * list, or a `let` binding container / one of its binding pairs.+ *+ * A binder NAMES things; it is not an invocation. Without this every function's+ * parameter list would mint a CALLS edge to its own first parameter — on+ * `(defun check_conditions (HEIGHTLOCK conditions) ...)` that is a phantom call+ * to HEIGHTLOCK, and real Chialisp is mostly such definitions.+ *+ * Cost note: this compares `node` against the parent's first three forms rather+ * than computing `node`'s own index. Searching for the index would scan all of+ * the parent's children, and since this runs once per child, a single list of N+ * forms would cost O(N^2) — `condition_codes.clib` is one list of forty, and a+ * generated table is one list of thousands. Reading forms 1 and 2 is O(1). */+static bool chialisp_node_is_binder_list(CBMArena *a, TSNode node, const char *source) {+ /* At most two levels: the binder itself, and one binding pair inside a+ * `let` binding container. Bounded on purpose — never an ancestor walk. */+ for (int level = 0; level < 2; level++) {+ TSNode parent = ts_node_parent(node);+ if (ts_node_is_null(parent) || strcmp(ts_node_type(parent), "list") != 0) {+ return false;+ }+ TSNode head = cbm_lisp_named_child_skip_comments(parent, 0);+ if (!ts_node_is_null(head) && strcmp(ts_node_type(head), "symbol") == 0) {+ char *ht = cbm_node_text(a, head, source);+ if (!ht) {+ return false;+ }+ /* `(defun NAME (params) ...)` — the params are the third form. */+ if (strcmp(ht, "defun") == 0 || strcmp(ht, "defun-inline") == 0 ||+ strcmp(ht, "defmacro") == 0 || strcmp(ht, "defmac") == 0) {+ TSNode params = cbm_lisp_named_child_skip_comments(parent, 2);+ return !ts_node_is_null(params) && ts_node_eq(params, node);+ }+ /* `(mod (ARGS) ...)`, `(lambda (x) ...)`, `(let ((a 1)) ...)`. */+ if (strcmp(ht, "mod") == 0 || strcmp(ht, "lambda") == 0 || strcmp(ht, "let") == 0 ||+ strcmp(ht, "let*") == 0) {+ TSNode binder = cbm_lisp_named_child_skip_comments(parent, 1);+ return !ts_node_is_null(binder) && ts_node_eq(binder, node);+ }+ return false;+ }+ /* The head is not a symbol, so `parent` may itself be a let-binding+ * container and `node` one of its pairs — retry one level up. */+ node = parent;+ }+ return false;+}++static char *extract_lisp_callee(CBMArena *a, TSNode node, const char *source, const char *nk,+ CBMLanguage lang) {if (strcmp(nk, "list") != 0 && strcmp(nk, "list_lit") != 0) {return NULL;}@@ -744,7 +831,16 @@ static char *extract_lisp_callee(CBMArena *a, TSNode node, const char *source, cconst char *hk = ts_node_type(head);if (strcmp(hk, "symbol") == 0 || strcmp(hk, "sym_lit") == 0 ||strcmp(hk, "identifier") == 0) {- return cbm_node_text(a, head, source);+ char *ht = cbm_node_text(a, head, source);+ /* Drop CLVM ops / syntax / def heads, binder positions, and+ * anything inside quoted data — a quoted form is a value, not an+ * invocation. */+ if (lang == CBM_LANG_CHIALISP &&+ (chialisp_head_is_not_call(ht) || chialisp_node_is_binder_list(a, node, source) ||+ cbm_lisp_node_in_quote(a, node, source))) {+ return NULL;+ }+ return ht;}}return NULL;@@ -1383,8 +1479,9 @@ static char *extract_callee_lang_specific(CBMArena *a, TSNode node, const char *}if (lang == CBM_LANG_CLOJURE || lang == CBM_LANG_COMMONLISP || lang == CBM_LANG_SCHEME ||- lang == CBM_LANG_FENNEL || lang == CBM_LANG_RACKET || lang == CBM_LANG_EMACSLISP) {- return extract_lisp_callee(a, node, source, nk);+ lang == CBM_LANG_FENNEL || lang == CBM_LANG_RACKET || lang == CBM_LANG_EMACSLISP ||+ lang == CBM_LANG_CHIALISP) {+ return extract_lisp_callee(a, node, source, nk, lang);}if (lang == CBM_LANG_FSHARP) {return extract_fsharp_callee(a, node, source, nk);diff --git a/internal/cbm/extract_defs.c b/internal/cbm/extract_defs.cindex 6982d6c13..a91a164e8 100644--- a/internal/cbm/extract_defs.c+++ b/internal/cbm/extract_defs.c@@ -7254,36 +7254,85 @@ static bool lisp_is_def_head(const char *t) {return false;}+/* Basename stem (no directory, no extension) of a path, into an arena string.+ * A Chialisp `(mod ...)` has no name of its own — the file IS the puzzle — so+ * the module entry point is named after the file that holds it. */+static char *lisp_path_stem(CBMArena *a, const char *path) {+ if (!path) {+ return NULL;+ }+ const char *slash = strrchr(path, '/');+ const char *base = slash ? slash + SKIP_CHAR : path;+ const char *dot = strrchr(base, '.');+ size_t len = (dot && dot != base) ? (size_t)(dot - base) : strlen(base);+ return cbm_arena_strndup(a, base, len);+}+static void extract_lisp_def(CBMExtractCtx *ctx, TSNode node) {CBMArena *a = ctx->arena;+ bool chialisp = (ctx->language == CBM_LANG_CHIALISP);if (ts_node_named_child_count(node) < 2) {return;}- char *head = cbm_node_text(a, ts_node_named_child(node, 0), ctx->source);- if (!lisp_is_def_head(head)) {+ TSNode head_node =+ chialisp ? cbm_lisp_named_child_skip_comments(node, 0) : ts_node_named_child(node, 0);+ if (ts_node_is_null(head_node)) {return;}- TSNode target = ts_node_named_child(node, 1);- const char *tk = ts_node_type(target);- TSNode name_node = target;- // (define (foo args) ...) — the name is the head symbol of the nested list.- if ((strcmp(tk, "list") == 0 || strcmp(tk, "list_lit") == 0) &&- ts_node_named_child_count(target) > 0) {- name_node = ts_node_named_child(target, 0);+ char *head = cbm_node_text(a, head_node, ctx->source);+ if (!(chialisp ? cbm_chialisp_is_def_head(head) : lisp_is_def_head(head))) {+ return;}- if (ts_node_is_null(name_node)) {+ /* A def head inside `(q ...)`/`(qq ...)` is quoted DATA — Chialisp macros+ * embed puzzle-shaped literals there — so it must not mint a node. */+ if (chialisp && cbm_lisp_node_in_quote(a, node, ctx->source)) {return;}- char *name = cbm_node_text(a, name_node, ctx->source);+ char *name = NULL;+ if (chialisp && strcmp(head, "mod") == 0) {+ /* A top-level `(mod (ARGS) ...)` is the puzzle entry point; its second+ * form is the curried-argument LIST, so the generic nested-name path+ * below would name the module after its first curried argument. */+ name = lisp_path_stem(a, ctx->rel_path);+ } else {+ TSNode target =+ chialisp ? cbm_lisp_named_child_skip_comments(node, 1) : ts_node_named_child(node, 1);+ if (ts_node_is_null(target)) {+ return;+ }+ const char *tk = ts_node_type(target);+ TSNode name_node = target;+ // (define (foo args) ...) — the name is the head symbol of the nested list.+ if ((strcmp(tk, "list") == 0 || strcmp(tk, "list_lit") == 0) &&+ ts_node_named_child_count(target) > 0) {+ name_node = ts_node_named_child(target, 0);+ }+ if (ts_node_is_null(name_node)) {+ return;+ }+ name = cbm_node_text(a, name_node, ctx->source);+ }if (!name || !name[0]) {return;}/* struct/record/type defining forms produce a type node, not a callable* (Racket `(struct point ...)`, Clojure `(defrecord ...)`, etc.). */const char *lisp_label = "Function";- if (strcmp(head, "struct") == 0 || strcmp(head, "define-struct") == 0 ||- strcmp(head, "define-record-type") == 0 || strcmp(head, "defrecord") == 0 ||- strcmp(head, "deftype") == 0) {+ if (chialisp) {+ /* Chialisp label map. `Constant` is admitted to the cross-file registry+ * by cbm_label_is_registry_symbol, so a constant defined in an included+ * .clib resolves from every puzzle that includes it. */+ if (strcmp(head, "mod") == 0) {+ lisp_label = "Module";+ } else if (strcmp(head, "defconstant") == 0 || strcmp(head, "defconst") == 0 ||+ strcmp(head, "embed-file") == 0 || strcmp(head, "compile-file") == 0) {+ lisp_label = "Constant";+ } else if (strcmp(head, "defmacro") == 0 || strcmp(head, "defmac") == 0) {+ lisp_label = "Macro";+ }+ } else if (strcmp(head, "struct") == 0 || strcmp(head, "define-struct") == 0 ||+ strcmp(head, "define-record-type") == 0 || strcmp(head, "defrecord") == 0 ||+ strcmp(head, "deftype") == 0) {lisp_label = "Struct";} else if (strcmp(head, "definterface") == 0 || strcmp(head, "defprotocol") == 0) {lisp_label = "Interface";@@ -7466,9 +7515,20 @@ static void walk_defs(CBMExtractCtx *ctx, TSNode root, const CBMLangSpec *spec,}if ((ctx->language == CBM_LANG_CLOJURE || ctx->language == CBM_LANG_RACKET ||- ctx->language == CBM_LANG_SCHEME) &&+ ctx->language == CBM_LANG_SCHEME || ctx->language == CBM_LANG_CHIALISP) &&(strcmp(kind, "list") == 0 || strcmp(kind, "list_lit") == 0)) {extract_lisp_def(ctx, node);+ if (ctx->language == CBM_LANG_CHIALISP) {+ /* Chialisp nests every helper `(defun ...)` inside the top-level+ * `(mod ...)`, and a .clib wraps its defuns in one enclosing+ * list. `list` is also chialisp_func_types, so the generic+ * function_node_types match below would fire on this same node+ * and `continue` WITHOUT descending — losing every nested def.+ * Push the children here and skip that match. Gated to Chialisp;+ * the other lisps keep their existing fall-through. */+ wd_push_children_reverse(&s, node, frame.enclosing_class_qn);+ continue;+ }// fall through: descend into children so nested defs are captured too}diff --git a/internal/cbm/extract_imports.c b/internal/cbm/extract_imports.cindex 2d8ed1e4e..9de2fd007 100644--- a/internal/cbm/extract_imports.c+++ b/internal/cbm/extract_imports.c@@ -1931,6 +1931,46 @@ static void lisp_process_list(CBMExtractCtx *ctx, TSNode node) {return;}+ /* Chialisp include/embed forms.+ *+ * `(include *standard-cl-26*)` selects a dialect; every `*...*` sigil is a+ * compiler directive, not a file dependency. The Chialisp compiler filters+ * these with its own `!name.starts_with("*")` check and so do we — recording+ * one as an import would invent a dependency on a file that does not exist.+ *+ * `(embed-file NAME kind "file")` / `(compile-file NAME "file")` DO create a+ * real dependency on the embedded/compiled artifact; the path is the string+ * argument. There is no dedicated EMBEDS edge type, so it is recorded as an+ * import — which is what it is for reachability. */+ if (ctx->language == CBM_LANG_CHIALISP) {+ if (strcmp(hn, "include") == 0) {+ for (uint32_t j = 1; j < nc; j++) {+ TSNode mod_node = ts_node_named_child(node, j);+ const char *mk = ts_node_type(mod_node);+ if (strcmp(mk, "symbol") == 0 || strcmp(mk, "sym_lit") == 0) {+ char *sig = cbm_node_text(ctx->arena, mod_node, ctx->source);+ if (sig && sig[0] == '*') {+ continue; /* dialect sigil, not a file */+ }+ }+ lisp_push_module(ctx, mod_node);+ }+ return;+ }+ if (strcmp(hn, "embed-file") == 0 || strcmp(hn, "compile-file") == 0) {+ /* the embedded/compiled path is the last string argument. */+ for (uint32_t j = nc; j-- > 1;) {+ TSNode arg = ts_node_named_child(node, j);+ const char *ak = ts_node_type(arg);+ if (strcmp(ak, "string") == 0 || strcmp(ak, "str_lit") == 0) {+ lisp_push_module(ctx, arg);+ break;+ }+ }+ return;+ }+ }+/* Plain import head: `(require :util)`, `(import ...)`, `(use ...)`. */if (strcmp(hn, "import") == 0 || strcmp(hn, "require") == 0 || strcmp(hn, "load") == 0 ||strcmp(hn, "use") == 0 || strcmp(hn, "include") == 0) {@@ -2996,6 +3036,7 @@ void cbm_extract_imports(CBMExtractCtx *ctx) {case CBM_LANG_FENNEL:case CBM_LANG_COMMONLISP:case CBM_LANG_CLOJURE:+ case CBM_LANG_CHIALISP:parse_lisp_imports(ctx);break;case CBM_LANG_STARLARK:diff --git a/internal/cbm/extract_unified.c b/internal/cbm/extract_unified.cindex f106f5635..a5e314272 100644--- a/internal/cbm/extract_unified.c+++ b/internal/cbm/extract_unified.c@@ -329,14 +329,48 @@ static bool lisp_head_is_def(const char *t) {* forms, ...), so push_boundary_scopes pushes no scope for them. Mirrors* extract_lisp_def() in extract_defs.c. */static const char *compute_lisp_func_qn(CBMExtractCtx *ctx, TSNode node) {+ bool chialisp = (ctx->language == CBM_LANG_CHIALISP);if (ts_node_named_child_count(node) < 2) {return NULL;}- char *head = cbm_node_text(ctx->arena, ts_node_named_child(node, 0), ctx->source);- if (!lisp_head_is_def(head)) {+ /* Chialisp reads its head and name through the comment-skipping accessor —+ * the SAME one extract_lisp_def() uses. When these two disagree (one+ * skipping comments, the other not), a doc comment between a def head and+ * its name shifts the named-child indices for only one of them, and the+ * call scope silently stops matching the def it belongs to. */+ TSNode head_node =+ chialisp ? cbm_lisp_named_child_skip_comments(node, 0) : ts_node_named_child(node, 0);+ if (ts_node_is_null(head_node)) {+ return NULL;+ }+ char *head = cbm_node_text(ctx->arena, head_node, ctx->source);+ if (!(chialisp ? cbm_chialisp_is_def_head(head) : lisp_head_is_def(head))) {+ return NULL;+ }+ if (chialisp && cbm_lisp_node_in_quote(ctx->arena, node, ctx->source)) {+ return NULL;+ }+ if (chialisp && head && strcmp(head, "mod") == 0) {+ /* `mod`'s second form is the curried-arg list, not a name; the puzzle+ * entry point is named by its file, so in-body top-level calls+ * attribute to the entry rather than to a curried argument. Mirrors the+ * lisp_path_stem() naming in extract_defs.c. */+ const char *path = ctx->rel_path;+ const char *slash = path ? strrchr(path, '/') : NULL;+ const char *base = slash ? slash + 1 : path;+ if (!base || !base[0]) {+ return NULL;+ }+ const char *dot = strrchr(base, '.');+ size_t len = (dot && dot != base) ? (size_t)(dot - base) : strlen(base);+ char *stem = cbm_arena_strndup(ctx->arena, base, len);+ return cbm_fqn_compute(ctx->arena, ctx->project, ctx->rel_path, stem);+ }+ TSNode target =+ chialisp ? cbm_lisp_named_child_skip_comments(node, 1) : ts_node_named_child(node, 1);+ if (ts_node_is_null(target)) {return NULL;}- TSNode target = ts_node_named_child(node, 1);const char *tk = ts_node_type(target);TSNode name_node = target;/* (define (foo args) ...) — the name is the head symbol of the nested list. */@@ -746,7 +780,7 @@ static const char *compute_func_qn(CBMExtractCtx *ctx, TSNode node, const CBMLan* lives here (we have ctx->source). Non-def lists return NULL → no scope* pushed → the in-body call sources to the enclosing def, not the Module. */if (ctx->language == CBM_LANG_CLOJURE || ctx->language == CBM_LANG_SCHEME ||- ctx->language == CBM_LANG_RACKET) {+ ctx->language == CBM_LANG_RACKET || ctx->language == CBM_LANG_CHIALISP) {return compute_lisp_func_qn(ctx, node);}diff --git a/internal/cbm/extract_usages.c b/internal/cbm/extract_usages.cindex 1f2e4098e..c47c8434b 100644--- a/internal/cbm/extract_usages.c+++ b/internal/cbm/extract_usages.c@@ -162,6 +162,7 @@ static bool is_reference_node(TSNode node, CBMLanguage lang) {case CBM_LANG_SCHEME:case CBM_LANG_FENNEL:case CBM_LANG_RACKET:+ case CBM_LANG_CHIALISP:case CBM_LANG_LINKERSCRIPT:return strcmp(kind, "symbol") == 0;case CBM_LANG_MAKEFILE:@@ -464,6 +465,7 @@ static const CBMOccurrenceSpec occurrence_specs[CBM_LANG_COUNT] = {[CBM_LANG_CLOJURE] = {NULL, NULL, CBM_OCCURRENCE_LISP_DEF, false},[CBM_LANG_SCHEME] = {NULL, NULL, CBM_OCCURRENCE_LISP_DEF, false},[CBM_LANG_RACKET] = {NULL, NULL, CBM_OCCURRENCE_LISP_DEF, false},+ [CBM_LANG_CHIALISP] = {NULL, NULL, CBM_OCCURRENCE_LISP_DEF, false},[CBM_LANG_COMMONLISP] = {NULL, NULL, CBM_OCCURRENCE_COMMONLISP_DEFUN, false},[CBM_LANG_FENNEL] = {NULL, NULL, CBM_OCCURRENCE_FENNEL_FN, false},[CBM_LANG_ELIXIR] = {NULL, NULL, CBM_OCCURRENCE_ELIXIR_DEF, false},@@ -537,23 +539,39 @@ static bool lisp_def_head(const char *text) {return kind_in_exact_set(text, heads);}+/* Chialisp heads whose THIRD form is a parameter list, so the symbols in it+ * bind rather than refer: `(defun NAME (params) body)`. Deliberately not+ * `defconstant` — its third form is the VALUE expression, whose symbols are+ * genuine usages — and not `mod`, whose binder is the second form and is+ * already covered by the shared named_child(1) rule below. */+static bool chialisp_head_binds_params_at_2(const char *head) {+ return head && (strcmp(head, "defun") == 0 || strcmp(head, "defun-inline") == 0 ||+ strcmp(head, "defmacro") == 0 || strcmp(head, "defmac") == 0);+}+static bool is_lisp_def_binding(CBMExtractCtx *ctx, TSNode node) {+ bool chialisp = (ctx->language == CBM_LANG_CHIALISP);for (TSNode form = ts_node_parent(node); !ts_node_is_null(form); form = ts_node_parent(form)) {const char *kind = ts_node_type(form);if ((strcmp(kind, "list") != 0 && strcmp(kind, "list_lit") != 0) ||ts_node_named_child_count(form) < 2) {continue;}- TSNode head_node = ts_node_named_child(form, 0);+ TSNode head_node =+ chialisp ? cbm_lisp_named_child_skip_comments(form, 0) : ts_node_named_child(form, 0);+ if (ts_node_is_null(head_node)) {+ continue;+ }char *head = cbm_node_text(ctx->arena, head_node, ctx->source);- if (!lisp_def_head(head)) {+ if (!(chialisp ? cbm_chialisp_is_def_head(head) : lisp_def_head(head))) {continue;}if (node_contains(head_node, node) || named_child_contains(form, 1, node)) {return true;}- if (ctx->language == CBM_LANG_CLOJURE && ts_node_named_child_count(form) > 2 &&- named_child_contains(form, 2, node)) {+ if ((ctx->language == CBM_LANG_CLOJURE ||+ (chialisp && chialisp_head_binds_params_at_2(head))) &&+ ts_node_named_child_count(form) > 2 && named_child_contains(form, 2, node)) {return true;}return false;diff --git a/internal/cbm/grammar_chialisp.c b/internal/cbm/grammar_chialisp.cnew file mode 100644index 000000000..cf5ff3641--- /dev/null+++ b/internal/cbm/grammar_chialisp.c@@ -0,0 +1,3 @@+// Vendored tree-sitter grammar: chialisp+// Each grammar compiled as separate unit (conflicting static symbols).+#include "vendored/grammars/chialisp/parser.c"diff --git a/internal/cbm/helpers.c b/internal/cbm/helpers.cindex 46d3fda6a..5ea8c6cef 100644--- a/internal/cbm/helpers.c+++ b/internal/cbm/helpers.c@@ -17,6 +17,10 @@ enum {INIT_FILE_LEN = 8, /* strlen("__init__") */INDEX_FILE_LEN = 5, /* strlen("index") */NOT_FOUND = -1,+ /* Ancestor-walk bound for cbm_lisp_node_in_quote. A quote nest deeper than+ * this is pathological input, not Chialisp; bounding it keeps the walk O(1)+ * per node rather than O(depth) on adversarially nested data. */+ CBM_LISP_QUOTE_ANCESTOR_MAX = 256,};/* Prefix length helper for strncmp with string literals. */@@ -190,9 +194,76 @@ bool cbm_label_is_registry_symbol(const char *label) {if (!label) {return false;}+ /* "Constant" is a named, file-scope-transcending symbol exactly like+ * Variable: Chialisp's `(defconstant CREATE_COIN 51)` lives in an included+ * .clib and is referenced by name from every puzzle that includes it. Left+ * out of the registry it can never be the target of a cross-file resolve,+ * and the ~half of a Chialisp graph that is constants would be unreachable.+ * It is deliberately NOT type-like (cbm_label_is_type_like): a constant+ * must never satisfy an inheritance, impl-receiver or semantic-type+ * lookup. */return strcmp(label, "Function") == 0 || strcmp(label, "Method") == 0 ||cbm_label_is_type_like(label) || strcmp(label, "Variable") == 0 ||- strcmp(label, "Field") == 0 || cbm_label_is_relation(label);+ strcmp(label, "Constant") == 0 || strcmp(label, "Field") == 0 ||+ cbm_label_is_relation(label);+}++bool cbm_lisp_node_in_quote(CBMArena *a, TSNode node, const char *source) {+ TSNode cur = ts_node_parent(node);+ for (int guard = 0; guard < CBM_LISP_QUOTE_ANCESTOR_MAX && !ts_node_is_null(cur); guard++) {+ const char *ck = ts_node_type(cur);+ if ((strcmp(ck, "list") == 0 || strcmp(ck, "list_lit") == 0) &&+ ts_node_named_child_count(cur) > 0) {+ TSNode h = ts_node_named_child(cur, 0);+ const char *hk = ts_node_type(h);+ if (strcmp(hk, "symbol") == 0 || strcmp(hk, "sym_lit") == 0) {+ char *ht = cbm_node_text(a, h, source);+ if (ht &&+ (strcmp(ht, "q") == 0 || strcmp(ht, "quote") == 0 || strcmp(ht, "qq") == 0)) {+ return true;+ }+ }+ }+ cur = ts_node_parent(cur);+ }+ return false;+}++TSNode cbm_lisp_named_child_skip_comments(TSNode node, uint32_t want) {+ uint32_t nc = ts_node_named_child_count(node);+ uint32_t seen = 0;+ for (uint32_t i = 0; i < nc; i++) {+ TSNode c = ts_node_named_child(node, i);+ if (strcmp(ts_node_type(c), "comment") == 0) {+ continue;+ }+ if (seen == want) {+ return c;+ }+ seen++;+ }+ TSNode null_node = {0};+ return null_node;+}++bool cbm_chialisp_is_def_head(const char *t) {+ if (!t) {+ return false;+ }+ /* `export` and `namespace` are absent ON PURPOSE. `(export foo)` re-exports+ * a function `(defun foo ...)` already defined in the same file, so+ * admitting it here mints a SECOND node for the same symbol. They stay in+ * the not-a-call filter (extract_calls.c) because they are still not calls.+ */+ static const char *heads[] = {"mod", "defun", "defun-inline", "defmacro",+ "defmac", "defconstant", "defconst", "embed-file",+ "compile-file", NULL};+ for (int i = 0; heads[i]; i++) {+ if (strcmp(t, heads[i]) == 0) {+ return true;+ }+ }+ return false;}bool cbm_is_keyword(const char *name, CBMLanguage lang) {diff --git a/internal/cbm/helpers.h b/internal/cbm/helpers.hindex b03ef3743..4e8150b6f 100644--- a/internal/cbm/helpers.h+++ b/internal/cbm/helpers.h@@ -122,6 +122,36 @@ char *cbm_cpp_out_of_line_parent_class(CBMArena *a, TSNode node, const char *sou// Find a child node by kind string.TSNode cbm_find_child_by_kind(TSNode parent, const char *kind);+/* --- Lisp-family shared gates ---------------------------------------------+ * The defs, calls and unified extractors each walk the same generic `list`+ * node and must agree on what it means. The predicates below therefore live+ * here rather than being copied per translation unit: a private copy in each+ * drifts, and the drift is silent — defs and call-scope simply stop describing+ * the same tree.+ */++/* True when any ancestor list of `node` is headed by a quote symbol+ * (`q` / `quote` / `qq`) — its contents are DATA, not code, so no def and no+ * call may be minted from them. Bounded ancestor walk; the arena is used only+ * for the head-text reads. */+bool cbm_lisp_node_in_quote(CBMArena *a, TSNode node, const char *source);++/* The `want`-th named child of `node`, skipping `comment` nodes. Comments are+ * named in the s-expression grammars and so occupy named-child indices: a+ * comment between a def head and its name shifts every later index by one.+ * Definition extraction and call-scope attribution MUST use this same skipping+ * rule or they desynchronise on exactly the files that carry doc comments. */+TSNode cbm_lisp_named_child_skip_comments(TSNode node, uint32_t want);++/* True for a Chialisp definition-form head. Deliberately separate from the+ * Clojure/Scheme def-head set: Chialisp shares the generic `list` kind, and+ * treating `mod`/`defconstant` as defs must not leak into the other lisps (in+ * Scheme `(mod x y)` is a call). Excludes the expression-local binding forms+ * (`let`, `assign`, `lambda`), which would fragment call attribution, and+ * excludes `export`/`namespace`, which NAME an already-defined function rather+ * than defining one. */+bool cbm_chialisp_is_def_head(const char *t);+// Check if node kind matches a set of types (NULL-terminated array of strings).bool cbm_kind_in_set(TSNode node, const char **types);diff --git a/internal/cbm/lang_specs.c b/internal/cbm/lang_specs.cindex 040700702..51ca4ba60 100644--- a/internal/cbm/lang_specs.c+++ b/internal/cbm/lang_specs.c@@ -80,6 +80,7 @@ extern const TSLanguage *tree_sitter_powershell(void);extern const TSLanguage *tree_sitter_pascal(void);extern const TSLanguage *tree_sitter_d(void);extern const TSLanguage *tree_sitter_scheme(void);+extern const TSLanguage *tree_sitter_chialisp(void);extern const TSLanguage *tree_sitter_fennel(void);extern const TSLanguage *tree_sitter_fish(void);extern const TSLanguage *tree_sitter_awk(void);@@ -1107,6 +1108,13 @@ static const char *scheme_func_types[] = {"list", NULL};static const char *scheme_call_types[] = {"list", NULL};static const char *scheme_var_types[] = {"symbol", NULL};static const char *scheme_module_types[] = {"program", NULL};+// Chialisp: a deliberately generic s-expression grammar (tools/tree-sitter-chialisp).+// Every parenthesized form is a `list` and every atom a `symbol`; which lists are+// definitions is decided in extract_defs.c, not by the parser. Root is `source_file`.+static const char *chialisp_func_types[] = {"list", NULL};+static const char *chialisp_call_types[] = {"list", NULL};+static const char *chialisp_var_types[] = {"symbol", NULL};+static const char *chialisp_module_types[] = {"source_file", NULL};static const char *fennel_func_types[] = {"fn", "lambda", "hashfn", NULL};static const char *fennel_call_types[] = {"list", NULL};static const char *fennel_branch_types[] = {"each", "for", "match", NULL};@@ -2161,6 +2169,12 @@ static const CBMLangSpec lang_specs[CBM_LANG_COUNT] = {empty_types, scheme_var_types, empty_types, empty_types, NULL, empty_types,NULL, NULL, tree_sitter_scheme, NULL},+ // CBM_LANG_CHIALISP — lisp-family shape (generic list/symbol nodes)+ [CBM_LANG_CHIALISP] = {CBM_LANG_CHIALISP, chialisp_func_types, empty_types, empty_types,+ chialisp_module_types, chialisp_call_types, empty_types, empty_types,+ empty_types, chialisp_var_types, empty_types, empty_types, NULL,+ empty_types, NULL, NULL, tree_sitter_chialisp, NULL},+// CBM_LANG_FENNEL[CBM_LANG_FENNEL] = {CBM_LANG_FENNEL, fennel_func_types, empty_types, empty_types,fennel_module_types, fennel_call_types, empty_types, empty_types,diff --git a/internal/cbm/vendored/grammars/MANIFEST.md b/internal/cbm/vendored/grammars/MANIFEST.mdindex ea80f8c74..9b5b0127b 100644--- a/internal/cbm/vendored/grammars/MANIFEST.md+++ b/internal/cbm/vendored/grammars/MANIFEST.md@@ -9,8 +9,8 @@ The grammars were originally vendored as bare `parser.c`+`scanner.c` with **no r## Summary-- Grammars: **161** — vendored-from-upstream: **143**, first-party/self-maintained: **13**, registry-disagreement: **5** (nim removed 2026-06-12; objectscript_udl + objectscript_routine added 2026-06-24; mojo added 2026-07-01; arkts added 2026-08-26; plsql added 2026-08-27 — see notes below)-- ABI distribution: **7×** ABI-13 **86×** ABI-14 **65×** ABI-15 (runtime ceiling is ABI 15; never vendor ABI 16 without a runtime upgrade)+- Grammars: **162** — vendored-from-upstream: **143**, first-party/self-maintained: **14**, registry-disagreement: **5** (nim removed 2026-06-12; objectscript_udl + objectscript_routine added 2026-06-24; mojo added 2026-07-01; arkts added 2026-08-26; plsql added 2026-08-27; chialisp added 2026-08-28 — see notes below)+- ABI distribution: **7×** ABI-13 **87×** ABI-14 **65×** ABI-15 (runtime ceiling is ABI 15; never vendor ABI 16 without a runtime upgrade)- Vendored copies missing LICENSE: **0** — all upstream LICENSE files restored 2026-06-11 (first-party grammars carry the project MIT license; `move` uses the Helix-listed upstream tzakian/tree-sitter-move MIT text, `zsh` uses georgeharker/tree-sitter-zsh MIT)- `verdict`: VERIFIED-BOTH = our source matches *both* registries; VERIFIED-NVIM/HELIX = matches one; registry-disagreement = registries name a different repo (listed separately); `vendor-maintained` = the language vendor's own grammar, not in nvim/Helix; `community-niche` = an individual/community-maintained grammar for a niche language, not in nvim/Helix — provenance hand-verified against the upstream repository instead of a registry.- **objectscript_udl / objectscript_routine** (added 2026-06-24): vendored from [intersystems/tree-sitter-objectscript](https://github.com/intersystems/tree-sitter-objectscript) @ `a7ffcdf` — MIT, the InterSystems-official grammars (a niche vendor language, hence `vendor-maintained`, not in nvim-treesitter/Helix). **Re-vendor note:** each `scanner.c`'s upstream `#include "../../common/scanner.h"` is repointed to a per-directory `objectscript_common.h` (a verbatim copy of upstream `common/scanner.h`), because this repo's shared `vendored/common/scanner.h` belongs to the cfml/fsharp grammars and differs. The generated `parser.c`/`scanner.c` are otherwise byte-for-byte upstream — on re-vendor, re-apply only that single include rename. **Local modification (2026-07-16):** in `objectscript_common.h`, two loop counters `uint8_t i` were widened to `int i` (the `reverse_marker` scan and the `html_marker_buffer` reversal) to clear CodeQL `cpp/comparison-with-wider-type` — a false positive in practice (both lengths are hard-bounded by `MARKER_BUFFER_MAX_LEN = 30`, so `uint8_t` could never wrap), fixed for cleanliness. On re-vendor, re-apply this widening too (or upstream it at intersystems/tree-sitter-objectscript).@@ -18,6 +18,8 @@ The grammars were originally vendored as bare `parser.c`+`scanner.c` with **no r- **arkts** (added 2026-08-26): **first-party derivative** — a fork of [tree-sitter/tree-sitter-typescript](https://github.com/tree-sitter/tree-sitter-typescript)'s `typescript` dialect pinned @ `75b3874edb2d` (v0.23.2, the same commit our vendored typescript/tsx come from), on the tree-sitter-javascript base @ `3a837b6f3658` (v0.23.1, the version upstream's own package-lock pins), extended with ArkTS/ArkUI syntax (`@Component struct` declarations, UI-DSL trailing-closure calls with post-block attribute chains, decorated function declarations, `import lazy`, `@Extend`/`@Styles` leading-dot attribute chains, anonymous `stateStyles` style blocks). Grammar source + corpus tests live in `tools/tree-sitter-arkts/`; regenerate with `npx [email protected] generate` (ABI 15). **External scanner:** `scanner.c` is a symbol-rename trampoline; `_common_scanner.h` is byte-identical (same SHA-256) to the reviewed `typescript/_common_scanner.h` already shipped. **LICENSE:** tree-sitter-typescript's MIT text **verbatim and byte-identical** (© 2017 Max Brunsfeld) — which is what MIT requires of a derivative work, and what lets the provenance audit byte-verify it against upstream rather than take a note on trust. The fork is registered in the audit's `FORKS` map. Our own copyright for the ArkTS additions, and the tree-sitter-javascript attribution (© 2014 Max Brunsfeld), live with the SOURCE in `tools/tree-sitter-arkts/grammar.js` and in `THIRD_PARTY.md`, which is what ships in the release archives.- **plsql** (added 2026-08-27): vendored from [AndreasMaierDe/tree-sitter-plsql](https://github.com/AndreasMaierDe/tree-sitter-plsql) @ `28aebef209be` (full: `28aebef209be57169600e1aa41ca1431cc6c916f`, upstream tip; repo dormant since 2023-02) — MIT, ABI 14, **no external scanner** (`EXTERNAL_TOKEN_COUNT 0`). Not listed in nvim-treesitter/Helix (`community-niche`, an individual-maintained grammar); provenance verified directly against upstream (pin = `git ls-remote` HEAD; vendored `parser.c` byte-identical to the pinned clone apart from the include-quote local patch below; 0 non-ASCII bytes; 0 dangerous calls). Security review covered only the vendored C surface (`parser.c`, `tree_sitter/parser.h`) plus upstream license/provenance metadata; no package manager hooks, workflow files, prompt/agent instruction files, or generated lockfiles were vendored. Known upstream limitation: `CREATE TYPE ... AS OBJECT` currently yields ERROR nodes (pinned by `plsql_create_type_as_object_limitation` in `tests/test_extraction.c` + `tests/fixtures/plsql/create_type_as_object_limitation.tps`). Originally contributed as PR #1033 by Oğuz (@ouzsrcm); re-vendored from upstream per vendoring policy with the PR's language wiring distilled on top.+- **chialisp** (added 2026-08-28): **first-party** — authored in this repository, not vendored from anywhere. Grammar source + corpus tests live in `tools/tree-sitter-chialisp/`; regenerate with `npx [email protected] generate --abi 14` and copy `src/parser.c` + `src/tree_sitter/*.h` here. ABI 14, **no external scanner** (`EXTERNAL_TOKEN_COUNT 0`), 0 non-ASCII bytes. It is a deliberately GENERIC s-expression grammar (`source_file`/`list`/`symbol`/`string`/`number`/`hex`/`dot`/`comment`) modelling the clvm_tools reader rather than the Chialisp form vocabulary: `mod`/`defun`/`defconstant`/`include` are ordinary head symbols, and which lists are definitions is decided in `internal/cbm/extract_defs.c`, so a dialect that adds a form does not need a regenerated parser. Written because the only public grammar (`Quexington/tree-sitter-chialisp`) cannot parse the language: it required CRLF to terminate a comment (`/;.*\r\n/`) while real files are LF, rejected the `.` in `(include foo.clib)`, and accepted only a primitive after `(defconstant NAME …)` — each of which desynchronised the rest of the file. Acceptance gate: all five `chia-blockchain@main` reference files parse with **zero ERROR and zero MISSING nodes**. **LICENSE:** the project's own LICENSE, byte-identical to the repository root — no third-party copyright is carried, because there is no third party.+> ⚠️ **Pinned commit = the revision nvim-treesitter/Helix vendor** (battle-tested, canonical source), not bleeding-edge HEAD. When re-vendoring, update the pinned commit here.## Custom extraction handling (definition extraction)@@ -38,6 +40,7 @@ Guarded by the `contract_all_grammars_in_graph` graph-breadth test in|---|---|| ada | `resolve_func_name`: `subprogram_body`/`subprogram_declaration` → `procedure_specification`/`function_specification` child's `name` field || cairo | `resolve_func_name`: `function_definition`/`function_signature` → `identifier` child |+| chialisp | `extract_lisp_def`: `(mod/defun/defun-inline/defmacro/defmac/defconstant/defconst …)` head-symbol forms in `list`; `mod` named by filename; `defconstant` → `Constant`; CLVM operators, quoted data and dialect sigils filtered out of calls/imports || clojure | `extract_lisp_def`: `(defn …)` / `(def …)` head-symbol forms in `list_lit` || d | `resolve_func_name`: `function_declaration` → `identifier` child || fortran | `resolve_func_name`: `subroutine`/`function` → inner `*_statement`'s `name` field |@@ -234,6 +237,7 @@ upstream author (correctly retained). The table now records the true origin.| magma | 15 | ✅ project MIT || protobuf | 13 | ✅ project MIT || wolfram | 13 | ✅ project MIT |+| chialisp | 14 | ✅ project MIT |### Self-maintained forks (upstream license retained, byte-verified 2026-06-12)diff --git a/internal/cbm/vendored/grammars/chialisp/LICENSE b/internal/cbm/vendored/grammars/chialisp/LICENSEnew file mode 100644index 000000000..0b9535274--- /dev/null+++ b/internal/cbm/vendored/grammars/chialisp/LICENSE@@ -0,0 +1,22 @@+MIT License++ Copyright (c) 2025 DeusData++ Permission is hereby granted, free of charge, to any person obtaining a copy+ of this software and associated documentation files (the "Software"), to deal+ in the Software without restriction, including without limitation the rights+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+ copies of the Software, and to permit persons to whom the Software is+ furnished to do so, subject to the following conditions:++ The above copyright notice and this permission notice shall be included in all+ copies or substantial portions of the Software.++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+ SOFTWARE.+\ No newline at end of filediff --git a/internal/cbm/vendored/grammars/chialisp/parser.c b/internal/cbm/vendored/grammars/chialisp/parser.cnew file mode 100644index 000000000..d929151ea--- /dev/null+++ b/internal/cbm/vendored/grammars/chialisp/parser.c@@ -0,0 +1,485 @@+/* Automatically @generated by tree-sitter v0.25.10 */++#include "tree_sitter/parser.h"++#if defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"+#endif++#define LANGUAGE_VERSION 14+#define STATE_COUNT 9+#define LARGE_STATE_COUNT 8+#define SYMBOL_COUNT 14+#define ALIAS_COUNT 0+#define TOKEN_COUNT 9+#define EXTERNAL_TOKEN_COUNT 0+#define FIELD_COUNT 0+#define MAX_ALIAS_SEQUENCE_LENGTH 3+#define MAX_RESERVED_WORD_SET_SIZE 0+#define PRODUCTION_ID_COUNT 1+#define SUPERTYPE_COUNT 0++enum ts_symbol_identifiers {+ anon_sym_LPAREN = 1,+ anon_sym_RPAREN = 2,+ sym_comment = 3,+ sym_hex = 4,+ sym_number = 5,+ sym_string = 6,+ sym_dot = 7,+ sym_symbol = 8,+ sym_source_file = 9,+ sym__form = 10,+ sym__sexp = 11,+ sym_list = 12,+ aux_sym_source_file_repeat1 = 13,+};++static const char * const ts_symbol_names[] = {+ [ts_builtin_sym_end] = "end",+ [anon_sym_LPAREN] = "(",+ [anon_sym_RPAREN] = ")",+ [sym_comment] = "comment",+ [sym_hex] = "hex",+ [sym_number] = "number",+ [sym_string] = "string",+ [sym_dot] = "dot",+ [sym_symbol] = "symbol",+ [sym_source_file] = "source_file",+ [sym__form] = "_form",+ [sym__sexp] = "_sexp",+ [sym_list] = "list",+ [aux_sym_source_file_repeat1] = "source_file_repeat1",+};++static const TSSymbol ts_symbol_map[] = {+ [ts_builtin_sym_end] = ts_builtin_sym_end,+ [anon_sym_LPAREN] = anon_sym_LPAREN,+ [anon_sym_RPAREN] = anon_sym_RPAREN,+ [sym_comment] = sym_comment,+ [sym_hex] = sym_hex,+ [sym_number] = sym_number,+ [sym_string] = sym_string,+ [sym_dot] = sym_dot,+ [sym_symbol] = sym_symbol,+ [sym_source_file] = sym_source_file,+ [sym__form] = sym__form,+ [sym__sexp] = sym__sexp,+ [sym_list] = sym_list,+ [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1,+};++static const TSSymbolMetadata ts_symbol_metadata[] = {+ [ts_builtin_sym_end] = {+ .visible = false,+ .named = true,+ },+ [anon_sym_LPAREN] = {+ .visible = true,+ .named = false,+ },+ [anon_sym_RPAREN] = {+ .visible = true,+ .named = false,+ },+ [sym_comment] = {+ .visible = true,+ .named = true,+ },+ [sym_hex] = {+ .visible = true,+ .named = true,+ },+ [sym_number] = {+ .visible = true,+ .named = true,+ },+ [sym_string] = {+ .visible = true,+ .named = true,+ },+ [sym_dot] = {+ .visible = true,+ .named = true,+ },+ [sym_symbol] = {+ .visible = true,+ .named = true,+ },+ [sym_source_file] = {+ .visible = true,+ .named = true,+ },+ [sym__form] = {+ .visible = false,+ .named = true,+ },+ [sym__sexp] = {+ .visible = false,+ .named = true,+ },+ [sym_list] = {+ .visible = true,+ .named = true,+ },+ [aux_sym_source_file_repeat1] = {+ .visible = false,+ .named = false,+ },+};++static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {+ [0] = {0},+};++static const uint16_t ts_non_terminal_alias_map[] = {+ 0,+};++static const TSStateId ts_primary_state_ids[STATE_COUNT] = {+ [0] = 0,+ [1] = 1,+ [2] = 2,+ [3] = 3,+ [4] = 4,+ [5] = 5,+ [6] = 6,+ [7] = 7,+ [8] = 8,+};++static bool ts_lex(TSLexer *lexer, TSStateId state) {+ START_LEXER();+ eof = lexer->eof(lexer);+ switch (state) {+ case 0:+ if (eof) ADVANCE(5);+ ADVANCE_MAP(+ '"', 1,+ '\'', 2,+ '(', 6,+ ')', 7,+ '-', 14,+ '.', 13,+ '0', 10,+ ';', 8,+ );+ if (('\t' <= lookahead && lookahead <= '\r') ||+ lookahead == ' ') SKIP(0);+ if (('1' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0) ADVANCE(16);+ END_STATE();+ case 1:+ if (lookahead == '"') ADVANCE(12);+ if (lookahead == '\\') ADVANCE(3);+ if (lookahead != 0) ADVANCE(1);+ END_STATE();+ case 2:+ if (lookahead == '\'') ADVANCE(12);+ if (lookahead == '\\') ADVANCE(4);+ if (lookahead != 0) ADVANCE(2);+ END_STATE();+ case 3:+ if (lookahead != 0 &&+ lookahead != '\n') ADVANCE(1);+ END_STATE();+ case 4:+ if (lookahead != 0 &&+ lookahead != '\n') ADVANCE(2);+ END_STATE();+ case 5:+ ACCEPT_TOKEN(ts_builtin_sym_end);+ END_STATE();+ case 6:+ ACCEPT_TOKEN(anon_sym_LPAREN);+ END_STATE();+ case 7:+ ACCEPT_TOKEN(anon_sym_RPAREN);+ END_STATE();+ case 8:+ ACCEPT_TOKEN(sym_comment);+ if (lookahead != 0 &&+ lookahead != '\n' &&+ lookahead != '\r') ADVANCE(8);+ END_STATE();+ case 9:+ ACCEPT_TOKEN(sym_hex);+ if (('0' <= lookahead && lookahead <= '9') ||+ ('A' <= lookahead && lookahead <= 'F') ||+ ('a' <= lookahead && lookahead <= 'f')) ADVANCE(9);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 10:+ ACCEPT_TOKEN(sym_number);+ if (lookahead == 'X' ||+ lookahead == 'x') ADVANCE(15);+ if (('0' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 11:+ ACCEPT_TOKEN(sym_number);+ if (('0' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 12:+ ACCEPT_TOKEN(sym_string);+ END_STATE();+ case 13:+ ACCEPT_TOKEN(sym_dot);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 14:+ ACCEPT_TOKEN(sym_symbol);+ if (('0' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 15:+ ACCEPT_TOKEN(sym_symbol);+ if (('0' <= lookahead && lookahead <= '9') ||+ ('A' <= lookahead && lookahead <= 'F') ||+ ('a' <= lookahead && lookahead <= 'f')) ADVANCE(9);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 16:+ ACCEPT_TOKEN(sym_symbol);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ default:+ return false;+ }+}++static const TSLexMode ts_lex_modes[STATE_COUNT] = {+ [0] = {.lex_state = 0},+ [1] = {.lex_state = 0},+ [2] = {.lex_state = 0},+ [3] = {.lex_state = 0},+ [4] = {.lex_state = 0},+ [5] = {.lex_state = 0},+ [6] = {.lex_state = 0},+ [7] = {.lex_state = 0},+ [8] = {.lex_state = 0},+};++static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {+ [STATE(0)] = {+ [ts_builtin_sym_end] = ACTIONS(1),+ [anon_sym_LPAREN] = ACTIONS(1),+ [anon_sym_RPAREN] = ACTIONS(1),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(1),+ [sym_number] = ACTIONS(1),+ [sym_string] = ACTIONS(1),+ [sym_dot] = ACTIONS(1),+ [sym_symbol] = ACTIONS(1),+ },+ [STATE(1)] = {+ [sym_source_file] = STATE(8),+ [sym__form] = STATE(4),+ [sym__sexp] = STATE(4),+ [sym_list] = STATE(4),+ [aux_sym_source_file_repeat1] = STATE(4),+ [ts_builtin_sym_end] = ACTIONS(5),+ [anon_sym_LPAREN] = ACTIONS(7),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(9),+ [sym_number] = ACTIONS(9),+ [sym_string] = ACTIONS(11),+ [sym_dot] = ACTIONS(9),+ [sym_symbol] = ACTIONS(9),+ },+ [STATE(2)] = {+ [sym__form] = STATE(2),+ [sym__sexp] = STATE(2),+ [sym_list] = STATE(2),+ [aux_sym_source_file_repeat1] = STATE(2),+ [ts_builtin_sym_end] = ACTIONS(13),+ [anon_sym_LPAREN] = ACTIONS(15),+ [anon_sym_RPAREN] = ACTIONS(13),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(18),+ [sym_number] = ACTIONS(18),+ [sym_string] = ACTIONS(21),+ [sym_dot] = ACTIONS(18),+ [sym_symbol] = ACTIONS(18),+ },+ [STATE(3)] = {+ [sym__form] = STATE(5),+ [sym__sexp] = STATE(5),+ [sym_list] = STATE(5),+ [aux_sym_source_file_repeat1] = STATE(5),+ [anon_sym_LPAREN] = ACTIONS(7),+ [anon_sym_RPAREN] = ACTIONS(24),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(26),+ [sym_number] = ACTIONS(26),+ [sym_string] = ACTIONS(28),+ [sym_dot] = ACTIONS(26),+ [sym_symbol] = ACTIONS(26),+ },+ [STATE(4)] = {+ [sym__form] = STATE(2),+ [sym__sexp] = STATE(2),+ [sym_list] = STATE(2),+ [aux_sym_source_file_repeat1] = STATE(2),+ [ts_builtin_sym_end] = ACTIONS(30),+ [anon_sym_LPAREN] = ACTIONS(7),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(32),+ [sym_number] = ACTIONS(32),+ [sym_string] = ACTIONS(34),+ [sym_dot] = ACTIONS(32),+ [sym_symbol] = ACTIONS(32),+ },+ [STATE(5)] = {+ [sym__form] = STATE(2),+ [sym__sexp] = STATE(2),+ [sym_list] = STATE(2),+ [aux_sym_source_file_repeat1] = STATE(2),+ [anon_sym_LPAREN] = ACTIONS(7),+ [anon_sym_RPAREN] = ACTIONS(36),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(32),+ [sym_number] = ACTIONS(32),+ [sym_string] = ACTIONS(34),+ [sym_dot] = ACTIONS(32),+ [sym_symbol] = ACTIONS(32),+ },+ [STATE(6)] = {+ [ts_builtin_sym_end] = ACTIONS(38),+ [anon_sym_LPAREN] = ACTIONS(38),+ [anon_sym_RPAREN] = ACTIONS(38),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(40),+ [sym_number] = ACTIONS(40),+ [sym_string] = ACTIONS(38),+ [sym_dot] = ACTIONS(40),+ [sym_symbol] = ACTIONS(40),+ },+ [STATE(7)] = {+ [ts_builtin_sym_end] = ACTIONS(42),+ [anon_sym_LPAREN] = ACTIONS(42),+ [anon_sym_RPAREN] = ACTIONS(42),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(44),+ [sym_number] = ACTIONS(44),+ [sym_string] = ACTIONS(42),+ [sym_dot] = ACTIONS(44),+ [sym_symbol] = ACTIONS(44),+ },+};++static const uint16_t ts_small_parse_table[] = {+ [0] = 2,+ ACTIONS(3), 1,+ sym_comment,+ ACTIONS(46), 1,+ ts_builtin_sym_end,+};++static const uint32_t ts_small_parse_table_map[] = {+ [SMALL_STATE(8)] = 0,+};++static const TSParseActionEntry ts_parse_actions[] = {+ [0] = {.entry = {.count = 0, .reusable = false}},+ [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),+ [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),+ [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0),+ [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),+ [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4),+ [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),+ [13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0),+ [15] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(3),+ [18] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(2),+ [21] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(2),+ [24] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6),+ [26] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5),+ [28] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),+ [30] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0),+ [32] = {.entry = {.count = 1, .reusable = false}}, SHIFT(2),+ [34] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),+ [36] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),+ [38] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list, 2, 0, 0),+ [40] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_list, 2, 0, 0),+ [42] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list, 3, 0, 0),+ [44] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_list, 3, 0, 0),+ [46] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),+};++#ifdef __cplusplus+extern "C" {+#endif+#ifdef TREE_SITTER_HIDE_SYMBOLS+#define TS_PUBLIC+#elif defined(_WIN32)+#define TS_PUBLIC __declspec(dllexport)+#else+#define TS_PUBLIC __attribute__((visibility("default")))+#endif++TS_PUBLIC const TSLanguage *tree_sitter_chialisp(void) {+ static const TSLanguage language = {+ .abi_version = LANGUAGE_VERSION,+ .symbol_count = SYMBOL_COUNT,+ .alias_count = ALIAS_COUNT,+ .token_count = TOKEN_COUNT,+ .external_token_count = EXTERNAL_TOKEN_COUNT,+ .state_count = STATE_COUNT,+ .large_state_count = LARGE_STATE_COUNT,+ .production_id_count = PRODUCTION_ID_COUNT,+ .field_count = FIELD_COUNT,+ .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,+ .parse_table = &ts_parse_table[0][0],+ .small_parse_table = ts_small_parse_table,+ .small_parse_table_map = ts_small_parse_table_map,+ .parse_actions = ts_parse_actions,+ .symbol_names = ts_symbol_names,+ .symbol_metadata = ts_symbol_metadata,+ .public_symbol_map = ts_symbol_map,+ .alias_map = ts_non_terminal_alias_map,+ .alias_sequences = &ts_alias_sequences[0][0],+ .lex_modes = (const void*)ts_lex_modes,+ .lex_fn = ts_lex,+ .primary_state_ids = ts_primary_state_ids,+ };+ return &language;+}+#ifdef __cplusplus+}+#endifdiff --git a/internal/cbm/vendored/grammars/chialisp/tree_sitter/alloc.h b/internal/cbm/vendored/grammars/chialisp/tree_sitter/alloc.hnew file mode 100644index 000000000..1abdd1201--- /dev/null+++ b/internal/cbm/vendored/grammars/chialisp/tree_sitter/alloc.h@@ -0,0 +1,54 @@+#ifndef TREE_SITTER_ALLOC_H_+#define TREE_SITTER_ALLOC_H_++#ifdef __cplusplus+extern "C" {+#endif++#include <stdbool.h>+#include <stdio.h>+#include <stdlib.h>++// Allow clients to override allocation functions+#ifdef TREE_SITTER_REUSE_ALLOCATOR++extern void *(*ts_current_malloc)(size_t size);+extern void *(*ts_current_calloc)(size_t count, size_t size);+extern void *(*ts_current_realloc)(void *ptr, size_t size);+extern void (*ts_current_free)(void *ptr);++#ifndef ts_malloc+#define ts_malloc ts_current_malloc+#endif+#ifndef ts_calloc+#define ts_calloc ts_current_calloc+#endif+#ifndef ts_realloc+#define ts_realloc ts_current_realloc+#endif+#ifndef ts_free+#define ts_free ts_current_free+#endif++#else++#ifndef ts_malloc+#define ts_malloc malloc+#endif+#ifndef ts_calloc+#define ts_calloc calloc+#endif+#ifndef ts_realloc+#define ts_realloc realloc+#endif+#ifndef ts_free+#define ts_free free+#endif++#endif++#ifdef __cplusplus+}+#endif++#endif // TREE_SITTER_ALLOC_H_diff --git a/internal/cbm/vendored/grammars/chialisp/tree_sitter/array.h b/internal/cbm/vendored/grammars/chialisp/tree_sitter/array.hnew file mode 100644index 000000000..a17a574f0--- /dev/null+++ b/internal/cbm/vendored/grammars/chialisp/tree_sitter/array.h@@ -0,0 +1,291 @@+#ifndef TREE_SITTER_ARRAY_H_+#define TREE_SITTER_ARRAY_H_++#ifdef __cplusplus+extern "C" {+#endif++#include "./alloc.h"++#include <assert.h>+#include <stdbool.h>+#include <stdint.h>+#include <stdlib.h>+#include <string.h>++#ifdef _MSC_VER+#pragma warning(push)+#pragma warning(disable : 4101)+#elif defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic push+#pragma GCC diagnostic ignored "-Wunused-variable"+#endif++#define Array(T) \+ struct { \+ T *contents; \+ uint32_t size; \+ uint32_t capacity; \+ }++/// Initialize an array.+#define array_init(self) \+ ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)++/// Create an empty array.+#define array_new() \+ { NULL, 0, 0 }++/// Get a pointer to the element at a given `index` in the array.+#define array_get(self, _index) \+ (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])++/// Get a pointer to the first element in the array.+#define array_front(self) array_get(self, 0)++/// Get a pointer to the last element in the array.+#define array_back(self) array_get(self, (self)->size - 1)++/// Clear the array, setting its size to zero. Note that this does not free any+/// memory allocated for the array's contents.+#define array_clear(self) ((self)->size = 0)++/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is+/// less than the array's current capacity, this function has no effect.+#define array_reserve(self, new_capacity) \+ _array__reserve((Array *)(self), array_elem_size(self), new_capacity)++/// Free any memory allocated for this array. Note that this does not free any+/// memory allocated for the array's contents.+#define array_delete(self) _array__delete((Array *)(self))++/// Push a new `element` onto the end of the array.+#define array_push(self, element) \+ (_array__grow((Array *)(self), 1, array_elem_size(self)), \+ (self)->contents[(self)->size++] = (element))++/// Increase the array's size by `count` elements.+/// New elements are zero-initialized.+#define array_grow_by(self, count) \+ do { \+ if ((count) == 0) break; \+ _array__grow((Array *)(self), count, array_elem_size(self)); \+ memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \+ (self)->size += (count); \+ } while (0)++/// Append all elements from one array to the end of another.+#define array_push_all(self, other) \+ array_extend((self), (other)->size, (other)->contents)++/// Append `count` elements to the end of the array, reading their values from the+/// `contents` pointer.+#define array_extend(self, count, contents) \+ _array__splice( \+ (Array *)(self), array_elem_size(self), (self)->size, \+ 0, count, contents \+ )++/// Remove `old_count` elements from the array starting at the given `index`. At+/// the same index, insert `new_count` new elements, reading their values from the+/// `new_contents` pointer.+#define array_splice(self, _index, old_count, new_count, new_contents) \+ _array__splice( \+ (Array *)(self), array_elem_size(self), _index, \+ old_count, new_count, new_contents \+ )++/// Insert one `element` into the array at the given `index`.+#define array_insert(self, _index, element) \+ _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))++/// Remove one element from the array at the given `index`.+#define array_erase(self, _index) \+ _array__erase((Array *)(self), array_elem_size(self), _index)++/// Pop the last element off the array, returning the element by value.+#define array_pop(self) ((self)->contents[--(self)->size])++/// Assign the contents of one array to another, reallocating if necessary.+#define array_assign(self, other) \+ _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))++/// Swap one array with another+#define array_swap(self, other) \+ _array__swap((Array *)(self), (Array *)(other))++/// Get the size of the array contents+#define array_elem_size(self) (sizeof *(self)->contents)++/// Search a sorted array for a given `needle` value, using the given `compare`+/// callback to determine the order.+///+/// If an existing element is found to be equal to `needle`, then the `index`+/// out-parameter is set to the existing value's index, and the `exists`+/// out-parameter is set to true. Otherwise, `index` is set to an index where+/// `needle` should be inserted in order to preserve the sorting, and `exists`+/// is set to false.+#define array_search_sorted_with(self, compare, needle, _index, _exists) \+ _array__search_sorted(self, 0, compare, , needle, _index, _exists)++/// Search a sorted array for a given `needle` value, using integer comparisons+/// of a given struct field (specified with a leading dot) to determine the order.+///+/// See also `array_search_sorted_with`.+#define array_search_sorted_by(self, field, needle, _index, _exists) \+ _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)++/// Insert a given `value` into a sorted array, using the given `compare`+/// callback to determine the order.+#define array_insert_sorted_with(self, compare, value) \+ do { \+ unsigned _index, _exists; \+ array_search_sorted_with(self, compare, &(value), &_index, &_exists); \+ if (!_exists) array_insert(self, _index, value); \+ } while (0)++/// Insert a given `value` into a sorted array, using integer comparisons of+/// a given struct field (specified with a leading dot) to determine the order.+///+/// See also `array_search_sorted_by`.+#define array_insert_sorted_by(self, field, value) \+ do { \+ unsigned _index, _exists; \+ array_search_sorted_by(self, field, (value) field, &_index, &_exists); \+ if (!_exists) array_insert(self, _index, value); \+ } while (0)++// Private++typedef Array(void) Array;++/// This is not what you're looking for, see `array_delete`.+static inline void _array__delete(Array *self) {+ if (self->contents) {+ ts_free(self->contents);+ self->contents = NULL;+ self->size = 0;+ self->capacity = 0;+ }+}++/// This is not what you're looking for, see `array_erase`.+static inline void _array__erase(Array *self, size_t element_size,+ uint32_t index) {+ assert(index < self->size);+ char *contents = (char *)self->contents;+ memmove(contents + index * element_size, contents + (index + 1) * element_size,+ (self->size - index - 1) * element_size);+ self->size--;+}++/// This is not what you're looking for, see `array_reserve`.+static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {+ if (new_capacity > self->capacity) {+ if (self->contents) {+ self->contents = ts_realloc(self->contents, new_capacity * element_size);+ } else {+ self->contents = ts_malloc(new_capacity * element_size);+ }+ self->capacity = new_capacity;+ }+}++/// This is not what you're looking for, see `array_assign`.+static inline void _array__assign(Array *self, const Array *other, size_t element_size) {+ _array__reserve(self, element_size, other->size);+ self->size = other->size;+ memcpy(self->contents, other->contents, self->size * element_size);+}++/// This is not what you're looking for, see `array_swap`.+static inline void _array__swap(Array *self, Array *other) {+ Array swap = *other;+ *other = *self;+ *self = swap;+}++/// This is not what you're looking for, see `array_push` or `array_grow_by`.+static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {+ uint32_t new_size = self->size + count;+ if (new_size > self->capacity) {+ uint32_t new_capacity = self->capacity * 2;+ if (new_capacity < 8) new_capacity = 8;+ if (new_capacity < new_size) new_capacity = new_size;+ _array__reserve(self, element_size, new_capacity);+ }+}++/// This is not what you're looking for, see `array_splice`.+static inline void _array__splice(Array *self, size_t element_size,+ uint32_t index, uint32_t old_count,+ uint32_t new_count, const void *elements) {+ uint32_t new_size = self->size + new_count - old_count;+ uint32_t old_end = index + old_count;+ uint32_t new_end = index + new_count;+ assert(old_end <= self->size);++ _array__reserve(self, element_size, new_size);++ char *contents = (char *)self->contents;+ if (self->size > old_end) {+ memmove(+ contents + new_end * element_size,+ contents + old_end * element_size,+ (self->size - old_end) * element_size+ );+ }+ if (new_count > 0) {+ if (elements) {+ memcpy(+ (contents + index * element_size),+ elements,+ new_count * element_size+ );+ } else {+ memset(+ (contents + index * element_size),+ 0,+ new_count * element_size+ );+ }+ }+ self->size += new_count - old_count;+}++/// A binary search routine, based on Rust's `std::slice::binary_search_by`.+/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.+#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \+ do { \+ *(_index) = start; \+ *(_exists) = false; \+ uint32_t size = (self)->size - *(_index); \+ if (size == 0) break; \+ int comparison; \+ while (size > 1) { \+ uint32_t half_size = size / 2; \+ uint32_t mid_index = *(_index) + half_size; \+ comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \+ if (comparison <= 0) *(_index) = mid_index; \+ size -= half_size; \+ } \+ comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \+ if (comparison == 0) *(_exists) = true; \+ else if (comparison < 0) *(_index) += 1; \+ } while (0)++/// Helper macro for the `_sorted_by` routines below. This takes the left (existing)+/// parameter by reference in order to work with the generic sorting function above.+#define _compare_int(a, b) ((int)*(a) - (int)(b))++#ifdef _MSC_VER+#pragma warning(pop)+#elif defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic pop+#endif++#ifdef __cplusplus+}+#endif++#endif // TREE_SITTER_ARRAY_H_diff --git a/internal/cbm/vendored/grammars/chialisp/tree_sitter/parser.h b/internal/cbm/vendored/grammars/chialisp/tree_sitter/parser.hnew file mode 100644index 000000000..858107deb--- /dev/null+++ b/internal/cbm/vendored/grammars/chialisp/tree_sitter/parser.h@@ -0,0 +1,286 @@+#ifndef TREE_SITTER_PARSER_H_+#define TREE_SITTER_PARSER_H_++#ifdef __cplusplus+extern "C" {+#endif++#include <stdbool.h>+#include <stdint.h>+#include <stdlib.h>++#define ts_builtin_sym_error ((TSSymbol)-1)+#define ts_builtin_sym_end 0+#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024++#ifndef TREE_SITTER_API_H_+typedef uint16_t TSStateId;+typedef uint16_t TSSymbol;+typedef uint16_t TSFieldId;+typedef struct TSLanguage TSLanguage;+typedef struct TSLanguageMetadata {+ uint8_t major_version;+ uint8_t minor_version;+ uint8_t patch_version;+} TSLanguageMetadata;+#endif++typedef struct {+ TSFieldId field_id;+ uint8_t child_index;+ bool inherited;+} TSFieldMapEntry;++// Used to index the field and supertype maps.+typedef struct {+ uint16_t index;+ uint16_t length;+} TSMapSlice;++typedef struct {+ bool visible;+ bool named;+ bool supertype;+} TSSymbolMetadata;++typedef struct TSLexer TSLexer;++struct TSLexer {+ int32_t lookahead;+ TSSymbol result_symbol;+ void (*advance)(TSLexer *, bool);+ void (*mark_end)(TSLexer *);+ uint32_t (*get_column)(TSLexer *);+ bool (*is_at_included_range_start)(const TSLexer *);+ bool (*eof)(const TSLexer *);+ void (*log)(const TSLexer *, const char *, ...);+};++typedef enum {+ TSParseActionTypeShift,+ TSParseActionTypeReduce,+ TSParseActionTypeAccept,+ TSParseActionTypeRecover,+} TSParseActionType;++typedef union {+ struct {+ uint8_t type;+ TSStateId state;+ bool extra;+ bool repetition;+ } shift;+ struct {+ uint8_t type;+ uint8_t child_count;+ TSSymbol symbol;+ int16_t dynamic_precedence;+ uint16_t production_id;+ } reduce;+ uint8_t type;+} TSParseAction;++typedef struct {+ uint16_t lex_state;+ uint16_t external_lex_state;+} TSLexMode;++typedef struct {+ uint16_t lex_state;+ uint16_t external_lex_state;+ uint16_t reserved_word_set_id;+} TSLexerMode;++typedef union {+ TSParseAction action;+ struct {+ uint8_t count;+ bool reusable;+ } entry;+} TSParseActionEntry;++typedef struct {+ int32_t start;+ int32_t end;+} TSCharacterRange;++struct TSLanguage {+ uint32_t abi_version;+ uint32_t symbol_count;+ uint32_t alias_count;+ uint32_t token_count;+ uint32_t external_token_count;+ uint32_t state_count;+ uint32_t large_state_count;+ uint32_t production_id_count;+ uint32_t field_count;+ uint16_t max_alias_sequence_length;+ const uint16_t *parse_table;+ const uint16_t *small_parse_table;+ const uint32_t *small_parse_table_map;+ const TSParseActionEntry *parse_actions;+ const char * const *symbol_names;+ const char * const *field_names;+ const TSMapSlice *field_map_slices;+ const TSFieldMapEntry *field_map_entries;+ const TSSymbolMetadata *symbol_metadata;+ const TSSymbol *public_symbol_map;+ const uint16_t *alias_map;+ const TSSymbol *alias_sequences;+ const TSLexerMode *lex_modes;+ bool (*lex_fn)(TSLexer *, TSStateId);+ bool (*keyword_lex_fn)(TSLexer *, TSStateId);+ TSSymbol keyword_capture_token;+ struct {+ const bool *states;+ const TSSymbol *symbol_map;+ void *(*create)(void);+ void (*destroy)(void *);+ bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);+ unsigned (*serialize)(void *, char *);+ void (*deserialize)(void *, const char *, unsigned);+ } external_scanner;+ const TSStateId *primary_state_ids;+ const char *name;+ const TSSymbol *reserved_words;+ uint16_t max_reserved_word_set_size;+ uint32_t supertype_count;+ const TSSymbol *supertype_symbols;+ const TSMapSlice *supertype_map_slices;+ const TSSymbol *supertype_map_entries;+ TSLanguageMetadata metadata;+};++static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {+ uint32_t index = 0;+ uint32_t size = len - index;+ while (size > 1) {+ uint32_t half_size = size / 2;+ uint32_t mid_index = index + half_size;+ const TSCharacterRange *range = &ranges[mid_index];+ if (lookahead >= range->start && lookahead <= range->end) {+ return true;+ } else if (lookahead > range->end) {+ index = mid_index;+ }+ size -= half_size;+ }+ const TSCharacterRange *range = &ranges[index];+ return (lookahead >= range->start && lookahead <= range->end);+}++/*+ * Lexer Macros+ */++#ifdef _MSC_VER+#define UNUSED __pragma(warning(suppress : 4101))+#else+#define UNUSED __attribute__((unused))+#endif++#define START_LEXER() \+ bool result = false; \+ bool skip = false; \+ UNUSED \+ bool eof = false; \+ int32_t lookahead; \+ goto start; \+ next_state: \+ lexer->advance(lexer, skip); \+ start: \+ skip = false; \+ lookahead = lexer->lookahead;++#define ADVANCE(state_value) \+ { \+ state = state_value; \+ goto next_state; \+ }++#define ADVANCE_MAP(...) \+ { \+ static const uint16_t map[] = { __VA_ARGS__ }; \+ for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \+ if (map[i] == lookahead) { \+ state = map[i + 1]; \+ goto next_state; \+ } \+ } \+ }++#define SKIP(state_value) \+ { \+ skip = true; \+ state = state_value; \+ goto next_state; \+ }++#define ACCEPT_TOKEN(symbol_value) \+ result = true; \+ lexer->result_symbol = symbol_value; \+ lexer->mark_end(lexer);++#define END_STATE() return result;++/*+ * Parse Table Macros+ */++#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)++#define STATE(id) id++#define ACTIONS(id) id++#define SHIFT(state_value) \+ {{ \+ .shift = { \+ .type = TSParseActionTypeShift, \+ .state = (state_value) \+ } \+ }}++#define SHIFT_REPEAT(state_value) \+ {{ \+ .shift = { \+ .type = TSParseActionTypeShift, \+ .state = (state_value), \+ .repetition = true \+ } \+ }}++#define SHIFT_EXTRA() \+ {{ \+ .shift = { \+ .type = TSParseActionTypeShift, \+ .extra = true \+ } \+ }}++#define REDUCE(symbol_name, children, precedence, prod_id) \+ {{ \+ .reduce = { \+ .type = TSParseActionTypeReduce, \+ .symbol = symbol_name, \+ .child_count = children, \+ .dynamic_precedence = precedence, \+ .production_id = prod_id \+ }, \+ }}++#define RECOVER() \+ {{ \+ .type = TSParseActionTypeRecover \+ }}++#define ACCEPT_INPUT() \+ {{ \+ .type = TSParseActionTypeAccept \+ }}++#ifdef __cplusplus+}+#endif++#endif // TREE_SITTER_PARSER_H_diff --git a/pkg/chocolatey/codebase-memory-mcp.nuspec b/pkg/chocolatey/codebase-memory-mcp.nuspecindex d0509ecf1..3d2395fd2 100644--- a/pkg/chocolatey/codebase-memory-mcp.nuspec+++ b/pkg/chocolatey/codebase-memory-mcp.nuspec@@ -18,7 +18,7 @@ release-owned runtime assets. Chocolatey retains the complete extracted runtimeset and exposes its executable through a PATH shim.Full indexes an average repository in milliseconds, the Linux kernel (28M LOC) in-3 minutes. Answers structural queries in under 1ms. Supports 161 languages via+3 minutes. Answers structural queries in under 1ms. Supports 162 languages viavendored tree-sitter grammars. No hosted service or API key. Plug and play across11 coding agents including Claude Code, Codex CLI, Gemini CLI, and Zed.diff --git a/pkg/npm/README.md b/pkg/npm/README.mdindex 48ea2e64d..614b81b1c 100644--- a/pkg/npm/README.md+++ b/pkg/npm/README.md@@ -7,7 +7,7 @@**The fastest and most efficient code intelligence engine for AI coding agents.** Full-indexes an average repository in milliseconds, the Linux kernel (28M LOC, 75K files) in 3 minutes. Answers structural queries in under 1ms. This npm wrapper downloads, verifies, and caches the selected native runtime set: the executable, its authenticated integration asset, and—when requested—the content-addressed UI pack.-High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across 161 languages — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No hosted service or API key; this package requires Node.js to manage and launch the cached native runtime set. Plug and play across 45 automatic/conditional client surfaces.+High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across 162 languages — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No hosted service or API key; this package requires Node.js to manage and launch the cached native runtime set. Plug and play across 45 automatic/conditional client surfaces.## Installation@@ -29,7 +29,7 @@ Restart your agent. Say **"Index this project"** — done.- **Extreme indexing speed** — Linux kernel (28M LOC, 75K files) in 3 minutes. RAM-first pipeline with LZ4 compression and in-memory SQLite.- **Plug and play** — verified native runtime sets for macOS (arm64/amd64), Linux (arm64/amd64), and Windows (arm64/amd64). No Docker or API keys; Node.js owns package download, cache repair, and launch.-- **161 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.+- **162 languages** — vendored tree-sitter grammars compiled into the binary. Nothing to install, nothing that breaks.- **120x fewer tokens** — 5 structural queries: ~3,400 tokens vs ~412,000 via file-by-file search.- **45 supported automatic/conditional client surfaces** — `install` configures the appropriate MCP, durable-context, and documented hook surfaces without widening client permissions.- **Detected automatically (39)** — Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob Shell, Pochi, Pi, and Oh My Pi (omp).diff --git a/scripts/audit-license-provenance.py b/scripts/audit-license-provenance.pyindex edbdbfdb9..d22d4d15b 100755--- a/scripts/audit-license-provenance.py+++ b/scripts/audit-license-provenance.py@@ -20,7 +20,11 @@ import sysROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))GRAMMARS = os.path.join(ROOT, "internal/cbm/vendored/grammars")-FIRST_PARTY = {"cobol", "form", "janet", "magma", "protobuf", "wolfram"}+# Grammars authored in this repository. This is a REGISTRATION, not an+# exemption: membership only routes the check -- the audit still requires the+# vendored LICENSE to be byte-equal to the project root LICENSE, and reports+# FIRST-PARTY-VAR (a failing verdict) when it is not.+FIRST_PARTY = {"chialisp", "cobol", "form", "janet", "magma", "protobuf", "wolfram"}FORKS = { # self-maintained forks: vendored LICENSE must match the original upstream# arkts: our own ArkTS fork of tree-sitter-typescript. The vendored LICENSE is# upstream's MIT verbatim, which is what MIT requires of a derivative; our owndiff --git a/scripts/package-release.sh b/scripts/package-release.shindex 1ee35c539..ff399c76d 100755--- a/scripts/package-release.sh+++ b/scripts/package-release.sh@@ -293,7 +293,7 @@ build_mcpb_bundle() {"name": "codebase-memory-mcp","display_name": "Codebase Memory","version": "$mcpb_version",- "description": "Codebase knowledge graph for AI agents — 161 languages, sub-ms queries, 99% fewer tokens.",+ "description": "Codebase knowledge graph for AI agents — 162 languages, sub-ms queries, 99% fewer tokens.","author": { "name": "DeusData", "url": "https://github.com/DeusData" },"repository": { "type": "git", "url": "https://github.com/DeusData/codebase-memory-mcp" },"homepage": "https://deusdata.github.io/codebase-memory-mcp/",diff --git a/scripts/vendored-checksums.txt b/scripts/vendored-checksums.txtindex 905af7d48..992216603 100644--- a/scripts/vendored-checksums.txt+++ b/scripts/vendored-checksums.txt@@ -5,7 +5,7 @@ c5cfb43042b6b72045f4ba997834d0a7786d2793d91680868b5815b39f14fc78 internal/cbm/vb29c1c9fb7cc82f58c84b376df1297d6e2737a1d655fd356db0859e3c29c2fea internal/cbm/vendored/common/tree_sitter/alloc.h31e60a1bff6f715afacce03b5b70efe42b58371b4f9595dd4af52a577ff9608c internal/cbm/vendored/common/tree_sitter/array.h180b893c8734778fd32f372dfbc27bd6ad1cd2221f26150b31256ff6716320d2 internal/cbm/vendored/common/tree_sitter/parser.h-4db1d964d82c2f1c50ff8fc0de7a85708fa2f1884d0afbc587c59dd103163967 internal/cbm/vendored/grammars/MANIFEST.md+1fec60a59cb72bd61b4f9e771a77cc184597f49caf5d33f2e2a40f5739518571 internal/cbm/vendored/grammars/MANIFEST.mdad8425038de519f8c4e3e9339feebf99dfad8a6002dcf79227d91402780a32cc internal/cbm/vendored/grammars/ada/LICENSE02805ec13939b749c891567be36bf024b09034e04c80683a1ae667272458d549 internal/cbm/vendored/grammars/ada/parser.c115a75d000bef9c70c4de7dfbb7f2a80b90cbb14ba265056dc7abb1ef3b9b6db internal/cbm/vendored/grammars/ada/tree_sitter/alloc.h@@ -118,6 +118,11 @@ eeadc5447401a424faf2a9214727debb25a2c3f2b8315e43c86b6ed48bbb1290 internal/cbm/vb29c1c9fb7cc82f58c84b376df1297d6e2737a1d655fd356db0859e3c29c2fea internal/cbm/vendored/grammars/cfscript/tree_sitter/alloc.h31e60a1bff6f715afacce03b5b70efe42b58371b4f9595dd4af52a577ff9608c internal/cbm/vendored/grammars/cfscript/tree_sitter/array.h180b893c8734778fd32f372dfbc27bd6ad1cd2221f26150b31256ff6716320d2 internal/cbm/vendored/grammars/cfscript/tree_sitter/parser.h+1f58f9911dc5e3bcb96de28bb28e7b6bb7eb323952d29569c5d7214a152146bb internal/cbm/vendored/grammars/chialisp/LICENSE+c55f7903853b47242a8f3e4d3a945bfe97817deb9673561f1a806b89d734d2f7 internal/cbm/vendored/grammars/chialisp/parser.c+b29c1c9fb7cc82f58c84b376df1297d6e2737a1d655fd356db0859e3c29c2fea internal/cbm/vendored/grammars/chialisp/tree_sitter/alloc.h+5bdf6ed1a78e3409fd443e085ca967a64c188a5d082aaf7f819bccd53a471c94 internal/cbm/vendored/grammars/chialisp/tree_sitter/array.h+180b893c8734778fd32f372dfbc27bd6ad1cd2221f26150b31256ff6716320d2 internal/cbm/vendored/grammars/chialisp/tree_sitter/parser.ha2010f343487d3f7618affe54f789f5487602331c0a8d03f49e9a7c547cf0499 internal/cbm/vendored/grammars/clojure/LICENSE93e7bc5496b929e8627c95ec39fa78f267b084868f7ecc2ef34df00919eb9b06 internal/cbm/vendored/grammars/clojure/parser.c435ac887a97b4199fcf97707649aa987a94524f0e023f4e8287eae5dae49453f internal/cbm/vendored/grammars/clojure/tree_sitter/parser.hdiff --git a/server.json b/server.jsonindex 93bcccc3b..0241f5527 100644--- a/server.json+++ b/server.json@@ -2,7 +2,7 @@"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json","name": "io.github.DeusData/codebase-memory-mcp","title": "Codebase Memory",- "description": "Codebase knowledge graph for AI agents \u2014 161 languages, sub-ms queries, 99% fewer tokens.",+ "description": "Codebase knowledge graph for AI agents \u2014 162 languages, sub-ms queries, 99% fewer tokens.","repository": {"url": "https://github.com/DeusData/codebase-memory-mcp","source": "github"diff --git a/src/discover/language.c b/src/discover/language.cindex 3cb0bf6f8..666db536f 100644--- a/src/discover/language.c+++ b/src/discover/language.c@@ -574,6 +574,11 @@ static const ext_entry_t EXT_TABLE[] = {/* Scheme */{".scm", CBM_LANG_SCHEME},+ /* Chialisp — .clsp puzzles, .clib/.clinc includable libraries */+ {".clsp", CBM_LANG_CHIALISP},+ {".clib", CBM_LANG_CHIALISP},+ {".clinc", CBM_LANG_CHIALISP},+/* Slang */{".slang", CBM_LANG_SLANG},@@ -783,6 +788,7 @@ static const char *LANG_NAMES[CBM_LANG_COUNT] = {[CBM_LANG_DLANG] = "D",[CBM_LANG_NIM] = "Nim",[CBM_LANG_SCHEME] = "Scheme",+ [CBM_LANG_CHIALISP] = "Chialisp",[CBM_LANG_FENNEL] = "Fennel",[CBM_LANG_FISH] = "Fish",[CBM_LANG_AWK] = "AWK",diff --git a/src/discover/userconfig.c b/src/discover/userconfig.cindex c97fd48c9..8ba63d5bd 100644--- a/src/discover/userconfig.c+++ b/src/discover/userconfig.c@@ -142,6 +142,7 @@ static const lang_name_entry_t LANG_NAME_TABLE[] = {{"matlab", CBM_LANG_MATLAB},{"mojo", CBM_LANG_MOJO},{"plsql", CBM_LANG_PLSQL},+ {"chialisp", CBM_LANG_CHIALISP},{"lean", CBM_LANG_LEAN},{"form", CBM_LANG_FORM},{"magma", CBM_LANG_MAGMA},diff --git a/tests/repro/repro_call_argument_matrix_b.c b/tests/repro/repro_call_argument_matrix_b.cindex 733781344..e67bd19f4 100644--- a/tests/repro/repro_call_argument_matrix_b.c+++ b/tests/repro/repro_call_argument_matrix_b.c@@ -844,6 +844,17 @@ static const char OBJECTSCRIPT_ROUTINE_BARE[] = "SAMPLE\n""Run(watched)\n"" Quit watched\n";+/* Chialisp: a .clib wraps its definitions in one enclosing list; a call is a+ * `list` whose head symbol is the callee, and a parameter list is a `list`+ * too — so `total_calls` here also pins that a binder is not an invocation. */+static const char CHIALISP_INSIDE[] = "(\n"+ " (defun accept (value) value)\n"+ " (defun run (watched) (accept watched))\n"+ ")\n";+static const char CHIALISP_BARE[] = "(\n"+ " (defun run (watched) watched)\n"+ ")\n";+static const char PLSQL_INSIDE[] = "CREATE OR REPLACE PACKAGE BODY sample_pkg AS\n"" FUNCTION accept(value NUMBER) RETURN NUMBER IS\n"" BEGIN\n"@@ -1007,6 +1018,10 @@ static const RoutineArgumentCase PLSQL_CASE = ROUTINE_ARGUMENT_CASE("PLSQL", CBM_LANG_PLSQL, "sample_pkg.pkb", PLSQL_INSIDE, PLSQL_BARE, "ref_call", "run","accept", "watched", 1, 1, 0, "native PL/SQL package-body routine application");+static const RoutineArgumentCase CHIALISP_CASE = ROUTINE_ARGUMENT_CASE(+ "CHIALISP", CBM_LANG_CHIALISP, "sample.clib", CHIALISP_INSIDE, CHIALISP_BARE, "list", "run",+ "accept", "watched", 1, 1, 0, "Chialisp list application and symbol-reference vocabulary");+static const ModuleArgumentCase JUST_CASE = MODULE_ARGUMENT_CASE("JUST", CBM_LANG_JUST, "justfile", JUST_INSIDE, JUST_BARE, "function_call", "uppercase","watched", 1, 0, "Just expression call; recipe dependency is checked separately");@@ -1197,6 +1212,7 @@ DEFINE_ROUTINE_ARGUMENT_TEST(mojo, MOJO_CASE)DEFINE_ROUTINE_ARGUMENT_TEST(objectscript_udl, OBJECTSCRIPT_UDL_CASE)DEFINE_ROUTINE_ARGUMENT_TEST(objectscript_routine, OBJECTSCRIPT_ROUTINE_CASE)DEFINE_ROUTINE_ARGUMENT_TEST(plsql, PLSQL_CASE)+DEFINE_ROUTINE_ARGUMENT_TEST(chialisp, CHIALISP_CASE)#undef DEFINE_ROUTINE_ARGUMENT_TEST@@ -1266,15 +1282,15 @@ TEST(repro_call_argument_matrix_b_domain_bitbake) {}enum {- ROUTINE_ARGUMENT_LANGUAGE_COUNT = 37,+ ROUTINE_ARGUMENT_LANGUAGE_COUNT = 38,MODULE_ARGUMENT_LANGUAGE_COUNT = 4,DOMAIN_CONTROL_LANGUAGE_COUNT = 6,MATRIX_LANGUAGE_COUNT = ROUTINE_ARGUMENT_LANGUAGE_COUNT + MODULE_ARGUMENT_LANGUAGE_COUNT +DOMAIN_CONTROL_LANGUAGE_COUNT,};-_Static_assert(MATRIX_LANGUAGE_COUNT == 47,- "RACKET..PLSQL call-capable matrix must contain exactly 47 "+_Static_assert(MATRIX_LANGUAGE_COUNT == 48,+ "RACKET..CHIALISP call-capable matrix must contain exactly 48 ""language rows");#define MATRIX_B_LANGUAGE_ROWS(X) \@@ -1317,6 +1333,7 @@ _Static_assert(MATRIX_LANGUAGE_COUNT == 47,X(repro_call_argument_matrix_b_routine_objectscript_routine, \OBJECTSCRIPT_ROUTINE_CASE.identity.language) \X(repro_call_argument_matrix_b_routine_plsql, PLSQL_CASE.identity.language) \+ X(repro_call_argument_matrix_b_routine_chialisp, CHIALISP_CASE.identity.language) \X(repro_call_argument_matrix_b_module_just, JUST_CASE.identity.language) \X(repro_call_argument_matrix_b_module_gotemplate, GOTEMPLATE_CASE.identity.language) \X(repro_call_argument_matrix_b_module_linkerscript, LINKERSCRIPT_CASE.identity.language) \diff --git a/tests/repro/repro_call_node_manifest.c b/tests/repro/repro_call_node_manifest.cindex 97042df51..4405590b3 100644--- a/tests/repro/repro_call_node_manifest.c+++ b/tests/repro/repro_call_node_manifest.c@@ -54,9 +54,9 @@ typedef struct {} CallNodeManifestEntry;enum {- EXPECTED_HISTORICAL_CALL_NODE_TOTAL = 222,- EXPECTED_ACTIVE_PRIMARY_TOTAL = 192,- EXPECTED_DIRECT_CALLS = 157,+ EXPECTED_HISTORICAL_CALL_NODE_TOTAL = 223,+ EXPECTED_ACTIVE_PRIMARY_TOTAL = 193,+ EXPECTED_DIRECT_CALLS = 158,EXPECTED_CONSTRUCTOR_CALLS = 21,EXPECTED_OPERATOR_CALLS = 12,EXPECTED_IMPLICIT_CALLS = 2,@@ -65,7 +65,7 @@ enum {EXPECTED_CALLEE_WRAPPERS = 8,EXPECTED_ARGUMENT_WRAPPERS = 1,EXPECTED_CONTROL_OR_DOCUMENT_NONCALLS = 6,- EXPECTED_PRIMARY_OWNERS = 192,+ EXPECTED_PRIMARY_OWNERS = 193,EXPECTED_SYNTHETIC_OWNERS = 10,EXPECTED_NO_CALL_EDGE_OWNERS = 20,EXPECTED_PRIMARY_OPERATOR_CALLS = 4,@@ -220,6 +220,7 @@ static const CallNodeManifestEntry CALL_NODE_MANIFEST[] = {ENTRY(CBM_LANG_DLANG, "function_call_expression", DIRECT_CALL, NO_CALL_EDGE, true, false),ENTRY(CBM_LANG_DLANG, "new_expression", CONSTRUCTOR_CALL, PRIMARY_EXTRACTOR, true, true),ENTRY(CBM_LANG_SCHEME, "list", DIRECT_CALL, PRIMARY_EXTRACTOR, true, true),+ ENTRY(CBM_LANG_CHIALISP, "list", DIRECT_CALL, PRIMARY_EXTRACTOR, true, true),ENTRY(CBM_LANG_FENNEL, "list", DIRECT_CALL, PRIMARY_EXTRACTOR, true, true),ENTRY(CBM_LANG_FISH, "command", DSL_INVOCATION, PRIMARY_EXTRACTOR, true, true),ENTRY(CBM_LANG_AWK, "func_call", DIRECT_CALL, PRIMARY_EXTRACTOR, true, true),diff --git a/tests/repro/repro_invariant_breadth.c b/tests/repro/repro_invariant_breadth.cindex b4becd790..6aa8924d3 100644--- a/tests/repro/repro_invariant_breadth.c+++ b/tests/repro/repro_invariant_breadth.c@@ -10,7 +10,7 @@** QUALITY_ANALYSIS.md gap #6 reports 27 languages failing this. This file* is the "large breadth table" — one per-language case, table-driven, asserting- * the invariant across 26 languages.+ * the invariant across 27 languages.** Fixture design rule:* Each fixture defines exactly TWO functions: a callee (helper) and a caller@@ -27,6 +27,9 @@* r, julia, dart, groovy, commonlisp, powershell, ada, clojure,* fsharp, racket, rescript, scheme (12 cases)*+ * Added after the original snapshot:+ * chialisp (1 case, expected GREEN — lisp-family scope attribution)+ ** Note: the "suspicious" group (r, julia, ...) from QUALITY_ANALYSIS may be* GREEN because the calls-breadth table (test_lang_contract.c) already shows* expect_calls=true for most. The module-sourcing assertion is STRICTER: a@@ -51,19 +54,17 @@/* ---- helper: count CALLS edges by source-node label --------------------- */-static int ib_calls_from_label(cbm_store_t *store, const char *project,- const char *label) {+static int ib_calls_from_label(cbm_store_t *store, const char *project, const char *label) {cbm_edge_t *edges = NULL;int edge_count = 0;- if (cbm_store_find_edges_by_type(store, project, "CALLS",- &edges, &edge_count) != CBM_STORE_OK) {+ if (cbm_store_find_edges_by_type(store, project, "CALLS", &edges, &edge_count) !=+ CBM_STORE_OK) {return -1;}int total = 0;for (int i = 0; i < edge_count; i++) {cbm_node_t src = {0};- if (cbm_store_find_node_by_id(store, edges[i].source_id,- &src) != CBM_STORE_OK) {+ if (cbm_store_find_node_by_id(store, edges[i].source_id, &src) != CBM_STORE_OK) {continue;}if (src.label && strcmp(src.label, label) == 0) {@@ -135,42 +136,40 @@ static const IBCase IB_CASES[] = {/* CALLS edge is produced -- but it may still be Module-sourced. *//* ------------------------------------------------------------------ */- {- "r", "a.R",- "helper <- function(x) {\n"- " x * 2\n"- "}\n"- "\n"- "run <- function() {\n"- " helper(21)\n"- "}\n",- /*- * R: extract_calls.c has an R branch that reads the callee from the- * call node's first child. However, enclosing-function detection- * for R may fall back to Module if func_kinds_for_lang does not- * include R's "function_definition" node type. RED when the CALLS- * edge is sourced at Module instead of the "run" Function node.- */- 0, "R enclosing-function detection likely missing from func_kinds_for_lang; "- "call may be sourced at Module"- },-- {- "julia", "a.jl",- "function helper(x)\n"- " return x + 1\n"- "end\n"- "\n"- "function run(n)\n"- " return helper(n)\n"- "end\n",- /*- * Julia: same issue -- function body extraction may not detect the- * enclosing Julia function node correctly, sourcing the call at Module.- */- 0, "Julia enclosing-function detection may not map function_definition to "- "a callable QN; call sourced at Module"- },+ {"r", "a.R",+ "helper <- function(x) {\n"+ " x * 2\n"+ "}\n"+ "\n"+ "run <- function() {\n"+ " helper(21)\n"+ "}\n",+ /*+ * R: extract_calls.c has an R branch that reads the callee from the+ * call node's first child. However, enclosing-function detection+ * for R may fall back to Module if func_kinds_for_lang does not+ * include R's "function_definition" node type. RED when the CALLS+ * edge is sourced at Module instead of the "run" Function node.+ */+ 0,+ "R enclosing-function detection likely missing from func_kinds_for_lang; "+ "call may be sourced at Module"},++ {"julia", "a.jl",+ "function helper(x)\n"+ " return x + 1\n"+ "end\n"+ "\n"+ "function run(n)\n"+ " return helper(n)\n"+ "end\n",+ /*+ * Julia: same issue -- function body extraction may not detect the+ * enclosing Julia function node correctly, sourcing the call at Module.+ */+ 0,+ "Julia enclosing-function detection may not map function_definition to "+ "a callable QN; call sourced at Module"},/* ------------------------------------------------------------------ *//* EXPECTED-GREEN GROUP (regression guards) */@@ -179,191 +178,163 @@ static const IBCase IB_CASES[] = {/* them will turn the corresponding case RED. *//* ------------------------------------------------------------------ */- {- "elixir", "a.ex",- "defmodule Sample do\n"- " def helper(x) do\n"- " x + 1\n"- " end\n"- "\n"- " def run do\n"- " helper(41)\n"- " end\n"- "end\n",- 1, NULL- },-- {- "ocaml", "a.ml",- "let helper x = x + 1\n"- "\n"- "let run () =\n"- " let result = helper 41 in\n"- " print_int result\n",- 1, NULL- },-- {- "fortran", "a.f90",- "function helper(x) result(y)\n"- " integer, intent(in) :: x\n"- " integer :: y\n"- " y = x + 1\n"- "end function helper\n"- "\n"- "function run(n) result(total)\n"- " integer, intent(in) :: n\n"- " integer :: total\n"- " total = helper(n) + helper(n + 1)\n"- "end function run\n",- 1, NULL- },-- {- "pascal", "a.pas",- "procedure Helper(x: Integer);\n"- "begin\n"- " WriteLn(x);\n"- "end;\n"- "\n"- "procedure Run;\n"- "begin\n"- " Helper(1);\n"- "end;\n",- 1, NULL- },-- {- "cuda", "a.cu",- "__device__ int helper(int x) {\n"- " return x * 2;\n"- "}\n"- "\n"- "__global__ void run(int *out) {\n"- " out[0] = helper(21);\n"- "}\n",- 1, NULL- },-- {- "d", "a.d",- "int helper(int x)\n"- "{\n"- " return x + 1;\n"- "}\n"- "\n"- "void run()\n"- "{\n"- " int y = helper(41);\n"- "}\n",- 1, NULL- },-- {- "glsl", "a.glsl",- "float helper(float x) {\n"- " return x * 2.0;\n"- "}\n"- "\n"- "void run() {\n"- " float y = helper(3.0);\n"- "}\n",- 1, NULL- },-- {- "hlsl", "a.hlsl",- "float helper(float x)\n"- "{\n"- " return x * 2.0;\n"- "}\n"- "\n"- "float run(float v)\n"- "{\n"- " return helper(v) + 1.0;\n"- "}\n",- 1, NULL- },-- {- "ispc", "a.ispc",- "static inline uniform float helper(uniform float x) {\n"- " return x * 2.0f;\n"- "}\n"- "\n"- "export void run(uniform float in[], uniform float out[],\n"- " uniform int n) {\n"- " foreach (i = 0 ... n) {\n"- " out[i] = helper(in[i]);\n"- " }\n"- "}\n",- 1, NULL- },-- {- "odin", "a.odin",- "package fixture\n"- "\n"- "helper :: proc() -> int {\n"- "\treturn 42\n"- "}\n"- "\n"- "run :: proc() {\n"- "\tx := helper()\n"- "\t_ = x\n"- "}\n",- 1, NULL- },-- {- "slang", "a.slang",- "void helper()\n"- "{\n"- " int x = 1;\n"- "}\n"- "\n"- "void run()\n"- "{\n"- " helper();\n"- "}\n",- 1, NULL- },-- {- "squirrel", "a.nut",- "function helper(x) {\n"- " return x + 1;\n"- "}\n"- "\n"- "function run() {\n"- " return helper(41);\n"- "}\n",- 1, NULL- },-- {- "vimscript", "a.vim",- "function! Helper() abort\n"- " return 1\n"- "endfunction\n"- "\n"- "function! Run() abort\n"- " call Helper()\n"- "endfunction\n",- 1, NULL- },-- {- "cairo", "a.cairo",- "fn helper(x: felt252) -> felt252 {\n"- " x + 1\n"- "}\n"- "\n"- "fn run() -> felt252 {\n"- " helper(41)\n"- "}\n",- 1, NULL- },+ {"elixir", "a.ex",+ "defmodule Sample do\n"+ " def helper(x) do\n"+ " x + 1\n"+ " end\n"+ "\n"+ " def run do\n"+ " helper(41)\n"+ " end\n"+ "end\n",+ 1, NULL},++ {"ocaml", "a.ml",+ "let helper x = x + 1\n"+ "\n"+ "let run () =\n"+ " let result = helper 41 in\n"+ " print_int result\n",+ 1, NULL},++ {"fortran", "a.f90",+ "function helper(x) result(y)\n"+ " integer, intent(in) :: x\n"+ " integer :: y\n"+ " y = x + 1\n"+ "end function helper\n"+ "\n"+ "function run(n) result(total)\n"+ " integer, intent(in) :: n\n"+ " integer :: total\n"+ " total = helper(n) + helper(n + 1)\n"+ "end function run\n",+ 1, NULL},++ {"pascal", "a.pas",+ "procedure Helper(x: Integer);\n"+ "begin\n"+ " WriteLn(x);\n"+ "end;\n"+ "\n"+ "procedure Run;\n"+ "begin\n"+ " Helper(1);\n"+ "end;\n",+ 1, NULL},++ {"cuda", "a.cu",+ "__device__ int helper(int x) {\n"+ " return x * 2;\n"+ "}\n"+ "\n"+ "__global__ void run(int *out) {\n"+ " out[0] = helper(21);\n"+ "}\n",+ 1, NULL},++ {"d", "a.d",+ "int helper(int x)\n"+ "{\n"+ " return x + 1;\n"+ "}\n"+ "\n"+ "void run()\n"+ "{\n"+ " int y = helper(41);\n"+ "}\n",+ 1, NULL},++ {"glsl", "a.glsl",+ "float helper(float x) {\n"+ " return x * 2.0;\n"+ "}\n"+ "\n"+ "void run() {\n"+ " float y = helper(3.0);\n"+ "}\n",+ 1, NULL},++ {"hlsl", "a.hlsl",+ "float helper(float x)\n"+ "{\n"+ " return x * 2.0;\n"+ "}\n"+ "\n"+ "float run(float v)\n"+ "{\n"+ " return helper(v) + 1.0;\n"+ "}\n",+ 1, NULL},++ {"ispc", "a.ispc",+ "static inline uniform float helper(uniform float x) {\n"+ " return x * 2.0f;\n"+ "}\n"+ "\n"+ "export void run(uniform float in[], uniform float out[],\n"+ " uniform int n) {\n"+ " foreach (i = 0 ... n) {\n"+ " out[i] = helper(in[i]);\n"+ " }\n"+ "}\n",+ 1, NULL},++ {"odin", "a.odin",+ "package fixture\n"+ "\n"+ "helper :: proc() -> int {\n"+ "\treturn 42\n"+ "}\n"+ "\n"+ "run :: proc() {\n"+ "\tx := helper()\n"+ "\t_ = x\n"+ "}\n",+ 1, NULL},++ {"slang", "a.slang",+ "void helper()\n"+ "{\n"+ " int x = 1;\n"+ "}\n"+ "\n"+ "void run()\n"+ "{\n"+ " helper();\n"+ "}\n",+ 1, NULL},++ {"squirrel", "a.nut",+ "function helper(x) {\n"+ " return x + 1;\n"+ "}\n"+ "\n"+ "function run() {\n"+ " return helper(41);\n"+ "}\n",+ 1, NULL},++ {"vimscript", "a.vim",+ "function! Helper() abort\n"+ " return 1\n"+ "endfunction\n"+ "\n"+ "function! Run() abort\n"+ " call Helper()\n"+ "endfunction\n",+ 1, NULL},++ {"cairo", "a.cairo",+ "fn helper(x: felt252) -> felt252 {\n"+ " x + 1\n"+ "}\n"+ "\n"+ "fn run() -> felt252 {\n"+ " helper(41)\n"+ "}\n",+ 1, NULL},/* ------------------------------------------------------------------ *//* KNOWN-GAP GROUP */@@ -374,163 +345,169 @@ static const IBCase IB_CASES[] = {/* calls >= 1 AND module_calls == 0. *//* ------------------------------------------------------------------ */- {- "dart", "a.dart",- "void helper() {\n"- " print('helper');\n"- "}\n"- "\n"- "void run() {\n"- " helper();\n"- "}\n",- /*- * Dart: selector call node carries no callee field and the first child- * is not an identifier; no dart branch in extract_calls.c. No CALLS- * edge is produced at all, so callable-sourcing cannot be tested- * independently. Both gaps (no CALLS + callable-sourcing) are RED.- */- 0, "selector call node: no callee field, first child not identifier; "- "no dart branch in extract_calls.c"- },-- {- "groovy", "a.groovy",- "def helper() {\n"- " println 'helping'\n"- "}\n"- "\n"- "def run() {\n"- " helper()\n"- "}\n",- /*- * Groovy: function_call callee not on a function/name field and first- * child is not 'identifier'; no groovy branch in extract_calls.c.- */- 0, "function_call callee not on function/name field; "- "first child is not identifier; no groovy branch in extract_calls.c"- },-- {- "commonlisp", "a.lisp",- "(defun helper (x)\n"- " (* x 2))\n"- "\n"- "(defun run ()\n"- " (helper 21))\n",- /*- * Common Lisp: list_lit call head is sym_lit not identifier;- * no commonlisp branch in extract_callee_name.- */- 0, "list_lit call head is sym_lit not identifier; "- "no commonlisp branch in extract_callee_name"- },-- {- "powershell", "a.ps1",- "function helper {\n"- " Write-Output 'hi'\n"- "}\n"- "\n"- "function run {\n"- " helper\n"- "}\n",- /*- * PowerShell: command node child is command_name not identifier;- * extract_scripting_callee handles MATLAB not PowerShell.- */- 0, "command node child is command_name not identifier; "- "extract_scripting_callee handles MATLAB not PowerShell"- },-- {- "ada", "a.adb",- "procedure Run is\n"- " procedure Helper is\n"- " begin\n"- " null;\n"- " end Helper;\n"- "begin\n"- " Helper;\n"- "end Run;\n",- /*- * Ada: procedure_call_statement callee did not resolve to a CALLS edge;- * no Ada branch in extract_calls.c.- */- 0, "procedure_call_statement callee not resolved; "- "no Ada branch in extract_calls.c"- },-- {- "clojure", "a.clj",- "(defn helper [] 42)\n"- "\n"- "(defn run [] (helper))\n",- /*- * Clojure: lisp call is a list_lit whose head is a sym_lit (not a- * field, not a first-child 'identifier'); no lisp branch in- * extract_callee_name.- */- 0, "list_lit head is sym_lit not identifier; "- "no lisp/clojure branch in extract_callee_name"- },-- {- "fsharp", "a.fs",- "let helper x = x + 1\n"- "\n"- "let run () = helper 41\n",- /*- * F#: application_expression callee head is a long_identifier_or_op- * wrapper, not a bare identifier/field; no fsharp callee branch.- */- 0, "application_expression callee head is long_identifier_or_op wrapper; "- "no fsharp callee branch in extract_callee_name"- },-- {- "racket", "a.rkt",- "#lang racket\n"- "\n"- "(define (helper x)\n"- " (+ x 1))\n"- "\n"- "(define (run)\n"- " (helper 41))\n",- /*- * Racket: lisp call is a 'list' whose head is a 'symbol' (grammar has- * no 'identifier' node); no racket branch in extract_callee_name.- */- 0, "list head is symbol not identifier; "- "no racket branch in extract_callee_name"- },-- {- "rescript", "a.res",- "let helper = (x) => x + 1\n"- "\n"- "let run = () => helper(41)\n",- /*- * ReScript: call_expression 'function' field is a 'value_identifier'- * (not in extract_callee_from_fields' accepted type list).- */- 0, "call_expression function field is value_identifier; "- "not in extract_callee_from_fields accepted type list"- },-- {- "scheme", "a.scm",- "(define (helper x)\n"- " (* x 2))\n"- "\n"- "(define (run)\n"- " (helper 21))\n",- /*- * Scheme: lisp call is a 'list' whose head is a 'symbol';- * no scheme branch in extract_callee_name.- */- 0, "list head is symbol not identifier; "- "no scheme branch in extract_callee_name"- },+ {"dart", "a.dart",+ "void helper() {\n"+ " print('helper');\n"+ "}\n"+ "\n"+ "void run() {\n"+ " helper();\n"+ "}\n",+ /*+ * Dart: selector call node carries no callee field and the first child+ * is not an identifier; no dart branch in extract_calls.c. No CALLS+ * edge is produced at all, so callable-sourcing cannot be tested+ * independently. Both gaps (no CALLS + callable-sourcing) are RED.+ */+ 0,+ "selector call node: no callee field, first child not identifier; "+ "no dart branch in extract_calls.c"},++ {"groovy", "a.groovy",+ "def helper() {\n"+ " println 'helping'\n"+ "}\n"+ "\n"+ "def run() {\n"+ " helper()\n"+ "}\n",+ /*+ * Groovy: function_call callee not on a function/name field and first+ * child is not 'identifier'; no groovy branch in extract_calls.c.+ */+ 0,+ "function_call callee not on function/name field; "+ "first child is not identifier; no groovy branch in extract_calls.c"},++ {"commonlisp", "a.lisp",+ "(defun helper (x)\n"+ " (* x 2))\n"+ "\n"+ "(defun run ()\n"+ " (helper 21))\n",+ /*+ * Common Lisp: list_lit call head is sym_lit not identifier;+ * no commonlisp branch in extract_callee_name.+ */+ 0,+ "list_lit call head is sym_lit not identifier; "+ "no commonlisp branch in extract_callee_name"},++ {"powershell", "a.ps1",+ "function helper {\n"+ " Write-Output 'hi'\n"+ "}\n"+ "\n"+ "function run {\n"+ " helper\n"+ "}\n",+ /*+ * PowerShell: command node child is command_name not identifier;+ * extract_scripting_callee handles MATLAB not PowerShell.+ */+ 0,+ "command node child is command_name not identifier; "+ "extract_scripting_callee handles MATLAB not PowerShell"},++ {"ada", "a.adb",+ "procedure Run is\n"+ " procedure Helper is\n"+ " begin\n"+ " null;\n"+ " end Helper;\n"+ "begin\n"+ " Helper;\n"+ "end Run;\n",+ /*+ * Ada: procedure_call_statement callee did not resolve to a CALLS edge;+ * no Ada branch in extract_calls.c.+ */+ 0,+ "procedure_call_statement callee not resolved; "+ "no Ada branch in extract_calls.c"},++ {"clojure", "a.clj",+ "(defn helper [] 42)\n"+ "\n"+ "(defn run [] (helper))\n",+ /*+ * Clojure: lisp call is a list_lit whose head is a sym_lit (not a+ * field, not a first-child 'identifier'); no lisp branch in+ * extract_callee_name.+ */+ 0,+ "list_lit head is sym_lit not identifier; "+ "no lisp/clojure branch in extract_callee_name"},++ {"fsharp", "a.fs",+ "let helper x = x + 1\n"+ "\n"+ "let run () = helper 41\n",+ /*+ * F#: application_expression callee head is a long_identifier_or_op+ * wrapper, not a bare identifier/field; no fsharp callee branch.+ */+ 0,+ "application_expression callee head is long_identifier_or_op wrapper; "+ "no fsharp callee branch in extract_callee_name"},++ {"racket", "a.rkt",+ "#lang racket\n"+ "\n"+ "(define (helper x)\n"+ " (+ x 1))\n"+ "\n"+ "(define (run)\n"+ " (helper 41))\n",+ /*+ * Racket: lisp call is a 'list' whose head is a 'symbol' (grammar has+ * no 'identifier' node); no racket branch in extract_callee_name.+ */+ 0,+ "list head is symbol not identifier; "+ "no racket branch in extract_callee_name"},++ {"rescript", "a.res",+ "let helper = (x) => x + 1\n"+ "\n"+ "let run = () => helper(41)\n",+ /*+ * ReScript: call_expression 'function' field is a 'value_identifier'+ * (not in extract_callee_from_fields' accepted type list).+ */+ 0,+ "call_expression function field is value_identifier; "+ "not in extract_callee_from_fields accepted type list"},++ {"scheme", "a.scm",+ "(define (helper x)\n"+ " (* x 2))\n"+ "\n"+ "(define (run)\n"+ " (helper 21))\n",+ /*+ * Scheme: lisp call is a 'list' whose head is a 'symbol';+ * no scheme branch in extract_callee_name.+ */+ 0,+ "list head is symbol not identifier; "+ "no scheme branch in extract_callee_name"},++ {"chialisp", "a.clsp",+ "(mod ()\n"+ " (defun helper (x)\n"+ " (* x 2))\n"+ " (defun run ()\n"+ " (helper 21))\n"+ ")\n",+ /*+ * Chialisp: EXPECTED-GREEN. Every def is nested inside the top-level+ * `(mod ...)`, so the in-body call can only be Function-sourced if+ * compute_lisp_func_qn pushes a scope for the inner `(defun run ...)`+ * rather than stopping at the module. That is exactly what would+ * regress if the Chialisp def-head set drifted from the defs walk.+ */+ 1, NULL},};enum { IB_CASES_COUNT = (int)(sizeof(IB_CASES) / sizeof(IB_CASES[0])) };@@ -564,17 +541,14 @@ TEST(repro_invariant_breadth_callable_sourcing) {const IBCase *c = &IB_CASES[i];IBMetrics m = ib_metrics(c->filename, c->src);- int pass = (m.ok && m.calls >= 1 && m.callable_calls >= 1 &&- m.module_calls == 0);+ int pass = (m.ok && m.calls >= 1 && m.callable_calls >= 1 && m.module_calls == 0);if (!pass) {fprintf(stderr," [INV-BREADTH] FAIL %-12s ok=%d calls=%d ""callable=%d module=%d%s%s\n",- c->lang, m.ok, m.calls, m.callable_calls,- m.module_calls,- c->gap_note ? " -- " : "",- c->gap_note ? c->gap_note : "");+ c->lang, m.ok, m.calls, m.callable_calls, m.module_calls,+ c->gap_note ? " -- " : "", c->gap_note ? c->gap_note : "");failures++;} else {fprintf(stderr,diff --git a/tests/repro/repro_language_registry.c b/tests/repro/repro_language_registry.cindex afa1ee596..31a55b97e 100644--- a/tests/repro/repro_language_registry.c+++ b/tests/repro/repro_language_registry.c@@ -212,6 +212,7 @@ static const LanguageCapabilityEntry LANGUAGE_CAPABILITIES[CBM_LANG_COUNT] = {TRANSFORM_ONLY(OBJECTSCRIPT_EXPORT),CALL_WITH_REFERENCE_VOCAB(ARKTS),CALL_WITHOUT_REFERENCE_VOCAB(PLSQL),+ CALL_WITHOUT_REFERENCE_VOCAB(CHIALISP),};#undef CALL_WITH_REFERENCE_VOCAB@@ -301,7 +302,7 @@ TEST(repro_language_capability_ledger_covers_every_enum) {}if (counts[CAP_CALL_WITH_REFERENCE_VOCAB] != 87 ||- counts[CAP_CALL_WITHOUT_REFERENCE_VOCAB] != 26 || counts[CAP_NO_CALL] != 50 ||+ counts[CAP_CALL_WITHOUT_REFERENCE_VOCAB] != 27 || counts[CAP_NO_CALL] != 50 ||counts[CAP_TRANSFORM_ONLY] != 1 || counts[CAP_UNSUPPORTED] != 1) {fprintf(stderr," [language-registry] invariant=capability_partition call_ref_vocab=%d ref_gap=%d "@@ -318,8 +319,8 @@ TEST(repro_language_capability_ledger_covers_every_enum) {TEST(repro_call_argument_matrices_equal_call_capability_ledger) {enum {EXPECTED_MATRIX_A_ROWS = 68,- EXPECTED_MATRIX_B_ROWS = 47,- EXPECTED_CALL_CAPABLE_LANGUAGES = 113,+ EXPECTED_MATRIX_B_ROWS = 48,+ EXPECTED_CALL_CAPABLE_LANGUAGES = 114,EXPECTED_NON_CALL_LANGUAGES = 52,EXPECTED_NON_CALL_DOMAIN_CONTROLS = 2,};diff --git a/tests/test_extraction.c b/tests/test_extraction.cindex 935eda07c..ac75b16a6 100644--- a/tests/test_extraction.c+++ b/tests/test_extraction.c@@ -1225,19 +1225,18 @@ TEST(form_procedure) {/* --- Oracle PL/SQL --- */TEST(plsql_package_and_call) {- const char *src =- "CREATE OR REPLACE PACKAGE BODY emp_pkg AS\n"- " FUNCTION hire(p_name VARCHAR2) RETURN NUMBER IS\n"- " v_sal NUMBER;\n"- " BEGIN\n"- " v_sal := util_pkg.calc_salary(p_name);\n"- " IF v_sal > 0 THEN\n"- " RETURN v_sal;\n"- " END IF;\n"- " RAISE no_data_found;\n"- " END;\n"- "END emp_pkg;\n"- "/\n";+ const char *src = "CREATE OR REPLACE PACKAGE BODY emp_pkg AS\n"+ " FUNCTION hire(p_name VARCHAR2) RETURN NUMBER IS\n"+ " v_sal NUMBER;\n"+ " BEGIN\n"+ " v_sal := util_pkg.calc_salary(p_name);\n"+ " IF v_sal > 0 THEN\n"+ " RETURN v_sal;\n"+ " END IF;\n"+ " RAISE no_data_found;\n"+ " END;\n"+ "END emp_pkg;\n"+ "/\n";CBMFileResult *r = extract(src, CBM_LANG_PLSQL, "t", "emp_pkg.pkb");ASSERT_NOT_NULL(r);ASSERT_FALSE(r->has_error);@@ -1286,6 +1285,156 @@ TEST(plsql_create_type_as_object_limitation) {PASS();}+/* --- Chialisp ---+ *+ * Three defects in the only public Chialisp grammar+ * (Quexington/tree-sitter-chialisp) motivated writing our own, and each is+ * pinned below as a parse-level assertion rather than a note: comments that+ * required CRLF to terminate, `(include foo.clib)` rejected because of the dot+ * in the filename, and `(defconstant NAME <expr>)` accepting only a primitive.+ * All three desynchronised the rest of the file, so a regression here shows up+ * as `has_error` plus missing defs, not as one lost node. */+TEST(chialisp_puzzle_defs_and_labels) {+ const char *src = "; a Chialisp puzzle\n"+ "(mod (ARG)\n"+ " (include condition_codes.clib)\n"+ " (defconstant TWO 2)\n"+ " (defconstant HASH (sha256 1))\n"+ " (defun-inline square (x) (* x x))\n"+ " (defun apply_twice (v) (square (square v)))\n"+ " (defmacro assert items (f items))\n"+ " (apply_twice ARG)\n"+ ")\n";+ CBMFileResult *r = extract(src, CBM_LANG_CHIALISP, "t", "puzzles/my_puzzle.clsp");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);+ /* `mod` has no name of its own — the puzzle is named by its file. */+ ASSERT(has_def(r, "Module", "my_puzzle"));+ /* Defs are NESTED inside `(mod ...)`; a walk that stops at the module+ * loses every one of them. */+ ASSERT(has_def(r, "Function", "square"));+ ASSERT(has_def(r, "Function", "apply_twice"));+ ASSERT(has_def(r, "Macro", "assert"));+ /* `defconstant` binds an arbitrary EXPRESSION, not just a primitive. */+ ASSERT(has_def(r, "Constant", "TWO"));+ ASSERT(has_def(r, "Constant", "HASH"));+ /* A dotted include filename resolves as one symbol. */+ ASSERT(has_import(r, "condition_codes.clib"));+ /* Real calls survive; CLVM primitives and def heads do not become calls. */+ ASSERT(has_call(r, "square"));+ ASSERT(has_call(r, "apply_twice"));+ ASSERT(!has_call(r, "sha256"));+ ASSERT(!has_call(r, "defun"));+ ASSERT(!has_call(r, "mod"));+ ASSERT(!has_call(r, "include"));+ /* A parameter list is a `list` too — but it binds, it does not invoke. */+ ASSERT(!has_call(r, "x"));+ ASSERT(!has_call(r, "v"));+ ASSERT(!has_call(r, "items"));+ cbm_free_result(r);+ PASS();+}++TEST(chialisp_comment_line_endings) {+ /* LF, CRLF, and a comment closed by EOF with no trailing newline. The+ * public grammar's comment rule was `/;.*\r\n/`, so an LF file lost every+ * form after the first comment. */+ const char *lf = "(mod (A)\n; note\n(defun f (x) x)\n)\n";+ const char *crlf = "(mod (A)\r\n; note\r\n(defun f (x) x)\r\n)\r\n";+ const char *eof = "(mod (A)\n(defun f (x) x)\n)\n; trailing comment, no newline";+ const char *srcs[] = {lf, crlf, eof};+ for (int i = 0; i < 3; i++) {+ CBMFileResult *r = extract(srcs[i], CBM_LANG_CHIALISP, "t", "c.clsp");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);+ ASSERT_FALSE(r->parse_incomplete);+ ASSERT(has_def(r, "Function", "f"));+ cbm_free_result(r);+ }+ PASS();+}++TEST(chialisp_library_defs_and_quoted_data) {+ /* A .clib wraps its definitions in one enclosing list, and its macros embed+ * puzzle-shaped literals under `(q ...)`. Those literals are DATA: a def+ * head or call symbol inside one must mint nothing. */+ const char *src = "(\n"+ " (defconstant TWO 2)\n"+ " (defmacro emit () (q . (defun ghost (x) (real_helper x))))\n"+ " (defun real_helper (x) (+ x TWO))\n"+ ")\n";+ CBMFileResult *r = extract(src, CBM_LANG_CHIALISP, "t", "curry.clib");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);+ ASSERT(has_def(r, "Constant", "TWO"));+ ASSERT(has_def(r, "Macro", "emit"));+ ASSERT(has_def(r, "Function", "real_helper"));+ ASSERT(!has_def_any(r, "ghost"));+ ASSERT(!has_call(r, "real_helper"));+ cbm_free_result(r);+ PASS();+}++TEST(chialisp_export_names_do_not_duplicate_defs) {+ /* `(export foo)` names a function already defined in the same file. As a+ * def head it would mint a SECOND node for `foo`; as a call head it would+ * mint a phantom call. It is neither. */+ const char *src = "(\n"+ " (defun foo (x) x)\n"+ " (export foo)\n"+ ")\n";+ CBMFileResult *r = extract(src, CBM_LANG_CHIALISP, "t", "e.clsp");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);+ int foo_defs = 0;+ for (int i = 0; i < r->defs.count; i++) {+ if (r->defs.items[i].name && strcmp(r->defs.items[i].name, "foo") == 0) {+ foo_defs++;+ }+ }+ ASSERT_EQ(foo_defs, 1);+ ASSERT(!has_call(r, "export"));+ ASSERT(!has_call(r, "foo"));+ cbm_free_result(r);+ PASS();+}++TEST(chialisp_comment_before_def_head_keeps_the_name) {+ /* Comments are NAMED nodes and so occupy named-child indices. A comment+ * between the head and the name shifts them by one; defs and call-scope+ * must skip comments the same way or they stop describing the same tree. */+ const char *src = "(mod ()\n"+ " (defun ; why this exists\n"+ " documented (x) (* x 2))\n"+ " (defun caller () (documented 21))\n"+ ")\n";+ CBMFileResult *r = extract(src, CBM_LANG_CHIALISP, "t", "d.clsp");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);+ ASSERT(has_def(r, "Function", "documented"));+ ASSERT(has_def(r, "Function", "caller"));+ ASSERT(has_call(r, "documented"));+ cbm_free_result(r);+ PASS();+}++TEST(chialisp_dialect_sigil_is_not_a_file_import) {+ /* `(include *standard-cl-26*)` selects a dialect; recording it as an import+ * invents a dependency on a file that does not exist. The compiler filters+ * `*...*` names and so must we. */+ const char *src = "(mod ()\n"+ " (include *standard-cl-26*)\n"+ " (include curry.clib)\n"+ ")\n";+ CBMFileResult *r = extract(src, CBM_LANG_CHIALISP, "t", "s.clsp");+ ASSERT_NOT_NULL(r);+ ASSERT_FALSE(r->has_error);+ ASSERT(has_import(r, "curry.clib"));+ ASSERT(!has_import(r, "standard-cl-26"));+ cbm_free_result(r);+ PASS();+}+/* --- Wolfram --- */TEST(wolfram_function) {CBMFileResult *r =@@ -2052,9 +2201,10 @@ TEST(dbt_source_and_two_arg_ref) {/* Both dbt builtins name the relation in their LAST string argument:* source('group','table') -> table, and the two-argument* ref('package','model') form -> model. */- CBMFileResult *r = extract("SELECT * FROM {{ source('raw', 'customers') }}\n"- "UNION ALL SELECT * FROM {{ ref('analytics', 'legacy_customers') }}\n",- CBM_LANG_SQL, "t", "models/stg_customers.sql");+ CBMFileResult *r =+ extract("SELECT * FROM {{ source('raw', 'customers') }}\n"+ "UNION ALL SELECT * FROM {{ ref('analytics', 'legacy_customers') }}\n",+ CBM_LANG_SQL, "t", "models/stg_customers.sql");ASSERT_NOT_NULL(r);ASSERT(has_def(r, "Model", "stg_customers"));ASSERT(has_usage(r, "customers"));@@ -3073,8 +3223,8 @@ TEST(vue_embedded_structure_negative_controls_issue1410) {}TEST(vue_embedded_structure_host_controls_issue1410) {- CBMFileResult *plain = extract("function plainTs(): void { target(); }\n", CBM_LANG_TYPESCRIPT,- "t", "plain.ts");+ CBMFileResult *plain =+ extract("function plainTs(): void { target(); }\n", CBM_LANG_TYPESCRIPT, "t", "plain.ts");ASSERT_NOT_NULL(plain);ASSERT_FALSE(plain->has_error);ASSERT_EQ(count_defs_named(plain, "Function", "plainTs"), 1);@@ -3532,11 +3682,11 @@ TEST(extract_java_method_annotations_issue382) {/* ── ArkTS (HarmonyOS .ets) ─────────────────────────────────────── */TEST(arkts_component_struct) {- CBMFileResult *r = extract(- "@Entry\n@Component\nstruct Index {\n @State message: string = 'Hello'\n\n"- " build() {\n Column() {\n Text(this.message).fontSize(20)\n }\n"- " .width('100%')\n }\n}\n",- CBM_LANG_ARKTS, "t", "Index.ets");+ CBMFileResult *r =+ extract("@Entry\n@Component\nstruct Index {\n @State message: string = 'Hello'\n\n"+ " build() {\n Column() {\n Text(this.message).fontSize(20)\n }\n"+ " .width('100%')\n }\n}\n",+ CBM_LANG_ARKTS, "t", "Index.ets");ASSERT_NOT_NULL(r);ASSERT_FALSE(r->has_error);ASSERT(has_def(r, "Struct", "Index"));@@ -3567,12 +3717,12 @@ TEST(arkts_exported_struct_decorators) {}TEST(arkts_member_decorators) {- CBMFileResult *r = extract(- "@Component\nstruct S {\n @State a: number = 0\n @Prop b: string\n"- " @Link c: boolean\n @Provide('k') d: string = ''\n @Consume('k') e: string\n"- " @StorageLink('s') f: number = 1\n @State @Watch('onW') g: boolean = false\n\n"- " build() {\n }\n}\n",- CBM_LANG_ARKTS, "t", "S.ets");+ CBMFileResult *r =+ extract("@Component\nstruct S {\n @State a: number = 0\n @Prop b: string\n"+ " @Link c: boolean\n @Provide('k') d: string = ''\n @Consume('k') e: string\n"+ " @StorageLink('s') f: number = 1\n @State @Watch('onW') g: boolean = false\n\n"+ " build() {\n }\n}\n",+ CBM_LANG_ARKTS, "t", "S.ets");ASSERT_NOT_NULL(r);ASSERT_FALSE(r->has_error);ASSERT(decorators_contain(find_def_by_name(r, "a"), "State"));@@ -3612,11 +3762,11 @@ TEST(arkts_no_phantom_builtin_defs) {}TEST(arkts_builder_extend_styles) {- CBMFileResult *r = extract(- "@Builder\nfunction card(t: string) {\n Column() {\n Text(t)\n }\n}\n\n"- "@Extend(Text)\nfunction fancy(size: number) {\n .fontSize(size)\n}\n\n"- "@Styles\nfunction pressed() {\n .backgroundColor('#eee')\n}\n",- CBM_LANG_ARKTS, "t", "b.ets");+ CBMFileResult *r =+ extract("@Builder\nfunction card(t: string) {\n Column() {\n Text(t)\n }\n}\n\n"+ "@Extend(Text)\nfunction fancy(size: number) {\n .fontSize(size)\n}\n\n"+ "@Styles\nfunction pressed() {\n .backgroundColor('#eee')\n}\n",+ CBM_LANG_ARKTS, "t", "b.ets");ASSERT_NOT_NULL(r);ASSERT_FALSE(r->has_error);ASSERT(has_def(r, "Function", "card"));@@ -4960,8 +5110,8 @@ TEST(extract_c_test_dir_marks_is_test_issue1294) {* not be (#1294). */TEST(extract_python_method_test_dir_marks_is_test_issue1294) {const char *src = "class Foo:\n"- " def helper(self):\n"- " pass\n";+ " def helper(self):\n"+ " pass\n";/* Python's LSP layer injects synthetic builtin stub Methods (str.upper,* dict.get, ...) into defs.items alongside real ones (py_builtins.c), so@@ -6150,6 +6300,12 @@ SUITE(extraction) {RUN_TEST(plsql_package_and_call);RUN_TEST(plsql_standalone_function);RUN_TEST(plsql_create_type_as_object_limitation);+ RUN_TEST(chialisp_puzzle_defs_and_labels);+ RUN_TEST(chialisp_comment_line_endings);+ RUN_TEST(chialisp_library_defs_and_quoted_data);+ RUN_TEST(chialisp_export_names_do_not_duplicate_defs);+ RUN_TEST(chialisp_comment_before_def_head_keeps_the_name);+ RUN_TEST(chialisp_dialect_sigil_is_not_a_file_import);RUN_TEST(wolfram_function);RUN_TEST(magma_function);diff --git a/tests/test_grammar_labels.c b/tests/test_grammar_labels.cindex 6f7a8780e..4008b6d2c 100644--- a/tests/test_grammar_labels.c+++ b/tests/test_grammar_labels.c@@ -141,6 +141,7 @@ static const LabelGolden LABEL_GOLDENS[] = {{"racket", "Function:2,Module:1"},{"rescript", "Function:2,Module:1"},{"scheme", "Function:2,Module:1"},+ {"chialisp", "Constant:1,Function:1,Macro:1,Module:2"},{"slang", "Function:2,Module:1"},{"squirrel", "Function:2,Module:1"},{"starlark", "Function:2,Module:1"},diff --git a/tests/test_grammar_regression.c b/tests/test_grammar_regression.cindex cdf598ab3..219c68edb 100644--- a/tests/test_grammar_regression.c+++ b/tests/test_grammar_regression.c@@ -171,6 +171,21 @@ const GrammarCase CBM_GRAMMAR_CASES[] = {{"racket", CBM_LANG_RACKET, "a.rkt", "(define (foo) 1)\n(define (bar) 2)\n", 1, {NULL}},{"rescript", CBM_LANG_RESCRIPT, "a.res", "let foo = () => 1\nlet bar = () => 2\n", 1, {NULL}},{"scheme", CBM_LANG_SCHEME, "a.scm", "(define (foo) 1)\n(define (bar) 2)\n", 1, {NULL}},+ /* Chialisp: every def is a head symbol of a generic `list`, and they are+ * NESTED inside the top-level `(mod ...)` — the fixture must exercise that+ * nesting, or the walk could stop at `mod` and still look green. */+ {"chialisp",+ CBM_LANG_CHIALISP,+ "a.clsp",+ "(mod (ARG)\n"+ " (include condition_codes.clib)\n"+ " (defconstant TWO 2)\n"+ " (defun-inline square (x) (* x x))\n"+ " (defmacro twice (v) (qq (+ (unquote v) (unquote v))))\n"+ " (square ARG)\n"+ ")\n",+ 3,+ {"square", "TWO", "twice", NULL}},{"slang", CBM_LANG_SLANG, "a.slang", "void foo() {}\nvoid bar() {}\n", 1, {NULL}},{"squirrel", CBM_LANG_SQUIRREL, "a.nut", "function foo() {}\nfunction bar() {}\n", 1, {NULL}},{"starlark",@@ -199,7 +214,8 @@ const GrammarCase CBM_GRAMMAR_CASES[] = {{"mojo",CBM_LANG_MOJO,"a.mojo",- "fn foo() -> Int:\n return 1\n\nstruct A:\n fn bar(self) -> Int:\n return foo()\n",+ "fn foo() -> Int:\n return 1\n\nstruct A:\n fn bar(self) -> Int:\n return "+ "foo()\n",2,{"foo", "A", NULL}},{"arkts",diff --git a/tests/test_lang_contract.c b/tests/test_lang_contract.cindex 586452e2b..3ec63d80e 100644--- a/tests/test_lang_contract.c+++ b/tests/test_lang_contract.c@@ -463,11 +463,10 @@ TEST(contract_python_relative_import) {/* Python: relative aliased from-import must CALLS the real def (execute). */TEST(contract_python_aliased_from_import_calls) {- static const LangFile f[] = {- {"gate.py", "def execute(x):\n return x\n"},- {"router.py",- "from .gate import execute as bridge_execute\n\n\n"- "def submit_task(y):\n return bridge_execute(y)\n"}};+ static const LangFile f[] = {{"gate.py", "def execute(x):\n return x\n"},+ {"router.py",+ "from .gate import execute as bridge_execute\n\n\n"+ "def submit_task(y):\n return bridge_execute(y)\n"}};LangProj lp;cbm_store_t *store = lang_index_files(&lp, f, 2);ASSERT_TRUE(store != NULL);@@ -560,10 +559,8 @@ TEST(contract_python_absolute_aliased_from_import_calls) {/* Python: unresolvable module + alias must emit no CALLS (no invented edge). */TEST(contract_python_ghost_module_aliased_from_import_no_calls) {- static const LangFile f[] = {- {"router.py",- "from ghost_module import nope as alias\n\n\n"- "def submit_task(y):\n return alias(y)\n"}};+ static const LangFile f[] = {{"router.py", "from ghost_module import nope as alias\n\n\n"+ "def submit_task(y):\n return alias(y)\n"}};LangProj lp;cbm_store_t *store = lang_index_files(&lp, f, 1);ASSERT_TRUE(store != NULL);@@ -694,6 +691,57 @@ static void breadth_diag(cbm_store_t *store, const char *project, const char *re}}+/* Chialisp: a constant defined in an included .clib must resolve from the+ * puzzle that includes it.+ *+ * This is the whole reason `Constant` is admitted to the cross-file name+ * registry (cbm_label_is_registry_symbol). Chialisp's condition codes,+ * CREATE_COIN and friends, are `(defconstant ...)` forms in a shared .clib and+ * are referenced by name from every puzzle. Labelled `Constant` but left OUT of+ * the registry, they are seeded nowhere, cbm_registry_resolve returns nothing,+ * and roughly half of a Chialisp graph is unreachable — present as nodes, but+ * never the target of an edge. This test fails (zero cross-file USAGE edges)+ * the moment "Constant" is dropped from that predicate. */+TEST(contract_chialisp_constant_resolves_across_files) {+ static const LangFile f[] = {{"condition_codes.clib", "(\n (defconstant CREATE_COIN 51)\n)\n"},+ {"puzzle.clsp", "(mod (ARG)\n"+ " (include condition_codes.clib)\n"+ " (defun run (amount)\n"+ " (list CREATE_COIN amount))\n"+ ")\n"}};+ LangProj lp;+ cbm_store_t *store = lang_index_files(&lp, f, 2);+ ASSERT_TRUE(store != NULL);++ cbm_node_t *consts = NULL;+ int nconst = 0;+ ASSERT_EQ(cbm_store_find_nodes_by_name(store, lp.project, "CREATE_COIN", &consts, &nconst),+ CBM_STORE_OK);+ ASSERT_TRUE(nconst >= 1);+ ASSERT_TRUE(consts[0].label != NULL && strcmp(consts[0].label, "Constant") == 0);+ ASSERT_TRUE(consts[0].file_path != NULL && strstr(consts[0].file_path, "condition_codes.clib"));++ cbm_edge_t *edges = NULL;+ int nedges = 0;+ ASSERT_EQ(cbm_store_find_edges_by_target_type(store, consts[0].id, "USAGE", &edges, &nedges),+ CBM_STORE_OK);+ int cross_file = 0;+ for (int i = 0; i < nedges; i++) {+ cbm_node_t src;+ if (cbm_store_find_node_by_id(store, edges[i].source_id, &src) != CBM_STORE_OK) {+ continue;+ }+ if (src.file_path && strstr(src.file_path, "puzzle.clsp")) {+ cross_file++;+ }+ }+ cbm_store_free_edges(edges, nedges);+ cbm_store_free_nodes(consts, nconst);+ lang_cleanup(&lp, store);+ ASSERT_TRUE(cross_file >= 1);+ PASS();+}+TEST(contract_all_grammars_in_graph) {int n = (int)CBM_GRAMMAR_CASES_COUNT;if (n > GRAMMAR_BREADTH_MAX) {@@ -859,6 +907,9 @@ static const CallCase CALL_CASES[] = {"fn helper(x: felt252) -> felt252 {\n x + 1\n}\n\nfn run() -> felt252 {\n ""helper(41)\n}\n",true, NULL},+ {"chialisp", "a.clsp",+ "(mod ()\n (defun helper (x)\n (* x 2))\n (defun run ()\n (helper 21))\n)\n", true,+ NULL},{"clojure", "a.clj", "(defn helper [] 42)\n\n(defn run [] (helper))\n", false,"lisp: call is a list_lit whose head is a sym_lit (not a field, not a first-child ""'identifier'); no lisp branch in extract_callee_name"},@@ -1704,10 +1755,11 @@ TEST(contract_edge_parallel_service_edges) {if (store) {sqlite3_stmt *stmt = NULL;sqlite3 *db = cbm_store_get_db(store);- if (db && sqlite3_prepare_v2(db,- "SELECT count(*) FROM edges WHERE properties IS NOT NULL "- "AND properties != '' AND json_valid(properties)=0;",- -1, &stmt, NULL) == SQLITE_OK &&+ if (db &&+ sqlite3_prepare_v2(db,+ "SELECT count(*) FROM edges WHERE properties IS NOT NULL "+ "AND properties != '' AND json_valid(properties)=0;",+ -1, &stmt, NULL) == SQLITE_OK &&sqlite3_step(stmt) == SQLITE_ROW) {invalid_props = sqlite3_column_int(stmt, 0);}@@ -1809,6 +1861,7 @@ SUITE(lang_contract) {RUN_TEST(contract_typescript_relative_import);/* Graph-level breadth across all grammars (P4). */+ RUN_TEST(contract_chialisp_constant_resolves_across_files);RUN_TEST(contract_all_grammars_in_graph);/* CALLS-edge breadth across non-LSP languages (P5). */diff --git a/tests/test_language.c b/tests/test_language.cindex 6914e64f4..2c8d6576b 100644--- a/tests/test_language.c+++ b/tests/test_language.c@@ -748,6 +748,15 @@ TEST(lang_ext_scheme) {PASS();}+TEST(lang_ext_chialisp) {+ ASSERT_EQ(cbm_language_for_extension(".clsp"), CBM_LANG_CHIALISP);+ ASSERT_EQ(cbm_language_for_extension(".clib"), CBM_LANG_CHIALISP);+ ASSERT_EQ(cbm_language_for_extension(".clinc"), CBM_LANG_CHIALISP);+ /* .clj stays Clojure — the Chialisp extensions must not widen it. */+ ASSERT_EQ(cbm_language_for_extension(".clj"), CBM_LANG_CLOJURE);+ PASS();+}+TEST(lang_ext_fennel) {ASSERT_EQ(cbm_language_for_extension(".fnl"), CBM_LANG_FENNEL);PASS();@@ -1338,6 +1347,7 @@ SUITE(language) {RUN_TEST(lang_ext_d);RUN_TEST(lang_ext_nim);RUN_TEST(lang_ext_scheme);+ RUN_TEST(lang_ext_chialisp);RUN_TEST(lang_ext_fennel);RUN_TEST(lang_ext_fish);RUN_TEST(lang_ext_awk);diff --git a/tests/test_language_count_contract.sh b/tests/test_language_count_contract.shindex bf910c771..57d26186c 100644--- a/tests/test_language_count_contract.sh+++ b/tests/test_language_count_contract.sh@@ -63,7 +63,7 @@ EXEMPT=('docs/EVALUATION_PLAN.md' # historical plan, pinned to its authoring date'docs/BENCHMARK.md' # benchmark corpus subsets (63/17 scored)'scripts/clone-bench-repos.sh' # bench repo tiers (44 + 22)- 'tests/repro/repro_invariant_breadth.c' # breadth of one invariant (26/27)+ 'tests/repro/repro_invariant_breadth.c' # breadth of one invariant (27/27)'tests/repro/repro_grammar_scripting.c' # scripting-grammar probe scope (12)'tests/test_grammar_probe_b.c' # grammar probe scope (12)'tests/test_language_count_contract.sh' # this file, which names the numbers abovediff --git a/tools/tree-sitter-chialisp/grammar.js b/tools/tree-sitter-chialisp/grammar.jsnew file mode 100644index 000000000..f736411ff--- /dev/null+++ b/tools/tree-sitter-chialisp/grammar.js@@ -0,0 +1,77 @@+/// <reference types="tree-sitter-cli/dsl" />+// tree-sitter grammar for Chialisp (Chia smart-coin s-expression language).+//+// Copyright (c) DeusData — MIT (the project's own license).+//+// Deliberately GENERIC. Chialisp has no reserved words at the reader level:+// `mod`, `defun`, `defconstant`, `include` and friends are ordinary head+// symbols of ordinary lists, resolved by the compiler, not by the tokenizer.+// Encoding them as grammar rules is how a Chialisp grammar breaks the moment+// the dialect gains a form (cl-21 -> cl-23 -> cl-26 each added several). So we+// model exactly what the clvm_tools reader models: nested s-expressions over+// five atom kinds. Definition/call/import shape is then decided in the+// extractor (internal/cbm/extract_defs.c and friends), where it can be revised+// without regenerating a parser.+//+// Reader model taken from clvm_tools' IR reader:+// - a token ends at whitespace, `(`, `)`, `;` or a quote character;+// - `;` starts a comment that runs to end of line (LF, CRLF or EOF);+// - both `"` and `'` delimit strings;+// - `.` standing alone is the dotted-pair marker, but a `.` INSIDE a token is+// an ordinary character — which is why `(include foo.clib)` must parse.+//+// Atom kinds are ordered hex -> number -> symbol so that the lexer's+// equal-length tiebreak (match specificity, then rule order) prefers the+// specific reading: `0x17` is hex, `-5` is a number, and anything longer than+// either match — `0xdeadZZ`, `123abc` — falls through to `symbol` by longest+// match. Do not add token(prec(...)) here: lexical precedence outranks match+// length in tree-sitter, which would split `123abc` into `123` + `abc`.+module.exports = grammar({+ name: 'chialisp',++ extras: $ => [+ /\s/,+ $.comment,+ ],++ rules: {+ source_file: $ => repeat($._form),++ // `dot` is admitted anywhere a form is, rather than only in the one+ // grammatical dotted-pair slot. clvm_tools' reader is equally permissive,+ // and a stricter rule would turn a hand-written constant table into an+ // ERROR node — a mis-parse we would then have to explain rather than index.+ _form: $ => choice($._sexp, $.dot),++ _sexp: $ => choice(+ $.list,+ $.hex,+ $.number,+ $.string,+ $.symbol,+ ),++ list: $ => seq('(', repeat($._form), ')'),++ // `[^\r\n]*` (not `[^\n]*`) so a CRLF file does not carry the CR inside the+ // comment node; the CR is whitespace and is consumed by `extras`. Runs to+ // EOF when the last line has no terminator.+ comment: _ => token(seq(';', /[^\r\n]*/)),++ hex: _ => /0[xX][0-9a-fA-F]+/,++ // `-?` and not a separate sign token: a bare `-` is the subtraction+ // operator and must stay a `symbol`, which it does because this pattern+ // requires at least one digit.+ number: _ => /-?[0-9]+/,++ string: _ => token(choice(+ seq('"', repeat(choice(/[^"\\]/, /\\./)), '"'),+ seq("'", repeat(choice(/[^'\\]/, /\\./)), "'"),+ )),++ dot: _ => '.',++ symbol: _ => /[^\s()";']+/,+ },+});diff --git a/tools/tree-sitter-chialisp/package.json b/tools/tree-sitter-chialisp/package.jsonnew file mode 100644index 000000000..4ac1a8fae--- /dev/null+++ b/tools/tree-sitter-chialisp/package.json@@ -0,0 +1,21 @@+{+ "name": "tree-sitter-chialisp",+ "version": "0.1.0",+ "description": "Chialisp (Chia smart-coin s-expression language) grammar for tree-sitter",+ "main": "bindings/node",+ "keywords": ["tree-sitter", "chialisp", "chia", "clvm", "lisp"],+ "license": "MIT",+ "dependencies": {+ "nan": "^2.18.0"+ },+ "devDependencies": {+ "tree-sitter-cli": "^0.25.0"+ },+ "tree-sitter": [+ {+ "scope": "source.chialisp",+ "file-types": ["clsp", "clib", "clinc"],+ "highlights": "queries/highlights.scm"+ }+ ]+}diff --git a/tools/tree-sitter-chialisp/src/grammar.json b/tools/tree-sitter-chialisp/src/grammar.jsonnew file mode 100644index 000000000..0b1a7f3a5--- /dev/null+++ b/tools/tree-sitter-chialisp/src/grammar.json@@ -0,0 +1,185 @@+{+ "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",+ "name": "chialisp",+ "rules": {+ "source_file": {+ "type": "REPEAT",+ "content": {+ "type": "SYMBOL",+ "name": "_form"+ }+ },+ "_form": {+ "type": "CHOICE",+ "members": [+ {+ "type": "SYMBOL",+ "name": "_sexp"+ },+ {+ "type": "SYMBOL",+ "name": "dot"+ }+ ]+ },+ "_sexp": {+ "type": "CHOICE",+ "members": [+ {+ "type": "SYMBOL",+ "name": "list"+ },+ {+ "type": "SYMBOL",+ "name": "hex"+ },+ {+ "type": "SYMBOL",+ "name": "number"+ },+ {+ "type": "SYMBOL",+ "name": "string"+ },+ {+ "type": "SYMBOL",+ "name": "symbol"+ }+ ]+ },+ "list": {+ "type": "SEQ",+ "members": [+ {+ "type": "STRING",+ "value": "("+ },+ {+ "type": "REPEAT",+ "content": {+ "type": "SYMBOL",+ "name": "_form"+ }+ },+ {+ "type": "STRING",+ "value": ")"+ }+ ]+ },+ "comment": {+ "type": "TOKEN",+ "content": {+ "type": "SEQ",+ "members": [+ {+ "type": "STRING",+ "value": ";"+ },+ {+ "type": "PATTERN",+ "value": "[^\\r\\n]*"+ }+ ]+ }+ },+ "hex": {+ "type": "PATTERN",+ "value": "0[xX][0-9a-fA-F]+"+ },+ "number": {+ "type": "PATTERN",+ "value": "-?[0-9]+"+ },+ "string": {+ "type": "TOKEN",+ "content": {+ "type": "CHOICE",+ "members": [+ {+ "type": "SEQ",+ "members": [+ {+ "type": "STRING",+ "value": "\""+ },+ {+ "type": "REPEAT",+ "content": {+ "type": "CHOICE",+ "members": [+ {+ "type": "PATTERN",+ "value": "[^\"\\\\]"+ },+ {+ "type": "PATTERN",+ "value": "\\\\."+ }+ ]+ }+ },+ {+ "type": "STRING",+ "value": "\""+ }+ ]+ },+ {+ "type": "SEQ",+ "members": [+ {+ "type": "STRING",+ "value": "'"+ },+ {+ "type": "REPEAT",+ "content": {+ "type": "CHOICE",+ "members": [+ {+ "type": "PATTERN",+ "value": "[^'\\\\]"+ },+ {+ "type": "PATTERN",+ "value": "\\\\."+ }+ ]+ }+ },+ {+ "type": "STRING",+ "value": "'"+ }+ ]+ }+ ]+ }+ },+ "dot": {+ "type": "STRING",+ "value": "."+ },+ "symbol": {+ "type": "PATTERN",+ "value": "[^\\s()\";']+"+ }+ },+ "extras": [+ {+ "type": "PATTERN",+ "value": "\\s"+ },+ {+ "type": "SYMBOL",+ "name": "comment"+ }+ ],+ "conflicts": [],+ "precedences": [],+ "externals": [],+ "inline": [],+ "supertypes": [],+ "reserved": {}+}\ No newline at end of filediff --git a/tools/tree-sitter-chialisp/src/node-types.json b/tools/tree-sitter-chialisp/src/node-types.jsonnew file mode 100644index 000000000..c63cb5367--- /dev/null+++ b/tools/tree-sitter-chialisp/src/node-types.json@@ -0,0 +1,106 @@+[+ {+ "type": "list",+ "named": true,+ "fields": {},+ "children": {+ "multiple": true,+ "required": false,+ "types": [+ {+ "type": "dot",+ "named": true+ },+ {+ "type": "hex",+ "named": true+ },+ {+ "type": "list",+ "named": true+ },+ {+ "type": "number",+ "named": true+ },+ {+ "type": "string",+ "named": true+ },+ {+ "type": "symbol",+ "named": true+ }+ ]+ }+ },+ {+ "type": "source_file",+ "named": true,+ "root": true,+ "fields": {},+ "children": {+ "multiple": true,+ "required": false,+ "types": [+ {+ "type": "dot",+ "named": true+ },+ {+ "type": "hex",+ "named": true+ },+ {+ "type": "list",+ "named": true+ },+ {+ "type": "number",+ "named": true+ },+ {+ "type": "string",+ "named": true+ },+ {+ "type": "symbol",+ "named": true+ }+ ]+ }+ },+ {+ "type": "(",+ "named": false+ },+ {+ "type": ")",+ "named": false+ },+ {+ "type": "comment",+ "named": true,+ "extra": true+ },+ {+ "type": "dot",+ "named": true+ },+ {+ "type": "hex",+ "named": true+ },+ {+ "type": "number",+ "named": true+ },+ {+ "type": "string",+ "named": true+ },+ {+ "type": "symbol",+ "named": true+ }+]\ No newline at end of filediff --git a/tools/tree-sitter-chialisp/src/parser.c b/tools/tree-sitter-chialisp/src/parser.cnew file mode 100644index 000000000..d929151ea--- /dev/null+++ b/tools/tree-sitter-chialisp/src/parser.c@@ -0,0 +1,485 @@+/* Automatically @generated by tree-sitter v0.25.10 */++#include "tree_sitter/parser.h"++#if defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"+#endif++#define LANGUAGE_VERSION 14+#define STATE_COUNT 9+#define LARGE_STATE_COUNT 8+#define SYMBOL_COUNT 14+#define ALIAS_COUNT 0+#define TOKEN_COUNT 9+#define EXTERNAL_TOKEN_COUNT 0+#define FIELD_COUNT 0+#define MAX_ALIAS_SEQUENCE_LENGTH 3+#define MAX_RESERVED_WORD_SET_SIZE 0+#define PRODUCTION_ID_COUNT 1+#define SUPERTYPE_COUNT 0++enum ts_symbol_identifiers {+ anon_sym_LPAREN = 1,+ anon_sym_RPAREN = 2,+ sym_comment = 3,+ sym_hex = 4,+ sym_number = 5,+ sym_string = 6,+ sym_dot = 7,+ sym_symbol = 8,+ sym_source_file = 9,+ sym__form = 10,+ sym__sexp = 11,+ sym_list = 12,+ aux_sym_source_file_repeat1 = 13,+};++static const char * const ts_symbol_names[] = {+ [ts_builtin_sym_end] = "end",+ [anon_sym_LPAREN] = "(",+ [anon_sym_RPAREN] = ")",+ [sym_comment] = "comment",+ [sym_hex] = "hex",+ [sym_number] = "number",+ [sym_string] = "string",+ [sym_dot] = "dot",+ [sym_symbol] = "symbol",+ [sym_source_file] = "source_file",+ [sym__form] = "_form",+ [sym__sexp] = "_sexp",+ [sym_list] = "list",+ [aux_sym_source_file_repeat1] = "source_file_repeat1",+};++static const TSSymbol ts_symbol_map[] = {+ [ts_builtin_sym_end] = ts_builtin_sym_end,+ [anon_sym_LPAREN] = anon_sym_LPAREN,+ [anon_sym_RPAREN] = anon_sym_RPAREN,+ [sym_comment] = sym_comment,+ [sym_hex] = sym_hex,+ [sym_number] = sym_number,+ [sym_string] = sym_string,+ [sym_dot] = sym_dot,+ [sym_symbol] = sym_symbol,+ [sym_source_file] = sym_source_file,+ [sym__form] = sym__form,+ [sym__sexp] = sym__sexp,+ [sym_list] = sym_list,+ [aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1,+};++static const TSSymbolMetadata ts_symbol_metadata[] = {+ [ts_builtin_sym_end] = {+ .visible = false,+ .named = true,+ },+ [anon_sym_LPAREN] = {+ .visible = true,+ .named = false,+ },+ [anon_sym_RPAREN] = {+ .visible = true,+ .named = false,+ },+ [sym_comment] = {+ .visible = true,+ .named = true,+ },+ [sym_hex] = {+ .visible = true,+ .named = true,+ },+ [sym_number] = {+ .visible = true,+ .named = true,+ },+ [sym_string] = {+ .visible = true,+ .named = true,+ },+ [sym_dot] = {+ .visible = true,+ .named = true,+ },+ [sym_symbol] = {+ .visible = true,+ .named = true,+ },+ [sym_source_file] = {+ .visible = true,+ .named = true,+ },+ [sym__form] = {+ .visible = false,+ .named = true,+ },+ [sym__sexp] = {+ .visible = false,+ .named = true,+ },+ [sym_list] = {+ .visible = true,+ .named = true,+ },+ [aux_sym_source_file_repeat1] = {+ .visible = false,+ .named = false,+ },+};++static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {+ [0] = {0},+};++static const uint16_t ts_non_terminal_alias_map[] = {+ 0,+};++static const TSStateId ts_primary_state_ids[STATE_COUNT] = {+ [0] = 0,+ [1] = 1,+ [2] = 2,+ [3] = 3,+ [4] = 4,+ [5] = 5,+ [6] = 6,+ [7] = 7,+ [8] = 8,+};++static bool ts_lex(TSLexer *lexer, TSStateId state) {+ START_LEXER();+ eof = lexer->eof(lexer);+ switch (state) {+ case 0:+ if (eof) ADVANCE(5);+ ADVANCE_MAP(+ '"', 1,+ '\'', 2,+ '(', 6,+ ')', 7,+ '-', 14,+ '.', 13,+ '0', 10,+ ';', 8,+ );+ if (('\t' <= lookahead && lookahead <= '\r') ||+ lookahead == ' ') SKIP(0);+ if (('1' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0) ADVANCE(16);+ END_STATE();+ case 1:+ if (lookahead == '"') ADVANCE(12);+ if (lookahead == '\\') ADVANCE(3);+ if (lookahead != 0) ADVANCE(1);+ END_STATE();+ case 2:+ if (lookahead == '\'') ADVANCE(12);+ if (lookahead == '\\') ADVANCE(4);+ if (lookahead != 0) ADVANCE(2);+ END_STATE();+ case 3:+ if (lookahead != 0 &&+ lookahead != '\n') ADVANCE(1);+ END_STATE();+ case 4:+ if (lookahead != 0 &&+ lookahead != '\n') ADVANCE(2);+ END_STATE();+ case 5:+ ACCEPT_TOKEN(ts_builtin_sym_end);+ END_STATE();+ case 6:+ ACCEPT_TOKEN(anon_sym_LPAREN);+ END_STATE();+ case 7:+ ACCEPT_TOKEN(anon_sym_RPAREN);+ END_STATE();+ case 8:+ ACCEPT_TOKEN(sym_comment);+ if (lookahead != 0 &&+ lookahead != '\n' &&+ lookahead != '\r') ADVANCE(8);+ END_STATE();+ case 9:+ ACCEPT_TOKEN(sym_hex);+ if (('0' <= lookahead && lookahead <= '9') ||+ ('A' <= lookahead && lookahead <= 'F') ||+ ('a' <= lookahead && lookahead <= 'f')) ADVANCE(9);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 10:+ ACCEPT_TOKEN(sym_number);+ if (lookahead == 'X' ||+ lookahead == 'x') ADVANCE(15);+ if (('0' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 11:+ ACCEPT_TOKEN(sym_number);+ if (('0' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 12:+ ACCEPT_TOKEN(sym_string);+ END_STATE();+ case 13:+ ACCEPT_TOKEN(sym_dot);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 14:+ ACCEPT_TOKEN(sym_symbol);+ if (('0' <= lookahead && lookahead <= '9')) ADVANCE(11);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 15:+ ACCEPT_TOKEN(sym_symbol);+ if (('0' <= lookahead && lookahead <= '9') ||+ ('A' <= lookahead && lookahead <= 'F') ||+ ('a' <= lookahead && lookahead <= 'f')) ADVANCE(9);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ case 16:+ ACCEPT_TOKEN(sym_symbol);+ if (lookahead != 0 &&+ (lookahead < '\t' || '\r' < lookahead) &&+ lookahead != ' ' &&+ lookahead != '"' &&+ (lookahead < '\'' || ')' < lookahead) &&+ lookahead != ';') ADVANCE(16);+ END_STATE();+ default:+ return false;+ }+}++static const TSLexMode ts_lex_modes[STATE_COUNT] = {+ [0] = {.lex_state = 0},+ [1] = {.lex_state = 0},+ [2] = {.lex_state = 0},+ [3] = {.lex_state = 0},+ [4] = {.lex_state = 0},+ [5] = {.lex_state = 0},+ [6] = {.lex_state = 0},+ [7] = {.lex_state = 0},+ [8] = {.lex_state = 0},+};++static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {+ [STATE(0)] = {+ [ts_builtin_sym_end] = ACTIONS(1),+ [anon_sym_LPAREN] = ACTIONS(1),+ [anon_sym_RPAREN] = ACTIONS(1),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(1),+ [sym_number] = ACTIONS(1),+ [sym_string] = ACTIONS(1),+ [sym_dot] = ACTIONS(1),+ [sym_symbol] = ACTIONS(1),+ },+ [STATE(1)] = {+ [sym_source_file] = STATE(8),+ [sym__form] = STATE(4),+ [sym__sexp] = STATE(4),+ [sym_list] = STATE(4),+ [aux_sym_source_file_repeat1] = STATE(4),+ [ts_builtin_sym_end] = ACTIONS(5),+ [anon_sym_LPAREN] = ACTIONS(7),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(9),+ [sym_number] = ACTIONS(9),+ [sym_string] = ACTIONS(11),+ [sym_dot] = ACTIONS(9),+ [sym_symbol] = ACTIONS(9),+ },+ [STATE(2)] = {+ [sym__form] = STATE(2),+ [sym__sexp] = STATE(2),+ [sym_list] = STATE(2),+ [aux_sym_source_file_repeat1] = STATE(2),+ [ts_builtin_sym_end] = ACTIONS(13),+ [anon_sym_LPAREN] = ACTIONS(15),+ [anon_sym_RPAREN] = ACTIONS(13),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(18),+ [sym_number] = ACTIONS(18),+ [sym_string] = ACTIONS(21),+ [sym_dot] = ACTIONS(18),+ [sym_symbol] = ACTIONS(18),+ },+ [STATE(3)] = {+ [sym__form] = STATE(5),+ [sym__sexp] = STATE(5),+ [sym_list] = STATE(5),+ [aux_sym_source_file_repeat1] = STATE(5),+ [anon_sym_LPAREN] = ACTIONS(7),+ [anon_sym_RPAREN] = ACTIONS(24),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(26),+ [sym_number] = ACTIONS(26),+ [sym_string] = ACTIONS(28),+ [sym_dot] = ACTIONS(26),+ [sym_symbol] = ACTIONS(26),+ },+ [STATE(4)] = {+ [sym__form] = STATE(2),+ [sym__sexp] = STATE(2),+ [sym_list] = STATE(2),+ [aux_sym_source_file_repeat1] = STATE(2),+ [ts_builtin_sym_end] = ACTIONS(30),+ [anon_sym_LPAREN] = ACTIONS(7),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(32),+ [sym_number] = ACTIONS(32),+ [sym_string] = ACTIONS(34),+ [sym_dot] = ACTIONS(32),+ [sym_symbol] = ACTIONS(32),+ },+ [STATE(5)] = {+ [sym__form] = STATE(2),+ [sym__sexp] = STATE(2),+ [sym_list] = STATE(2),+ [aux_sym_source_file_repeat1] = STATE(2),+ [anon_sym_LPAREN] = ACTIONS(7),+ [anon_sym_RPAREN] = ACTIONS(36),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(32),+ [sym_number] = ACTIONS(32),+ [sym_string] = ACTIONS(34),+ [sym_dot] = ACTIONS(32),+ [sym_symbol] = ACTIONS(32),+ },+ [STATE(6)] = {+ [ts_builtin_sym_end] = ACTIONS(38),+ [anon_sym_LPAREN] = ACTIONS(38),+ [anon_sym_RPAREN] = ACTIONS(38),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(40),+ [sym_number] = ACTIONS(40),+ [sym_string] = ACTIONS(38),+ [sym_dot] = ACTIONS(40),+ [sym_symbol] = ACTIONS(40),+ },+ [STATE(7)] = {+ [ts_builtin_sym_end] = ACTIONS(42),+ [anon_sym_LPAREN] = ACTIONS(42),+ [anon_sym_RPAREN] = ACTIONS(42),+ [sym_comment] = ACTIONS(3),+ [sym_hex] = ACTIONS(44),+ [sym_number] = ACTIONS(44),+ [sym_string] = ACTIONS(42),+ [sym_dot] = ACTIONS(44),+ [sym_symbol] = ACTIONS(44),+ },+};++static const uint16_t ts_small_parse_table[] = {+ [0] = 2,+ ACTIONS(3), 1,+ sym_comment,+ ACTIONS(46), 1,+ ts_builtin_sym_end,+};++static const uint32_t ts_small_parse_table_map[] = {+ [SMALL_STATE(8)] = 0,+};++static const TSParseActionEntry ts_parse_actions[] = {+ [0] = {.entry = {.count = 0, .reusable = false}},+ [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),+ [3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),+ [5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 0, 0, 0),+ [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(3),+ [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(4),+ [11] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),+ [13] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0),+ [15] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(3),+ [18] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(2),+ [21] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2, 0, 0), SHIFT_REPEAT(2),+ [24] = {.entry = {.count = 1, .reusable = true}}, SHIFT(6),+ [26] = {.entry = {.count = 1, .reusable = false}}, SHIFT(5),+ [28] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),+ [30] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1, 0, 0),+ [32] = {.entry = {.count = 1, .reusable = false}}, SHIFT(2),+ [34] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),+ [36] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7),+ [38] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list, 2, 0, 0),+ [40] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_list, 2, 0, 0),+ [42] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_list, 3, 0, 0),+ [44] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_list, 3, 0, 0),+ [46] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),+};++#ifdef __cplusplus+extern "C" {+#endif+#ifdef TREE_SITTER_HIDE_SYMBOLS+#define TS_PUBLIC+#elif defined(_WIN32)+#define TS_PUBLIC __declspec(dllexport)+#else+#define TS_PUBLIC __attribute__((visibility("default")))+#endif++TS_PUBLIC const TSLanguage *tree_sitter_chialisp(void) {+ static const TSLanguage language = {+ .abi_version = LANGUAGE_VERSION,+ .symbol_count = SYMBOL_COUNT,+ .alias_count = ALIAS_COUNT,+ .token_count = TOKEN_COUNT,+ .external_token_count = EXTERNAL_TOKEN_COUNT,+ .state_count = STATE_COUNT,+ .large_state_count = LARGE_STATE_COUNT,+ .production_id_count = PRODUCTION_ID_COUNT,+ .field_count = FIELD_COUNT,+ .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,+ .parse_table = &ts_parse_table[0][0],+ .small_parse_table = ts_small_parse_table,+ .small_parse_table_map = ts_small_parse_table_map,+ .parse_actions = ts_parse_actions,+ .symbol_names = ts_symbol_names,+ .symbol_metadata = ts_symbol_metadata,+ .public_symbol_map = ts_symbol_map,+ .alias_map = ts_non_terminal_alias_map,+ .alias_sequences = &ts_alias_sequences[0][0],+ .lex_modes = (const void*)ts_lex_modes,+ .lex_fn = ts_lex,+ .primary_state_ids = ts_primary_state_ids,+ };+ return &language;+}+#ifdef __cplusplus+}+#endifdiff --git a/tools/tree-sitter-chialisp/src/tree_sitter/alloc.h b/tools/tree-sitter-chialisp/src/tree_sitter/alloc.hnew file mode 100644index 000000000..1abdd1201--- /dev/null+++ b/tools/tree-sitter-chialisp/src/tree_sitter/alloc.h@@ -0,0 +1,54 @@+#ifndef TREE_SITTER_ALLOC_H_+#define TREE_SITTER_ALLOC_H_++#ifdef __cplusplus+extern "C" {+#endif++#include <stdbool.h>+#include <stdio.h>+#include <stdlib.h>++// Allow clients to override allocation functions+#ifdef TREE_SITTER_REUSE_ALLOCATOR++extern void *(*ts_current_malloc)(size_t size);+extern void *(*ts_current_calloc)(size_t count, size_t size);+extern void *(*ts_current_realloc)(void *ptr, size_t size);+extern void (*ts_current_free)(void *ptr);++#ifndef ts_malloc+#define ts_malloc ts_current_malloc+#endif+#ifndef ts_calloc+#define ts_calloc ts_current_calloc+#endif+#ifndef ts_realloc+#define ts_realloc ts_current_realloc+#endif+#ifndef ts_free+#define ts_free ts_current_free+#endif++#else++#ifndef ts_malloc+#define ts_malloc malloc+#endif+#ifndef ts_calloc+#define ts_calloc calloc+#endif+#ifndef ts_realloc+#define ts_realloc realloc+#endif+#ifndef ts_free+#define ts_free free+#endif++#endif++#ifdef __cplusplus+}+#endif++#endif // TREE_SITTER_ALLOC_H_diff --git a/tools/tree-sitter-chialisp/src/tree_sitter/array.h b/tools/tree-sitter-chialisp/src/tree_sitter/array.hnew file mode 100644index 000000000..a17a574f0--- /dev/null+++ b/tools/tree-sitter-chialisp/src/tree_sitter/array.h@@ -0,0 +1,291 @@+#ifndef TREE_SITTER_ARRAY_H_+#define TREE_SITTER_ARRAY_H_++#ifdef __cplusplus+extern "C" {+#endif++#include "./alloc.h"++#include <assert.h>+#include <stdbool.h>+#include <stdint.h>+#include <stdlib.h>+#include <string.h>++#ifdef _MSC_VER+#pragma warning(push)+#pragma warning(disable : 4101)+#elif defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic push+#pragma GCC diagnostic ignored "-Wunused-variable"+#endif++#define Array(T) \+ struct { \+ T *contents; \+ uint32_t size; \+ uint32_t capacity; \+ }++/// Initialize an array.+#define array_init(self) \+ ((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)++/// Create an empty array.+#define array_new() \+ { NULL, 0, 0 }++/// Get a pointer to the element at a given `index` in the array.+#define array_get(self, _index) \+ (assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])++/// Get a pointer to the first element in the array.+#define array_front(self) array_get(self, 0)++/// Get a pointer to the last element in the array.+#define array_back(self) array_get(self, (self)->size - 1)++/// Clear the array, setting its size to zero. Note that this does not free any+/// memory allocated for the array's contents.+#define array_clear(self) ((self)->size = 0)++/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is+/// less than the array's current capacity, this function has no effect.+#define array_reserve(self, new_capacity) \+ _array__reserve((Array *)(self), array_elem_size(self), new_capacity)++/// Free any memory allocated for this array. Note that this does not free any+/// memory allocated for the array's contents.+#define array_delete(self) _array__delete((Array *)(self))++/// Push a new `element` onto the end of the array.+#define array_push(self, element) \+ (_array__grow((Array *)(self), 1, array_elem_size(self)), \+ (self)->contents[(self)->size++] = (element))++/// Increase the array's size by `count` elements.+/// New elements are zero-initialized.+#define array_grow_by(self, count) \+ do { \+ if ((count) == 0) break; \+ _array__grow((Array *)(self), count, array_elem_size(self)); \+ memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \+ (self)->size += (count); \+ } while (0)++/// Append all elements from one array to the end of another.+#define array_push_all(self, other) \+ array_extend((self), (other)->size, (other)->contents)++/// Append `count` elements to the end of the array, reading their values from the+/// `contents` pointer.+#define array_extend(self, count, contents) \+ _array__splice( \+ (Array *)(self), array_elem_size(self), (self)->size, \+ 0, count, contents \+ )++/// Remove `old_count` elements from the array starting at the given `index`. At+/// the same index, insert `new_count` new elements, reading their values from the+/// `new_contents` pointer.+#define array_splice(self, _index, old_count, new_count, new_contents) \+ _array__splice( \+ (Array *)(self), array_elem_size(self), _index, \+ old_count, new_count, new_contents \+ )++/// Insert one `element` into the array at the given `index`.+#define array_insert(self, _index, element) \+ _array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))++/// Remove one element from the array at the given `index`.+#define array_erase(self, _index) \+ _array__erase((Array *)(self), array_elem_size(self), _index)++/// Pop the last element off the array, returning the element by value.+#define array_pop(self) ((self)->contents[--(self)->size])++/// Assign the contents of one array to another, reallocating if necessary.+#define array_assign(self, other) \+ _array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))++/// Swap one array with another+#define array_swap(self, other) \+ _array__swap((Array *)(self), (Array *)(other))++/// Get the size of the array contents+#define array_elem_size(self) (sizeof *(self)->contents)++/// Search a sorted array for a given `needle` value, using the given `compare`+/// callback to determine the order.+///+/// If an existing element is found to be equal to `needle`, then the `index`+/// out-parameter is set to the existing value's index, and the `exists`+/// out-parameter is set to true. Otherwise, `index` is set to an index where+/// `needle` should be inserted in order to preserve the sorting, and `exists`+/// is set to false.+#define array_search_sorted_with(self, compare, needle, _index, _exists) \+ _array__search_sorted(self, 0, compare, , needle, _index, _exists)++/// Search a sorted array for a given `needle` value, using integer comparisons+/// of a given struct field (specified with a leading dot) to determine the order.+///+/// See also `array_search_sorted_with`.+#define array_search_sorted_by(self, field, needle, _index, _exists) \+ _array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)++/// Insert a given `value` into a sorted array, using the given `compare`+/// callback to determine the order.+#define array_insert_sorted_with(self, compare, value) \+ do { \+ unsigned _index, _exists; \+ array_search_sorted_with(self, compare, &(value), &_index, &_exists); \+ if (!_exists) array_insert(self, _index, value); \+ } while (0)++/// Insert a given `value` into a sorted array, using integer comparisons of+/// a given struct field (specified with a leading dot) to determine the order.+///+/// See also `array_search_sorted_by`.+#define array_insert_sorted_by(self, field, value) \+ do { \+ unsigned _index, _exists; \+ array_search_sorted_by(self, field, (value) field, &_index, &_exists); \+ if (!_exists) array_insert(self, _index, value); \+ } while (0)++// Private++typedef Array(void) Array;++/// This is not what you're looking for, see `array_delete`.+static inline void _array__delete(Array *self) {+ if (self->contents) {+ ts_free(self->contents);+ self->contents = NULL;+ self->size = 0;+ self->capacity = 0;+ }+}++/// This is not what you're looking for, see `array_erase`.+static inline void _array__erase(Array *self, size_t element_size,+ uint32_t index) {+ assert(index < self->size);+ char *contents = (char *)self->contents;+ memmove(contents + index * element_size, contents + (index + 1) * element_size,+ (self->size - index - 1) * element_size);+ self->size--;+}++/// This is not what you're looking for, see `array_reserve`.+static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {+ if (new_capacity > self->capacity) {+ if (self->contents) {+ self->contents = ts_realloc(self->contents, new_capacity * element_size);+ } else {+ self->contents = ts_malloc(new_capacity * element_size);+ }+ self->capacity = new_capacity;+ }+}++/// This is not what you're looking for, see `array_assign`.+static inline void _array__assign(Array *self, const Array *other, size_t element_size) {+ _array__reserve(self, element_size, other->size);+ self->size = other->size;+ memcpy(self->contents, other->contents, self->size * element_size);+}++/// This is not what you're looking for, see `array_swap`.+static inline void _array__swap(Array *self, Array *other) {+ Array swap = *other;+ *other = *self;+ *self = swap;+}++/// This is not what you're looking for, see `array_push` or `array_grow_by`.+static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {+ uint32_t new_size = self->size + count;+ if (new_size > self->capacity) {+ uint32_t new_capacity = self->capacity * 2;+ if (new_capacity < 8) new_capacity = 8;+ if (new_capacity < new_size) new_capacity = new_size;+ _array__reserve(self, element_size, new_capacity);+ }+}++/// This is not what you're looking for, see `array_splice`.+static inline void _array__splice(Array *self, size_t element_size,+ uint32_t index, uint32_t old_count,+ uint32_t new_count, const void *elements) {+ uint32_t new_size = self->size + new_count - old_count;+ uint32_t old_end = index + old_count;+ uint32_t new_end = index + new_count;+ assert(old_end <= self->size);++ _array__reserve(self, element_size, new_size);++ char *contents = (char *)self->contents;+ if (self->size > old_end) {+ memmove(+ contents + new_end * element_size,+ contents + old_end * element_size,+ (self->size - old_end) * element_size+ );+ }+ if (new_count > 0) {+ if (elements) {+ memcpy(+ (contents + index * element_size),+ elements,+ new_count * element_size+ );+ } else {+ memset(+ (contents + index * element_size),+ 0,+ new_count * element_size+ );+ }+ }+ self->size += new_count - old_count;+}++/// A binary search routine, based on Rust's `std::slice::binary_search_by`.+/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.+#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \+ do { \+ *(_index) = start; \+ *(_exists) = false; \+ uint32_t size = (self)->size - *(_index); \+ if (size == 0) break; \+ int comparison; \+ while (size > 1) { \+ uint32_t half_size = size / 2; \+ uint32_t mid_index = *(_index) + half_size; \+ comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \+ if (comparison <= 0) *(_index) = mid_index; \+ size -= half_size; \+ } \+ comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \+ if (comparison == 0) *(_exists) = true; \+ else if (comparison < 0) *(_index) += 1; \+ } while (0)++/// Helper macro for the `_sorted_by` routines below. This takes the left (existing)+/// parameter by reference in order to work with the generic sorting function above.+#define _compare_int(a, b) ((int)*(a) - (int)(b))++#ifdef _MSC_VER+#pragma warning(pop)+#elif defined(__GNUC__) || defined(__clang__)+#pragma GCC diagnostic pop+#endif++#ifdef __cplusplus+}+#endif++#endif // TREE_SITTER_ARRAY_H_diff --git a/tools/tree-sitter-chialisp/src/tree_sitter/parser.h b/tools/tree-sitter-chialisp/src/tree_sitter/parser.hnew file mode 100644index 000000000..858107deb--- /dev/null+++ b/tools/tree-sitter-chialisp/src/tree_sitter/parser.h@@ -0,0 +1,286 @@+#ifndef TREE_SITTER_PARSER_H_+#define TREE_SITTER_PARSER_H_++#ifdef __cplusplus+extern "C" {+#endif++#include <stdbool.h>+#include <stdint.h>+#include <stdlib.h>++#define ts_builtin_sym_error ((TSSymbol)-1)+#define ts_builtin_sym_end 0+#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024++#ifndef TREE_SITTER_API_H_+typedef uint16_t TSStateId;+typedef uint16_t TSSymbol;+typedef uint16_t TSFieldId;+typedef struct TSLanguage TSLanguage;+typedef struct TSLanguageMetadata {+ uint8_t major_version;+ uint8_t minor_version;+ uint8_t patch_version;+} TSLanguageMetadata;+#endif++typedef struct {+ TSFieldId field_id;+ uint8_t child_index;+ bool inherited;+} TSFieldMapEntry;++// Used to index the field and supertype maps.+typedef struct {+ uint16_t index;+ uint16_t length;+} TSMapSlice;++typedef struct {+ bool visible;+ bool named;+ bool supertype;+} TSSymbolMetadata;++typedef struct TSLexer TSLexer;++struct TSLexer {+ int32_t lookahead;+ TSSymbol result_symbol;+ void (*advance)(TSLexer *, bool);+ void (*mark_end)(TSLexer *);+ uint32_t (*get_column)(TSLexer *);+ bool (*is_at_included_range_start)(const TSLexer *);+ bool (*eof)(const TSLexer *);+ void (*log)(const TSLexer *, const char *, ...);+};++typedef enum {+ TSParseActionTypeShift,+ TSParseActionTypeReduce,+ TSParseActionTypeAccept,+ TSParseActionTypeRecover,+} TSParseActionType;++typedef union {+ struct {+ uint8_t type;+ TSStateId state;+ bool extra;+ bool repetition;+ } shift;+ struct {+ uint8_t type;+ uint8_t child_count;+ TSSymbol symbol;+ int16_t dynamic_precedence;+ uint16_t production_id;+ } reduce;+ uint8_t type;+} TSParseAction;++typedef struct {+ uint16_t lex_state;+ uint16_t external_lex_state;+} TSLexMode;++typedef struct {+ uint16_t lex_state;+ uint16_t external_lex_state;+ uint16_t reserved_word_set_id;+} TSLexerMode;++typedef union {+ TSParseAction action;+ struct {+ uint8_t count;+ bool reusable;+ } entry;+} TSParseActionEntry;++typedef struct {+ int32_t start;+ int32_t end;+} TSCharacterRange;++struct TSLanguage {+ uint32_t abi_version;+ uint32_t symbol_count;+ uint32_t alias_count;+ uint32_t token_count;+ uint32_t external_token_count;+ uint32_t state_count;+ uint32_t large_state_count;+ uint32_t production_id_count;+ uint32_t field_count;+ uint16_t max_alias_sequence_length;+ const uint16_t *parse_table;+ const uint16_t *small_parse_table;+ const uint32_t *small_parse_table_map;+ const TSParseActionEntry *parse_actions;+ const char * const *symbol_names;+ const char * const *field_names;+ const TSMapSlice *field_map_slices;+ const TSFieldMapEntry *field_map_entries;+ const TSSymbolMetadata *symbol_metadata;+ const TSSymbol *public_symbol_map;+ const uint16_t *alias_map;+ const TSSymbol *alias_sequences;+ const TSLexerMode *lex_modes;+ bool (*lex_fn)(TSLexer *, TSStateId);+ bool (*keyword_lex_fn)(TSLexer *, TSStateId);+ TSSymbol keyword_capture_token;+ struct {+ const bool *states;+ const TSSymbol *symbol_map;+ void *(*create)(void);+ void (*destroy)(void *);+ bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);+ unsigned (*serialize)(void *, char *);+ void (*deserialize)(void *, const char *, unsigned);+ } external_scanner;+ const TSStateId *primary_state_ids;+ const char *name;+ const TSSymbol *reserved_words;+ uint16_t max_reserved_word_set_size;+ uint32_t supertype_count;+ const TSSymbol *supertype_symbols;+ const TSMapSlice *supertype_map_slices;+ const TSSymbol *supertype_map_entries;+ TSLanguageMetadata metadata;+};++static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {+ uint32_t index = 0;+ uint32_t size = len - index;+ while (size > 1) {+ uint32_t half_size = size / 2;+ uint32_t mid_index = index + half_size;+ const TSCharacterRange *range = &ranges[mid_index];+ if (lookahead >= range->start && lookahead <= range->end) {+ return true;+ } else if (lookahead > range->end) {+ index = mid_index;+ }+ size -= half_size;+ }+ const TSCharacterRange *range = &ranges[index];+ return (lookahead >= range->start && lookahead <= range->end);+}++/*+ * Lexer Macros+ */++#ifdef _MSC_VER+#define UNUSED __pragma(warning(suppress : 4101))+#else+#define UNUSED __attribute__((unused))+#endif++#define START_LEXER() \+ bool result = false; \+ bool skip = false; \+ UNUSED \+ bool eof = false; \+ int32_t lookahead; \+ goto start; \+ next_state: \+ lexer->advance(lexer, skip); \+ start: \+ skip = false; \+ lookahead = lexer->lookahead;++#define ADVANCE(state_value) \+ { \+ state = state_value; \+ goto next_state; \+ }++#define ADVANCE_MAP(...) \+ { \+ static const uint16_t map[] = { __VA_ARGS__ }; \+ for (uint32_t i = 0; i < sizeof(map) / sizeof(map[0]); i += 2) { \+ if (map[i] == lookahead) { \+ state = map[i + 1]; \+ goto next_state; \+ } \+ } \+ }++#define SKIP(state_value) \+ { \+ skip = true; \+ state = state_value; \+ goto next_state; \+ }++#define ACCEPT_TOKEN(symbol_value) \+ result = true; \+ lexer->result_symbol = symbol_value; \+ lexer->mark_end(lexer);++#define END_STATE() return result;++/*+ * Parse Table Macros+ */++#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)++#define STATE(id) id++#define ACTIONS(id) id++#define SHIFT(state_value) \+ {{ \+ .shift = { \+ .type = TSParseActionTypeShift, \+ .state = (state_value) \+ } \+ }}++#define SHIFT_REPEAT(state_value) \+ {{ \+ .shift = { \+ .type = TSParseActionTypeShift, \+ .state = (state_value), \+ .repetition = true \+ } \+ }}++#define SHIFT_EXTRA() \+ {{ \+ .shift = { \+ .type = TSParseActionTypeShift, \+ .extra = true \+ } \+ }}++#define REDUCE(symbol_name, children, precedence, prod_id) \+ {{ \+ .reduce = { \+ .type = TSParseActionTypeReduce, \+ .symbol = symbol_name, \+ .child_count = children, \+ .dynamic_precedence = precedence, \+ .production_id = prod_id \+ }, \+ }}++#define RECOVER() \+ {{ \+ .type = TSParseActionTypeRecover \+ }}++#define ACCEPT_INPUT() \+ {{ \+ .type = TSParseActionTypeAccept \+ }}++#ifdef __cplusplus+}+#endif++#endif // TREE_SITTER_PARSER_H_diff --git a/tools/tree-sitter-chialisp/test/corpus/atoms.txt b/tools/tree-sitter-chialisp/test/corpus/atoms.txtnew file mode 100644index 000000000..06ee243b6--- /dev/null+++ b/tools/tree-sitter-chialisp/test/corpus/atoms.txt@@ -0,0 +1,119 @@+================================================================================+Hex literals, integers and negative numbers+================================================================================++(0x17 0x0a1B2c 12345 -42 0)++--------------------------------------------------------------------------------++(source_file+ (list+ (hex)+ (hex)+ (number)+ (number)+ (number)))++================================================================================+Strings with escapes, both quote characters+================================================================================++("plain" "a\"b" 'single' "back\\slash")++--------------------------------------------------------------------------------++(source_file+ (list+ (string)+ (string)+ (string)+ (string)))++================================================================================+Dot in dotted-pair position+================================================================================++(defun curry_hashes (mod_hash . curry_parameter_hashes)+ (q . (x))+)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (symbol)+ (list+ (symbol)+ (dot)+ (symbol))+ (list+ (symbol)+ (dot)+ (list+ (symbol)))))++================================================================================+Bare minus is a symbol, not a number+================================================================================++(- (lsh 1 128) 1)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (list+ (symbol)+ (number)+ (number))+ (number)))++================================================================================+Longest match wins over the specific atom kinds+================================================================================++(0xdeadZZ 123abc foo.clib @ #q .5)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (symbol)+ (symbol)+ (symbol)+ (symbol)+ (symbol)))++================================================================================+Constant table of hex pairs with interleaved comments+================================================================================++(defconstant constant_tree (+ (0x4b . ; = `(sha256 1)`+ 0x9d) . ; = `(sha256 1 1)`+ (0x02 .+ 0xa8)+ )+)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (symbol)+ (list+ (list+ (hex)+ (dot)+ (comment)+ (hex))+ (dot)+ (comment)+ (list+ (hex)+ (dot)+ (hex)))))diff --git a/tools/tree-sitter-chialisp/test/corpus/comments.txt b/tools/tree-sitter-chialisp/test/corpus/comments.txtnew file mode 100644index 000000000..0c0a173ed--- /dev/null+++ b/tools/tree-sitter-chialisp/test/corpus/comments.txt@@ -0,0 +1,83 @@+================================================================================+Comment with LF line endings+================================================================================++(mod (A)+ ; a comment+ (f A)+)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (list+ (symbol))+ (comment)+ (list+ (symbol)+ (symbol))))++================================================================================+Comment with CRLF line endings+================================================================================++(mod (A)+ ; a comment+ (f A)+)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (list+ (symbol))+ (comment)+ (list+ (symbol)+ (symbol))))++================================================================================+Comment terminated by EOF with no trailing newline+================================================================================++(mod (A) (f A))+; trailing comment at EOF+--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (list+ (symbol))+ (list+ (symbol)+ (symbol)))+ (comment))++================================================================================+Double-semicolon doc comments between definitions+================================================================================++(+ ;; the tree hash of a curried function+ (defun-inline sha256_one _noargs (f (f constant_tree)))+)++--------------------------------------------------------------------------------++(source_file+ (list+ (comment)+ (list+ (symbol)+ (symbol)+ (symbol)+ (list+ (symbol)+ (list+ (symbol)+ (symbol))))))diff --git a/tools/tree-sitter-chialisp/test/corpus/forms.txt b/tools/tree-sitter-chialisp/test/corpus/forms.txtnew file mode 100644index 000000000..d79a92e5d--- /dev/null+++ b/tools/tree-sitter-chialisp/test/corpus/forms.txt@@ -0,0 +1,136 @@+================================================================================+Include with a dotted filename+================================================================================++(include condition_codes.clib)+(include curry-and-treehash.clinc)+(include *standard-cl-26*)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (symbol))+ (list+ (symbol)+ (symbol))+ (list+ (symbol)+ (symbol)))++================================================================================+defconstant bound to an arbitrary expression+================================================================================++(defconstant HASH (sha256 1))+(defconstant TWO 2)+(defconst MAX 1000)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (symbol)+ (list+ (symbol)+ (number)))+ (list+ (symbol)+ (symbol)+ (number))+ (list+ (symbol)+ (symbol)+ (number)))++================================================================================+Nested mod / defun / defun-inline / defmacro / defmac / let / assign+================================================================================++(mod (ARG)+ (defun-inline sq (x) (* x x))+ (defmacro assert items (f items))+ (defmac and ARGS 1)+ (defun outer (y) (let ((a 1)) (+ a y)))+ (defun outer2 (y) (assign z (* y 2) (+ z 1)))+ (sq ARG)+)++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (list+ (symbol))+ (list+ (symbol)+ (symbol)+ (list+ (symbol))+ (list+ (symbol)+ (symbol)+ (symbol)))+ (list+ (symbol)+ (symbol)+ (symbol)+ (list+ (symbol)+ (symbol)))+ (list+ (symbol)+ (symbol)+ (symbol)+ (number))+ (list+ (symbol)+ (symbol)+ (list+ (symbol))+ (list+ (symbol)+ (list+ (list+ (symbol)+ (number)))+ (list+ (symbol)+ (symbol)+ (symbol))))+ (list+ (symbol)+ (symbol)+ (list+ (symbol))+ (list+ (symbol)+ (symbol)+ (list+ (symbol)+ (symbol)+ (number))+ (list+ (symbol)+ (symbol)+ (number))))+ (list+ (symbol)+ (symbol))))++================================================================================+Empty list and empty file body+================================================================================++(mod () ())++--------------------------------------------------------------------------------++(source_file+ (list+ (symbol)+ (list)+ (list)))diff --git a/tools/tree-sitter-chialisp/tree-sitter.json b/tools/tree-sitter-chialisp/tree-sitter.jsonnew file mode 100644index 000000000..e6841d702--- /dev/null+++ b/tools/tree-sitter-chialisp/tree-sitter.json@@ -0,0 +1,16 @@+{+ "grammars": [+ {+ "name": "chialisp",+ "camelcase": "Chialisp",+ "scope": "source.chialisp",+ "path": ".",+ "file-types": ["clsp", "clib", "clinc"]+ }+ ],+ "metadata": {+ "version": "0.1.0",+ "license": "MIT",+ "description": "Chialisp (Chia smart-coin s-expression language) grammar for tree-sitter"+ }+}