tree-sitter-delphi13-pure 1.4.2 → 1.4.4
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/grammar.js +37 -16
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/tree-sitter-delphi13-pure.node +0 -0
- package/prebuilds/darwin-x64/tree-sitter-delphi13-pure.node +0 -0
- package/prebuilds/linux-x64/tree-sitter-delphi13-pure.node +0 -0
- package/prebuilds/win32-x64/tree-sitter-delphi13-pure.node +0 -0
- package/src/grammar.json +308 -269
- package/src/node-types.json +10761 -10761
- package/src/parser.c +411215 -363637
- package/tree-sitter-delphi13_pure.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -123,12 +123,14 @@ function statements(trailing) {
|
|
|
123
123
|
|
|
124
124
|
[rn('nestedIf'), $ => prec(1,$.if)],
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
// Dynamic precedence +1, as exprIf's is -1: where both read the same
|
|
127
|
+
// text, the statement wins (see exprIf).
|
|
128
|
+
[rn('ifElse'), $ => prec.dynamic(1, prec.right(1, seq(
|
|
127
129
|
$.kIf, field('condition', $._expr), $.kThen,
|
|
128
130
|
field('then', optional(choice(tr($,'_statement'), $.if))),
|
|
129
131
|
$.kElse,
|
|
130
132
|
field('else', lastStatement($))
|
|
131
|
-
))],
|
|
133
|
+
)))],
|
|
132
134
|
|
|
133
135
|
[rn('while'), $ => seq(
|
|
134
136
|
$.kWhile, field('condition', $._expr), $.kDo,
|
|
@@ -442,6 +444,9 @@ module.exports = grammar({
|
|
|
442
444
|
[$._declProc ], [ $._declOperator], [$.declConst], [$.declVar],
|
|
443
445
|
[$.declType], [$.declProp]
|
|
444
446
|
),
|
|
447
|
+
// `external L name 'x'` without `;` before `[`: an attribute on the next
|
|
448
|
+
// declaration, or an index on the string. One token too few; GLR decides.
|
|
449
|
+
[$._literal, $.procExternal],
|
|
445
450
|
// RTTI attributes clash with fpc declaration hints syntax since both
|
|
446
451
|
// are surrounded by brackets.
|
|
447
452
|
...enable_if(rtti,
|
|
@@ -665,11 +670,17 @@ module.exports = grammar({
|
|
|
665
670
|
// the if-then-else STATEMENT (rn('ifElse')) — this one returns a value.
|
|
666
671
|
// Right-associative + lower precedence than binary operators so that
|
|
667
672
|
// `a + if c then x else y` groups as `a + (if c then x else y)`.
|
|
668
|
-
|
|
673
|
+
// Dynamic precedence -1: where an if STATEMENT reads the same text, it
|
|
674
|
+
// wins. Both branches may pass for expressions, as in `if Q then Foo
|
|
675
|
+
// else raise;` (a bare `raise` an identifier) or `if Q then Foo else
|
|
676
|
+
// N := 1;` (the whole if an assignment's target); dcc reads both as
|
|
677
|
+
// statements. Only an expression fits on the right of `:=` or in an
|
|
678
|
+
// argument, so those are unchanged.
|
|
679
|
+
exprIf: $ => prec.dynamic(-1, prec.right(0, seq(
|
|
669
680
|
$.kIf, field('condition', $._expr),
|
|
670
681
|
$.kThen, field('then', $._expr),
|
|
671
682
|
$.kElse, field('else', $._expr),
|
|
672
|
-
)),
|
|
683
|
+
))),
|
|
673
684
|
|
|
674
685
|
_ref: $ => choice(
|
|
675
686
|
...enable_if(templates && fpc,
|
|
@@ -1867,21 +1878,31 @@ module.exports = grammar({
|
|
|
1867
1878
|
'[', optional(seq($.identifier, ':')), delimited($._ref), ']'
|
|
1868
1879
|
)),
|
|
1869
1880
|
|
|
1881
|
+
// The closing `;` may be omitted after `name '<string>'`: dcc accepts it and Borland
|
|
1882
|
+
// shipped it (Delphi 5 shlobj.pas, five `function X; external shell32 name 'X'` lines
|
|
1883
|
+
// before the next routine or `end.`). Deliberately only that form: an optional `;`
|
|
1884
|
+
// after every clause puts ALL declaration starts in the follow set of `_expr` here
|
|
1885
|
+
// and grows the parser by 16% states (measured). A `[` after the string forks (see conflicts).
|
|
1870
1886
|
procExternal: $ => seq(
|
|
1871
1887
|
$.kExternal,
|
|
1872
1888
|
optional($._expr),
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1889
|
+
choice(
|
|
1890
|
+
seq(
|
|
1891
|
+
optional(seq(choice($.kName, $.kIndex), $._expr)),
|
|
1892
|
+
...enable_if(delphi, optional($.kDelayed)),
|
|
1893
|
+
// Phase 3b iter 17: native library dependency hint
|
|
1894
|
+
// function f; cdecl; external LIB name 'foo' dependency 'c++_static','c++abi';
|
|
1895
|
+
// (Embarcadero FlatBox2D Android/iOS linker pattern.)
|
|
1896
|
+
// Phase 3b iter 35: `dependency` clause may use identifier-name
|
|
1897
|
+
// constants too: `dependency LibCPP, LibCPP_ABI` (FireDAC.Phys.IBCli).
|
|
1898
|
+
optional(seq(
|
|
1899
|
+
$.kDependency,
|
|
1900
|
+
delimited1(choice($._literalString, $.identifier)),
|
|
1901
|
+
)),
|
|
1902
|
+
';'
|
|
1903
|
+
),
|
|
1904
|
+
seq($.kName, $.literalString)
|
|
1905
|
+
)
|
|
1885
1906
|
),
|
|
1886
1907
|
|
|
1887
1908
|
// INITIALIZERS --------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-delphi13-pure",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Pure Delphi 13 tree-sitter sub-grammar — drops {$IFDEF}/pp_* tokens entirely and expects preprocessor-resolved source as input. Pairs with delphi13-preprocessor to reach 99%+ pass on real Delphi 13 corpora.",
|
|
5
5
|
"main": "bindings/node",
|
|
6
6
|
"types": "bindings/node",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|