tree-sitter-delphi13 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alexander Liberov
4
+
5
+ Portions derived from tree-sitter-pascal:
6
+ Copyright (c) Philip Zander
7
+ Copyright (c) Benjamin Gray (Isopod)
8
+ https://github.com/Isopod/tree-sitter-pascal
9
+ (also MIT licensed)
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # tree-sitter-delphi13
2
+
3
+ Tree-sitter grammar focused on **Delphi 13 (RAD Studio 37.0)** — what the
4
+ modern Delphi compiler accepts, nothing more.
5
+
6
+ ## Why a fresh project?
7
+
8
+ This is a focused derivation of [Isopod/tree-sitter-pascal][upstream]
9
+ (MIT licensed; see [LICENSE](LICENSE)). The differences in design intent:
10
+
11
+ | | tree-sitter-pascal (upstream) | tree-sitter-delphi13 (this) |
12
+ |---|---|---|
13
+ | Target | Pascal family (Delphi, FreePascal, FPC variants) | Delphi 13 only |
14
+ | Grammar surface | Many `enable_if(fpc, ...)` branches | Single Delphi-13 surface |
15
+ | Inline asm | Parsed structurally | Treated as opaque (comment-like) |
16
+ | Preprocessor blocks | Token-level `{$IFDEF}` | External scanner consumes whole `{$IF*}...{$END*}` blocks |
17
+ | Non-Pascal corpus files | Counted as failures | Filtered by harness (binary DFM, JCL templates, JEDI interpreter fragments, etc.) |
18
+ | Companion | — | Pairs with separate `tree-sitter-dfm` for form files |
19
+
20
+ ## Status
21
+
22
+ | Component | State |
23
+ |-----------|-------|
24
+ | Grammar | Delphi-13-focused, all proven fixes from upstream forked in |
25
+ | External scanner | (planned — IFDEF blocks + `^X` char literal disambiguation) |
26
+ | Preprocessor | (planned as separate `delphi13-preprocessor` library, for `{$I X.inc}` expansion) |
27
+ | Harness | Day-1 filtering for non-Delphi files |
28
+ | Corpus | Curated Delphi-13 only (modern projects + RAD Studio 13 RTL/VCL) |
29
+
30
+ ## Build
31
+
32
+ ```powershell
33
+ npm install --ignore-scripts
34
+ .\node_modules\.bin\tree-sitter generate
35
+ node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild
36
+ ```
37
+
38
+ ## Run baseline
39
+
40
+ ```powershell
41
+ pwsh -File tools\run-baseline.ps1
42
+ ```
43
+
44
+ ## Credits
45
+
46
+ - [Philip Zander][isopod-author] — original tree-sitter-pascal grammar
47
+ - [Benjamin Gray (Isopod)][upstream] — current maintainer
48
+
49
+ [upstream]: https://github.com/Isopod/tree-sitter-pascal
50
+ [isopod-author]: https://github.com/PhilipRoman
package/binding.gyp ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "tree_sitter_delphi13_binding",
5
+ "dependencies": [
6
+ "<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
7
+ ],
8
+ "include_dirs": [
9
+ "src",
10
+ ],
11
+ "sources": [
12
+ "bindings/node/binding.cc",
13
+ "src/parser.c",
14
+ "src/scanner.c",
15
+ ],
16
+ "cflags_c": [
17
+ "-std=c11",
18
+ ],
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,19 @@
1
+ #include <napi.h>
2
+
3
+ typedef struct TSLanguage TSLanguage;
4
+
5
+ extern "C" TSLanguage *tree_sitter_delphi13();
6
+
7
+ const napi_type_tag LANGUAGE_TYPE_TAG = {
8
+ 0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
9
+ };
10
+
11
+ Napi::Object Init(Napi::Env env, Napi::Object exports) {
12
+ exports["name"] = Napi::String::New(env, "delphi13");
13
+ auto language = Napi::External<TSLanguage>::New(env, tree_sitter_delphi13());
14
+ language.TypeTag(&LANGUAGE_TYPE_TAG);
15
+ exports["language"] = language;
16
+ return exports;
17
+ }
18
+
19
+ NODE_API_MODULE(tree_sitter_delphi13_binding, Init)
@@ -0,0 +1,9 @@
1
+ const assert = require("node:assert");
2
+ const { test } = require("node:test");
3
+
4
+ const Parser = require("tree-sitter");
5
+
6
+ test("can load grammar", () => {
7
+ const parser = new Parser();
8
+ assert.doesNotThrow(() => parser.setLanguage(require(".")));
9
+ });
@@ -0,0 +1,28 @@
1
+ type BaseNode = {
2
+ type: string;
3
+ named: boolean;
4
+ };
5
+
6
+ type ChildNode = {
7
+ multiple: boolean;
8
+ required: boolean;
9
+ types: BaseNode[];
10
+ };
11
+
12
+ type NodeInfo =
13
+ | (BaseNode & {
14
+ subtypes: BaseNode[];
15
+ })
16
+ | (BaseNode & {
17
+ fields: { [name: string]: ChildNode };
18
+ children: ChildNode[];
19
+ });
20
+
21
+ type Language = {
22
+ name: string;
23
+ language: unknown;
24
+ nodeTypeInfo: NodeInfo[];
25
+ };
26
+
27
+ declare const language: Language;
28
+ export = language;
@@ -0,0 +1,7 @@
1
+ const root = require("path").join(__dirname, "..", "..");
2
+
3
+ module.exports = require("node-gyp-build")(root);
4
+
5
+ try {
6
+ module.exports.nodeTypeInfo = require("../../src/node-types.json");
7
+ } catch (_) {}