gitnexus 1.6.12-rc.2 → 1.6.12-rc.21
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/dist/_shared/graph/types.d.ts +1 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/language-detection.d.ts.map +1 -1
- package/dist/_shared/language-detection.js +2 -0
- package/dist/_shared/language-detection.js.map +1 -1
- package/dist/_shared/languages.d.ts +1 -0
- package/dist/_shared/languages.d.ts.map +1 -1
- package/dist/_shared/languages.js +1 -0
- package/dist/_shared/languages.js.map +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.js +2 -0
- package/dist/_shared/lbug/schema-constants.js.map +1 -1
- package/dist/_shared/scope-resolution/language-classification.d.ts +2 -1
- package/dist/_shared/scope-resolution/language-classification.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/language-classification.js +3 -1
- package/dist/_shared/scope-resolution/language-classification.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/class-registry.d.ts +3 -3
- package/dist/_shared/scope-resolution/registries/class-registry.js +3 -3
- package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.js +2 -0
- package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
- package/dist/_shared/scope-resolution/resolve-type-ref.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/resolve-type-ref.js +2 -0
- package/dist/_shared/scope-resolution/resolve-type-ref.js.map +1 -1
- package/dist/cli/analyze-config.d.ts +2 -2
- package/dist/cli/analyze-config.js +10 -33
- package/dist/cli/doctor.js +6 -4
- package/dist/cli/eval-server.js +13 -1
- package/dist/cli/i18n/en.d.ts +4 -2
- package/dist/cli/i18n/en.js +4 -2
- package/dist/cli/i18n/resources.d.ts +6 -2
- package/dist/cli/i18n/zh-CN.d.ts +2 -0
- package/dist/cli/i18n/zh-CN.js +4 -2
- package/dist/core/analysis-feature-registry.d.ts +1 -1
- package/dist/core/analysis-feature-registry.js +2 -0
- package/dist/core/auto-sync/starter.js +2 -2
- package/dist/core/embeddings/ast-utils.js +8 -3
- package/dist/core/embeddings/chunker.js +67 -10
- package/dist/core/embeddings/embedding-pipeline.d.ts +1 -1
- package/dist/core/embeddings/embedding-pipeline.js +1 -1
- package/dist/core/embeddings/structural-extractor.js +2 -2
- package/dist/core/embeddings/types.d.ts +4 -2
- package/dist/core/embeddings/types.js +18 -0
- package/dist/core/git-ref.d.ts +22 -0
- package/dist/core/git-ref.js +114 -0
- package/dist/core/git-staleness.js +14 -0
- package/dist/core/group/extractors/graphql-extractor.d.ts +1 -1
- package/dist/core/group/extractors/graphql-extractor.js +149 -13
- package/dist/core/group/extractors/manifest-extractor.d.ts +1 -1
- package/dist/core/group/extractors/manifest-extractor.js +2 -2
- package/dist/core/ingestion/call-extractors/zig-static-gating.d.ts +5 -8
- package/dist/core/ingestion/content-language-classification.d.ts +10 -0
- package/dist/core/ingestion/content-language-classification.js +30 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +1 -0
- package/dist/core/ingestion/filesystem-walker.js +1 -1
- package/dist/core/ingestion/import-resolvers/node-workspace-packages.js +3 -2
- package/dist/core/ingestion/language-config.d.ts +82 -13
- package/dist/core/ingestion/language-config.js +217 -13
- package/dist/core/ingestion/language-provider.d.ts +88 -1
- package/dist/core/ingestion/languages/index.d.ts +7 -0
- package/dist/core/ingestion/languages/index.js +30 -1
- package/dist/core/ingestion/languages/objective-c/analysis-features.d.ts +10 -0
- package/dist/core/ingestion/languages/objective-c/analysis-features.js +19 -0
- package/dist/core/ingestion/languages/objective-c/compilation-unit-siblings.d.ts +13 -0
- package/dist/core/ingestion/languages/objective-c/compilation-unit-siblings.js +124 -0
- package/dist/core/ingestion/languages/objective-c/facts.d.ts +148 -0
- package/dist/core/ingestion/languages/objective-c/facts.js +1150 -0
- package/dist/core/ingestion/languages/objective-c/import-target.d.ts +11 -0
- package/dist/core/ingestion/languages/objective-c/import-target.js +122 -0
- package/dist/core/ingestion/languages/objective-c/macro-marker-preprocess.d.ts +24 -0
- package/dist/core/ingestion/languages/objective-c/macro-marker-preprocess.js +261 -0
- package/dist/core/ingestion/languages/objective-c/resolution-config.d.ts +41 -0
- package/dist/core/ingestion/languages/objective-c/resolution-config.js +282 -0
- package/dist/core/ingestion/languages/objective-c/scope-resolver.d.ts +2 -0
- package/dist/core/ingestion/languages/objective-c/scope-resolver.js +503 -0
- package/dist/core/ingestion/languages/objective-c.d.ts +2 -0
- package/dist/core/ingestion/languages/objective-c.js +300 -0
- package/dist/core/ingestion/languages/typescript/query.d.ts +31 -0
- package/dist/core/ingestion/languages/typescript/query.js +7 -1
- package/dist/core/ingestion/languages/typescript/tsconfig.js +3 -2
- package/dist/core/ingestion/languages/typescript.js +1 -1
- package/dist/core/ingestion/languages/zig/query.d.ts +26 -0
- package/dist/core/ingestion/languages/zig/query.js +61 -1
- package/dist/core/ingestion/languages/zig/range-binding.d.ts +8 -0
- package/dist/core/ingestion/languages/zig/range-binding.js +24 -0
- package/dist/core/ingestion/languages/zig/scope-resolver.d.ts +3 -2
- package/dist/core/ingestion/languages/zig/scope-resolver.js +18 -5
- package/dist/core/ingestion/languages/zig/this-alias-bindings.d.ts +58 -0
- package/dist/core/ingestion/languages/zig/this-alias-bindings.js +176 -0
- package/dist/core/ingestion/languages/zig/workspace-static-gating.d.ts +8 -0
- package/dist/core/ingestion/languages/zig/workspace-static-gating.js +82 -0
- package/dist/core/ingestion/model/registration-table.d.ts +3 -3
- package/dist/core/ingestion/model/registration-table.js +9 -5
- package/dist/core/ingestion/model/symbol-table.d.ts +1 -1
- package/dist/core/ingestion/model/symbol-table.js +2 -0
- package/dist/core/ingestion/model/type-registry.d.ts +1 -1
- package/dist/core/ingestion/parsing-processor.d.ts +22 -6
- package/dist/core/ingestion/parsing-processor.js +39 -20
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +9 -1
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +307 -96
- package/dist/core/ingestion/pipeline-phases/parse-round-budget.d.ts +42 -0
- package/dist/core/ingestion/pipeline-phases/parse-round-budget.js +50 -0
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +7 -1
- package/dist/core/ingestion/scope-extractor.js +4 -0
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +13 -0
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +2 -0
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +2 -0
- package/dist/core/ingestion/scope-resolution/passes/property-dispatch.d.ts +78 -5
- package/dist/core/ingestion/scope-resolution/passes/property-dispatch.js +262 -7
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +5 -2
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +2 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +10 -1
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +39 -3
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +82 -3
- package/dist/core/ingestion/scope-resolution/value-ref-edges.d.ts +14 -0
- package/dist/core/ingestion/scope-resolution/value-ref-edges.js +14 -0
- package/dist/core/ingestion/tree-sitter-queries.js +2 -0
- package/dist/core/ingestion/utils/symbol-labels.js +2 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +1 -1
- package/dist/core/ingestion/workers/parse-worker.js +63 -3
- package/dist/core/ingestion/workers/worker-pool.d.ts +56 -2
- package/dist/core/ingestion/workers/worker-pool.js +117 -26
- package/dist/core/lbug/csv-generator.js +2 -0
- package/dist/core/lbug/schema.d.ts +3 -1
- package/dist/core/lbug/schema.js +27 -0
- package/dist/core/search/fts-indexes.js +13 -4
- package/dist/core/search/fts-schema.js +2 -0
- package/dist/core/tree-sitter/parser-loader.js +10 -0
- package/dist/core/tree-sitter/vendored-grammars.d.ts +1 -1
- package/dist/core/tree-sitter/vendored-grammars.js +2 -1
- package/dist/mcp/local/local-backend.d.ts +33 -0
- package/dist/mcp/local/local-backend.js +166 -5
- package/dist/mcp/tools.js +6 -4
- package/dist/server/analyze-job.d.ts +19 -1
- package/dist/server/analyze-job.js +14 -3
- package/dist/server/analyze-launch.d.ts +14 -0
- package/dist/server/analyze-launch.js +59 -14
- package/dist/server/analyze-worker-ipc.d.ts +6 -5
- package/dist/server/analyze-worker-ipc.js +4 -0
- package/dist/server/api.js +68 -21
- package/dist/server/git-clone.d.ts +38 -5
- package/dist/server/git-clone.js +216 -38
- package/dist/server/repo-projection.d.ts +88 -0
- package/dist/server/repo-projection.js +53 -0
- package/dist/storage/file-lock.js +5 -3
- package/dist/storage/parse-cache.js +32 -1
- package/dist/storage/parsedfile-store.js +53 -1
- package/dist/storage/v8-sidecar.d.ts +11 -0
- package/dist/storage/v8-sidecar.js +15 -7
- package/dist/utils/process-identity.d.ts +13 -0
- package/dist/utils/process-identity.js +18 -0
- package/package.json +1 -1
- package/scripts/build-tree-sitter-grammars.cjs +4 -3
- package/vendor/tree-sitter-objc/LICENSE +21 -0
- package/vendor/tree-sitter-objc/README.md +18 -0
- package/vendor/tree-sitter-objc/binding.gyp +35 -0
- package/vendor/tree-sitter-objc/bindings/node/binding.cc +19 -0
- package/vendor/tree-sitter-objc/bindings/node/binding_test.js +9 -0
- package/vendor/tree-sitter-objc/bindings/node/index.d.ts +27 -0
- package/vendor/tree-sitter-objc/bindings/node/index.js +11 -0
- package/vendor/tree-sitter-objc/grammar.js +1286 -0
- package/vendor/tree-sitter-objc/package.json +56 -0
- package/vendor/tree-sitter-objc/prebuilds/SHA256SUMS +6 -0
- package/vendor/tree-sitter-objc/prebuilds/darwin-arm64/tree-sitter-objc.node +0 -0
- package/vendor/tree-sitter-objc/prebuilds/darwin-x64/tree-sitter-objc.node +0 -0
- package/vendor/tree-sitter-objc/prebuilds/linux-arm64/tree-sitter-objc.node +0 -0
- package/vendor/tree-sitter-objc/prebuilds/linux-x64/tree-sitter-objc.node +0 -0
- package/vendor/tree-sitter-objc/prebuilds/win32-arm64/tree-sitter-objc.node +0 -0
- package/vendor/tree-sitter-objc/prebuilds/win32-x64/tree-sitter-objc.node +0 -0
- package/vendor/tree-sitter-objc/queries/folds.scm +20 -0
- package/vendor/tree-sitter-objc/queries/highlights.scm +216 -0
- package/vendor/tree-sitter-objc/queries/indents.scm +1 -0
- package/vendor/tree-sitter-objc/queries/injections.scm +10 -0
- package/vendor/tree-sitter-objc/queries/locals.scm +1 -0
- package/vendor/tree-sitter-objc/src/grammar.json +16292 -0
- package/vendor/tree-sitter-objc/src/node-types.json +7524 -0
- package/vendor/tree-sitter-objc/src/parser.c +684023 -0
- package/vendor/tree-sitter-objc/src/tree_sitter/alloc.h +54 -0
- package/vendor/tree-sitter-objc/src/tree_sitter/array.h +291 -0
- package/vendor/tree-sitter-objc/src/tree_sitter/parser.h +266 -0
- package/vendor/tree-sitter-objc/tree-sitter-objc.wasm +0 -0
- package/vendor/tree-sitter-objc/tree-sitter.json +38 -0
- package/web/assets/{agent-BMRqXorA.js → agent-C2n33ANd.js} +1 -1
- package/web/assets/{index-Dj3vQOHK.js → index-CHJoW_P1.js} +18 -18
- package/web/assets/src-jc8Ffy3T.js +1 -0
- package/web/index.html +2 -2
- package/web/assets/src-Df5C1Nz4.js +0 -1
|
@@ -0,0 +1,1286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Objective-C grammar for tree-sitter
|
|
3
|
+
* @author Amaan Qureshi <amaanq12@gmail.com>
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/// <reference types="tree-sitter-cli/dsl" />
|
|
9
|
+
// @ts-check
|
|
10
|
+
|
|
11
|
+
const C = require('tree-sitter-c/grammar');
|
|
12
|
+
|
|
13
|
+
// Welcome to Hell
|
|
14
|
+
module.exports = grammar(C, {
|
|
15
|
+
name: 'objc',
|
|
16
|
+
|
|
17
|
+
extras: $ => [
|
|
18
|
+
/\u00A0|\s|\\\r?\n/,
|
|
19
|
+
$.comment,
|
|
20
|
+
],
|
|
21
|
+
|
|
22
|
+
conflicts: ($, original) => original.filter(
|
|
23
|
+
(e) => !(e.length == 2 && e[0].name == 'type_qualifier' && e[1].name == 'extension_expression'),
|
|
24
|
+
).concat([
|
|
25
|
+
[$.enum_specifier],
|
|
26
|
+
[$.expression, $.generic_specifier],
|
|
27
|
+
[$._declarator, $.type_specifier, $.generic_specifier],
|
|
28
|
+
[$._declarator, $.type_specifier, $.sized_type_specifier],
|
|
29
|
+
[$.attribute, $.expression],
|
|
30
|
+
[$.parameterized_arguments],
|
|
31
|
+
[$.string_literal],
|
|
32
|
+
[$.extension_expression, $.range_expression],
|
|
33
|
+
[$.abstract_array_declarator, $.array_type_specifier],
|
|
34
|
+
[$._type_definition_type],
|
|
35
|
+
[$.keyword_declarator, $.method_parameter],
|
|
36
|
+
]),
|
|
37
|
+
|
|
38
|
+
inline: ($, original) => original.concat([
|
|
39
|
+
$.method_selector,
|
|
40
|
+
$.method_selector_no_list,
|
|
41
|
+
$.keyword_selector,
|
|
42
|
+
$.interface_declaration,
|
|
43
|
+
$.typedefed_identifier,
|
|
44
|
+
$.keyword_identifier,
|
|
45
|
+
]),
|
|
46
|
+
|
|
47
|
+
supertypes: ($, original) => original.concat([
|
|
48
|
+
$.specifier_qualifier,
|
|
49
|
+
]),
|
|
50
|
+
|
|
51
|
+
rules: {
|
|
52
|
+
_top_level_item: ($, original) => choice(
|
|
53
|
+
original,
|
|
54
|
+
$.class_declaration,
|
|
55
|
+
$.class_interface,
|
|
56
|
+
$.class_implementation,
|
|
57
|
+
$.protocol_declaration,
|
|
58
|
+
$.protocol_forward_declaration,
|
|
59
|
+
$.module_import,
|
|
60
|
+
$.compatibility_alias_declaration,
|
|
61
|
+
$.preproc_undef,
|
|
62
|
+
$.preproc_linemarker,
|
|
63
|
+
),
|
|
64
|
+
|
|
65
|
+
_block_item: ($, original) => choice(
|
|
66
|
+
original,
|
|
67
|
+
$.class_declaration,
|
|
68
|
+
$.class_interface,
|
|
69
|
+
$.class_implementation,
|
|
70
|
+
$.protocol_declaration,
|
|
71
|
+
$.protocol_forward_declaration,
|
|
72
|
+
$.module_import,
|
|
73
|
+
$.compatibility_alias_declaration,
|
|
74
|
+
$.preproc_undef,
|
|
75
|
+
$.preproc_linemarker,
|
|
76
|
+
),
|
|
77
|
+
|
|
78
|
+
function_definition: $ => seq(
|
|
79
|
+
optional($.ms_call_modifier),
|
|
80
|
+
$._declaration_specifiers,
|
|
81
|
+
field('declarator', $._declarator),
|
|
82
|
+
field('body', $.compound_statement),
|
|
83
|
+
),
|
|
84
|
+
|
|
85
|
+
declaration: $ => seq(
|
|
86
|
+
$._declaration_specifiers,
|
|
87
|
+
commaSep1(prec.right(field('declarator', choice(
|
|
88
|
+
seq($._declarator, optional($.gnu_asm_expression)),
|
|
89
|
+
$.init_declarator,
|
|
90
|
+
seq($.type_qualifier, $.identifier),
|
|
91
|
+
)))),
|
|
92
|
+
optional($._declaration_modifiers),
|
|
93
|
+
';',
|
|
94
|
+
),
|
|
95
|
+
|
|
96
|
+
type_definition: $ => seq(
|
|
97
|
+
optional('__extension__'),
|
|
98
|
+
optional($.ms_declspec_modifier),
|
|
99
|
+
'typedef',
|
|
100
|
+
optional($.attribute_specifier),
|
|
101
|
+
optional($.ms_declspec_modifier),
|
|
102
|
+
$._type_definition_type,
|
|
103
|
+
$._type_definition_declarators,
|
|
104
|
+
';',
|
|
105
|
+
),
|
|
106
|
+
|
|
107
|
+
_type_definition_type: $ => seq(
|
|
108
|
+
repeat($.type_qualifier),
|
|
109
|
+
optional($.attribute_specifier),
|
|
110
|
+
field('type', $.type_specifier),
|
|
111
|
+
optional($.ms_declspec_modifier),
|
|
112
|
+
repeat($.type_qualifier),
|
|
113
|
+
),
|
|
114
|
+
|
|
115
|
+
_type_definition_declarators: $ => seq(
|
|
116
|
+
commaSep1(field('declarator', $._type_declarator)),
|
|
117
|
+
optional($._declaration_modifiers),
|
|
118
|
+
),
|
|
119
|
+
|
|
120
|
+
_declaration_modifiers: ($, original) => choice(
|
|
121
|
+
original,
|
|
122
|
+
$.availability_attribute_specifier,
|
|
123
|
+
$.attribute_declaration,
|
|
124
|
+
),
|
|
125
|
+
|
|
126
|
+
_declaration_specifiers: $ => prec.right(seq(
|
|
127
|
+
repeat($._declaration_modifiers),
|
|
128
|
+
field('type', $.type_specifier),
|
|
129
|
+
repeat($._declaration_modifiers),
|
|
130
|
+
)),
|
|
131
|
+
|
|
132
|
+
parameter_declaration: $ => seq(
|
|
133
|
+
$._declaration_specifiers,
|
|
134
|
+
optional(field('declarator', choice(
|
|
135
|
+
seq($._declarator, optional($._declaration_modifiers)),
|
|
136
|
+
$._abstract_declarator,
|
|
137
|
+
))),
|
|
138
|
+
),
|
|
139
|
+
|
|
140
|
+
_non_case_statement: ($, original) => choice(
|
|
141
|
+
...original.members.filter(member => member.name !== 'seh_try_statement' && member.name !== 'seh_leave_statement'),
|
|
142
|
+
$.try_statement,
|
|
143
|
+
$.throw_statement,
|
|
144
|
+
$.synchronized_statement,
|
|
145
|
+
$.ms_asm_block,
|
|
146
|
+
),
|
|
147
|
+
|
|
148
|
+
attribute: $ => seq(
|
|
149
|
+
optional(seq(field('prefix', $.identifier), '::')),
|
|
150
|
+
field('name', $.identifier),
|
|
151
|
+
optional(seq('(', commaSep($.expression), ')')),
|
|
152
|
+
),
|
|
153
|
+
|
|
154
|
+
attribute_declaration: $ => seq(
|
|
155
|
+
'[',
|
|
156
|
+
'[',
|
|
157
|
+
commaSep1($.attribute),
|
|
158
|
+
']',
|
|
159
|
+
']',
|
|
160
|
+
),
|
|
161
|
+
|
|
162
|
+
_expression_not_binary: ($, original) => choice(
|
|
163
|
+
original,
|
|
164
|
+
$.message_expression,
|
|
165
|
+
$.selector_expression,
|
|
166
|
+
$.available_expression,
|
|
167
|
+
$.range_expression,
|
|
168
|
+
$.block_literal,
|
|
169
|
+
$.dictionary_literal,
|
|
170
|
+
$.array_literal,
|
|
171
|
+
$.at_expression,
|
|
172
|
+
$.encode_expression,
|
|
173
|
+
$.va_arg_expression,
|
|
174
|
+
$.keyword_identifier,
|
|
175
|
+
),
|
|
176
|
+
|
|
177
|
+
cast_expression: $ => prec(C.PREC.CAST, choice(
|
|
178
|
+
seq(
|
|
179
|
+
'(',
|
|
180
|
+
field('type', choice($.type_descriptor, $.typeof_specifier, $.parameterized_arguments)),
|
|
181
|
+
')',
|
|
182
|
+
field('value', $.expression),
|
|
183
|
+
),
|
|
184
|
+
seq(choice('__real', '__imag'), field('value', $.expression)),
|
|
185
|
+
)),
|
|
186
|
+
|
|
187
|
+
argument_list: $ => seq(
|
|
188
|
+
'(',
|
|
189
|
+
choice(
|
|
190
|
+
commaSep(choice(
|
|
191
|
+
seq(optional($.type_qualifier), choice($.expression, $.typeof_specifier)),
|
|
192
|
+
$.compound_statement,
|
|
193
|
+
)),
|
|
194
|
+
seq($._type_identifier, token.immediate('<'), commaSep1($.type_name), '>'),
|
|
195
|
+
$.objc_bridge,
|
|
196
|
+
$.availability,
|
|
197
|
+
),
|
|
198
|
+
')',
|
|
199
|
+
),
|
|
200
|
+
|
|
201
|
+
objc_bridge: $ => seq(
|
|
202
|
+
'objc_bridge_related',
|
|
203
|
+
'(',
|
|
204
|
+
$.expression,
|
|
205
|
+
',',
|
|
206
|
+
optional(seq($.expression, ':')),
|
|
207
|
+
',',
|
|
208
|
+
optional($.expression),
|
|
209
|
+
')',
|
|
210
|
+
),
|
|
211
|
+
|
|
212
|
+
typeof_specifier: $ => seq(
|
|
213
|
+
choice('__typeof__', '__typeof', 'typeof'),
|
|
214
|
+
'(',
|
|
215
|
+
choice($.expression, $.type_descriptor),
|
|
216
|
+
')',
|
|
217
|
+
),
|
|
218
|
+
|
|
219
|
+
compound_statement: $ => seq(
|
|
220
|
+
optional('@autoreleasepool'),
|
|
221
|
+
'{',
|
|
222
|
+
repeat($._block_item),
|
|
223
|
+
'}',
|
|
224
|
+
),
|
|
225
|
+
|
|
226
|
+
availability: $ => seq(
|
|
227
|
+
'availability',
|
|
228
|
+
'(',
|
|
229
|
+
commaSep1(seq(
|
|
230
|
+
$.identifier,
|
|
231
|
+
optional(seq(
|
|
232
|
+
'=',
|
|
233
|
+
choice($.version, $.expression),
|
|
234
|
+
)),
|
|
235
|
+
)),
|
|
236
|
+
')',
|
|
237
|
+
),
|
|
238
|
+
version: $ => prec.right(choice(
|
|
239
|
+
$.platform,
|
|
240
|
+
$.version_number,
|
|
241
|
+
seq(
|
|
242
|
+
$.platform,
|
|
243
|
+
'(',
|
|
244
|
+
commaSep1(choice($.number_literal, $.identifier)),
|
|
245
|
+
')',
|
|
246
|
+
),
|
|
247
|
+
)),
|
|
248
|
+
version_number: _ => /\d+([\._]\d+)*/,
|
|
249
|
+
platform: _ => choice('ios', 'tvos', 'macos', 'macosx', 'watchos'),
|
|
250
|
+
|
|
251
|
+
_declarator: ($, original) => prec.right(choice(
|
|
252
|
+
...original.members.filter(member => member.name !== 'attributed_declarator'),
|
|
253
|
+
$.block_pointer_declarator,
|
|
254
|
+
)),
|
|
255
|
+
|
|
256
|
+
_abstract_declarator: ($, original) => choice(
|
|
257
|
+
original,
|
|
258
|
+
$.abstract_block_pointer_declarator,
|
|
259
|
+
),
|
|
260
|
+
|
|
261
|
+
_field_declarator: ($, original) => choice(
|
|
262
|
+
original,
|
|
263
|
+
alias($.block_pointer_field_declarator, $.block_pointer_declarator),
|
|
264
|
+
),
|
|
265
|
+
|
|
266
|
+
_type_declarator: $ => choice(
|
|
267
|
+
alias($.pointer_type_declarator, $.pointer_declarator),
|
|
268
|
+
alias($.function_type_declarator, $.function_declarator),
|
|
269
|
+
alias($.array_type_declarator, $.array_declarator),
|
|
270
|
+
alias($.parenthesized_type_declarator, $.parenthesized_declarator),
|
|
271
|
+
alias($.block_pointer_type_declarator, $.block_pointer_declarator),
|
|
272
|
+
$._type_identifier,
|
|
273
|
+
alias(choice('signed', 'unsigned', 'long', 'short'), $.primitive_type),
|
|
274
|
+
$.primitive_type,
|
|
275
|
+
),
|
|
276
|
+
|
|
277
|
+
for_statement: ($, original) => choice(
|
|
278
|
+
original,
|
|
279
|
+
prec(1, seq(
|
|
280
|
+
'for',
|
|
281
|
+
'(',
|
|
282
|
+
choice(
|
|
283
|
+
seq($._declaration_specifiers, $._declarator),
|
|
284
|
+
$.identifier,
|
|
285
|
+
),
|
|
286
|
+
'in',
|
|
287
|
+
$.expression,
|
|
288
|
+
')',
|
|
289
|
+
$._non_case_statement,
|
|
290
|
+
)),
|
|
291
|
+
),
|
|
292
|
+
|
|
293
|
+
type_qualifier: (_, original) => prec.right(choice(
|
|
294
|
+
original,
|
|
295
|
+
'nullable',
|
|
296
|
+
'_Complex',
|
|
297
|
+
'_Nonnull',
|
|
298
|
+
'_Nullable',
|
|
299
|
+
'_Nullable_result',
|
|
300
|
+
'_Null_unspecified',
|
|
301
|
+
'__autoreleasing',
|
|
302
|
+
'__block',
|
|
303
|
+
'__bridge',
|
|
304
|
+
'__bridge_retained',
|
|
305
|
+
'__bridge_transfer',
|
|
306
|
+
'__complex',
|
|
307
|
+
'__const',
|
|
308
|
+
'__imag',
|
|
309
|
+
'__kindof',
|
|
310
|
+
'__nonnull',
|
|
311
|
+
'__nullable',
|
|
312
|
+
'__ptrauth_objc_class_ro',
|
|
313
|
+
'__ptrauth_objc_isa_pointer',
|
|
314
|
+
'__ptrauth_objc_super_pointer',
|
|
315
|
+
'__real',
|
|
316
|
+
'__strong',
|
|
317
|
+
'__unsafe_unretained',
|
|
318
|
+
'__unused',
|
|
319
|
+
'__weak',
|
|
320
|
+
)),
|
|
321
|
+
|
|
322
|
+
storage_class_specifier: (_, original) => choice(
|
|
323
|
+
original,
|
|
324
|
+
'__inline__',
|
|
325
|
+
'CG_EXTERN',
|
|
326
|
+
'CG_INLINE',
|
|
327
|
+
'FOUNDATION_EXPORT',
|
|
328
|
+
'FOUNDATION_EXTERN',
|
|
329
|
+
'FOUNDATION_STATIC_INLINE',
|
|
330
|
+
'IBOutlet',
|
|
331
|
+
'IBInspectable',
|
|
332
|
+
'IB_DESIGNABLE',
|
|
333
|
+
'NS_INLINE',
|
|
334
|
+
'NS_VALID_UNTIL_END_OF_SCOPE',
|
|
335
|
+
'OBJC_EXPORT',
|
|
336
|
+
'OBJC_ROOT_CLASS',
|
|
337
|
+
'UIKIT_EXTERN',
|
|
338
|
+
),
|
|
339
|
+
|
|
340
|
+
preproc_include: $ => seq(
|
|
341
|
+
field('directive', choice(preprocessor('include'), preprocessor('import'))),
|
|
342
|
+
field('path', choice(
|
|
343
|
+
$.string_literal,
|
|
344
|
+
$.system_lib_string,
|
|
345
|
+
$.identifier,
|
|
346
|
+
alias($.preproc_call_expression, $.call_expression),
|
|
347
|
+
)),
|
|
348
|
+
token.immediate(/\r?\n/),
|
|
349
|
+
),
|
|
350
|
+
|
|
351
|
+
module_import: $ => seq(
|
|
352
|
+
'@import',
|
|
353
|
+
field('path', seq($.identifier, repeat(seq('.', $.identifier)))),
|
|
354
|
+
';',
|
|
355
|
+
),
|
|
356
|
+
|
|
357
|
+
...preprocIf('', $ => choice($._block_item, $.attribute_specifier, $.property_implementation)),
|
|
358
|
+
...preprocIf('_in_implementation_definition', $ => $.implementation_definition),
|
|
359
|
+
...preprocIf('_in_interface_declaration', $ => $.interface_declaration),
|
|
360
|
+
...preprocIf('_in_enumerator', $ => seq($.enumerator, ',')),
|
|
361
|
+
|
|
362
|
+
preproc_undef: $ => seq(
|
|
363
|
+
preprocessor('undef'),
|
|
364
|
+
field('name', $.identifier),
|
|
365
|
+
token.immediate(/\r?\n/),
|
|
366
|
+
),
|
|
367
|
+
|
|
368
|
+
preproc_linemarker: $ => seq(
|
|
369
|
+
'#',
|
|
370
|
+
$.number_literal,
|
|
371
|
+
field('filename', $.string_literal),
|
|
372
|
+
optional(seq(
|
|
373
|
+
field('row', $.number_literal),
|
|
374
|
+
optional(field('column', $.number_literal)),
|
|
375
|
+
)),
|
|
376
|
+
token.immediate(/\r?\n/),
|
|
377
|
+
),
|
|
378
|
+
|
|
379
|
+
_preproc_expression: ($, original) => choice(
|
|
380
|
+
original,
|
|
381
|
+
$.system_lib_string,
|
|
382
|
+
),
|
|
383
|
+
|
|
384
|
+
preproc_params: $ => seq(
|
|
385
|
+
token.immediate('('), commaSep(choice($.identifier, '...')), optional('...'), ')',
|
|
386
|
+
),
|
|
387
|
+
|
|
388
|
+
attribute_specifier: $ => seq(
|
|
389
|
+
choice('__attribute__', '__attribute'),
|
|
390
|
+
'(',
|
|
391
|
+
choice($.argument_list, seq('(', commaSep1(choice('noreturn', 'nothrow')), ')')),
|
|
392
|
+
')',
|
|
393
|
+
),
|
|
394
|
+
|
|
395
|
+
availability_attribute_specifier: $ => choice(
|
|
396
|
+
'NS_AUTOMATED_REFCOUNT_UNAVAILABLE',
|
|
397
|
+
'NS_ROOT_CLASS',
|
|
398
|
+
'NS_UNAVAILABLE',
|
|
399
|
+
'NS_REQUIRES_NIL_TERMINATION',
|
|
400
|
+
'CF_RETURNS_RETAINED',
|
|
401
|
+
'CF_RETURNS_NOT_RETAINED',
|
|
402
|
+
'DEPRECATED_ATTRIBUTE',
|
|
403
|
+
'UI_APPEARANCE_SELECTOR',
|
|
404
|
+
'UNAVAILABLE_ATTRIBUTE',
|
|
405
|
+
seq(
|
|
406
|
+
choice(
|
|
407
|
+
'CF_FORMAT_FUNCTION',
|
|
408
|
+
'NS_AVAILABLE',
|
|
409
|
+
'__IOS_AVAILABLE',
|
|
410
|
+
'NS_AVAILABLE_IOS',
|
|
411
|
+
'API_AVAILABLE',
|
|
412
|
+
'API_UNAVAILABLE',
|
|
413
|
+
'API_DEPRECATED',
|
|
414
|
+
'NS_ENUM_AVAILABLE_IOS',
|
|
415
|
+
'NS_DEPRECATED_IOS',
|
|
416
|
+
'NS_ENUM_DEPRECATED_IOS',
|
|
417
|
+
'NS_FORMAT_FUNCTION',
|
|
418
|
+
'DEPRECATED_MSG_ATTRIBUTE',
|
|
419
|
+
'__deprecated_msg',
|
|
420
|
+
'__deprecated_enum_msg',
|
|
421
|
+
'NS_SWIFT_NAME',
|
|
422
|
+
'NS_SWIFT_UNAVAILABLE',
|
|
423
|
+
'NS_EXTENSION_UNAVAILABLE_IOS',
|
|
424
|
+
'NS_CLASS_AVAILABLE_IOS',
|
|
425
|
+
'NS_CLASS_DEPRECATED_IOS',
|
|
426
|
+
'__OSX_AVAILABLE_STARTING',
|
|
427
|
+
),
|
|
428
|
+
'(',
|
|
429
|
+
commaSep1(choice(
|
|
430
|
+
$.string_literal,
|
|
431
|
+
$.concatenated_string,
|
|
432
|
+
$.version,
|
|
433
|
+
$.method_identifier,
|
|
434
|
+
$.identifier,
|
|
435
|
+
seq($.identifier, '(', optional($.method_identifier), ')'),
|
|
436
|
+
)),
|
|
437
|
+
')',
|
|
438
|
+
),
|
|
439
|
+
),
|
|
440
|
+
|
|
441
|
+
struct_specifier: $ => prec.right(seq(
|
|
442
|
+
'struct',
|
|
443
|
+
optional($.attribute_specifier),
|
|
444
|
+
optional($.ms_declspec_modifier),
|
|
445
|
+
choice(
|
|
446
|
+
seq(
|
|
447
|
+
field('name', $._type_identifier),
|
|
448
|
+
field('body', optional($.field_declaration_list)),
|
|
449
|
+
),
|
|
450
|
+
field('body', $.field_declaration_list),
|
|
451
|
+
),
|
|
452
|
+
optional($.attribute_specifier),
|
|
453
|
+
)),
|
|
454
|
+
|
|
455
|
+
enum_specifier: $ => seq(
|
|
456
|
+
'enum',
|
|
457
|
+
optional($.attribute_specifier),
|
|
458
|
+
optional($.ms_declspec_modifier),
|
|
459
|
+
choice(
|
|
460
|
+
seq(
|
|
461
|
+
field('name', $._type_identifier),
|
|
462
|
+
optional(seq(':', field('underlying_type', choice($._type_identifier, $.primitive_type)))),
|
|
463
|
+
field('body', optional($.enumerator_list)),
|
|
464
|
+
),
|
|
465
|
+
seq(
|
|
466
|
+
optional(seq(':', field('base', $._type_identifier))),
|
|
467
|
+
field('body', $.enumerator_list),
|
|
468
|
+
),
|
|
469
|
+
),
|
|
470
|
+
optional($.attribute_specifier),
|
|
471
|
+
),
|
|
472
|
+
|
|
473
|
+
enumerator_list: $ => seq(
|
|
474
|
+
'{',
|
|
475
|
+
optionalCommaSep(choice(
|
|
476
|
+
seq($.enumerator, optional($._declaration_modifiers)),
|
|
477
|
+
alias($.preproc_ifdef_in_enumerator, $.preproc_ifdef),
|
|
478
|
+
)),
|
|
479
|
+
optional(','),
|
|
480
|
+
'}',
|
|
481
|
+
),
|
|
482
|
+
|
|
483
|
+
enumerator: $ => seq(
|
|
484
|
+
field('name', $.identifier),
|
|
485
|
+
optional(seq('=', field('value', $.expression))),
|
|
486
|
+
),
|
|
487
|
+
|
|
488
|
+
union_specifier: $ => prec.right(seq(
|
|
489
|
+
'union',
|
|
490
|
+
optional($.attribute_specifier),
|
|
491
|
+
optional($.ms_declspec_modifier),
|
|
492
|
+
choice(
|
|
493
|
+
seq(
|
|
494
|
+
field('name', $._type_identifier),
|
|
495
|
+
field('body', optional($.field_declaration_list)),
|
|
496
|
+
),
|
|
497
|
+
field('body', $.field_declaration_list),
|
|
498
|
+
),
|
|
499
|
+
optional($.attribute_specifier),
|
|
500
|
+
)),
|
|
501
|
+
|
|
502
|
+
protocol_forward_declaration: $ => seq(
|
|
503
|
+
repeat($._declaration_modifiers),
|
|
504
|
+
'@protocol',
|
|
505
|
+
commaSep1($.identifier),
|
|
506
|
+
';',
|
|
507
|
+
),
|
|
508
|
+
|
|
509
|
+
class_declaration: $ => seq(
|
|
510
|
+
'@',
|
|
511
|
+
'class',
|
|
512
|
+
commaSep1(seq($.identifier, optional($.parameterized_arguments))),
|
|
513
|
+
';',
|
|
514
|
+
),
|
|
515
|
+
|
|
516
|
+
class_interface: $ => seq(
|
|
517
|
+
$._class_interface_header,
|
|
518
|
+
optional($._type_params),
|
|
519
|
+
optional($._class_interface_inheritance),
|
|
520
|
+
optional($.parameterized_arguments),
|
|
521
|
+
optional($.instance_variables),
|
|
522
|
+
repeat($.interface_declaration),
|
|
523
|
+
'@end',
|
|
524
|
+
),
|
|
525
|
+
|
|
526
|
+
_class_interface_header: $ => seq(
|
|
527
|
+
repeat($._declaration_modifiers),
|
|
528
|
+
'@interface',
|
|
529
|
+
$.identifier,
|
|
530
|
+
optional(';'),
|
|
531
|
+
),
|
|
532
|
+
|
|
533
|
+
_type_params: $ => prec.right(choice(
|
|
534
|
+
seq($.generic_arguments, optional($.parameterized_arguments)),
|
|
535
|
+
$.parameterized_arguments,
|
|
536
|
+
)),
|
|
537
|
+
|
|
538
|
+
_class_interface_inheritance: $ => prec.right(1, choice(
|
|
539
|
+
seq(':', field('superclass', $.identifier), optional($.parameterized_arguments)),
|
|
540
|
+
seq('(', field('category', optional($.identifier)), ')'),
|
|
541
|
+
)),
|
|
542
|
+
|
|
543
|
+
class_implementation: $ => seq(
|
|
544
|
+
$._class_implementation_header,
|
|
545
|
+
optional($._type_params),
|
|
546
|
+
optional($._class_implementation_inheritance),
|
|
547
|
+
optional($.instance_variables),
|
|
548
|
+
repeat($.implementation_definition),
|
|
549
|
+
'@end',
|
|
550
|
+
),
|
|
551
|
+
|
|
552
|
+
_class_implementation_header: $ => seq(
|
|
553
|
+
repeat($._declaration_modifiers),
|
|
554
|
+
'@implementation',
|
|
555
|
+
$.identifier,
|
|
556
|
+
optional(';'),
|
|
557
|
+
),
|
|
558
|
+
|
|
559
|
+
_class_implementation_inheritance: $ => prec(1, choice(
|
|
560
|
+
seq(':', field('superclass', $.identifier)),
|
|
561
|
+
seq('(', field('category', $.identifier), ')'),
|
|
562
|
+
)),
|
|
563
|
+
|
|
564
|
+
protocol_reference_list: $ => seq('<', commaSep1($.identifier), '>'),
|
|
565
|
+
|
|
566
|
+
parameterized_arguments: $ => prec(-1, seq(
|
|
567
|
+
'<',
|
|
568
|
+
choice(
|
|
569
|
+
commaSep1(seq(
|
|
570
|
+
commaSep1(seq(optional(choice('__covariant', '__contravariant')), $._type_identifier)),
|
|
571
|
+
optional(seq(':', $.type_name)),
|
|
572
|
+
)),
|
|
573
|
+
// commaSep1($._type_identifier),
|
|
574
|
+
commaSep1($.type_name),
|
|
575
|
+
),
|
|
576
|
+
'>',
|
|
577
|
+
)),
|
|
578
|
+
|
|
579
|
+
generic_arguments: $ => prec.right(seq('(', commaSep1($._type_identifier), ')')),
|
|
580
|
+
|
|
581
|
+
instance_variables: $ => seq(
|
|
582
|
+
'{',
|
|
583
|
+
repeat(seq(
|
|
584
|
+
optional(choice($.attribute_specifier, $.attribute_declaration)),
|
|
585
|
+
$.instance_variable,
|
|
586
|
+
)),
|
|
587
|
+
'}',
|
|
588
|
+
optional(';'),
|
|
589
|
+
),
|
|
590
|
+
|
|
591
|
+
instance_variable: $ => choice(
|
|
592
|
+
$.visibility_specification,
|
|
593
|
+
$.struct_declaration,
|
|
594
|
+
$.atomic_declaration,
|
|
595
|
+
$.preproc_ifdef,
|
|
596
|
+
$.preproc_if,
|
|
597
|
+
),
|
|
598
|
+
|
|
599
|
+
visibility_specification: _ => choice(
|
|
600
|
+
'@private',
|
|
601
|
+
'@protected',
|
|
602
|
+
'@package',
|
|
603
|
+
'@public',
|
|
604
|
+
),
|
|
605
|
+
|
|
606
|
+
protocol_declaration: $ => seq(
|
|
607
|
+
repeat($._declaration_modifiers),
|
|
608
|
+
'@protocol',
|
|
609
|
+
$.identifier,
|
|
610
|
+
optional($.protocol_reference_list),
|
|
611
|
+
repeat($.interface_declaration),
|
|
612
|
+
repeat($.qualified_protocol_interface_declaration),
|
|
613
|
+
'@end',
|
|
614
|
+
),
|
|
615
|
+
|
|
616
|
+
compatibility_alias_declaration: $ => seq(
|
|
617
|
+
'@compatibility_alias',
|
|
618
|
+
field('class', $.identifier),
|
|
619
|
+
field('alias', $.identifier),
|
|
620
|
+
';',
|
|
621
|
+
),
|
|
622
|
+
|
|
623
|
+
interface_declaration: $ => choice(
|
|
624
|
+
$.declaration,
|
|
625
|
+
$.property_declaration,
|
|
626
|
+
$.method_declaration,
|
|
627
|
+
$.function_definition,
|
|
628
|
+
$.type_definition,
|
|
629
|
+
alias($.preproc_if_in_interface_declaration, $.preproc_if),
|
|
630
|
+
$.preproc_def,
|
|
631
|
+
$.preproc_ifdef,
|
|
632
|
+
$.preproc_undef,
|
|
633
|
+
$.preproc_call,
|
|
634
|
+
seq($.struct_specifier, ';'),
|
|
635
|
+
),
|
|
636
|
+
|
|
637
|
+
qualified_protocol_interface_declaration: $ => choice(
|
|
638
|
+
seq('@optional', repeat($.interface_declaration)),
|
|
639
|
+
seq('@required', repeat($.interface_declaration)),
|
|
640
|
+
),
|
|
641
|
+
|
|
642
|
+
implementation_definition: $ => prec(1, choice(
|
|
643
|
+
$.function_definition,
|
|
644
|
+
$.declaration,
|
|
645
|
+
$.property_implementation,
|
|
646
|
+
seq($.struct_specifier, ';'),
|
|
647
|
+
$.method_definition,
|
|
648
|
+
$.preproc_function_def,
|
|
649
|
+
$.macro_type_specifier,
|
|
650
|
+
$.type_definition,
|
|
651
|
+
alias($.preproc_if_in_implementation_definition, $.preproc_if),
|
|
652
|
+
$.preproc_ifdef,
|
|
653
|
+
$.preproc_undef,
|
|
654
|
+
$.preproc_def,
|
|
655
|
+
$.preproc_call,
|
|
656
|
+
)),
|
|
657
|
+
|
|
658
|
+
property_implementation: $ => choice(
|
|
659
|
+
seq(
|
|
660
|
+
'@synthesize',
|
|
661
|
+
commaSep1(seq($.identifier, optional(seq('=', $.identifier)))),
|
|
662
|
+
';',
|
|
663
|
+
),
|
|
664
|
+
seq('@dynamic', optional('(class)'), commaSep1($.identifier), ';'),
|
|
665
|
+
),
|
|
666
|
+
|
|
667
|
+
method_definition: $ => seq(
|
|
668
|
+
choice('+', '-'), // class = '+', instance = '-'
|
|
669
|
+
optional($.method_type),
|
|
670
|
+
optional($.attribute_specifier),
|
|
671
|
+
choice(
|
|
672
|
+
seq(
|
|
673
|
+
$.method_selector_no_list,
|
|
674
|
+
optional(seq(
|
|
675
|
+
$.method_parameter,
|
|
676
|
+
repeat(seq(optional($.method_selector), $.method_parameter)),
|
|
677
|
+
)),
|
|
678
|
+
),
|
|
679
|
+
seq(
|
|
680
|
+
$.method_parameter,
|
|
681
|
+
repeat(seq(optional($.method_selector), $.method_parameter)),
|
|
682
|
+
),
|
|
683
|
+
),
|
|
684
|
+
optional(seq(',', choice('...', commaSep1(alias($.c_method_parameter, $.method_parameter))))),
|
|
685
|
+
repeat($.declaration),
|
|
686
|
+
repeat($._declaration_modifiers),
|
|
687
|
+
optional(';'),
|
|
688
|
+
$.compound_statement,
|
|
689
|
+
optional(';'),
|
|
690
|
+
),
|
|
691
|
+
|
|
692
|
+
method_type: $ => seq(
|
|
693
|
+
'(',
|
|
694
|
+
commaSep1(seq(optional($.attribute_specifier), choice($.type_name, $.parameterized_arguments))),
|
|
695
|
+
')',
|
|
696
|
+
),
|
|
697
|
+
|
|
698
|
+
method_selector: $ => prec.left(choice(
|
|
699
|
+
$.method_selector_no_list,
|
|
700
|
+
seq($.keyword_selector, ','),
|
|
701
|
+
)),
|
|
702
|
+
|
|
703
|
+
method_selector_no_list: $ => choice(
|
|
704
|
+
$.identifier,
|
|
705
|
+
$.keyword_selector,
|
|
706
|
+
seq($.keyword_selector, ',', '...'),
|
|
707
|
+
),
|
|
708
|
+
|
|
709
|
+
keyword_selector: $ => repeat1($.keyword_declarator),
|
|
710
|
+
|
|
711
|
+
keyword_declarator: $ => seq(
|
|
712
|
+
optional($.identifier),
|
|
713
|
+
':',
|
|
714
|
+
optional($.method_type),
|
|
715
|
+
$.identifier,
|
|
716
|
+
),
|
|
717
|
+
|
|
718
|
+
property_declaration: $ => (seq(
|
|
719
|
+
optional($._declaration_modifiers),
|
|
720
|
+
'@property',
|
|
721
|
+
optional($.property_attributes_declaration),
|
|
722
|
+
optional(choice($.attribute_specifier, $.attribute_declaration)),
|
|
723
|
+
choice($.struct_declaration, $.atomic_declaration),
|
|
724
|
+
)),
|
|
725
|
+
|
|
726
|
+
property_attributes_declaration: $ => seq(
|
|
727
|
+
'(',
|
|
728
|
+
commaSep($.property_attribute),
|
|
729
|
+
')',
|
|
730
|
+
),
|
|
731
|
+
|
|
732
|
+
property_attribute: $ => choice(
|
|
733
|
+
$.identifier,
|
|
734
|
+
seq($.identifier, '=', $.identifier, optional(':')),
|
|
735
|
+
),
|
|
736
|
+
|
|
737
|
+
method_declaration: $ => seq(
|
|
738
|
+
choice('+', '-'), // class = '+', instance = '-'
|
|
739
|
+
optional($.method_type),
|
|
740
|
+
optional(choice($.attribute_specifier, $.attribute_declaration)),
|
|
741
|
+
repeat1(choice(
|
|
742
|
+
seq(
|
|
743
|
+
$.method_selector,
|
|
744
|
+
optional($.attribute_specifier),
|
|
745
|
+
optional($.method_parameter),
|
|
746
|
+
),
|
|
747
|
+
$.method_parameter,
|
|
748
|
+
)),
|
|
749
|
+
optional(seq(',', choice('...', commaSep1(alias($.c_method_parameter, $.method_parameter))))),
|
|
750
|
+
repeat($._declaration_modifiers),
|
|
751
|
+
repeat1(prec.right(';')),
|
|
752
|
+
),
|
|
753
|
+
|
|
754
|
+
method_parameter: $ => prec.right(seq(
|
|
755
|
+
':',
|
|
756
|
+
optional($.method_type),
|
|
757
|
+
optional($._declaration_modifiers),
|
|
758
|
+
choice($.identifier, $.keyword_identifier),
|
|
759
|
+
repeat($._declaration_modifiers),
|
|
760
|
+
)),
|
|
761
|
+
|
|
762
|
+
c_method_parameter: $ => prec.left(seq(
|
|
763
|
+
$._declaration_specifiers,
|
|
764
|
+
commaSep1(prec.right(field('declarator', choice(
|
|
765
|
+
$._declarator,
|
|
766
|
+
$.init_declarator,
|
|
767
|
+
)))),
|
|
768
|
+
)),
|
|
769
|
+
|
|
770
|
+
struct_declaration: $ => seq(
|
|
771
|
+
repeat1($.specifier_qualifier),
|
|
772
|
+
commaSep1($.struct_declarator),
|
|
773
|
+
optional($._declaration_modifiers),
|
|
774
|
+
';',
|
|
775
|
+
),
|
|
776
|
+
|
|
777
|
+
atomic_declaration: $ => seq(
|
|
778
|
+
'_Atomic',
|
|
779
|
+
'(',
|
|
780
|
+
$.type_specifier,
|
|
781
|
+
')',
|
|
782
|
+
$._field_identifier,
|
|
783
|
+
';',
|
|
784
|
+
),
|
|
785
|
+
|
|
786
|
+
preproc_block: $ => prec.right(seq(
|
|
787
|
+
$.identifier,
|
|
788
|
+
'\n',
|
|
789
|
+
repeat($._block_item),
|
|
790
|
+
$.identifier,
|
|
791
|
+
'\n',
|
|
792
|
+
)),
|
|
793
|
+
|
|
794
|
+
specifier_qualifier: $ => prec.right(choice(
|
|
795
|
+
$.type_specifier,
|
|
796
|
+
$.type_qualifier,
|
|
797
|
+
$.protocol_qualifier,
|
|
798
|
+
)),
|
|
799
|
+
|
|
800
|
+
struct_declarator: $ => choice(
|
|
801
|
+
$._declarator,
|
|
802
|
+
seq(optional($._declarator), ':', $.expression),
|
|
803
|
+
),
|
|
804
|
+
|
|
805
|
+
field_declaration: $ => seq(
|
|
806
|
+
$._declaration_specifiers,
|
|
807
|
+
commaSep(seq(
|
|
808
|
+
field('declarator', choice($._field_declarator, $.enum_specifier)),
|
|
809
|
+
optional($.bitfield_clause),
|
|
810
|
+
)),
|
|
811
|
+
optional($.bitfield_clause),
|
|
812
|
+
optional($.attribute_specifier),
|
|
813
|
+
';',
|
|
814
|
+
),
|
|
815
|
+
|
|
816
|
+
function_declarator: $ => prec.right(1, seq(
|
|
817
|
+
field('declarator', $._declarator),
|
|
818
|
+
field('parameters', $.parameter_list),
|
|
819
|
+
optional($.gnu_asm_expression),
|
|
820
|
+
repeat($.attribute_specifier),
|
|
821
|
+
)),
|
|
822
|
+
function_field_declarator: $ => prec.right(1, seq(
|
|
823
|
+
field('declarator', $._field_declarator),
|
|
824
|
+
field('parameters', $.parameter_list),
|
|
825
|
+
repeat(choice($.attribute_specifier, $.type_qualifier)),
|
|
826
|
+
)),
|
|
827
|
+
function_type_declarator: $ => prec.right(1, seq(
|
|
828
|
+
field('declarator', $._type_declarator),
|
|
829
|
+
field('parameters', $.parameter_list),
|
|
830
|
+
repeat(choice($.attribute_specifier, $.type_qualifier)),
|
|
831
|
+
)),
|
|
832
|
+
abstract_function_declarator: $ => prec.right(1, seq(
|
|
833
|
+
field('declarator', optional($._abstract_declarator)),
|
|
834
|
+
field('parameters', $.parameter_list),
|
|
835
|
+
repeat(choice($.attribute_specifier, $.type_qualifier)),
|
|
836
|
+
)),
|
|
837
|
+
|
|
838
|
+
// This is missing binary expressions, others were kept so that macro code can be parsed better and code examples
|
|
839
|
+
_top_level_expression_statement: $ => seq(
|
|
840
|
+
optional($._expression_not_binary),
|
|
841
|
+
';',
|
|
842
|
+
),
|
|
843
|
+
|
|
844
|
+
try_statement: $ => seq(
|
|
845
|
+
choice('@try', '__try'),
|
|
846
|
+
$.compound_statement,
|
|
847
|
+
choice(
|
|
848
|
+
seq(repeat1($.catch_clause), optional($.finally_clause)),
|
|
849
|
+
$.finally_clause,
|
|
850
|
+
),
|
|
851
|
+
),
|
|
852
|
+
|
|
853
|
+
catch_clause: $ => seq(
|
|
854
|
+
choice('@catch', '__catch'),
|
|
855
|
+
optional(seq('(', choice('...', $.type_name), ')')),
|
|
856
|
+
$.compound_statement,
|
|
857
|
+
),
|
|
858
|
+
|
|
859
|
+
finally_clause: $ => seq(
|
|
860
|
+
choice('@finally', '__finally'),
|
|
861
|
+
$.compound_statement,
|
|
862
|
+
),
|
|
863
|
+
|
|
864
|
+
throw_statement: $ => seq(
|
|
865
|
+
'@throw',
|
|
866
|
+
optional($.expression),
|
|
867
|
+
';',
|
|
868
|
+
),
|
|
869
|
+
|
|
870
|
+
selector_expression: $ => prec.left(seq(
|
|
871
|
+
'@selector',
|
|
872
|
+
repeat1('('),
|
|
873
|
+
choice($.identifier, $.method_identifier, prec(-1, /[^)]*/)),
|
|
874
|
+
repeat1(')'),
|
|
875
|
+
)),
|
|
876
|
+
|
|
877
|
+
available_expression: $ => seq(
|
|
878
|
+
choice('@available', '__builtin_available'),
|
|
879
|
+
'(',
|
|
880
|
+
commaSep1(choice(
|
|
881
|
+
$.identifier,
|
|
882
|
+
seq($.identifier, $.version),
|
|
883
|
+
'*',
|
|
884
|
+
)),
|
|
885
|
+
')',
|
|
886
|
+
),
|
|
887
|
+
|
|
888
|
+
range_expression: $ => prec.right(seq($.expression, '...', $.expression)),
|
|
889
|
+
|
|
890
|
+
block_literal: $ => seq(
|
|
891
|
+
'^',
|
|
892
|
+
optional($.attribute_specifier),
|
|
893
|
+
optional($.type_name),
|
|
894
|
+
optional($.attribute_specifier),
|
|
895
|
+
optional($.parameter_list),
|
|
896
|
+
optional($.attribute_specifier),
|
|
897
|
+
$.compound_statement,
|
|
898
|
+
),
|
|
899
|
+
|
|
900
|
+
message_expression: $ => prec(C.PREC.CALL, seq(
|
|
901
|
+
'[',
|
|
902
|
+
field('receiver', choice($.expression, $.generic_specifier)),
|
|
903
|
+
repeat1(seq(
|
|
904
|
+
field('method', $.identifier),
|
|
905
|
+
repeat(seq(
|
|
906
|
+
':',
|
|
907
|
+
commaSep1($.expression),
|
|
908
|
+
)),
|
|
909
|
+
)),
|
|
910
|
+
']',
|
|
911
|
+
)),
|
|
912
|
+
|
|
913
|
+
parenthesized_expression: $ => seq(
|
|
914
|
+
'(',
|
|
915
|
+
choice($.expression, $.comma_expression, $.compound_statement),
|
|
916
|
+
')',
|
|
917
|
+
),
|
|
918
|
+
|
|
919
|
+
va_arg_expression: $ => seq('va_arg', '(', $.expression, ',', $.type_descriptor, ')'),
|
|
920
|
+
|
|
921
|
+
ms_asm_block: _ => seq(
|
|
922
|
+
'__asm',
|
|
923
|
+
'{',
|
|
924
|
+
/[^}]*/,
|
|
925
|
+
'}',
|
|
926
|
+
),
|
|
927
|
+
|
|
928
|
+
encode_expression: $ => seq('@encode', '(', $.type_name, ')'),
|
|
929
|
+
|
|
930
|
+
synchronized_statement: $ => seq('@synchronized', '(', commaSep1($.expression), ')', $.compound_statement),
|
|
931
|
+
|
|
932
|
+
parenthesized_declarator: $ => prec.dynamic(C.PREC.PAREN_DECLARATOR, seq(
|
|
933
|
+
'(',
|
|
934
|
+
repeat($._declaration_modifiers),
|
|
935
|
+
$._declarator,
|
|
936
|
+
')',
|
|
937
|
+
)),
|
|
938
|
+
parenthesized_field_declarator: $ => prec.dynamic(C.PREC.PAREN_DECLARATOR, seq(
|
|
939
|
+
'(',
|
|
940
|
+
repeat($._declaration_modifiers),
|
|
941
|
+
$._field_declarator,
|
|
942
|
+
')',
|
|
943
|
+
)),
|
|
944
|
+
parenthesized_type_declarator: $ => prec.dynamic(C.PREC.PAREN_DECLARATOR, seq(
|
|
945
|
+
'(',
|
|
946
|
+
repeat($._declaration_modifiers),
|
|
947
|
+
$._type_declarator,
|
|
948
|
+
')',
|
|
949
|
+
)),
|
|
950
|
+
abstract_parenthesized_declarator: $ => prec(1, seq(
|
|
951
|
+
'(',
|
|
952
|
+
repeat($._declaration_modifiers),
|
|
953
|
+
$._abstract_declarator,
|
|
954
|
+
')',
|
|
955
|
+
)),
|
|
956
|
+
|
|
957
|
+
pointer_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
958
|
+
optional($.ms_based_modifier),
|
|
959
|
+
'*',
|
|
960
|
+
repeat($.ms_pointer_modifier),
|
|
961
|
+
repeat($._declaration_modifiers),
|
|
962
|
+
field('declarator', $._declarator),
|
|
963
|
+
))),
|
|
964
|
+
pointer_field_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
965
|
+
optional($.ms_based_modifier),
|
|
966
|
+
'*',
|
|
967
|
+
repeat($.ms_pointer_modifier),
|
|
968
|
+
repeat($._declaration_modifiers),
|
|
969
|
+
field('declarator', $._field_declarator),
|
|
970
|
+
))),
|
|
971
|
+
pointer_type_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
972
|
+
optional($.ms_based_modifier),
|
|
973
|
+
'*',
|
|
974
|
+
repeat($.ms_pointer_modifier),
|
|
975
|
+
repeat($._declaration_modifiers),
|
|
976
|
+
field('declarator', $._type_declarator),
|
|
977
|
+
))),
|
|
978
|
+
abstract_pointer_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
979
|
+
'*',
|
|
980
|
+
repeat($._declaration_modifiers),
|
|
981
|
+
field('declarator', optional($._abstract_declarator)),
|
|
982
|
+
))),
|
|
983
|
+
block_pointer_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
984
|
+
'^',
|
|
985
|
+
repeat($.type_qualifier),
|
|
986
|
+
field('declarator', $._declarator),
|
|
987
|
+
))),
|
|
988
|
+
block_pointer_field_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
989
|
+
'^',
|
|
990
|
+
repeat($.type_qualifier),
|
|
991
|
+
field('declarator', $._field_declarator),
|
|
992
|
+
))),
|
|
993
|
+
block_pointer_type_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
994
|
+
'^',
|
|
995
|
+
repeat($.type_qualifier),
|
|
996
|
+
field('declarator', $._type_declarator),
|
|
997
|
+
))),
|
|
998
|
+
abstract_block_pointer_declarator: $ => prec.dynamic(1, prec.right(seq(
|
|
999
|
+
'^',
|
|
1000
|
+
repeat($.type_qualifier),
|
|
1001
|
+
field('declarator', optional($._abstract_declarator)),
|
|
1002
|
+
))),
|
|
1003
|
+
|
|
1004
|
+
init_declarator: $ => seq(
|
|
1005
|
+
field('declarator', $._declarator),
|
|
1006
|
+
optional($.attribute_specifier),
|
|
1007
|
+
'=',
|
|
1008
|
+
field('value', choice($.initializer_list, $.expression)),
|
|
1009
|
+
),
|
|
1010
|
+
|
|
1011
|
+
generic_specifier: $ => prec.right(seq(
|
|
1012
|
+
$._type_identifier,
|
|
1013
|
+
repeat1(seq(
|
|
1014
|
+
'<',
|
|
1015
|
+
commaSep1($.type_name),
|
|
1016
|
+
'>',
|
|
1017
|
+
)),
|
|
1018
|
+
)),
|
|
1019
|
+
|
|
1020
|
+
type_specifier: ($, original) => choice(
|
|
1021
|
+
original,
|
|
1022
|
+
$.typedefed_specifier,
|
|
1023
|
+
$.generic_specifier,
|
|
1024
|
+
$.typeof_specifier,
|
|
1025
|
+
$.array_type_specifier,
|
|
1026
|
+
),
|
|
1027
|
+
|
|
1028
|
+
typedefed_identifier: _ => choice(
|
|
1029
|
+
'BOOL',
|
|
1030
|
+
'IMP',
|
|
1031
|
+
'SEL',
|
|
1032
|
+
'Class',
|
|
1033
|
+
'id',
|
|
1034
|
+
),
|
|
1035
|
+
|
|
1036
|
+
typedefed_specifier: $ => prec.right(seq(
|
|
1037
|
+
$.typedefed_identifier,
|
|
1038
|
+
optional($.protocol_reference_list),
|
|
1039
|
+
)),
|
|
1040
|
+
|
|
1041
|
+
array_type_specifier: $ => seq(
|
|
1042
|
+
$.type_specifier,
|
|
1043
|
+
'[',
|
|
1044
|
+
optional(seq(repeat($.type_qualifier), $.expression)),
|
|
1045
|
+
']',
|
|
1046
|
+
),
|
|
1047
|
+
|
|
1048
|
+
atdef_field: $ => seq('@defs', '(', $.identifier, ')'),
|
|
1049
|
+
|
|
1050
|
+
_field_declaration_list_item: $ => choice(
|
|
1051
|
+
$.field_declaration,
|
|
1052
|
+
$.preproc_def,
|
|
1053
|
+
$.preproc_function_def,
|
|
1054
|
+
$.preproc_call,
|
|
1055
|
+
alias($.preproc_if_in_field_declaration_list, $.preproc_if),
|
|
1056
|
+
alias($.preproc_ifdef_in_field_declaration_list, $.preproc_ifdef),
|
|
1057
|
+
$.atdef_field,
|
|
1058
|
+
),
|
|
1059
|
+
|
|
1060
|
+
protocol_qualifier: _ => choice(
|
|
1061
|
+
'out',
|
|
1062
|
+
'inout',
|
|
1063
|
+
'bycopy',
|
|
1064
|
+
'byref',
|
|
1065
|
+
'oneway',
|
|
1066
|
+
'in',
|
|
1067
|
+
),
|
|
1068
|
+
|
|
1069
|
+
type_name: $ => prec.right(seq(
|
|
1070
|
+
repeat1(prec.right(choice($.specifier_qualifier, $.attribute_specifier, $._declarator))),
|
|
1071
|
+
optional($.protocol_reference_list),
|
|
1072
|
+
optional($._abstract_declarator),
|
|
1073
|
+
)),
|
|
1074
|
+
|
|
1075
|
+
at_expression: $ => prec.right(seq(
|
|
1076
|
+
'@',
|
|
1077
|
+
$.expression,
|
|
1078
|
+
)),
|
|
1079
|
+
|
|
1080
|
+
number_literal: $ => {
|
|
1081
|
+
const separator = '\'';
|
|
1082
|
+
const hex = /[0-9a-fA-F]/;
|
|
1083
|
+
const decimal = /[0-9]/;
|
|
1084
|
+
const hexDigits = seq(repeat1(hex), repeat(seq(separator, repeat1(hex))));
|
|
1085
|
+
const decimalDigits = seq(repeat1(decimal), repeat(seq(separator, repeat1(decimal))));
|
|
1086
|
+
return token(seq(
|
|
1087
|
+
optional(/[-\+]/),
|
|
1088
|
+
optional(choice('0x', '0b')),
|
|
1089
|
+
choice(
|
|
1090
|
+
seq(
|
|
1091
|
+
choice(
|
|
1092
|
+
decimalDigits,
|
|
1093
|
+
seq('0b', decimalDigits),
|
|
1094
|
+
seq('0x', hexDigits),
|
|
1095
|
+
),
|
|
1096
|
+
optional(seq('.', optional(hexDigits))),
|
|
1097
|
+
),
|
|
1098
|
+
seq('.', decimalDigits),
|
|
1099
|
+
),
|
|
1100
|
+
optional(seq(
|
|
1101
|
+
/[eEpP]/,
|
|
1102
|
+
optional(seq(
|
|
1103
|
+
optional(/[-\+]/),
|
|
1104
|
+
hexDigits,
|
|
1105
|
+
)),
|
|
1106
|
+
)),
|
|
1107
|
+
repeat(choice('i', 'u', 'l', 'U', 'L', 'f', 'F')),
|
|
1108
|
+
));
|
|
1109
|
+
},
|
|
1110
|
+
|
|
1111
|
+
string_literal: $ => seq(
|
|
1112
|
+
choice(seq('@', '"'), 'L"', 'u"', 'U"', 'u8"', '"'),
|
|
1113
|
+
repeat(choice(
|
|
1114
|
+
alias(token.immediate(prec(1, /[^\\"\n]+/)), $.string_content),
|
|
1115
|
+
$.escape_sequence,
|
|
1116
|
+
)),
|
|
1117
|
+
'"',
|
|
1118
|
+
),
|
|
1119
|
+
|
|
1120
|
+
dictionary_literal: $ => seq(
|
|
1121
|
+
'@',
|
|
1122
|
+
'{',
|
|
1123
|
+
optional(seq(
|
|
1124
|
+
commaSep1($.dictionary_pair),
|
|
1125
|
+
optional(','),
|
|
1126
|
+
)),
|
|
1127
|
+
'}',
|
|
1128
|
+
),
|
|
1129
|
+
|
|
1130
|
+
dictionary_pair: $ => seq($.expression, ':', $.expression),
|
|
1131
|
+
|
|
1132
|
+
array_literal: $ => seq(
|
|
1133
|
+
'@',
|
|
1134
|
+
'[',
|
|
1135
|
+
optional(seq(
|
|
1136
|
+
commaSep1($.expression),
|
|
1137
|
+
optional(','),
|
|
1138
|
+
)),
|
|
1139
|
+
']',
|
|
1140
|
+
),
|
|
1141
|
+
|
|
1142
|
+
identifier: _ =>
|
|
1143
|
+
/(\$|\p{XID_Start}|_|\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})(\$|\p{XID_Continue}|\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})*/u,
|
|
1144
|
+
|
|
1145
|
+
method_identifier: $ => prec.right(seq(
|
|
1146
|
+
optional($.identifier),
|
|
1147
|
+
repeat1(token.immediate(':')),
|
|
1148
|
+
repeat(seq(
|
|
1149
|
+
$.identifier,
|
|
1150
|
+
repeat1(token.immediate(':')),
|
|
1151
|
+
)),
|
|
1152
|
+
)),
|
|
1153
|
+
|
|
1154
|
+
keyword_identifier: $ => alias(
|
|
1155
|
+
prec(-3,
|
|
1156
|
+
choice(
|
|
1157
|
+
'id',
|
|
1158
|
+
'in',
|
|
1159
|
+
'struct',
|
|
1160
|
+
'const',
|
|
1161
|
+
),
|
|
1162
|
+
),
|
|
1163
|
+
$.identifier,
|
|
1164
|
+
),
|
|
1165
|
+
},
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
*
|
|
1170
|
+
* @param {string} suffix
|
|
1171
|
+
*
|
|
1172
|
+
* @param {any} content
|
|
1173
|
+
*
|
|
1174
|
+
* @returns {any}
|
|
1175
|
+
*/
|
|
1176
|
+
function preprocIf(suffix, content) {
|
|
1177
|
+
/**
|
|
1178
|
+
*
|
|
1179
|
+
* @param {GrammarSymbols<string>} $
|
|
1180
|
+
*
|
|
1181
|
+
* @returns {ChoiceRule}
|
|
1182
|
+
*/
|
|
1183
|
+
function elseBlock($) {
|
|
1184
|
+
return choice(
|
|
1185
|
+
suffix ? alias($['preproc_else' + suffix], $.preproc_else) : $.preproc_else,
|
|
1186
|
+
suffix ? alias($['preproc_elif' + suffix], $.preproc_elif) : $.preproc_elif,
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
return {
|
|
1191
|
+
['preproc_if' + suffix]: $ => seq(
|
|
1192
|
+
preprocessor('if'),
|
|
1193
|
+
field('condition', $._preproc_expression),
|
|
1194
|
+
'\n',
|
|
1195
|
+
repeat(prec(2, content($))),
|
|
1196
|
+
field('alternative', optional(elseBlock($))),
|
|
1197
|
+
preprocessor('endif'),
|
|
1198
|
+
),
|
|
1199
|
+
|
|
1200
|
+
['preproc_ifdef' + suffix]: $ => seq(
|
|
1201
|
+
choice(preprocessor('ifdef'), preprocessor('ifndef')),
|
|
1202
|
+
field('name', $.identifier),
|
|
1203
|
+
repeat(prec(2, content($))),
|
|
1204
|
+
field('alternative', optional(choice(elseBlock($), $.preproc_elifdef))),
|
|
1205
|
+
preprocessor('endif'),
|
|
1206
|
+
),
|
|
1207
|
+
|
|
1208
|
+
['preproc_else' + suffix]: $ => seq(
|
|
1209
|
+
preprocessor('else'),
|
|
1210
|
+
repeat(prec(2, content($))),
|
|
1211
|
+
),
|
|
1212
|
+
|
|
1213
|
+
['preproc_elif' + suffix]: $ => seq(
|
|
1214
|
+
preprocessor('elif'),
|
|
1215
|
+
field('condition', $._preproc_expression),
|
|
1216
|
+
'\n',
|
|
1217
|
+
repeat(prec(2, content($))),
|
|
1218
|
+
field('alternative', optional(elseBlock($))),
|
|
1219
|
+
),
|
|
1220
|
+
|
|
1221
|
+
['preproc_elifdef' + suffix]: $ => seq(
|
|
1222
|
+
choice(preprocessor('elifdef'), preprocessor('elifndef')),
|
|
1223
|
+
field('name', $.identifier),
|
|
1224
|
+
repeat(prec(2, content($))),
|
|
1225
|
+
field('alternative', optional(elseBlock($))),
|
|
1226
|
+
),
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Creates a preprocessor regex rule
|
|
1233
|
+
*
|
|
1234
|
+
* @param {RegExp | Rule | string} command
|
|
1235
|
+
*
|
|
1236
|
+
* @returns {AliasRule}
|
|
1237
|
+
*/
|
|
1238
|
+
function preprocessor(command) {
|
|
1239
|
+
return alias(new RegExp('#[ \t]*' + command), '#' + command);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* Creates a rule to optionally match one or more of the rules separated by a comma
|
|
1244
|
+
*
|
|
1245
|
+
* @param {Rule} rule
|
|
1246
|
+
*
|
|
1247
|
+
* @returns {ChoiceRule}
|
|
1248
|
+
*/
|
|
1249
|
+
function commaSep(rule) {
|
|
1250
|
+
return optional(commaSep1(rule));
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* Creates a rule to match one or more of the rules separated by a comma
|
|
1255
|
+
*
|
|
1256
|
+
* @param {Rule} rule
|
|
1257
|
+
*
|
|
1258
|
+
* @returns {SeqRule}
|
|
1259
|
+
*/
|
|
1260
|
+
function commaSep1(rule) {
|
|
1261
|
+
return seq(rule, repeat(seq(',', rule)));
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Creates a rule to match optionally match one or more of the rules
|
|
1266
|
+
* separated by a comma and optionally ending with a comma
|
|
1267
|
+
*
|
|
1268
|
+
* @param {Rule} rule
|
|
1269
|
+
*
|
|
1270
|
+
* @returns {ChoiceRule}
|
|
1271
|
+
*/
|
|
1272
|
+
function optionalCommaSep(rule) {
|
|
1273
|
+
return optional(optionalCommaSep1(rule));
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Creates a rule to match one or more of the rules separated by a comma
|
|
1278
|
+
* and optionally ending with a comma
|
|
1279
|
+
*
|
|
1280
|
+
* @param {Rule} rule
|
|
1281
|
+
*
|
|
1282
|
+
* @returns {SeqRule}
|
|
1283
|
+
*/
|
|
1284
|
+
function optionalCommaSep1(rule) {
|
|
1285
|
+
return seq(rule, repeat(seq(optional(','), rule)));
|
|
1286
|
+
}
|