@sshadows/tree-sitter-al 3.2.0 → 3.3.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/grammar.js +27 -0
- package/package.json +3 -4
- package/queries/folds.scm +4 -16
- package/queries/highlights.scm +307 -97
- package/queries/indents.scm +5 -5
- package/queries/locals.scm +28 -7
- package/queries/tags.scm +179 -68
- package/queries/textobjects.scm +67 -27
- package/src/grammar.json +16 -0
- package/src/node-types.json +10 -0
- package/src/parser.c +77021 -56029
- package/src/scanner.c +51 -38
- package/src/tree_sitter/array.h +23 -17
- package/tree-sitter-al.wasm +0 -0
- package/queries/bad_delete.scm.v1 +0 -30
package/grammar.js
CHANGED
|
@@ -88,6 +88,8 @@ module.exports = grammar({
|
|
|
88
88
|
$.pragma,
|
|
89
89
|
$.preproc_region,
|
|
90
90
|
$.preproc_endregion,
|
|
91
|
+
$.preproc_define,
|
|
92
|
+
$.preproc_undef,
|
|
91
93
|
/\uFEFF/, // BOM
|
|
92
94
|
],
|
|
93
95
|
|
|
@@ -3221,6 +3223,31 @@ module.exports = grammar({
|
|
|
3221
3223
|
|
|
3222
3224
|
preproc_endregion: $ => new RustRegex('(?i)#[ \\t]*endregion[^\\n\\r]*'),
|
|
3223
3225
|
|
|
3226
|
+
// Symbol definition directives. Line-level like #pragma/#region: they take a
|
|
3227
|
+
// single symbol name, never open or close a conditional, and so must NOT
|
|
3228
|
+
// touch the scanner's #if/#endif depth counter.
|
|
3229
|
+
//
|
|
3230
|
+
// Positionally the AL compiler is far stricter than this rule — verified
|
|
3231
|
+
// against alc 18.0.37 (full accept/reject matrix in
|
|
3232
|
+
// docs/preproc-define-undef.md):
|
|
3233
|
+
// * accepted ONLY before the first real token of the file — comments,
|
|
3234
|
+
// #pragma, #region/#endregion and whole #if/#else/#endif blocks may
|
|
3235
|
+
// precede or wrap them, but a `namespace`, `using` or object
|
|
3236
|
+
// declaration ends the window (error AL0625, "Cannot define/undefine
|
|
3237
|
+
// preprocessor symbols after first token in file")
|
|
3238
|
+
// * the symbol must be a bare identifier — letters, digits, underscores
|
|
3239
|
+
// (error AL0107 on a missing or quoted name)
|
|
3240
|
+
// * only a trailing `//` comment may follow the symbol (error AL0631)
|
|
3241
|
+
// * `#` and the directive must share a line (error AL0621)
|
|
3242
|
+
// Per "parse structure, don't validate", those are semantic checks for a
|
|
3243
|
+
// linter, so these stay `extras` alongside the other line-level directives.
|
|
3244
|
+
// That also buys reachability for free: file-leading position, inside a
|
|
3245
|
+
// leading pragma-only #if block, and after leading comments/pragmas are all
|
|
3246
|
+
// the same rule with no new parser states and no GLR conflicts.
|
|
3247
|
+
preproc_define: $ => new RustRegex('(?i)#[ \\t]*define[^\\n\\r]*'),
|
|
3248
|
+
|
|
3249
|
+
preproc_undef: $ => new RustRegex('(?i)#[ \\t]*undef[^\\n\\r]*'),
|
|
3250
|
+
|
|
3224
3251
|
// =====================================================================
|
|
3225
3252
|
// Statements
|
|
3226
3253
|
// =====================================================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sshadows/tree-sitter-al",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "AL for Business Central",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
"binding.gyp",
|
|
25
25
|
"prebuilds/**",
|
|
26
26
|
"bindings/node/*",
|
|
27
|
-
"queries
|
|
27
|
+
"queries/*.scm",
|
|
28
28
|
"src/**",
|
|
29
29
|
"*.wasm"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"node-addon-api": "^8.7.0",
|
|
33
|
-
"node-gyp-build": "^4.8.4"
|
|
34
|
-
"ts-check": "^0.2.4"
|
|
33
|
+
"node-gyp-build": "^4.8.4"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/jquery": "^4.0.0",
|
package/queries/folds.scm
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
; AL Language (v2) - Tree-sitter Code Folding Queries
|
|
2
2
|
; Defines regions that can be collapsed in editors supporting tree-sitter folding
|
|
3
|
-
|
|
4
3
|
; =============================================================================
|
|
5
4
|
; Object Declarations
|
|
6
5
|
; =============================================================================
|
|
7
|
-
|
|
8
6
|
[
|
|
9
7
|
(table_declaration)
|
|
10
8
|
(tableextension_declaration)
|
|
@@ -31,23 +29,24 @@
|
|
|
31
29
|
; =============================================================================
|
|
32
30
|
; Procedures and Triggers
|
|
33
31
|
; =============================================================================
|
|
34
|
-
|
|
35
32
|
(procedure) @fold
|
|
33
|
+
|
|
36
34
|
(trigger_declaration) @fold
|
|
35
|
+
|
|
37
36
|
(event_declaration) @fold
|
|
37
|
+
|
|
38
38
|
(interface_procedure) @fold
|
|
39
|
+
|
|
39
40
|
(preproc_split_procedure) @fold
|
|
40
41
|
|
|
41
42
|
; =============================================================================
|
|
42
43
|
; Code Blocks (begin ... end)
|
|
43
44
|
; =============================================================================
|
|
44
|
-
|
|
45
45
|
(code_block) @fold
|
|
46
46
|
|
|
47
47
|
; =============================================================================
|
|
48
48
|
; Sections
|
|
49
49
|
; =============================================================================
|
|
50
|
-
|
|
51
50
|
[
|
|
52
51
|
(fields_section)
|
|
53
52
|
(keys_section)
|
|
@@ -66,7 +65,6 @@
|
|
|
66
65
|
; =============================================================================
|
|
67
66
|
; Layout Elements
|
|
68
67
|
; =============================================================================
|
|
69
|
-
|
|
70
68
|
[
|
|
71
69
|
(area_section)
|
|
72
70
|
(group_section)
|
|
@@ -82,7 +80,6 @@
|
|
|
82
80
|
; =============================================================================
|
|
83
81
|
; Action Sections
|
|
84
82
|
; =============================================================================
|
|
85
|
-
|
|
86
83
|
[
|
|
87
84
|
(action_area_section)
|
|
88
85
|
(action_group_section)
|
|
@@ -95,7 +92,6 @@
|
|
|
95
92
|
; =============================================================================
|
|
96
93
|
; Report Elements
|
|
97
94
|
; =============================================================================
|
|
98
|
-
|
|
99
95
|
[
|
|
100
96
|
(report_dataitem)
|
|
101
97
|
(report_column)
|
|
@@ -106,7 +102,6 @@
|
|
|
106
102
|
; =============================================================================
|
|
107
103
|
; Query Elements
|
|
108
104
|
; =============================================================================
|
|
109
|
-
|
|
110
105
|
[
|
|
111
106
|
(query_dataitem)
|
|
112
107
|
(query_column)
|
|
@@ -116,7 +111,6 @@
|
|
|
116
111
|
; =============================================================================
|
|
117
112
|
; XMLport Elements
|
|
118
113
|
; =============================================================================
|
|
119
|
-
|
|
120
114
|
[
|
|
121
115
|
(xmlport_element)
|
|
122
116
|
(xmlport_attribute)
|
|
@@ -125,7 +119,6 @@
|
|
|
125
119
|
; =============================================================================
|
|
126
120
|
; Declarations with Bodies
|
|
127
121
|
; =============================================================================
|
|
128
|
-
|
|
129
122
|
[
|
|
130
123
|
(field_declaration)
|
|
131
124
|
(enum_value_declaration)
|
|
@@ -137,13 +130,11 @@
|
|
|
137
130
|
; =============================================================================
|
|
138
131
|
; Var Sections
|
|
139
132
|
; =============================================================================
|
|
140
|
-
|
|
141
133
|
(var_section) @fold
|
|
142
134
|
|
|
143
135
|
; =============================================================================
|
|
144
136
|
; Control Flow
|
|
145
137
|
; =============================================================================
|
|
146
|
-
|
|
147
138
|
[
|
|
148
139
|
(if_statement)
|
|
149
140
|
(case_statement)
|
|
@@ -159,7 +150,6 @@
|
|
|
159
150
|
; =============================================================================
|
|
160
151
|
; Modification Blocks
|
|
161
152
|
; =============================================================================
|
|
162
|
-
|
|
163
153
|
[
|
|
164
154
|
(addafter_modification)
|
|
165
155
|
(addbefore_modification)
|
|
@@ -191,13 +181,11 @@
|
|
|
191
181
|
; =============================================================================
|
|
192
182
|
; Comments
|
|
193
183
|
; =============================================================================
|
|
194
|
-
|
|
195
184
|
(multiline_comment) @fold
|
|
196
185
|
|
|
197
186
|
; =============================================================================
|
|
198
187
|
; Preprocessor Regions
|
|
199
188
|
; =============================================================================
|
|
200
|
-
|
|
201
189
|
(preproc_region) @fold
|
|
202
190
|
|
|
203
191
|
; Preprocessor conditionals
|