tree-sitter-lmcode reference
Reference tables for tree-sitter-lmcode AST node types, external scanner tokens, verification scripts, and exit codes.
AST node and grammar surface
| Node / Artifact | Kind | Description |
|---|---|---|
| function_declaration | Named AST node | Fields: name, parameters, return_type, body; optional annotation and implements_clause children |
| annotation | Named AST node | Leading @identifier or @"path/template" attached to a function_declaration |
| implements_clause | Named AST node | Trailing implements InterfaceName clause on a rule or REST/CLI entry |
| return_assignment | Named AST node | Assignment statement targeting $return, $return.field, or $return[key_expr] |
| map_entry | Named AST node | Key-value pair separated by => inside %{ ... } map literals |
| splice | Named AST node | Outer-language ${...} splice expression parsed with nested brace and string tracking |
| heredoc_start / heredoc_body | AST node + extra | Expression-position heredoc tag and FIFO-paired raw body token |
| end_of_file | Scanner sentinel | Zero-width EOF check ensuring unclosed queued heredocs fail closed |
Standard REST and CLI interfaces recognized by the grammar
| Interface | Canonical declaration | Behavior |
|---|---|---|
| RestGet | interface RestGet(exchange: RestExchange) -> void | HTTP GET endpoint bound by path annotation such as @"/users/:id" |
| RestPost | interface RestPost(exchange: RestExchange) -> void | HTTP POST endpoint bound by path annotation such as @"/users" |
| RestPut | interface RestPut(exchange: RestExchange) -> void | HTTP PUT endpoint bound by path annotation such as @"/users/:id" |
| RestDelete | interface RestDelete(exchange: RestExchange) -> void | HTTP DELETE endpoint bound by path annotation such as @"/users/:id" |
| RestPatch | interface RestPatch(exchange: RestExchange) -> void | HTTP PATCH endpoint bound by path annotation such as @"/users/:id" |
| RestHead | interface RestHead(exchange: RestExchange) -> void | HTTP HEAD endpoint bound by path annotation |
| RestOptions | interface RestOptions(exchange: RestExchange) -> void | HTTP OPTIONS endpoint bound by path annotation |
| RestHandler | interface RestHandler(exchange: RestExchange) -> void | Method-prefixed (@"POST /users") or rest_route(method, path, annotation) handler |
| CliCommand | interface CliCommand(exchange: RestExchange) -> void | Stateless CLI subcommand entry dispatched by rest_cli(args) |
| CliOption | interface CliOption(exchange: RestExchange) -> void | Stateless CLI flag or option entry dispatched before CliCommand by rest_cli(args) |
Verification exit statuses
| Exit code | Stage | Result | Condition |
|---|---|---|---|
| 0 | parse / test | Exit 0 | All grammar generation, corpus cases, negative syntax-refusal checks, incremental edit gates, and mutation controls pass |
| 1 | conformance | Exit 1 | A corpus fixture produces unexpected ERROR or MISSING nodes, or a negative refusal fixture parses without syntax errors |
| 1 | freshness | Exit 1 | Generated src/parser.c, grammar.json, or node-types.json differs from grammar.js after tree-sitter generate |
| 2 | cli / pin | Exit 2 | Missing TREE_SITTER CLI binary, mismatched tree-sitter-cli version (requires 0.27.1), or missing live corpus root |