tree-sitter-delphi13-pure 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/README.md +38 -0
- package/binding.gyp +21 -0
- package/bindings/node/binding.cc +19 -0
- package/bindings/node/index.js +7 -0
- package/grammar.js +1897 -0
- package/package.json +53 -0
- package/src/grammar.json +11901 -0
- package/src/node-types.json +10551 -0
- package/src/parser.c +474988 -0
- package/src/scanner.c +112 -0
- package/src/tree_sitter/alloc.h +54 -0
- package/src/tree_sitter/array.h +291 -0
- package/src/tree_sitter/parser.h +266 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# tree-sitter-delphi13-pure
|
|
2
|
+
|
|
3
|
+
Sub-tree-sitter that parses **pure Delphi only** — no IFDEF awareness.
|
|
4
|
+
|
|
5
|
+
Designed to be fed the virtual text output of `../preprocessor/cli.js` (or any
|
|
6
|
+
equivalent preprocessor). All `{$IF*}` / `{$IFDEF}` / `{$ELSE}` / `{$ENDIF}` /
|
|
7
|
+
`{$I}` directives are expected to have been resolved upstream into plain
|
|
8
|
+
Pascal source.
|
|
9
|
+
|
|
10
|
+
## Differences vs the parent `tree-sitter-delphi13` grammar
|
|
11
|
+
|
|
12
|
+
| Aspect | Parent (master) | Pure |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `pp_block` external token | Yes | **Dropped** |
|
|
15
|
+
| `pp_open` / `pp_else_tail` / `pp_end_only` externals | Yes | **Dropped** |
|
|
16
|
+
| `pp_block` in `type` choice | Yes | **Dropped** |
|
|
17
|
+
| `pp_block` in `declUses` / `declRequires` | Yes | **Dropped** |
|
|
18
|
+
| `pp_block` in `declFieldNoSemi` type set | Yes | **Dropped** |
|
|
19
|
+
| THEN-wins scanner logic | Yes | **Dropped** (much smaller scanner) |
|
|
20
|
+
| `pp` regex (single-line `{$X}`) | In extras | In extras (kept — for harmless directives like `{$EXTERNALSYM}` that don't affect structure) |
|
|
21
|
+
|
|
22
|
+
## Status
|
|
23
|
+
|
|
24
|
+
Phase 2 scaffold landed (grammar.js stripped of IFDEF-related tokens and
|
|
25
|
+
rules). Next steps:
|
|
26
|
+
1. Strip THEN-wins scanner code from `scanner.c`.
|
|
27
|
+
2. Set up `binding.gyp` / `package.json` for an independent native binding.
|
|
28
|
+
3. Wire the orchestrator: `preprocessor -> pure parse -> source-map rewrite`.
|
|
29
|
+
4. Run the orchestrator on the curated corpus and measure.
|
|
30
|
+
|
|
31
|
+
## Why split?
|
|
32
|
+
|
|
33
|
+
The parent grammar's `pp_block` machinery and the iter-37+ `declFieldNoSemi`
|
|
34
|
+
conflict-cascade family fundamentally limit grammar evolution. Carving out a
|
|
35
|
+
pure variant removes ~150-200 lines of pp_*-handling, eliminates 4 conflict
|
|
36
|
+
declarations that were paid taxes on every state, and lets us iterate the
|
|
37
|
+
core grammar without GLR-cascade risk from IFDEF tokens that the preprocessor
|
|
38
|
+
has already resolved.
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tree_sitter_delphi13_pure_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_pure();
|
|
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_pure");
|
|
13
|
+
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_delphi13_pure());
|
|
14
|
+
language.TypeTag(&LANGUAGE_TYPE_TAG);
|
|
15
|
+
exports["language"] = language;
|
|
16
|
+
return exports;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
NODE_API_MODULE(tree_sitter_delphi13_pure_binding, Init)
|