gitnexus 1.6.4-rc.2 → 1.6.4-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/README.md +35 -0
- package/dist/_shared/index.d.ts +1 -1
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js +1 -1
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.d.ts +22 -14
- package/dist/_shared/scope-resolution/finalize-algorithm.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.js +298 -37
- package/dist/_shared/scope-resolution/finalize-algorithm.js.map +1 -1
- package/dist/_shared/scope-resolution/scope-tree.d.ts +23 -1
- package/dist/_shared/scope-resolution/scope-tree.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/scope-tree.js +36 -2
- package/dist/_shared/scope-resolution/scope-tree.js.map +1 -1
- package/dist/_shared/scope-resolution/types.d.ts +47 -3
- package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/types.js +10 -2
- package/dist/_shared/scope-resolution/types.js.map +1 -1
- package/dist/cli/analyze.d.ts +6 -0
- package/dist/cli/analyze.js +35 -0
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/cli/doctor.js +31 -0
- package/dist/cli/index.js +13 -0
- package/dist/cli/setup.js +2 -2
- package/dist/core/embeddings/config.d.ts +2 -0
- package/dist/core/embeddings/config.js +36 -0
- package/dist/core/embeddings/embedder.js +11 -6
- package/dist/core/embeddings/embedding-pipeline.d.ts +7 -1
- package/dist/core/embeddings/embedding-pipeline.js +93 -29
- package/dist/core/embeddings/exact-search.d.ts +15 -0
- package/dist/core/embeddings/exact-search.js +27 -0
- package/dist/core/embeddings/types.d.ts +4 -0
- package/dist/core/embeddings/types.js +2 -0
- package/dist/core/group/config-parser.js +2 -0
- package/dist/core/group/matching.d.ts +3 -3
- package/dist/core/group/matching.js +46 -6
- package/dist/core/group/storage.js +2 -0
- package/dist/core/group/sync.js +1 -1
- package/dist/core/group/types.d.ts +18 -0
- package/dist/core/ingestion/call-processor.d.ts +3 -3
- package/dist/core/ingestion/call-processor.js +58 -65
- package/dist/core/ingestion/constants.d.ts +4 -3
- package/dist/core/ingestion/constants.js +8 -3
- package/dist/core/ingestion/finalize-orchestrator.js +6 -3
- package/dist/core/ingestion/heritage-processor.js +2 -2
- package/dist/core/ingestion/import-processor.js +1 -1
- package/dist/core/ingestion/language-provider.d.ts +8 -0
- package/dist/core/ingestion/languages/csharp/captures.js +4 -1
- package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +14 -13
- package/dist/core/ingestion/languages/csharp/namespace-siblings.js +62 -50
- package/dist/core/ingestion/languages/python/captures.js +9 -1
- package/dist/core/ingestion/languages/python/index.d.ts +1 -1
- package/dist/core/ingestion/languages/python/index.js +1 -1
- package/dist/core/ingestion/languages/python/simple-hooks.d.ts +3 -1
- package/dist/core/ingestion/languages/python/simple-hooks.js +8 -0
- package/dist/core/ingestion/languages/python.js +28 -1
- package/dist/core/ingestion/languages/swift.js +14 -0
- package/dist/core/ingestion/languages/typescript/arity-metadata.d.ts +59 -0
- package/dist/core/ingestion/languages/typescript/arity-metadata.js +103 -0
- package/dist/core/ingestion/languages/typescript/arity.d.ts +37 -0
- package/dist/core/ingestion/languages/typescript/arity.js +54 -0
- package/dist/core/ingestion/languages/typescript/cache-stats.d.ts +17 -0
- package/dist/core/ingestion/languages/typescript/cache-stats.js +28 -0
- package/dist/core/ingestion/languages/typescript/captures.d.ts +28 -0
- package/dist/core/ingestion/languages/typescript/captures.js +451 -0
- package/dist/core/ingestion/languages/typescript/import-decomposer.d.ts +49 -0
- package/dist/core/ingestion/languages/typescript/import-decomposer.js +371 -0
- package/dist/core/ingestion/languages/typescript/import-target.d.ts +50 -0
- package/dist/core/ingestion/languages/typescript/import-target.js +61 -0
- package/dist/core/ingestion/languages/typescript/index.d.ts +94 -0
- package/dist/core/ingestion/languages/typescript/index.js +94 -0
- package/dist/core/ingestion/languages/typescript/interpret.d.ts +35 -0
- package/dist/core/ingestion/languages/typescript/interpret.js +317 -0
- package/dist/core/ingestion/languages/typescript/merge-bindings.d.ts +62 -0
- package/dist/core/ingestion/languages/typescript/merge-bindings.js +158 -0
- package/dist/core/ingestion/languages/typescript/query.d.ts +77 -0
- package/dist/core/ingestion/languages/typescript/query.js +778 -0
- package/dist/core/ingestion/languages/typescript/receiver-binding.d.ts +59 -0
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +171 -0
- package/dist/core/ingestion/languages/typescript/scope-resolver.d.ts +16 -0
- package/dist/core/ingestion/languages/typescript/scope-resolver.js +113 -0
- package/dist/core/ingestion/languages/typescript/simple-hooks.d.ts +71 -0
- package/dist/core/ingestion/languages/typescript/simple-hooks.js +131 -0
- package/dist/core/ingestion/languages/typescript.js +19 -0
- package/dist/core/ingestion/method-extractors/configs/swift.js +3 -4
- package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +14 -1
- package/dist/core/ingestion/parsing-processor.js +20 -9
- package/dist/core/ingestion/pipeline-phases/processes.js +9 -4
- package/dist/core/ingestion/pipeline-phases/tools.d.ts +1 -0
- package/dist/core/ingestion/pipeline-phases/tools.js +10 -4
- package/dist/core/ingestion/registry-primary-flag.d.ts +3 -1
- package/dist/core/ingestion/registry-primary-flag.js +4 -1
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +5 -2
- package/dist/core/ingestion/scope-extractor-bridge.js +7 -2
- package/dist/core/ingestion/scope-extractor.js +19 -18
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +73 -11
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +48 -10
- package/dist/core/ingestion/scope-resolution/passes/compound-receiver.js +283 -14
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.d.ts +23 -2
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +109 -37
- package/dist/core/ingestion/scope-resolution/passes/mro.js +3 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +13 -5
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +11 -2
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +2 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +8 -0
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +21 -5
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.d.ts +39 -0
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +65 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +54 -11
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +105 -30
- package/dist/core/ingestion/type-extractors/swift.js +7 -4
- package/dist/core/ingestion/utils/ast-helpers.d.ts +2 -0
- package/dist/core/ingestion/utils/ast-helpers.js +12 -0
- package/dist/core/ingestion/utils/env.d.ts +10 -0
- package/dist/core/ingestion/utils/env.js +14 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +1 -0
- package/dist/core/ingestion/workers/parse-worker.js +15 -9
- package/dist/core/ingestion/workers/worker-pool.d.ts +11 -4
- package/dist/core/ingestion/workers/worker-pool.js +244 -48
- package/dist/core/lbug/extension-loader.d.ts +86 -0
- package/dist/core/lbug/extension-loader.js +184 -0
- package/dist/core/lbug/lbug-adapter.d.ts +18 -17
- package/dist/core/lbug/lbug-adapter.js +45 -73
- package/dist/core/lbug/pool-adapter.js +10 -28
- package/dist/core/platform/capabilities.d.ts +24 -0
- package/dist/core/platform/capabilities.js +54 -0
- package/dist/core/run-analyze.js +36 -9
- package/dist/core/search/bm25-index.d.ts +0 -17
- package/dist/core/search/bm25-index.js +10 -118
- package/dist/core/search/fts-indexes.d.ts +1 -0
- package/dist/core/search/fts-indexes.js +7 -0
- package/dist/core/search/fts-schema.d.ts +6 -0
- package/dist/core/search/fts-schema.js +7 -0
- package/dist/mcp/core/embedder.js +11 -4
- package/dist/mcp/local/local-backend.js +50 -15
- package/dist/server/api.d.ts +5 -0
- package/dist/server/api.js +113 -0
- package/hooks/claude/gitnexus-hook.cjs +11 -1
- package/package.json +6 -5
- package/scripts/build-tree-sitter-dart.cjs +42 -0
- package/scripts/build-tree-sitter-proto.cjs +1 -1
- package/scripts/build.js +22 -2
- package/scripts/install-duckdb-extension.mjs +37 -0
- package/vendor/tree-sitter-dart/README.md +18 -0
- package/vendor/tree-sitter-dart/binding.gyp +31 -0
- package/vendor/tree-sitter-dart/bindings/node/binding.cc +20 -0
- package/vendor/tree-sitter-dart/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-dart/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-dart/grammar.js +2895 -0
- package/vendor/tree-sitter-dart/package.json +18 -0
- package/vendor/tree-sitter-dart/queries/highlights.scm +246 -0
- package/vendor/tree-sitter-dart/queries/tags.scm +92 -0
- package/vendor/tree-sitter-dart/queries/test.scm +1 -0
- package/vendor/tree-sitter-dart/src/grammar.json +12459 -0
- package/vendor/tree-sitter-dart/src/node-types.json +15055 -0
- package/vendor/tree-sitter-dart/src/parser.c +196127 -0
- package/vendor/tree-sitter-dart/src/scanner.c +130 -0
- package/vendor/tree-sitter-dart/src/tree_sitter/alloc.h +54 -0
- package/vendor/tree-sitter-dart/src/tree_sitter/array.h +290 -0
- package/vendor/tree-sitter-dart/src/tree_sitter/parser.h +265 -0
- package/vendor/tree-sitter-swift/LICENSE +21 -0
- package/vendor/tree-sitter-swift/README.md +139 -0
- package/vendor/tree-sitter-swift/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-swift/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-swift/package.json +28 -0
- package/vendor/tree-sitter-swift/prebuilds/darwin-arm64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/darwin-x64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/linux-arm64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/linux-x64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/win32-arm64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/prebuilds/win32-x64/tree-sitter-swift.node +0 -0
- package/vendor/tree-sitter-swift/src/node-types.json +30694 -0
- package/web/assets/agent-DaprsFSX.js +597 -0
- package/web/assets/architecture-YZFGNWBL-S5CXDPWN-DEdGaPg2.js +1 -0
- package/web/assets/architectureDiagram-EMZXCZ2Q-Domyk_gO.js +36 -0
- package/web/assets/blockDiagram-IGV67L2C-B_2kD7tM.js +132 -0
- package/web/assets/c4Diagram-DFAF54RM-BhJJW8Gg.js +10 -0
- package/web/assets/chunk-3GS5O3IE-jlWIjPsl.js +231 -0
- package/web/assets/chunk-3YCYZ6SJ-Blq_IzZs.js +1 -0
- package/web/assets/chunk-6NTNNK5N-DyPc58pp.js +1 -0
- package/web/assets/chunk-7RZVMHOQ-BdIU-RGO.js +321 -0
- package/web/assets/chunk-A34GCYZU-BI2i_LdU.js +1 -0
- package/web/assets/chunk-AEOMTBSW-D7qjBMHW.js +1 -0
- package/web/assets/chunk-CilyBKbf.js +1 -0
- package/web/assets/chunk-DJ7UZH7F-i11ywiBl.js +1 -0
- package/web/assets/chunk-DKKBVRCY-1SffGI1N.js +4 -0
- package/web/assets/chunk-DU5LTGQ6-DaPeiwD5.js +1 -0
- package/web/assets/chunk-FXACKDTF-uhhi2PC2.js +159 -0
- package/web/assets/chunk-H3VCZNTA-IchcISDt.js +1 -0
- package/web/assets/chunk-HN6EAY2L-D7ZFMNrB.js +1 -0
- package/web/assets/chunk-KSICW3F5-C2tZmXwv.js +15 -0
- package/web/assets/chunk-O5ABG6QK-Bt-Km84H.js +1 -0
- package/web/assets/chunk-PK6DOVAG-ChlWY0BQ.js +206 -0
- package/web/assets/chunk-RNJOYNJ4-B724K7cW.js +1 -0
- package/web/assets/chunk-RWUO3TPN-DYn1XriD.js +1 -0
- package/web/assets/chunk-TBF5ZNIQ-DKtDz6ae.js +1 -0
- package/web/assets/chunk-TU3PZOEN-DE5Qhc0N.js +1 -0
- package/web/assets/chunk-TYMNRAUI-g1h33cq-.js +1 -0
- package/web/assets/chunk-VELTKBKT-C9dVN39o.js +1 -0
- package/web/assets/chunk-W7ZLLLMY-Du-Hb9yb.js +1 -0
- package/web/assets/chunk-WSB5WSVC-B123clsZ.js +1 -0
- package/web/assets/chunk-XGPFEOL4-BR7Eue38.js +1 -0
- package/web/assets/classDiagram-PPOCWD7C-BglfKSs_.js +1 -0
- package/web/assets/classDiagram-v2-23LJLIIU-BSzTM28O.js +1 -0
- package/web/assets/context-builder-CqQNhRj1.js +15 -0
- package/web/assets/cose-bilkent-PNC4W37J-DCfErU-A.js +1 -0
- package/web/assets/dagre-E77IOHMT-tDRRhDoN.js +4 -0
- package/web/assets/diagram-H7BISOXX-CUVHlmAh.js +43 -0
- package/web/assets/diagram-JC5VWROH-BoyOxulB.js +24 -0
- package/web/assets/diagram-LXUTUG65-osr9hb7N.js +10 -0
- package/web/assets/diagram-WEHSV5V5-d8nUqS39.js +24 -0
- package/web/assets/erDiagram-GCSMX5X6-b-IwOhPS.js +85 -0
- package/web/assets/flowDiagram-OTCZ4VVT-Ott2Q0AP.js +162 -0
- package/web/assets/ganttDiagram-MUNLMDZQ-BYtgN_5s.js +292 -0
- package/web/assets/gitGraph-7Q5UKJZL-54BCDZD5-CFyBIGZq.js +1 -0
- package/web/assets/gitGraphDiagram-3HKGZ4G3-CsVD2gn4.js +106 -0
- package/web/assets/index-BleGLU8S.css +2 -0
- package/web/assets/index-C_xK08EW.js +885 -0
- package/web/assets/info-OMHHGYJF-BF2H5H6G-yjAxKEzh.js +1 -0
- package/web/assets/infoDiagram-MN7RKWGX-DXK0Unn5.js +2 -0
- package/web/assets/ishikawaDiagram-YMYX4NHK-CXsnC2FA.js +70 -0
- package/web/assets/journeyDiagram-SO5T7YLQ-BzZ07B-X.js +139 -0
- package/web/assets/kanban-definition-LJHFXRCJ-C6_EpAd9.js +89 -0
- package/web/assets/katex-GD7MH7QM-CJiOjBBJ.js +261 -0
- package/web/assets/mindmap-definition-2EUWGEK5-CCYGWZ1m.js +96 -0
- package/web/assets/packet-4T2RLAQJ-EV4IVRXR-B8k4E3IT.js +1 -0
- package/web/assets/pie-ZZUOXDRM-N23DN5KN-DdvfY118.js +1 -0
- package/web/assets/pieDiagram-3IATQBI2-RyvRlQb4.js +30 -0
- package/web/assets/quadrantDiagram-E256RVCF-Bfb6sxCx.js +7 -0
- package/web/assets/radar-PYXPWWZC-P6TP7ZYP-1EEDC_yU.js +1 -0
- package/web/assets/requirementDiagram-M5DCFWZL-DjvHDyvN.js +84 -0
- package/web/assets/sankeyDiagram-L3NBLAOT-CBCbbl8s.js +10 -0
- package/web/assets/sequenceDiagram-ZOUHS735-BscU8TUR.js +157 -0
- package/web/assets/stateDiagram-MLPALWAM-CJusEK2D.js +1 -0
- package/web/assets/stateDiagram-v2-B5LQ5ZB2-DImJ3PXD.js +1 -0
- package/web/assets/timeline-definition-5SPVSISX-DigPA1X8.js +120 -0
- package/web/assets/treeView-SZITEDCU-5DXDK3XO-CzPDt3aG.js +1 -0
- package/web/assets/treemap-W4RFUUIX-WYLRDWKO-B9Iqiorr.js +1 -0
- package/web/assets/vennDiagram-IE5QUKF5-C91UkZIf.js +34 -0
- package/web/assets/wardley-RL74JXVD-BCRCBASE-x42Qw7hp.js +1 -0
- package/web/assets/wardleyDiagram-XU3VSMPF-DloBhI0U.js +20 -0
- package/web/assets/xychartDiagram-ZHJ5623Y-BGWJvgwI.js +7 -0
- package/web/index.html +21 -0
- package/scripts/patch-tree-sitter-swift.cjs +0 -78
|
@@ -0,0 +1,2895 @@
|
|
|
1
|
+
/// <reference types="tree-sitter-cli/dsl" />
|
|
2
|
+
|
|
3
|
+
// Using the informal draft spec to support the newest features of dart
|
|
4
|
+
// https://spec.dart.dev/DartLangSpecDraft.pdf
|
|
5
|
+
|
|
6
|
+
const DIGITS = token(sep1(/[0-9]+/, /_+/))
|
|
7
|
+
const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, '_'))
|
|
8
|
+
|
|
9
|
+
//Everything above RelationalTypeCast was incremented from its original value
|
|
10
|
+
//This was to get type casting issues finally fixed.
|
|
11
|
+
|
|
12
|
+
const DART_PREC = {
|
|
13
|
+
IMPORT_EXPORT: 19,
|
|
14
|
+
TYPE_IDENTIFIER: 18, //was: 17
|
|
15
|
+
DOT_IDENTIFIER: 19, //was: 18
|
|
16
|
+
UNARY_POSTFIX: 17,
|
|
17
|
+
UNARY_PREFIX: 16,
|
|
18
|
+
Multiplicative: 15, // *, /, ˜/, % Left
|
|
19
|
+
Additive: 14, // +, - Left
|
|
20
|
+
Shift: 13, // <<, >>, >>> Left
|
|
21
|
+
TYPE_ARGUMENTS: 13,
|
|
22
|
+
Bitwise_AND: 12, // & Left
|
|
23
|
+
Bitwise_XOR: 11, // ˆ Left
|
|
24
|
+
Bitwise_Or: 10, // | Left
|
|
25
|
+
RelationalTypeCast: 9, // <, >, <=, >=, as, is, is! None 8
|
|
26
|
+
RelationalTypeTest: 9,
|
|
27
|
+
Relational: 8, // <, >, <=, >=, as, is, is! None 8
|
|
28
|
+
Equality: 7, // ==, != None 7
|
|
29
|
+
Logical_AND: 6, // AND && Left
|
|
30
|
+
Logical_OR: 5, // Or || Left
|
|
31
|
+
If: 4, //-null ?? Left
|
|
32
|
+
Conditional: 3, // e1?e2:e3 Right 3
|
|
33
|
+
Cascade: 2, // .. Left
|
|
34
|
+
Assignment: 1, // =, *=, /=, +=, -=, &=, ˆ=, etc. Right
|
|
35
|
+
BUILTIN: 0,
|
|
36
|
+
TRY: 0,
|
|
37
|
+
// Added by Ben for experimentation.
|
|
38
|
+
SELECTOR_IN_PRIMARY: 1,
|
|
39
|
+
SELECTOR_IN_ASSIGNMENT: 0,
|
|
40
|
+
TYPE_ARGS: 1
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// TODO: general things to add
|
|
44
|
+
// both string types
|
|
45
|
+
//get protocols in classes?
|
|
46
|
+
// todo: type test operators: as, is, and is!
|
|
47
|
+
//todo: assignment operators: ??=, and ~/=
|
|
48
|
+
//todo: ?? operator
|
|
49
|
+
// todo: cascade notation: dot dot accesses each object
|
|
50
|
+
//todo: conditional member access: blah?.foo
|
|
51
|
+
//todo: rethrow keyword
|
|
52
|
+
//todo: override operator notations
|
|
53
|
+
//todo: correct import statements to be strings
|
|
54
|
+
//todo: sync* and async* functions, plus yields
|
|
55
|
+
|
|
56
|
+
//DONE: override shorter constructor notations?
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
module.exports = grammar({
|
|
60
|
+
name: 'dart',
|
|
61
|
+
|
|
62
|
+
externals: $ => [
|
|
63
|
+
$._template_chars_double,
|
|
64
|
+
$._template_chars_single,
|
|
65
|
+
$._template_chars_double_single,
|
|
66
|
+
$._template_chars_single_single,
|
|
67
|
+
$._template_chars_raw_slash,
|
|
68
|
+
$._block_comment,
|
|
69
|
+
$._documentation_block_comment,
|
|
70
|
+
],
|
|
71
|
+
|
|
72
|
+
extras: $ => [
|
|
73
|
+
$.comment,
|
|
74
|
+
$.documentation_comment,
|
|
75
|
+
/\s/
|
|
76
|
+
],
|
|
77
|
+
|
|
78
|
+
supertypes: $ => [
|
|
79
|
+
// $._expression,
|
|
80
|
+
$._declaration,
|
|
81
|
+
$._statement,
|
|
82
|
+
$._literal,
|
|
83
|
+
// $._element
|
|
84
|
+
// $._primary_pattern
|
|
85
|
+
// $._primary,
|
|
86
|
+
// $._type,
|
|
87
|
+
],
|
|
88
|
+
|
|
89
|
+
inline: $ => [
|
|
90
|
+
$._ambiguous_name,
|
|
91
|
+
$._class_member_definition,
|
|
92
|
+
$._if_null_expression,
|
|
93
|
+
],
|
|
94
|
+
|
|
95
|
+
conflicts: $ => [
|
|
96
|
+
[$._record_literal_no_const, $.record_field],
|
|
97
|
+
[$.block, $.set_or_map_literal],
|
|
98
|
+
[$._type_name, $._primary, $.function_signature],
|
|
99
|
+
[$._primary, $._type_name],
|
|
100
|
+
[$._primary, $._simple_formal_parameter],
|
|
101
|
+
[$._primary, $._type_name, $._function_formal_parameter],
|
|
102
|
+
[$._primary, $.constructor_param],
|
|
103
|
+
[$._normal_formal_parameters],
|
|
104
|
+
[$._declared_identifier],
|
|
105
|
+
[$.equality_expression],
|
|
106
|
+
[$.record_type_field, $._function_formal_parameter, $._var_or_type],
|
|
107
|
+
[$.typed_identifier, $._var_or_type, $._function_formal_parameter],
|
|
108
|
+
[$._type_name, $._simple_formal_parameter],
|
|
109
|
+
[$._type_not_function, $._type_not_void],
|
|
110
|
+
[$.switch_statement_case],
|
|
111
|
+
// [$._argument_list],
|
|
112
|
+
[$.declaration, $._external_and_static],
|
|
113
|
+
[$.constructor_signature, $._formal_parameter_part],
|
|
114
|
+
// [$._type_not_function, $._type_not_void],
|
|
115
|
+
[$._cascade_subsection],
|
|
116
|
+
[$._expression],
|
|
117
|
+
// [$._real_expression, $._below_relational_expression],
|
|
118
|
+
[$._postfix_expression],
|
|
119
|
+
[$.pattern_variable_declaration, $._var_or_type],
|
|
120
|
+
[$._final_const_var_or_type, $.pattern_variable_declaration],
|
|
121
|
+
[$.type_arguments, $.relational_operator],
|
|
122
|
+
[$.prefix_operator, $.constant_pattern],
|
|
123
|
+
[$._primary, $.constant_pattern, $._type_name],
|
|
124
|
+
[$._literal, $.constant_pattern],
|
|
125
|
+
[$._primary, $.constant_pattern],
|
|
126
|
+
[$._final_var_or_type],
|
|
127
|
+
[$._primary, $.constant_pattern, $._type_name, $._simple_formal_parameter],
|
|
128
|
+
[$._parenthesized_pattern, $._pattern_field],
|
|
129
|
+
[$.record_type_field, $._var_or_type, $._final_var_or_type, $._function_formal_parameter],
|
|
130
|
+
[$._var_or_type, $._final_var_or_type],
|
|
131
|
+
[$._final_const_var_or_type, $._final_var_or_type],
|
|
132
|
+
[$._var_or_type, $._for_loop_parts, $.pattern_variable_declaration],
|
|
133
|
+
[$.pattern_variable_declaration, $._for_loop_parts, $._final_const_var_or_type],
|
|
134
|
+
[$._var_or_type, $._final_var_or_type, $._function_formal_parameter],
|
|
135
|
+
[$.set_or_map_literal, $.map_pattern],
|
|
136
|
+
[$.list_literal, $.list_pattern],
|
|
137
|
+
[$.constant_pattern, $._type_name],
|
|
138
|
+
[$._pattern_field, $.label],
|
|
139
|
+
[$.constructor_tearoff, $._identifier_or_new],
|
|
140
|
+
[$._primary, $.constant_pattern, $._simple_formal_parameter],
|
|
141
|
+
[$.record_type_field, $._final_var_or_type],
|
|
142
|
+
[$.set_or_map_literal, $.constant_pattern],
|
|
143
|
+
[$.list_literal, $.constant_pattern],
|
|
144
|
+
[$._var_or_type, $.function_signature],
|
|
145
|
+
[$._var_or_type, $._function_formal_parameter],
|
|
146
|
+
[$.relational_operator, $.type_arguments, $.type_parameters],
|
|
147
|
+
[$._var_or_type],
|
|
148
|
+
[$._final_const_var_or_type, $.const_object_expression],
|
|
149
|
+
[$._final_const_var_or_type],
|
|
150
|
+
[$.type_parameter, $._type_name],
|
|
151
|
+
[$._normal_formal_parameter],
|
|
152
|
+
[$._assignable_selector_part, $.selector],
|
|
153
|
+
[$._assignable_selector_part, $._postfix_expression],
|
|
154
|
+
[$._primary, $.assignable_expression],
|
|
155
|
+
[$._simple_formal_parameter, $.assignable_expression],
|
|
156
|
+
// [$._type_name, $._primary, $.assignable_expression],
|
|
157
|
+
[$.assignable_expression, $._postfix_expression],
|
|
158
|
+
// [$._type_name, $.assignable_expression],
|
|
159
|
+
// [$._type_name, $.function_signature],
|
|
160
|
+
[$._type_name, $._function_formal_parameter],
|
|
161
|
+
[$._type_name],
|
|
162
|
+
// [$.assignment_expression, $._expression],
|
|
163
|
+
[$._primary, $._type_name, $.assignable_expression],
|
|
164
|
+
[$._type_name, $.function_signature],
|
|
165
|
+
// [$.relational_operator, $._shift_operator],
|
|
166
|
+
[$.declaration, $._external],
|
|
167
|
+
[$.relational_expression],
|
|
168
|
+
[$._function_type_tail],
|
|
169
|
+
[$._type_not_void_not_function, $._function_type_tail],
|
|
170
|
+
[$._type_not_void],
|
|
171
|
+
[$._type_not_void_not_function],
|
|
172
|
+
[$.super_formal_parameter, $.unconditional_assignable_selector],
|
|
173
|
+
],
|
|
174
|
+
|
|
175
|
+
word: $ => $.identifier,
|
|
176
|
+
|
|
177
|
+
rules: {
|
|
178
|
+
|
|
179
|
+
// Page 188 libraryDeclaration
|
|
180
|
+
program: $ => seq(
|
|
181
|
+
optional($.script_tag),
|
|
182
|
+
optional($.library_name),
|
|
183
|
+
repeat($.import_or_export),
|
|
184
|
+
repeat($.part_directive),
|
|
185
|
+
repeat($.part_of_directive),
|
|
186
|
+
repeat($._top_level_definition),
|
|
187
|
+
),
|
|
188
|
+
|
|
189
|
+
// Page 187 topLevelDefinition
|
|
190
|
+
_top_level_definition: $ => choice(
|
|
191
|
+
$.class_definition,
|
|
192
|
+
$.mixin_declaration,
|
|
193
|
+
$.extension_declaration,
|
|
194
|
+
$.enum_declaration,
|
|
195
|
+
$.type_alias,
|
|
196
|
+
seq(
|
|
197
|
+
optional($._metadata),
|
|
198
|
+
optional($._external_builtin),
|
|
199
|
+
$.function_signature,
|
|
200
|
+
$._semicolon
|
|
201
|
+
),
|
|
202
|
+
seq(
|
|
203
|
+
optional($._metadata),
|
|
204
|
+
optional($._external_builtin),
|
|
205
|
+
$.getter_signature,
|
|
206
|
+
$._semicolon
|
|
207
|
+
),
|
|
208
|
+
seq(
|
|
209
|
+
optional($._metadata),
|
|
210
|
+
optional($._external_builtin),
|
|
211
|
+
$.setter_signature,
|
|
212
|
+
$._semicolon
|
|
213
|
+
),
|
|
214
|
+
seq(
|
|
215
|
+
optional($._metadata),
|
|
216
|
+
$.getter_signature,
|
|
217
|
+
$.function_body
|
|
218
|
+
),
|
|
219
|
+
seq(
|
|
220
|
+
optional($._metadata),
|
|
221
|
+
$.setter_signature,
|
|
222
|
+
$.function_body
|
|
223
|
+
),
|
|
224
|
+
seq(
|
|
225
|
+
optional($._metadata),
|
|
226
|
+
$.function_signature,
|
|
227
|
+
$.function_body
|
|
228
|
+
),
|
|
229
|
+
// final or const static final declaration list
|
|
230
|
+
seq(
|
|
231
|
+
optional($._metadata),
|
|
232
|
+
choice(
|
|
233
|
+
$.final_builtin,
|
|
234
|
+
$.const_builtin
|
|
235
|
+
),
|
|
236
|
+
optional($._type),
|
|
237
|
+
$.static_final_declaration_list,
|
|
238
|
+
$._semicolon
|
|
239
|
+
),
|
|
240
|
+
seq(
|
|
241
|
+
optional($._metadata),
|
|
242
|
+
$._late_builtin,
|
|
243
|
+
$.final_builtin,
|
|
244
|
+
optional($._type),
|
|
245
|
+
$.initialized_identifier_list,
|
|
246
|
+
$._semicolon
|
|
247
|
+
),
|
|
248
|
+
seq(
|
|
249
|
+
optional($._metadata),
|
|
250
|
+
optional($._late_builtin),
|
|
251
|
+
choice($._type, $.inferred_type),
|
|
252
|
+
$.initialized_identifier_list,
|
|
253
|
+
$._semicolon
|
|
254
|
+
)
|
|
255
|
+
),
|
|
256
|
+
|
|
257
|
+
/**************************************************************************************************
|
|
258
|
+
*********************************Literals**********************************************************
|
|
259
|
+
***************************************************************************************************
|
|
260
|
+
****These are the Literals from section 16.4-9 (Page 84-110) of the dart specification*************
|
|
261
|
+
***************************************************************************************************
|
|
262
|
+
***************************************************************************************************/
|
|
263
|
+
|
|
264
|
+
_bool_literal: $ => choice($.true, $.false),
|
|
265
|
+
|
|
266
|
+
_numeric_literal: $ => choice(
|
|
267
|
+
$.decimal_integer_literal,
|
|
268
|
+
$.decimal_floating_point_literal,
|
|
269
|
+
$.hex_integer_literal,
|
|
270
|
+
),
|
|
271
|
+
|
|
272
|
+
_literal: $ => choice(
|
|
273
|
+
$.null_literal,
|
|
274
|
+
$._bool_literal,
|
|
275
|
+
$._numeric_literal,
|
|
276
|
+
$.string_literal,
|
|
277
|
+
$.symbol_literal,
|
|
278
|
+
$.set_or_map_literal,
|
|
279
|
+
$.list_literal,
|
|
280
|
+
$.record_literal,
|
|
281
|
+
),
|
|
282
|
+
|
|
283
|
+
/****This is the symbol literals from section 16.8 (Page 99) of the dart specification****************/
|
|
284
|
+
symbol_literal: $ => seq('#', $.identifier),
|
|
285
|
+
//symbol literal can also be an operator?
|
|
286
|
+
|
|
287
|
+
/**************************************************************************************************
|
|
288
|
+
*********************************Numeric Literals**************************************************
|
|
289
|
+
***************************************************************************************************
|
|
290
|
+
****These are the Numeric Literals from section 16.5 (Page 84-85) of the dart specification********
|
|
291
|
+
***************************************************************************************************
|
|
292
|
+
***************************************************************************************************/
|
|
293
|
+
|
|
294
|
+
decimal_integer_literal: $ => token(DIGITS),
|
|
295
|
+
|
|
296
|
+
hex_integer_literal: $ => token(seq(
|
|
297
|
+
choice('0x', '0X'),
|
|
298
|
+
HEX_DIGITS
|
|
299
|
+
)),
|
|
300
|
+
|
|
301
|
+
decimal_floating_point_literal: $ => token(choice(
|
|
302
|
+
seq(DIGITS, '.', DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DIGITS))),
|
|
303
|
+
seq('.', DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DIGITS))),
|
|
304
|
+
seq(DIGITS, /[eE]/, optional(choice('-', '+')), DIGITS),
|
|
305
|
+
seq(DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DIGITS)))
|
|
306
|
+
)),
|
|
307
|
+
|
|
308
|
+
/**************************************************************************************************
|
|
309
|
+
*********************************Boolean Literals**************************************************
|
|
310
|
+
***************************************************************************************************
|
|
311
|
+
****These are the boolean from section 16.6 (Page 86) of the dart specification********************
|
|
312
|
+
***************************************************************************************************
|
|
313
|
+
***************************************************************************************************/
|
|
314
|
+
true: $ => prec(
|
|
315
|
+
DART_PREC.BUILTIN,
|
|
316
|
+
'true',
|
|
317
|
+
),
|
|
318
|
+
|
|
319
|
+
false: $ => prec(
|
|
320
|
+
DART_PREC.BUILTIN,
|
|
321
|
+
'false',
|
|
322
|
+
),
|
|
323
|
+
|
|
324
|
+
/**************************************************************************************************
|
|
325
|
+
*********************************String Parts******************************************************
|
|
326
|
+
***************************************************************************************************
|
|
327
|
+
****These are the parts of String from section 16.7 (Page 86-92) of the dart specification*********
|
|
328
|
+
***************************************************************************************************
|
|
329
|
+
***************************************************************************************************/
|
|
330
|
+
string_literal: $ => repeat1(
|
|
331
|
+
choice(
|
|
332
|
+
$._string_literal_double_quotes,
|
|
333
|
+
$._string_literal_single_quotes,
|
|
334
|
+
$._string_literal_double_quotes_multiple,
|
|
335
|
+
$._string_literal_single_quotes_multiple,
|
|
336
|
+
//raw, separate later
|
|
337
|
+
$._raw_string_literal_double_quotes,
|
|
338
|
+
$._raw_string_literal_single_quotes,
|
|
339
|
+
$._raw_string_literal_double_quotes_multiple,
|
|
340
|
+
$._raw_string_literal_single_quotes_multiple,
|
|
341
|
+
),
|
|
342
|
+
),
|
|
343
|
+
_string_literal_double_quotes: $ => seq(
|
|
344
|
+
'"',
|
|
345
|
+
repeat(
|
|
346
|
+
choice(
|
|
347
|
+
$._template_chars_double_single,
|
|
348
|
+
'\'',
|
|
349
|
+
$.escape_sequence,
|
|
350
|
+
$._sub_string_test,
|
|
351
|
+
$.template_substitution
|
|
352
|
+
)
|
|
353
|
+
),
|
|
354
|
+
'"'
|
|
355
|
+
),
|
|
356
|
+
_string_literal_single_quotes: $ => seq(
|
|
357
|
+
'\'',
|
|
358
|
+
repeat(choice(
|
|
359
|
+
$._template_chars_single_single,
|
|
360
|
+
'"',
|
|
361
|
+
$.escape_sequence,
|
|
362
|
+
$._sub_string_test,
|
|
363
|
+
$.template_substitution
|
|
364
|
+
)),
|
|
365
|
+
'\''
|
|
366
|
+
),
|
|
367
|
+
_string_literal_double_quotes_multiple: $ => prec.left(
|
|
368
|
+
seq(
|
|
369
|
+
'"""',
|
|
370
|
+
repeat(choice(
|
|
371
|
+
$._template_chars_double,
|
|
372
|
+
'\'',
|
|
373
|
+
'\"',
|
|
374
|
+
$.escape_sequence,
|
|
375
|
+
$._sub_string_test,
|
|
376
|
+
$.template_substitution
|
|
377
|
+
)),
|
|
378
|
+
'"""'
|
|
379
|
+
),
|
|
380
|
+
),
|
|
381
|
+
_string_literal_single_quotes_multiple: $ => prec.left(
|
|
382
|
+
seq(
|
|
383
|
+
'\'\'\'',
|
|
384
|
+
repeat(choice(
|
|
385
|
+
$._template_chars_single,
|
|
386
|
+
'"',
|
|
387
|
+
'\'',
|
|
388
|
+
$.escape_sequence,
|
|
389
|
+
$._sub_string_test,
|
|
390
|
+
$.template_substitution
|
|
391
|
+
)),
|
|
392
|
+
'\'\'\''
|
|
393
|
+
),
|
|
394
|
+
),
|
|
395
|
+
_raw_string_literal_double_quotes: $ => seq(
|
|
396
|
+
'r"',
|
|
397
|
+
repeat(choice(
|
|
398
|
+
$._template_chars_double_single,
|
|
399
|
+
// /[^\n"]*/,
|
|
400
|
+
'\'',
|
|
401
|
+
$._template_chars_raw_slash,
|
|
402
|
+
// '\\',
|
|
403
|
+
$._unused_escape_sequence,
|
|
404
|
+
$._sub_string_test,
|
|
405
|
+
'$'
|
|
406
|
+
)),
|
|
407
|
+
'"'
|
|
408
|
+
),
|
|
409
|
+
_raw_string_literal_single_quotes: $ => seq(
|
|
410
|
+
'r\'',
|
|
411
|
+
repeat(choice(
|
|
412
|
+
$._template_chars_single_single,
|
|
413
|
+
// /[^\n']/,
|
|
414
|
+
'"',
|
|
415
|
+
$._template_chars_raw_slash,
|
|
416
|
+
// '\\',
|
|
417
|
+
$._unused_escape_sequence,
|
|
418
|
+
$._sub_string_test,
|
|
419
|
+
'$'
|
|
420
|
+
)),
|
|
421
|
+
'\''
|
|
422
|
+
),
|
|
423
|
+
_raw_string_literal_double_quotes_multiple: $ => prec.left(
|
|
424
|
+
seq(
|
|
425
|
+
'r"""',
|
|
426
|
+
// $._triple_double_quote_end,
|
|
427
|
+
repeat(choice(
|
|
428
|
+
$._template_chars_double,
|
|
429
|
+
'\'',
|
|
430
|
+
// '\\',
|
|
431
|
+
$._template_chars_raw_slash,
|
|
432
|
+
'"',
|
|
433
|
+
$._unused_escape_sequence,
|
|
434
|
+
$._sub_string_test,
|
|
435
|
+
'$'
|
|
436
|
+
)),
|
|
437
|
+
'"""'
|
|
438
|
+
// $._triple_double_quote_end
|
|
439
|
+
),
|
|
440
|
+
),
|
|
441
|
+
_raw_string_literal_single_quotes_multiple: $ => prec.left(
|
|
442
|
+
seq(
|
|
443
|
+
'r\'\'\'',
|
|
444
|
+
// $._triple_quote_end,
|
|
445
|
+
repeat(choice(
|
|
446
|
+
$._template_chars_single,
|
|
447
|
+
'"',
|
|
448
|
+
'\'',
|
|
449
|
+
// '\\',
|
|
450
|
+
$._template_chars_raw_slash,
|
|
451
|
+
$._unused_escape_sequence,
|
|
452
|
+
$._sub_string_test,
|
|
453
|
+
'$'
|
|
454
|
+
)),
|
|
455
|
+
'\'\'\''
|
|
456
|
+
// $._triple_quote_end
|
|
457
|
+
),
|
|
458
|
+
),
|
|
459
|
+
_triple_quote_end: $ => token('\'\'\''),
|
|
460
|
+
_triple_double_quote_end: $ => token('"""'),
|
|
461
|
+
template_substitution: $ => seq(
|
|
462
|
+
'$',
|
|
463
|
+
choice(
|
|
464
|
+
seq('{',
|
|
465
|
+
$._expression,
|
|
466
|
+
'}'),
|
|
467
|
+
$.identifier_dollar_escaped
|
|
468
|
+
)
|
|
469
|
+
),
|
|
470
|
+
_sub_string_test: $ => seq('$', /[^a-zA-Z_{]/),
|
|
471
|
+
_string_interp: $ => /\$((\w+)|\{([^{}]+)\})/, // represents $word or ${word} for now
|
|
472
|
+
_unused_escape_sequence: $ => token.immediate(seq(
|
|
473
|
+
'\\',
|
|
474
|
+
choice(
|
|
475
|
+
/[^xu0-7]/,
|
|
476
|
+
/[0-7]{1,3}/,
|
|
477
|
+
/x[0-9a-fA-F]{2}/,
|
|
478
|
+
/u[0-9a-fA-F]{4}/,
|
|
479
|
+
/u\{[0-9a-fA-F]+\}/
|
|
480
|
+
)
|
|
481
|
+
)),
|
|
482
|
+
escape_sequence: $ => $._unused_escape_sequence,
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
/**************************************************************************************************
|
|
486
|
+
*********************************Collection Literals***********************************************
|
|
487
|
+
***************************************************************************************************
|
|
488
|
+
****These are the collection literals from section 16.9 (Page 92-108) of the dart specification****
|
|
489
|
+
***************************************************************************************************
|
|
490
|
+
***************************************************************************************************/
|
|
491
|
+
list_literal: $ => seq(
|
|
492
|
+
optional($.const_builtin), optional($.type_arguments), '[',
|
|
493
|
+
commaSepTrailingComma($._element),
|
|
494
|
+
']'
|
|
495
|
+
),
|
|
496
|
+
set_or_map_literal: $ => seq(
|
|
497
|
+
optional($.const_builtin), optional($.type_arguments), '{',
|
|
498
|
+
commaSepTrailingComma(
|
|
499
|
+
$._element
|
|
500
|
+
),
|
|
501
|
+
'}'
|
|
502
|
+
),
|
|
503
|
+
|
|
504
|
+
pair: $ => seq(
|
|
505
|
+
field('key', $._expression),
|
|
506
|
+
':',
|
|
507
|
+
field('value', $._expression)
|
|
508
|
+
),
|
|
509
|
+
// pair_or_element: $ => seq(
|
|
510
|
+
// field('key', $._expression),
|
|
511
|
+
// optional(
|
|
512
|
+
// seq(
|
|
513
|
+
// ':',
|
|
514
|
+
// field('value', $._expression)
|
|
515
|
+
// )
|
|
516
|
+
// )
|
|
517
|
+
// ),
|
|
518
|
+
|
|
519
|
+
_element: $ => choice(
|
|
520
|
+
$._expression,
|
|
521
|
+
$.pair,
|
|
522
|
+
$.spread_element,
|
|
523
|
+
$.if_element,
|
|
524
|
+
$.for_element
|
|
525
|
+
),
|
|
526
|
+
|
|
527
|
+
/****This is the null literal from section 16.4 (Page 84) of the dart specification****/
|
|
528
|
+
null_literal: $ => prec(
|
|
529
|
+
DART_PREC.BUILTIN,
|
|
530
|
+
'null',
|
|
531
|
+
),
|
|
532
|
+
|
|
533
|
+
/// Record literal (from Dart.g)
|
|
534
|
+
record_literal: $ => seq(
|
|
535
|
+
optional($.const_builtin),
|
|
536
|
+
$._record_literal_no_const,
|
|
537
|
+
),
|
|
538
|
+
|
|
539
|
+
_record_literal_no_const: $ => seq(
|
|
540
|
+
'(',
|
|
541
|
+
choice(
|
|
542
|
+
seq($.label, $._expression),
|
|
543
|
+
seq($._expression, ','),
|
|
544
|
+
commaSep2TrailingComma($.record_field),
|
|
545
|
+
),
|
|
546
|
+
')'
|
|
547
|
+
),
|
|
548
|
+
|
|
549
|
+
record_field: $ => seq(optional($.label), $._expression),
|
|
550
|
+
|
|
551
|
+
/**************************************************************************************************
|
|
552
|
+
*********************************Expressions*******************************************************
|
|
553
|
+
***************************************************************************************************
|
|
554
|
+
****These are the expressions from section 16.9 (Page 110-166) of the dart specification***********
|
|
555
|
+
***************************************************************************************************
|
|
556
|
+
***************************************************************************************************/
|
|
557
|
+
_expression: $ => choice(
|
|
558
|
+
$.pattern_assignment,
|
|
559
|
+
$.assignment_expression,
|
|
560
|
+
$.throw_expression,
|
|
561
|
+
$.rethrow_expression,
|
|
562
|
+
seq(
|
|
563
|
+
$._real_expression,
|
|
564
|
+
repeat($.cascade_section)
|
|
565
|
+
)
|
|
566
|
+
),
|
|
567
|
+
_expression_without_cascade: $ => choice(
|
|
568
|
+
$.assignment_expression_without_cascade,
|
|
569
|
+
$._real_expression,
|
|
570
|
+
$.throw_expression_without_cascade
|
|
571
|
+
),
|
|
572
|
+
_real_expression: $ => choice(
|
|
573
|
+
$.conditional_expression,
|
|
574
|
+
$.logical_or_expression,
|
|
575
|
+
$.if_null_expression,
|
|
576
|
+
$.additive_expression,
|
|
577
|
+
$.multiplicative_expression,
|
|
578
|
+
$.relational_expression,
|
|
579
|
+
$.equality_expression,
|
|
580
|
+
$.logical_and_expression,
|
|
581
|
+
$.bitwise_and_expression,
|
|
582
|
+
$.bitwise_or_expression,
|
|
583
|
+
$.bitwise_xor_expression,
|
|
584
|
+
$.shift_expression,
|
|
585
|
+
$.type_cast_expression,
|
|
586
|
+
$.type_test_expression,
|
|
587
|
+
$._unary_expression
|
|
588
|
+
),
|
|
589
|
+
|
|
590
|
+
// _below_relational_expression: $ => choice(
|
|
591
|
+
// // UNARY_POSTFIX: 16,
|
|
592
|
+
// // UNARY_PREFIX: 15,
|
|
593
|
+
// // Multiplicative: 14, // *, /, ˜/, % Left
|
|
594
|
+
// // Additive: 13, // +, - Left
|
|
595
|
+
// // Shift: 12, // <<, >>, >>> Left
|
|
596
|
+
// // Bitwise_AND: 11, // & Left
|
|
597
|
+
// // Bitwise_XOR: 10, // ˆ Left
|
|
598
|
+
// // Bitwise_Or: 9 , // | Left
|
|
599
|
+
// // $.type_cast_expression,
|
|
600
|
+
// $._unary_expression,
|
|
601
|
+
// $.multiplicative_expression,
|
|
602
|
+
// $.additive_expression,
|
|
603
|
+
// $.shift_expression,
|
|
604
|
+
// $.bitwise_and_expression,
|
|
605
|
+
// $.bitwise_or_expression,
|
|
606
|
+
// $.bitwise_xor_expression,
|
|
607
|
+
//
|
|
608
|
+
// ),
|
|
609
|
+
//
|
|
610
|
+
// _below_relational_type_cast_expression: $ => prec(
|
|
611
|
+
// DART_PREC.RelationalTypeCast,
|
|
612
|
+
// choice(
|
|
613
|
+
// // UNARY_POSTFIX: 16,
|
|
614
|
+
// // UNARY_PREFIX: 15,
|
|
615
|
+
// // Multiplicative: 14, // *, /, ˜/, % Left
|
|
616
|
+
// // Additive: 13, // +, - Left
|
|
617
|
+
// // Shift: 12, // <<, >>, >>> Left
|
|
618
|
+
// // Bitwise_AND: 11, // & Left
|
|
619
|
+
// // Bitwise_XOR: 10, // ˆ Left
|
|
620
|
+
// // Bitwise_Or: 9 , // | Left
|
|
621
|
+
// $._unary_expression,
|
|
622
|
+
// $.multiplicative_expression,
|
|
623
|
+
// $.additive_expression,
|
|
624
|
+
// $.shift_expression,
|
|
625
|
+
// $.bitwise_and_expression,
|
|
626
|
+
// $.bitwise_or_expression,
|
|
627
|
+
// $.bitwise_xor_expression,
|
|
628
|
+
//
|
|
629
|
+
// )
|
|
630
|
+
// ),
|
|
631
|
+
|
|
632
|
+
throw_expression: $ => seq(
|
|
633
|
+
'throw',
|
|
634
|
+
$._expression
|
|
635
|
+
),
|
|
636
|
+
throw_expression_without_cascade: $ => seq(
|
|
637
|
+
'throw',
|
|
638
|
+
$._expression_without_cascade
|
|
639
|
+
),
|
|
640
|
+
|
|
641
|
+
rethrow_expression: $ => $.rethrow_builtin,
|
|
642
|
+
|
|
643
|
+
/**************************************************************************************************
|
|
644
|
+
***********************Assignment Expressions*****************************************************
|
|
645
|
+
***************************************************************************************************
|
|
646
|
+
****These are the assignment expressions from section 16.34 (Page 159) of the dart DRAFT**********
|
|
647
|
+
* specification. (Very different from the formal spec in this instance)****************************
|
|
648
|
+
***************************************************************************************************
|
|
649
|
+
***************************************************************************************************/
|
|
650
|
+
|
|
651
|
+
assignment_expression: $ => prec.right(DART_PREC.Assignment, seq( //right
|
|
652
|
+
field('left', $.assignable_expression),
|
|
653
|
+
field('operator', $._assignment_operator),
|
|
654
|
+
field('right', $._expression)
|
|
655
|
+
)),
|
|
656
|
+
|
|
657
|
+
assignment_expression_without_cascade: $ => prec.right(DART_PREC.Assignment, seq( //right
|
|
658
|
+
field('left', $.assignable_expression),
|
|
659
|
+
field('operator', $._assignment_operator),
|
|
660
|
+
field('right', $._expression_without_cascade)
|
|
661
|
+
)),
|
|
662
|
+
|
|
663
|
+
assignable_expression: $ => choice(
|
|
664
|
+
seq($._primary, $._assignable_selector_part), // dart issue?
|
|
665
|
+
seq($.super, $.unconditional_assignable_selector),
|
|
666
|
+
seq($.constructor_invocation, $._assignable_selector_part),
|
|
667
|
+
$.identifier
|
|
668
|
+
),
|
|
669
|
+
_assignable_selector_part: $ => seq(
|
|
670
|
+
repeat($.selector),
|
|
671
|
+
$._assignable_selector
|
|
672
|
+
),
|
|
673
|
+
//'+=', '-=', '*=', '/=', '&=', '|=', '^=', '%=', '<<=', '>>=', '>>>=', '??='
|
|
674
|
+
//todo: use the op names in place of these.
|
|
675
|
+
_assignment_operator: $ => choice(
|
|
676
|
+
'=',
|
|
677
|
+
// additive operator
|
|
678
|
+
'+=',
|
|
679
|
+
'-=',
|
|
680
|
+
// multiplicative operator
|
|
681
|
+
'*=',
|
|
682
|
+
'/=',
|
|
683
|
+
'%=',
|
|
684
|
+
'~/=',
|
|
685
|
+
// shift operator
|
|
686
|
+
'<<=',
|
|
687
|
+
'>>=',
|
|
688
|
+
'>>>=',
|
|
689
|
+
'&=',
|
|
690
|
+
'^=',
|
|
691
|
+
'|=',
|
|
692
|
+
'??=',
|
|
693
|
+
),
|
|
694
|
+
|
|
695
|
+
// binary_expression: $ => choice(
|
|
696
|
+
// ...[
|
|
697
|
+
// ['>', PREC.REL],
|
|
698
|
+
// ['<', PREC.REL],
|
|
699
|
+
// ['==', PREC.REL],
|
|
700
|
+
// ['>=', PREC.REL],
|
|
701
|
+
// ['<=', PREC.REL],
|
|
702
|
+
// ['!=', PREC.REL],
|
|
703
|
+
// ['&&', PREC.AND],
|
|
704
|
+
// ['||', PREC.OR],
|
|
705
|
+
// ['+', PREC.PLUS],
|
|
706
|
+
// ['-', PREC.PLUS],
|
|
707
|
+
// ['*', PREC.TIMES],
|
|
708
|
+
// ['/', PREC.TIMES],
|
|
709
|
+
// ['&', PREC.AND],
|
|
710
|
+
// ['|', PREC.OR],
|
|
711
|
+
// ['^', PREC.OR],
|
|
712
|
+
// ['%', PREC.TIMES],
|
|
713
|
+
// ['<<', PREC.TIMES],
|
|
714
|
+
// ['>>', PREC.TIMES],
|
|
715
|
+
// ['>>>', PREC.TIMES],
|
|
716
|
+
// ].map(([operator, precedence]) =>
|
|
717
|
+
// prec.left(precedence, seq(
|
|
718
|
+
// field('left', $._expression),
|
|
719
|
+
// field('operator', operator),
|
|
720
|
+
// field('right', $._expression)
|
|
721
|
+
// ))
|
|
722
|
+
// )),
|
|
723
|
+
|
|
724
|
+
// instanceof_expression: $ => prec(PREC.REL, seq(
|
|
725
|
+
// field('left', $._expression),
|
|
726
|
+
// 'instanceof',
|
|
727
|
+
// field('right', $._type)
|
|
728
|
+
// )),
|
|
729
|
+
|
|
730
|
+
lambda_expression: $ => seq(
|
|
731
|
+
field('parameters', $.function_signature),
|
|
732
|
+
field(
|
|
733
|
+
'body',
|
|
734
|
+
$.function_body
|
|
735
|
+
)
|
|
736
|
+
),
|
|
737
|
+
|
|
738
|
+
function_expression: $ => seq(
|
|
739
|
+
field('parameters', $._formal_parameter_part),
|
|
740
|
+
field(
|
|
741
|
+
'body',
|
|
742
|
+
$.function_expression_body
|
|
743
|
+
)
|
|
744
|
+
),
|
|
745
|
+
|
|
746
|
+
inferred_parameters: $ => seq(
|
|
747
|
+
'(',
|
|
748
|
+
commaSep1($.identifier),
|
|
749
|
+
')'
|
|
750
|
+
),
|
|
751
|
+
|
|
752
|
+
if_null_expression: $ => prec.left( //left
|
|
753
|
+
DART_PREC.If,
|
|
754
|
+
seq(
|
|
755
|
+
field('first',
|
|
756
|
+
$._real_expression // logical_or_expression
|
|
757
|
+
),
|
|
758
|
+
$._if_null_expression
|
|
759
|
+
// optional(
|
|
760
|
+
// $._if_null_expression
|
|
761
|
+
// )
|
|
762
|
+
)
|
|
763
|
+
),
|
|
764
|
+
|
|
765
|
+
_if_null_expression: $ => repeat1(
|
|
766
|
+
seq(
|
|
767
|
+
'??',
|
|
768
|
+
field('second', $._real_expression)
|
|
769
|
+
)
|
|
770
|
+
),
|
|
771
|
+
|
|
772
|
+
conditional_expression: $ => prec.left( //left
|
|
773
|
+
DART_PREC.Conditional,
|
|
774
|
+
seq(
|
|
775
|
+
// $.if_null_expression,
|
|
776
|
+
$._real_expression,
|
|
777
|
+
seq(
|
|
778
|
+
'?',
|
|
779
|
+
field('consequence', $._expression_without_cascade),
|
|
780
|
+
':',
|
|
781
|
+
field('alternative', $._expression_without_cascade)
|
|
782
|
+
)
|
|
783
|
+
)
|
|
784
|
+
),
|
|
785
|
+
|
|
786
|
+
logical_or_expression: $ => prec.left( //left
|
|
787
|
+
DART_PREC.Logical_OR,
|
|
788
|
+
sep2($._real_expression, $.logical_or_operator)
|
|
789
|
+
),
|
|
790
|
+
|
|
791
|
+
logical_and_expression: $ => prec.left( //left
|
|
792
|
+
DART_PREC.Logical_AND,
|
|
793
|
+
sep2($._real_expression, $.logical_and_operator)
|
|
794
|
+
),
|
|
795
|
+
|
|
796
|
+
equality_expression: $ => prec( //neither
|
|
797
|
+
DART_PREC.Equality,
|
|
798
|
+
choice(
|
|
799
|
+
seq(
|
|
800
|
+
// $.relational_expression,
|
|
801
|
+
$._real_expression,
|
|
802
|
+
// optional(
|
|
803
|
+
//
|
|
804
|
+
// )
|
|
805
|
+
|
|
806
|
+
$.equality_operator,
|
|
807
|
+
$._real_expression
|
|
808
|
+
// $.relational_expression
|
|
809
|
+
|
|
810
|
+
),
|
|
811
|
+
seq(
|
|
812
|
+
$.super,
|
|
813
|
+
$.equality_operator,
|
|
814
|
+
// $.relational_expression
|
|
815
|
+
$._real_expression
|
|
816
|
+
)
|
|
817
|
+
)
|
|
818
|
+
),
|
|
819
|
+
|
|
820
|
+
equality_operator: $ => token(
|
|
821
|
+
choice(
|
|
822
|
+
'==',
|
|
823
|
+
'!='
|
|
824
|
+
)
|
|
825
|
+
),
|
|
826
|
+
type_cast_expression: $ => prec.left(
|
|
827
|
+
DART_PREC.RelationalTypeCast,
|
|
828
|
+
seq(
|
|
829
|
+
// $._below_relational_type_cast_expression,
|
|
830
|
+
$._real_expression,
|
|
831
|
+
$.type_cast,
|
|
832
|
+
)
|
|
833
|
+
),
|
|
834
|
+
type_test_expression: $ => prec(
|
|
835
|
+
DART_PREC.RelationalTypeTest,
|
|
836
|
+
seq(
|
|
837
|
+
// $._below_relational_type_cast_expression,
|
|
838
|
+
$._real_expression,
|
|
839
|
+
$.type_test,
|
|
840
|
+
)
|
|
841
|
+
),
|
|
842
|
+
// _raw_type_cast: $ => prec.right(
|
|
843
|
+
// seq(
|
|
844
|
+
// $._below_relational_type_cast_expression,
|
|
845
|
+
// $.type_cast,
|
|
846
|
+
// )
|
|
847
|
+
// ),
|
|
848
|
+
|
|
849
|
+
relational_expression: $ => prec( // neither
|
|
850
|
+
DART_PREC.Relational,
|
|
851
|
+
choice(
|
|
852
|
+
// $._raw_type_cast,
|
|
853
|
+
seq(
|
|
854
|
+
// $.bitwise_or_expression,
|
|
855
|
+
// $._below_relational_type_cast_expression,
|
|
856
|
+
// TODO: The spec says optional but it breaks tests, and I'm not sure in a good way.
|
|
857
|
+
// Modified to account for type casts being compared relationally!
|
|
858
|
+
// I am not certain this is what designers intended. (see other comments on github)
|
|
859
|
+
// optional(
|
|
860
|
+
$._real_expression,
|
|
861
|
+
$.relational_operator,
|
|
862
|
+
$._real_expression
|
|
863
|
+
// choice(
|
|
864
|
+
// $.type_test,
|
|
865
|
+
// $.type_cast,
|
|
866
|
+
// seq(
|
|
867
|
+
// $.relational_operator,
|
|
868
|
+
// $._real_expression
|
|
869
|
+
// )
|
|
870
|
+
// )
|
|
871
|
+
// ),
|
|
872
|
+
),
|
|
873
|
+
// seq(
|
|
874
|
+
// // $.bitwise_or_expression,
|
|
875
|
+
// choice(
|
|
876
|
+
// $._raw_type_cast,
|
|
877
|
+
// $._below_relational_type_cast_expression
|
|
878
|
+
// ),
|
|
879
|
+
// $.relational_operator,
|
|
880
|
+
// choice(
|
|
881
|
+
// $._raw_type_cast,
|
|
882
|
+
// $._below_relational_type_cast_expression
|
|
883
|
+
// )
|
|
884
|
+
// ),
|
|
885
|
+
seq(
|
|
886
|
+
$.super,
|
|
887
|
+
$.relational_operator,
|
|
888
|
+
$._real_expression
|
|
889
|
+
),
|
|
890
|
+
)
|
|
891
|
+
),
|
|
892
|
+
|
|
893
|
+
relational_operator: $ => choice(
|
|
894
|
+
'<',
|
|
895
|
+
'>',
|
|
896
|
+
'<=',
|
|
897
|
+
'>='
|
|
898
|
+
),
|
|
899
|
+
|
|
900
|
+
//BITWISE EXPRESSIONS
|
|
901
|
+
bitwise_or_expression: $ => binaryRunLeft($._real_expression, '|', $.super, DART_PREC.Bitwise_Or),
|
|
902
|
+
bitwise_xor_expression: $ => binaryRunLeft($._real_expression, '^', $.super, DART_PREC.Bitwise_XOR),
|
|
903
|
+
bitwise_and_expression: $ => binaryRunLeft($._real_expression, '&', $.super, DART_PREC.Bitwise_AND),
|
|
904
|
+
shift_expression: $ => binaryRunLeft($._real_expression, $.shift_operator, $.super, DART_PREC.Shift),
|
|
905
|
+
additive_expression: $ => binaryRunLeft($._real_expression, $.additive_operator, $.super, DART_PREC.Additive),
|
|
906
|
+
multiplicative_expression: $ => binaryRunLeft($._unary_expression, $.multiplicative_operator, $.super, DART_PREC.Multiplicative),
|
|
907
|
+
bitwise_operator: $ => $._bitwise_operator,
|
|
908
|
+
_bitwise_operator: $ => choice(
|
|
909
|
+
'&',
|
|
910
|
+
'^',
|
|
911
|
+
'|'
|
|
912
|
+
),
|
|
913
|
+
shift_operator: $ => $._shift_operator,
|
|
914
|
+
_shift_operator: $ => choice(
|
|
915
|
+
'<<',
|
|
916
|
+
'>>',
|
|
917
|
+
'>>>'
|
|
918
|
+
),
|
|
919
|
+
additive_operator: $ => $._additive_operator,
|
|
920
|
+
_additive_operator: $ => token(
|
|
921
|
+
choice(
|
|
922
|
+
'+',
|
|
923
|
+
'-'
|
|
924
|
+
)
|
|
925
|
+
),
|
|
926
|
+
multiplicative_operator: $ => $._multiplicative_operator,
|
|
927
|
+
_multiplicative_operator: $ => choice(
|
|
928
|
+
'*',
|
|
929
|
+
'/',
|
|
930
|
+
'%',
|
|
931
|
+
'~/'
|
|
932
|
+
),
|
|
933
|
+
|
|
934
|
+
_unary_expression: $ => prec(
|
|
935
|
+
DART_PREC.UNARY_PREFIX,
|
|
936
|
+
choice(
|
|
937
|
+
$._postfix_expression,
|
|
938
|
+
$.unary_expression,
|
|
939
|
+
)
|
|
940
|
+
),
|
|
941
|
+
|
|
942
|
+
unary_expression: $ => prec( //neither
|
|
943
|
+
DART_PREC.UNARY_PREFIX,
|
|
944
|
+
choice(
|
|
945
|
+
|
|
946
|
+
seq($.prefix_operator, $._unary_expression),
|
|
947
|
+
$.await_expression,
|
|
948
|
+
// prec(DART_PREC.UNARY_POSTFIX, $._postfix_expression),
|
|
949
|
+
seq(
|
|
950
|
+
choice(
|
|
951
|
+
$.minus_operator,
|
|
952
|
+
$.tilde_operator
|
|
953
|
+
),
|
|
954
|
+
$.super
|
|
955
|
+
),
|
|
956
|
+
seq(
|
|
957
|
+
$.increment_operator,
|
|
958
|
+
$.assignable_expression
|
|
959
|
+
)
|
|
960
|
+
)
|
|
961
|
+
),
|
|
962
|
+
|
|
963
|
+
_postfix_expression: $ => choice(
|
|
964
|
+
seq(
|
|
965
|
+
$._primary,
|
|
966
|
+
repeat(
|
|
967
|
+
$.selector
|
|
968
|
+
)
|
|
969
|
+
),
|
|
970
|
+
$.postfix_expression
|
|
971
|
+
),
|
|
972
|
+
|
|
973
|
+
postfix_expression: $ => prec.right(choice(
|
|
974
|
+
seq(
|
|
975
|
+
$.assignable_expression,
|
|
976
|
+
$.postfix_operator
|
|
977
|
+
),
|
|
978
|
+
seq(
|
|
979
|
+
$.constructor_invocation,
|
|
980
|
+
repeat(
|
|
981
|
+
$.selector
|
|
982
|
+
)
|
|
983
|
+
)
|
|
984
|
+
)),
|
|
985
|
+
|
|
986
|
+
postfix_operator: $ => $.increment_operator,
|
|
987
|
+
|
|
988
|
+
increment_operator: $ => token(choice(
|
|
989
|
+
'++',
|
|
990
|
+
'--'
|
|
991
|
+
)),
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
spread_element: $ => seq(
|
|
995
|
+
'...',
|
|
996
|
+
optional('?'),
|
|
997
|
+
$._expression
|
|
998
|
+
),
|
|
999
|
+
|
|
1000
|
+
selector: $ => prec.right(choice(
|
|
1001
|
+
// '!',
|
|
1002
|
+
$._exclamation_operator,
|
|
1003
|
+
$._assignable_selector,
|
|
1004
|
+
$.argument_part,
|
|
1005
|
+
$.type_arguments,
|
|
1006
|
+
)),
|
|
1007
|
+
|
|
1008
|
+
prefix_operator: $ => choice(
|
|
1009
|
+
$.minus_operator,
|
|
1010
|
+
$.negation_operator,
|
|
1011
|
+
$.tilde_operator
|
|
1012
|
+
),
|
|
1013
|
+
|
|
1014
|
+
minus_operator: $ => '-',
|
|
1015
|
+
negation_operator: $ => $._exclamation_operator,
|
|
1016
|
+
_exclamation_operator: $ => '!',
|
|
1017
|
+
tilde_operator: $ => '~',
|
|
1018
|
+
|
|
1019
|
+
await_expression: $ => seq(
|
|
1020
|
+
'await',
|
|
1021
|
+
$._unary_expression
|
|
1022
|
+
),
|
|
1023
|
+
|
|
1024
|
+
type_test: $ => seq(
|
|
1025
|
+
$.is_operator,
|
|
1026
|
+
$._type_not_void
|
|
1027
|
+
),
|
|
1028
|
+
|
|
1029
|
+
is_operator: $ => seq(
|
|
1030
|
+
token('is'),
|
|
1031
|
+
optional(
|
|
1032
|
+
$._exclamation_operator
|
|
1033
|
+
)
|
|
1034
|
+
),
|
|
1035
|
+
|
|
1036
|
+
type_cast: $ => seq(
|
|
1037
|
+
$.as_operator,
|
|
1038
|
+
$._type_not_void
|
|
1039
|
+
),
|
|
1040
|
+
|
|
1041
|
+
as_operator: $ => token('as'),
|
|
1042
|
+
|
|
1043
|
+
new_expression: $ => seq(
|
|
1044
|
+
$._new_builtin,
|
|
1045
|
+
$._type_not_void,
|
|
1046
|
+
optional(
|
|
1047
|
+
$._dot_identifier
|
|
1048
|
+
),
|
|
1049
|
+
$.arguments
|
|
1050
|
+
),
|
|
1051
|
+
|
|
1052
|
+
_dot_identifier: $ => prec.dynamic(
|
|
1053
|
+
DART_PREC.DOT_IDENTIFIER,
|
|
1054
|
+
seq(
|
|
1055
|
+
'.',
|
|
1056
|
+
$.identifier
|
|
1057
|
+
)
|
|
1058
|
+
),
|
|
1059
|
+
const_object_expression: $ => seq(
|
|
1060
|
+
$.const_builtin,
|
|
1061
|
+
$._type_not_void,
|
|
1062
|
+
optional(
|
|
1063
|
+
$._dot_identifier
|
|
1064
|
+
),
|
|
1065
|
+
$.arguments
|
|
1066
|
+
),
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
_primary: $ => choice(
|
|
1070
|
+
$._literal,
|
|
1071
|
+
$.identifier,
|
|
1072
|
+
$.function_expression,
|
|
1073
|
+
$.new_expression,
|
|
1074
|
+
$.const_object_expression,
|
|
1075
|
+
$.parenthesized_expression,
|
|
1076
|
+
// $.class_literal,
|
|
1077
|
+
$.this,
|
|
1078
|
+
seq(
|
|
1079
|
+
$.super,
|
|
1080
|
+
$.unconditional_assignable_selector
|
|
1081
|
+
),
|
|
1082
|
+
$.constructor_tearoff,
|
|
1083
|
+
$.switch_expression,
|
|
1084
|
+
// $.object_creation_expression,
|
|
1085
|
+
// $.field_access,
|
|
1086
|
+
// $.array_access,
|
|
1087
|
+
// $.method_invocation,
|
|
1088
|
+
// $.method_reference,
|
|
1089
|
+
),
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
parenthesized_expression: $ => seq('(', $._expression, ')'),
|
|
1093
|
+
|
|
1094
|
+
_compound_access: $ => choice('.', '?.'),
|
|
1095
|
+
|
|
1096
|
+
constructor_invocation: $ => prec.right(choice(
|
|
1097
|
+
seq($._type_name, $.type_arguments, '.', $.identifier, $.arguments),
|
|
1098
|
+
seq($._type_name, '.', $._new_builtin, $.arguments),
|
|
1099
|
+
)),
|
|
1100
|
+
|
|
1101
|
+
constructor_tearoff: $ => prec.right(seq(
|
|
1102
|
+
$._type_name, optional($.type_arguments), '.', $._new_builtin,
|
|
1103
|
+
)),
|
|
1104
|
+
|
|
1105
|
+
arguments: $ => seq('(', optional($._argument_list), ')'),
|
|
1106
|
+
|
|
1107
|
+
_argument_list: $ => prec.right(commaSep1TrailingComma($._any_argument)),
|
|
1108
|
+
|
|
1109
|
+
_any_argument: $ => choice($.argument, $.named_argument),
|
|
1110
|
+
|
|
1111
|
+
argument: $ => $._expression,
|
|
1112
|
+
|
|
1113
|
+
named_argument: $ => seq($.label, $._expression),
|
|
1114
|
+
|
|
1115
|
+
cascade_section: $ => prec.left(
|
|
1116
|
+
DART_PREC.Cascade,
|
|
1117
|
+
seq(
|
|
1118
|
+
choice('..', '?..'),
|
|
1119
|
+
$.cascade_selector,
|
|
1120
|
+
repeat($.argument_part),
|
|
1121
|
+
repeat(
|
|
1122
|
+
$._cascade_subsection
|
|
1123
|
+
),
|
|
1124
|
+
optional(
|
|
1125
|
+
$._cascade_assignment_section
|
|
1126
|
+
)
|
|
1127
|
+
)
|
|
1128
|
+
),
|
|
1129
|
+
|
|
1130
|
+
// prec.left(
|
|
1131
|
+
// DART_PREC.Cascade,
|
|
1132
|
+
// ),
|
|
1133
|
+
_cascade_subsection: $ => seq(
|
|
1134
|
+
$._assignable_selector,
|
|
1135
|
+
repeat($.argument_part)
|
|
1136
|
+
),
|
|
1137
|
+
_cascade_assignment_section: $ => seq(
|
|
1138
|
+
$._assignment_operator,
|
|
1139
|
+
$._expression_without_cascade
|
|
1140
|
+
),
|
|
1141
|
+
index_selector: $ => seq('[', $._expression, ']'),
|
|
1142
|
+
cascade_selector: $ => choice(
|
|
1143
|
+
seq(
|
|
1144
|
+
optional($.nullable_selector),
|
|
1145
|
+
$.index_selector,
|
|
1146
|
+
),
|
|
1147
|
+
$.identifier
|
|
1148
|
+
),
|
|
1149
|
+
argument_part: $ => seq(
|
|
1150
|
+
optional(
|
|
1151
|
+
$.type_arguments
|
|
1152
|
+
),
|
|
1153
|
+
// seq(
|
|
1154
|
+
// $.type_arguments,
|
|
1155
|
+
// $.arguments
|
|
1156
|
+
// ),
|
|
1157
|
+
$.arguments
|
|
1158
|
+
),
|
|
1159
|
+
|
|
1160
|
+
unconditional_assignable_selector: $ => choice(
|
|
1161
|
+
$.index_selector,
|
|
1162
|
+
seq('.', $.identifier)
|
|
1163
|
+
),
|
|
1164
|
+
|
|
1165
|
+
conditional_assignable_selector: $ => choice(
|
|
1166
|
+
seq('?.', $.identifier),
|
|
1167
|
+
seq('?', $.index_selector)
|
|
1168
|
+
),
|
|
1169
|
+
|
|
1170
|
+
_assignable_selector: $ => choice(
|
|
1171
|
+
$.unconditional_assignable_selector,
|
|
1172
|
+
$.conditional_assignable_selector
|
|
1173
|
+
),
|
|
1174
|
+
|
|
1175
|
+
type_arguments: $ => choice( // was prec.right
|
|
1176
|
+
// seq(
|
|
1177
|
+
// '<',
|
|
1178
|
+
// '>',
|
|
1179
|
+
// optional($.nullable_type)
|
|
1180
|
+
// ),
|
|
1181
|
+
seq(
|
|
1182
|
+
'<',
|
|
1183
|
+
commaSep($._type),
|
|
1184
|
+
'>',
|
|
1185
|
+
// optional($.nullable_type)
|
|
1186
|
+
)
|
|
1187
|
+
),
|
|
1188
|
+
|
|
1189
|
+
wildcard: $ => seq(
|
|
1190
|
+
optional($._metadata),
|
|
1191
|
+
'?',
|
|
1192
|
+
optional($._wildcard_bounds)
|
|
1193
|
+
),
|
|
1194
|
+
|
|
1195
|
+
_wildcard_bounds: $ => choice(
|
|
1196
|
+
seq('extends', $._type),
|
|
1197
|
+
seq($.super, $._type)
|
|
1198
|
+
),
|
|
1199
|
+
|
|
1200
|
+
dimensions: $ => prec.right(repeat1(
|
|
1201
|
+
seq(optional($._metadata), '[', ']')
|
|
1202
|
+
)),
|
|
1203
|
+
|
|
1204
|
+
// Statements
|
|
1205
|
+
_statement: $ => choice(
|
|
1206
|
+
$.block,
|
|
1207
|
+
prec.dynamic(1, $.local_function_declaration),
|
|
1208
|
+
prec.dynamic(2, $.local_variable_declaration),
|
|
1209
|
+
$.for_statement,
|
|
1210
|
+
$.while_statement,
|
|
1211
|
+
$.do_statement,
|
|
1212
|
+
$.switch_statement,
|
|
1213
|
+
$.if_statement,
|
|
1214
|
+
//TODO: add rethrow statement.
|
|
1215
|
+
// $._declaration,
|
|
1216
|
+
|
|
1217
|
+
$.try_statement,
|
|
1218
|
+
$.break_statement,
|
|
1219
|
+
$.continue_statement,
|
|
1220
|
+
$.return_statement,
|
|
1221
|
+
$.yield_statement,
|
|
1222
|
+
$.yield_each_statement,
|
|
1223
|
+
$.expression_statement,
|
|
1224
|
+
$.assert_statement,
|
|
1225
|
+
// $.labeled_statement,
|
|
1226
|
+
),
|
|
1227
|
+
|
|
1228
|
+
local_function_declaration: $ => seq(
|
|
1229
|
+
optional($._metadata),
|
|
1230
|
+
$.lambda_expression
|
|
1231
|
+
),
|
|
1232
|
+
|
|
1233
|
+
block: $ => seq(
|
|
1234
|
+
'{', repeat($._statement), '}'
|
|
1235
|
+
),
|
|
1236
|
+
|
|
1237
|
+
expression_statement: $ => seq(
|
|
1238
|
+
$._expression,
|
|
1239
|
+
$._semicolon
|
|
1240
|
+
),
|
|
1241
|
+
|
|
1242
|
+
labeled_statement: $ => seq(
|
|
1243
|
+
$.identifier, ':', $._statement
|
|
1244
|
+
),
|
|
1245
|
+
|
|
1246
|
+
assert_statement: $ => seq($.assertion, ';'),
|
|
1247
|
+
|
|
1248
|
+
assertion: $ => seq(
|
|
1249
|
+
$.assert_builtin,
|
|
1250
|
+
$.assertion_arguments,
|
|
1251
|
+
),
|
|
1252
|
+
|
|
1253
|
+
assertion_arguments: $ => seq(
|
|
1254
|
+
'(',
|
|
1255
|
+
$._expression,
|
|
1256
|
+
optional(
|
|
1257
|
+
seq(
|
|
1258
|
+
',',
|
|
1259
|
+
$._expression
|
|
1260
|
+
),
|
|
1261
|
+
),
|
|
1262
|
+
optional(','),
|
|
1263
|
+
')',
|
|
1264
|
+
),
|
|
1265
|
+
|
|
1266
|
+
switch_statement: $ => seq(
|
|
1267
|
+
'switch',
|
|
1268
|
+
field('condition', $.parenthesized_expression),
|
|
1269
|
+
field('body', $.switch_block)
|
|
1270
|
+
),
|
|
1271
|
+
|
|
1272
|
+
switch_expression: $ => seq(
|
|
1273
|
+
'switch',
|
|
1274
|
+
field('condition', $.parenthesized_expression),
|
|
1275
|
+
field('body',
|
|
1276
|
+
seq('{',
|
|
1277
|
+
commaSep1TrailingComma($.switch_expression_case),
|
|
1278
|
+
'}'
|
|
1279
|
+
))
|
|
1280
|
+
),
|
|
1281
|
+
|
|
1282
|
+
switch_expression_case: $ => seq($._guarded_pattern, '=>', $._expression),
|
|
1283
|
+
|
|
1284
|
+
_guarded_pattern: $ => seq(
|
|
1285
|
+
$._pattern, optional(seq('when', $._expression))
|
|
1286
|
+
),
|
|
1287
|
+
|
|
1288
|
+
_pattern: $ => choice(
|
|
1289
|
+
$._logical_or_pattern,
|
|
1290
|
+
),
|
|
1291
|
+
|
|
1292
|
+
_logical_or_pattern: $ => seq($._logical_and_pattern, repeat(seq($.logical_or_operator, $._logical_and_pattern))),
|
|
1293
|
+
_logical_and_pattern: $ => seq($._relational_pattern, repeat(seq($.logical_and_operator, $._relational_pattern))),
|
|
1294
|
+
_relational_pattern: $ =>
|
|
1295
|
+
prec(DART_PREC.Relational, choice(
|
|
1296
|
+
seq(choice($.relational_operator, $.equality_operator), $._real_expression),
|
|
1297
|
+
$._unary_pattern,
|
|
1298
|
+
)
|
|
1299
|
+
),
|
|
1300
|
+
|
|
1301
|
+
_unary_pattern: $ => choice(
|
|
1302
|
+
$.cast_pattern,
|
|
1303
|
+
$.null_check_pattern,
|
|
1304
|
+
$.null_assert_pattern,
|
|
1305
|
+
$._primary_pattern,
|
|
1306
|
+
),
|
|
1307
|
+
|
|
1308
|
+
_primary_pattern: $ => choice(
|
|
1309
|
+
$.constant_pattern,
|
|
1310
|
+
$.variable_pattern,
|
|
1311
|
+
$._parenthesized_pattern,
|
|
1312
|
+
$.list_pattern,
|
|
1313
|
+
$.map_pattern,
|
|
1314
|
+
$.record_pattern,
|
|
1315
|
+
$.object_pattern,
|
|
1316
|
+
),
|
|
1317
|
+
|
|
1318
|
+
cast_pattern: $ => seq($._primary_pattern, 'as', $._type),
|
|
1319
|
+
|
|
1320
|
+
null_check_pattern: $ => seq($._primary_pattern, '?'),
|
|
1321
|
+
|
|
1322
|
+
null_assert_pattern: $ => seq($._primary_pattern, '!'),
|
|
1323
|
+
|
|
1324
|
+
constant_pattern: $ => choice(
|
|
1325
|
+
$._bool_literal,
|
|
1326
|
+
$.null_literal,
|
|
1327
|
+
seq(optional($.minus_operator), $._numeric_literal),
|
|
1328
|
+
$.string_literal,
|
|
1329
|
+
$.symbol_literal,
|
|
1330
|
+
$.identifier,
|
|
1331
|
+
$.qualified,
|
|
1332
|
+
$.const_object_expression,
|
|
1333
|
+
seq($.const_builtin, optional($.type_arguments), '[', commaSep1TrailingComma($._element), ']'),
|
|
1334
|
+
seq($.const_builtin, optional($.type_arguments), '{', commaSep1TrailingComma($._element), '}'),
|
|
1335
|
+
seq($.const_builtin, '(', $._expression, ')'),
|
|
1336
|
+
),
|
|
1337
|
+
|
|
1338
|
+
variable_pattern: $ => seq($._final_var_or_type, $.identifier),
|
|
1339
|
+
|
|
1340
|
+
_parenthesized_pattern: $ => seq('(', $._pattern, ')'),
|
|
1341
|
+
|
|
1342
|
+
list_pattern: $ => seq(optional($.type_arguments), '[', commaSepTrailingComma($._list_pattern_element), ']'),
|
|
1343
|
+
|
|
1344
|
+
_list_pattern_element: $ => choice($._pattern, $.rest_pattern),
|
|
1345
|
+
|
|
1346
|
+
rest_pattern: $ => seq('...', optional($._pattern)),
|
|
1347
|
+
|
|
1348
|
+
map_pattern: $ => seq(optional($.type_arguments), '{', commaSepTrailingComma($._map_pattern_entry), '}'),
|
|
1349
|
+
|
|
1350
|
+
_map_pattern_entry: $ => choice(seq($._expression, ':', $._pattern), '...'),
|
|
1351
|
+
|
|
1352
|
+
record_pattern: $ => seq('(', commaSep1TrailingComma($._pattern_field), ')'),
|
|
1353
|
+
|
|
1354
|
+
_pattern_field: $ => seq(optional(seq(optional($.identifier), ':')), $._pattern),
|
|
1355
|
+
|
|
1356
|
+
object_pattern: $ => seq($._type_name, optional($.type_arguments), '(', commaSep1TrailingComma($._pattern_field), ')'),
|
|
1357
|
+
|
|
1358
|
+
pattern_variable_declaration: $ => seq(choice($.final_builtin, $.inferred_type), $._outer_pattern, '=', $._expression),
|
|
1359
|
+
|
|
1360
|
+
_outer_pattern: $ => choice($._parenthesized_pattern, $.list_pattern, $.map_pattern, $.record_pattern, $.object_pattern),
|
|
1361
|
+
|
|
1362
|
+
pattern_assignment: $ => seq($._outer_pattern, '=', $._expression),
|
|
1363
|
+
|
|
1364
|
+
switch_block: $ => seq(
|
|
1365
|
+
'{',
|
|
1366
|
+
repeat($.switch_statement_case),
|
|
1367
|
+
optional($.switch_statement_default),
|
|
1368
|
+
'}'
|
|
1369
|
+
),
|
|
1370
|
+
|
|
1371
|
+
switch_statement_case: $ => seq(
|
|
1372
|
+
repeat($.label), $.case_builtin, $._guarded_pattern, ':', repeat($._statement),
|
|
1373
|
+
),
|
|
1374
|
+
|
|
1375
|
+
switch_statement_default: $ => seq(
|
|
1376
|
+
repeat($.label), 'default', ':', repeat($._statement),
|
|
1377
|
+
),
|
|
1378
|
+
|
|
1379
|
+
switch_case: $ => choice(
|
|
1380
|
+
seq(repeat($.label), $.case_builtin, $._guarded_pattern, ':', repeat1($._statement)),
|
|
1381
|
+
),
|
|
1382
|
+
|
|
1383
|
+
default_case: $ => choice(
|
|
1384
|
+
seq(repeat($.label), 'default', ':', repeat1($._statement)),
|
|
1385
|
+
),
|
|
1386
|
+
|
|
1387
|
+
switch_label: $ => seq(
|
|
1388
|
+
repeat($.label),
|
|
1389
|
+
choice(
|
|
1390
|
+
seq($.case_builtin, $._expression, ':'),
|
|
1391
|
+
seq('default', ':')
|
|
1392
|
+
)),
|
|
1393
|
+
|
|
1394
|
+
do_statement: $ => seq(
|
|
1395
|
+
'do',
|
|
1396
|
+
field('body', $._statement),
|
|
1397
|
+
'while',
|
|
1398
|
+
field('condition', $.parenthesized_expression),
|
|
1399
|
+
$._semicolon
|
|
1400
|
+
),
|
|
1401
|
+
|
|
1402
|
+
break_statement: $ => seq($.break_builtin, optional($.identifier), $._semicolon),
|
|
1403
|
+
|
|
1404
|
+
continue_statement: $ => seq('continue', optional($.identifier), $._semicolon),
|
|
1405
|
+
|
|
1406
|
+
yield_statement: $ => seq('yield', $._expression, $._semicolon),
|
|
1407
|
+
|
|
1408
|
+
yield_each_statement: $ => seq('yield', '*', $._expression, $._semicolon),
|
|
1409
|
+
|
|
1410
|
+
return_statement: $ => seq(
|
|
1411
|
+
'return',
|
|
1412
|
+
optional($._expression),
|
|
1413
|
+
$._semicolon
|
|
1414
|
+
),
|
|
1415
|
+
|
|
1416
|
+
throw_statement: $ => seq('throw', $._expression, $._semicolon),
|
|
1417
|
+
|
|
1418
|
+
try_statement: $ => seq(
|
|
1419
|
+
$._try_head,
|
|
1420
|
+
optional(choice(
|
|
1421
|
+
$.finally_clause,
|
|
1422
|
+
seq(repeat1($._on_part), optional($.finally_clause))
|
|
1423
|
+
))
|
|
1424
|
+
),
|
|
1425
|
+
_on_part: $ => choice(
|
|
1426
|
+
seq(
|
|
1427
|
+
$.catch_clause,
|
|
1428
|
+
$.block
|
|
1429
|
+
),
|
|
1430
|
+
seq(
|
|
1431
|
+
'on',
|
|
1432
|
+
$._type_not_void,
|
|
1433
|
+
optional($.catch_clause),
|
|
1434
|
+
$.block
|
|
1435
|
+
)
|
|
1436
|
+
),
|
|
1437
|
+
_try_head: $ => seq(
|
|
1438
|
+
'try',
|
|
1439
|
+
field('body', $.block),
|
|
1440
|
+
),
|
|
1441
|
+
catch_clause: $ => seq(
|
|
1442
|
+
'catch',
|
|
1443
|
+
$.catch_parameters,
|
|
1444
|
+
// field('body', $.block)
|
|
1445
|
+
),
|
|
1446
|
+
|
|
1447
|
+
catch_parameters: $ => seq(
|
|
1448
|
+
'(',
|
|
1449
|
+
$.identifier,
|
|
1450
|
+
optional(
|
|
1451
|
+
seq(
|
|
1452
|
+
',',
|
|
1453
|
+
$.identifier
|
|
1454
|
+
),
|
|
1455
|
+
),
|
|
1456
|
+
')',
|
|
1457
|
+
),
|
|
1458
|
+
|
|
1459
|
+
catch_type: $ => sep1($._type, '|'),
|
|
1460
|
+
|
|
1461
|
+
finally_clause: $ => seq('finally', $.block),
|
|
1462
|
+
|
|
1463
|
+
if_element: $ => prec.right(seq(
|
|
1464
|
+
'if',
|
|
1465
|
+
'(', $._expression, optional(seq('case', $._guarded_pattern)) , ')',
|
|
1466
|
+
field('consequence', $._element),
|
|
1467
|
+
optional(seq('else', field('alternative', $._element)))
|
|
1468
|
+
)),
|
|
1469
|
+
|
|
1470
|
+
if_statement: $ => prec.right(seq(
|
|
1471
|
+
'if',
|
|
1472
|
+
'(', $._expression, optional(seq('case', $._guarded_pattern)) , ')',
|
|
1473
|
+
field('consequence', $._statement),
|
|
1474
|
+
optional(seq('else', field('alternative', $._statement)))
|
|
1475
|
+
)),
|
|
1476
|
+
|
|
1477
|
+
|
|
1478
|
+
while_statement: $ => seq(
|
|
1479
|
+
'while',
|
|
1480
|
+
field('condition', $.parenthesized_expression),
|
|
1481
|
+
field('body', $._statement)
|
|
1482
|
+
),
|
|
1483
|
+
|
|
1484
|
+
for_statement: $ => seq(
|
|
1485
|
+
optional('await'),
|
|
1486
|
+
'for',
|
|
1487
|
+
$.for_loop_parts,
|
|
1488
|
+
field('body', $._statement)
|
|
1489
|
+
),
|
|
1490
|
+
|
|
1491
|
+
for_loop_parts: $ => seq('(', $._for_loop_parts, ')'),
|
|
1492
|
+
|
|
1493
|
+
_for_loop_parts: $ => choice(
|
|
1494
|
+
seq(
|
|
1495
|
+
choice(
|
|
1496
|
+
$._declared_identifier,
|
|
1497
|
+
$.identifier
|
|
1498
|
+
),
|
|
1499
|
+
'in',
|
|
1500
|
+
field('value', $._expression),
|
|
1501
|
+
),
|
|
1502
|
+
seq(
|
|
1503
|
+
optional(choice(
|
|
1504
|
+
field('init', $.local_variable_declaration),
|
|
1505
|
+
seq(
|
|
1506
|
+
commaSep(field('init', $._expression)),
|
|
1507
|
+
$._semicolon
|
|
1508
|
+
)
|
|
1509
|
+
),),
|
|
1510
|
+
field('condition', optional($._expression)), $._semicolon,
|
|
1511
|
+
commaSep(field('update', $._expression)),
|
|
1512
|
+
),
|
|
1513
|
+
seq(
|
|
1514
|
+
choice($.final_builtin, $.inferred_type),
|
|
1515
|
+
$._outer_pattern,
|
|
1516
|
+
'in',
|
|
1517
|
+
field('value', $._expression)
|
|
1518
|
+
)
|
|
1519
|
+
),
|
|
1520
|
+
|
|
1521
|
+
// support map weirdness?
|
|
1522
|
+
for_element: $ => seq(
|
|
1523
|
+
optional('await'),
|
|
1524
|
+
'for',
|
|
1525
|
+
$.for_loop_parts,
|
|
1526
|
+
field('body', $._element)
|
|
1527
|
+
),
|
|
1528
|
+
|
|
1529
|
+
// Annotations
|
|
1530
|
+
annotation: $ => prec.right(seq(
|
|
1531
|
+
'@',
|
|
1532
|
+
field('name', choice($.identifier, $.scoped_identifier)),
|
|
1533
|
+
choice(
|
|
1534
|
+
optional(seq($.type_arguments, $.arguments)),
|
|
1535
|
+
optional($.arguments)
|
|
1536
|
+
)
|
|
1537
|
+
)),
|
|
1538
|
+
|
|
1539
|
+
// Declarations
|
|
1540
|
+
|
|
1541
|
+
_declaration: $ => prec(1, choice(
|
|
1542
|
+
$.import_specification,
|
|
1543
|
+
$.class_definition,
|
|
1544
|
+
// $.annotation_type_declaration,
|
|
1545
|
+
$.enum_declaration,
|
|
1546
|
+
)),
|
|
1547
|
+
|
|
1548
|
+
import_or_export: $ => prec(
|
|
1549
|
+
DART_PREC.IMPORT_EXPORT,
|
|
1550
|
+
choice(
|
|
1551
|
+
$.library_import,
|
|
1552
|
+
$.library_export
|
|
1553
|
+
)
|
|
1554
|
+
),
|
|
1555
|
+
|
|
1556
|
+
library_import: $ => seq(
|
|
1557
|
+
optional($._metadata),
|
|
1558
|
+
$.import_specification
|
|
1559
|
+
),
|
|
1560
|
+
|
|
1561
|
+
library_export: $ => seq(
|
|
1562
|
+
optional($._metadata),
|
|
1563
|
+
$._export,
|
|
1564
|
+
$.configurable_uri,
|
|
1565
|
+
repeat($.combinator),
|
|
1566
|
+
$._semicolon
|
|
1567
|
+
),
|
|
1568
|
+
|
|
1569
|
+
import_specification: $ => choice(
|
|
1570
|
+
seq(
|
|
1571
|
+
$._import,
|
|
1572
|
+
$.configurable_uri,
|
|
1573
|
+
optional(
|
|
1574
|
+
seq(
|
|
1575
|
+
$._as,
|
|
1576
|
+
$.identifier
|
|
1577
|
+
)
|
|
1578
|
+
),
|
|
1579
|
+
repeat($.combinator),
|
|
1580
|
+
$._semicolon
|
|
1581
|
+
),
|
|
1582
|
+
seq(
|
|
1583
|
+
$._import,
|
|
1584
|
+
$.uri,
|
|
1585
|
+
$._deferred,
|
|
1586
|
+
$._as,
|
|
1587
|
+
$.identifier,
|
|
1588
|
+
repeat($.combinator),
|
|
1589
|
+
$._semicolon
|
|
1590
|
+
)
|
|
1591
|
+
),
|
|
1592
|
+
|
|
1593
|
+
part_directive: $ => seq(
|
|
1594
|
+
optional($._metadata),
|
|
1595
|
+
'part',
|
|
1596
|
+
$.uri,
|
|
1597
|
+
$._semicolon
|
|
1598
|
+
),
|
|
1599
|
+
|
|
1600
|
+
part_of_directive: $ => seq(
|
|
1601
|
+
optional($._metadata),
|
|
1602
|
+
$.part_of_builtin,
|
|
1603
|
+
choice($.dotted_identifier_list, $.uri),
|
|
1604
|
+
$._semicolon
|
|
1605
|
+
),
|
|
1606
|
+
|
|
1607
|
+
uri: $ => $.string_literal,
|
|
1608
|
+
|
|
1609
|
+
configurable_uri: $ => seq(
|
|
1610
|
+
$.uri,
|
|
1611
|
+
repeat($.configuration_uri)
|
|
1612
|
+
),
|
|
1613
|
+
|
|
1614
|
+
configuration_uri: $ => seq(
|
|
1615
|
+
'if',
|
|
1616
|
+
$.configuration_uri_condition,
|
|
1617
|
+
$.uri
|
|
1618
|
+
),
|
|
1619
|
+
|
|
1620
|
+
configuration_uri_condition: $ => seq('(', $.uri_test, ')'),
|
|
1621
|
+
|
|
1622
|
+
uri_test: $ => seq(
|
|
1623
|
+
$.dotted_identifier_list,
|
|
1624
|
+
optional(
|
|
1625
|
+
seq(
|
|
1626
|
+
'==',
|
|
1627
|
+
$.string_literal
|
|
1628
|
+
)
|
|
1629
|
+
)
|
|
1630
|
+
),
|
|
1631
|
+
|
|
1632
|
+
combinator: $ => choice(
|
|
1633
|
+
seq('show', $._identifier_list),
|
|
1634
|
+
seq('hide', $._identifier_list)
|
|
1635
|
+
),
|
|
1636
|
+
|
|
1637
|
+
_identifier_list: $ => commaSep1($.identifier),
|
|
1638
|
+
|
|
1639
|
+
asterisk: $ => '*',
|
|
1640
|
+
|
|
1641
|
+
enum_declaration: $ => seq(
|
|
1642
|
+
optional($._metadata),
|
|
1643
|
+
'enum',
|
|
1644
|
+
field('name', $.identifier),
|
|
1645
|
+
optional($.type_parameters),
|
|
1646
|
+
optional($.mixins),
|
|
1647
|
+
optional($.interfaces),
|
|
1648
|
+
field('body', $.enum_body),
|
|
1649
|
+
),
|
|
1650
|
+
|
|
1651
|
+
enum_body: $ => seq(
|
|
1652
|
+
'{',
|
|
1653
|
+
commaSep1TrailingComma($.enum_constant),
|
|
1654
|
+
optional(
|
|
1655
|
+
seq(';', repeat(seq(optional($._metadata), $._class_member_definition)))
|
|
1656
|
+
),
|
|
1657
|
+
'}'
|
|
1658
|
+
),
|
|
1659
|
+
|
|
1660
|
+
enum_constant: $ => choice(
|
|
1661
|
+
seq(
|
|
1662
|
+
optional($._metadata),
|
|
1663
|
+
field('name', $.identifier),
|
|
1664
|
+
optional($.argument_part),
|
|
1665
|
+
),
|
|
1666
|
+
seq(
|
|
1667
|
+
optional($._metadata),
|
|
1668
|
+
field('name', $.identifier),
|
|
1669
|
+
optional($.type_arguments),
|
|
1670
|
+
'.',
|
|
1671
|
+
choice($.identifier, $._new_builtin),
|
|
1672
|
+
$.arguments,
|
|
1673
|
+
)),
|
|
1674
|
+
|
|
1675
|
+
type_alias: $ => choice(
|
|
1676
|
+
seq(
|
|
1677
|
+
optional($._metadata),
|
|
1678
|
+
$._typedef,
|
|
1679
|
+
optional($._type),
|
|
1680
|
+
$._type_name,
|
|
1681
|
+
$._formal_parameter_part, ';'),
|
|
1682
|
+
seq(
|
|
1683
|
+
optional($._metadata),
|
|
1684
|
+
$._typedef,
|
|
1685
|
+
$._type_name,
|
|
1686
|
+
optional($.type_parameters),
|
|
1687
|
+
'=', $._type, ';'),
|
|
1688
|
+
),
|
|
1689
|
+
|
|
1690
|
+
_class_modifiers: $ => seq(choice($.sealed, seq(optional($.abstract), optional(choice($.base, $.interface, 'final', 'inline')))), 'class'),
|
|
1691
|
+
|
|
1692
|
+
_mixin_class_modifiers: $ => seq(optional($.abstract), optional($.base), $.mixin, 'class'),
|
|
1693
|
+
|
|
1694
|
+
class_definition: $ => choice(
|
|
1695
|
+
seq(
|
|
1696
|
+
optional($._metadata),
|
|
1697
|
+
choice($._class_modifiers, $._mixin_class_modifiers),
|
|
1698
|
+
field('name', $.identifier),
|
|
1699
|
+
optional(field('type_parameters', $.type_parameters)),
|
|
1700
|
+
optional(field('superclass', $.superclass)),
|
|
1701
|
+
optional(field('interfaces', $.interfaces)),
|
|
1702
|
+
field('body', $.class_body)
|
|
1703
|
+
),
|
|
1704
|
+
seq(
|
|
1705
|
+
optional($._metadata),
|
|
1706
|
+
$._class_modifiers,
|
|
1707
|
+
$.mixin_application_class
|
|
1708
|
+
)
|
|
1709
|
+
),
|
|
1710
|
+
|
|
1711
|
+
extension_declaration: $ => choice(
|
|
1712
|
+
seq(
|
|
1713
|
+
optional($._metadata),
|
|
1714
|
+
'extension',
|
|
1715
|
+
optional(field('name', $.identifier)),
|
|
1716
|
+
optional(field('type_parameters', $.type_parameters)),
|
|
1717
|
+
'on',
|
|
1718
|
+
field('class', $._type),
|
|
1719
|
+
field('body', $.extension_body)
|
|
1720
|
+
),
|
|
1721
|
+
),
|
|
1722
|
+
|
|
1723
|
+
_metadata: $ => prec.right(repeat1($.annotation)),
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
type_parameters: $ => seq(
|
|
1727
|
+
'<', commaSep1($.type_parameter), '>'
|
|
1728
|
+
),
|
|
1729
|
+
|
|
1730
|
+
type_parameter: $ => seq(
|
|
1731
|
+
optional($._metadata),
|
|
1732
|
+
choice(alias(
|
|
1733
|
+
$.identifier,
|
|
1734
|
+
$.type_identifier),
|
|
1735
|
+
$.nullable_type
|
|
1736
|
+
),
|
|
1737
|
+
// This is a comment
|
|
1738
|
+
// comment with a link made in https://github.com/flutter/flutter/pull/48547
|
|
1739
|
+
// Changes made in https://github.com/flutter/flutter/pull/48547
|
|
1740
|
+
/* This is also a comment */
|
|
1741
|
+
/* this comment /* // /** ends here: */
|
|
1742
|
+
|
|
1743
|
+
optional($.nullable_type),
|
|
1744
|
+
optional($.type_bound)
|
|
1745
|
+
),
|
|
1746
|
+
|
|
1747
|
+
type_bound: $ => seq('extends', $._type_not_void),
|
|
1748
|
+
|
|
1749
|
+
superclass: $ => choice(
|
|
1750
|
+
seq(
|
|
1751
|
+
'extends',
|
|
1752
|
+
$._type_not_void,
|
|
1753
|
+
optional($.mixins)
|
|
1754
|
+
),
|
|
1755
|
+
$.mixins
|
|
1756
|
+
),
|
|
1757
|
+
|
|
1758
|
+
mixins: $ => seq(
|
|
1759
|
+
'with',
|
|
1760
|
+
$._type_not_void_list
|
|
1761
|
+
),
|
|
1762
|
+
|
|
1763
|
+
mixin_application_class: $ => seq(
|
|
1764
|
+
$.identifier,
|
|
1765
|
+
optional($.type_parameters),
|
|
1766
|
+
'=',
|
|
1767
|
+
$.mixin_application,
|
|
1768
|
+
$._semicolon
|
|
1769
|
+
),
|
|
1770
|
+
|
|
1771
|
+
mixin_application: $ => seq(
|
|
1772
|
+
$._type_not_void,
|
|
1773
|
+
$.mixins,
|
|
1774
|
+
optional($.interfaces)
|
|
1775
|
+
),
|
|
1776
|
+
mixin_declaration: $ => seq(
|
|
1777
|
+
optional($._metadata),
|
|
1778
|
+
optional($.base),
|
|
1779
|
+
$.mixin,
|
|
1780
|
+
$.identifier,
|
|
1781
|
+
optional($.type_parameters),
|
|
1782
|
+
optional(seq(
|
|
1783
|
+
'on',
|
|
1784
|
+
$._type_not_void_list
|
|
1785
|
+
)),
|
|
1786
|
+
optional($.interfaces),
|
|
1787
|
+
$.class_body
|
|
1788
|
+
),
|
|
1789
|
+
interfaces: $ => seq(
|
|
1790
|
+
$._implements,
|
|
1791
|
+
$._type_not_void_list
|
|
1792
|
+
),
|
|
1793
|
+
|
|
1794
|
+
interface_type_list: $ => seq(
|
|
1795
|
+
$._type,
|
|
1796
|
+
repeat(seq(',', $._type))
|
|
1797
|
+
),
|
|
1798
|
+
|
|
1799
|
+
class_body: $ => seq(
|
|
1800
|
+
'{',
|
|
1801
|
+
repeat(
|
|
1802
|
+
seq(
|
|
1803
|
+
optional($._metadata),
|
|
1804
|
+
$._class_member_definition
|
|
1805
|
+
)
|
|
1806
|
+
),
|
|
1807
|
+
'}'
|
|
1808
|
+
),
|
|
1809
|
+
extension_body: $ => seq(
|
|
1810
|
+
'{',
|
|
1811
|
+
repeat(
|
|
1812
|
+
choice(
|
|
1813
|
+
seq(optional($._metadata), $.declaration, $._semicolon),
|
|
1814
|
+
seq(
|
|
1815
|
+
optional($._metadata),
|
|
1816
|
+
seq(
|
|
1817
|
+
$.method_signature,
|
|
1818
|
+
$.function_body
|
|
1819
|
+
),
|
|
1820
|
+
)
|
|
1821
|
+
)
|
|
1822
|
+
),
|
|
1823
|
+
'}'
|
|
1824
|
+
),
|
|
1825
|
+
|
|
1826
|
+
_class_member_definition: $ => choice(
|
|
1827
|
+
seq($.declaration, $._semicolon),
|
|
1828
|
+
seq(
|
|
1829
|
+
$.method_signature,
|
|
1830
|
+
$.function_body
|
|
1831
|
+
),
|
|
1832
|
+
),
|
|
1833
|
+
|
|
1834
|
+
getter_signature: $ => seq(
|
|
1835
|
+
optional($._type),
|
|
1836
|
+
$._get,
|
|
1837
|
+
field('name', $.identifier),
|
|
1838
|
+
optional($._native)
|
|
1839
|
+
),
|
|
1840
|
+
setter_signature: $ => seq(
|
|
1841
|
+
optional($._type),
|
|
1842
|
+
$._set,
|
|
1843
|
+
field('name', $.identifier),
|
|
1844
|
+
$._formal_parameter_part,
|
|
1845
|
+
optional($._native)
|
|
1846
|
+
),
|
|
1847
|
+
method_signature: $ => choice(
|
|
1848
|
+
seq($.constructor_signature, optional($.initializers)),
|
|
1849
|
+
$.factory_constructor_signature,
|
|
1850
|
+
|
|
1851
|
+
seq(
|
|
1852
|
+
optional($._static),
|
|
1853
|
+
choice(
|
|
1854
|
+
$.function_signature,
|
|
1855
|
+
$.getter_signature,
|
|
1856
|
+
$.setter_signature
|
|
1857
|
+
)
|
|
1858
|
+
),
|
|
1859
|
+
$.operator_signature
|
|
1860
|
+
),
|
|
1861
|
+
|
|
1862
|
+
declaration: $ => choice(
|
|
1863
|
+
seq($.constant_constructor_signature, optional(choice($.redirection, $.initializers))),
|
|
1864
|
+
seq($.constructor_signature, optional(choice($.redirection, $.initializers))),
|
|
1865
|
+
seq($._external,
|
|
1866
|
+
optional($.const_builtin),
|
|
1867
|
+
$.factory_constructor_signature
|
|
1868
|
+
),
|
|
1869
|
+
seq(
|
|
1870
|
+
optional($.const_builtin),
|
|
1871
|
+
$.factory_constructor_signature, $._native
|
|
1872
|
+
),
|
|
1873
|
+
seq($._external,
|
|
1874
|
+
$.constant_constructor_signature
|
|
1875
|
+
),
|
|
1876
|
+
$.redirecting_factory_constructor_signature,
|
|
1877
|
+
seq($._external,
|
|
1878
|
+
$.constructor_signature
|
|
1879
|
+
),
|
|
1880
|
+
seq(
|
|
1881
|
+
optional($._external_builtin),
|
|
1882
|
+
optional($._static),
|
|
1883
|
+
$.getter_signature,
|
|
1884
|
+
),
|
|
1885
|
+
seq(
|
|
1886
|
+
optional($._external_and_static),
|
|
1887
|
+
$.setter_signature,
|
|
1888
|
+
),
|
|
1889
|
+
|
|
1890
|
+
seq(
|
|
1891
|
+
optional($._external),
|
|
1892
|
+
$.operator_signature
|
|
1893
|
+
),
|
|
1894
|
+
seq(
|
|
1895
|
+
optional($._external_and_static),
|
|
1896
|
+
$.function_signature,
|
|
1897
|
+
),
|
|
1898
|
+
// TODO: This should only work with native?
|
|
1899
|
+
seq(
|
|
1900
|
+
$._static,
|
|
1901
|
+
$.function_signature,
|
|
1902
|
+
),
|
|
1903
|
+
// | static const 〈type〉? 〈staticFinalDeclarationList〉
|
|
1904
|
+
// | static final 〈type〉? 〈staticFinalDeclarationList〉
|
|
1905
|
+
// | static late final 〈type〉? 〈initializedIdentifierList〉
|
|
1906
|
+
// | static late? 〈varOrType〉 〈initializedIdentifierList
|
|
1907
|
+
seq(
|
|
1908
|
+
$._static,
|
|
1909
|
+
choice(
|
|
1910
|
+
seq(
|
|
1911
|
+
$._final_or_const,
|
|
1912
|
+
optional($._type),
|
|
1913
|
+
$.static_final_declaration_list
|
|
1914
|
+
),
|
|
1915
|
+
seq(
|
|
1916
|
+
$._late_builtin,
|
|
1917
|
+
choice(
|
|
1918
|
+
seq(
|
|
1919
|
+
$.final_builtin,
|
|
1920
|
+
optional($._type),
|
|
1921
|
+
$.initialized_identifier_list
|
|
1922
|
+
),
|
|
1923
|
+
seq(
|
|
1924
|
+
choice(
|
|
1925
|
+
$._type,
|
|
1926
|
+
$.inferred_type,
|
|
1927
|
+
),
|
|
1928
|
+
$.initialized_identifier_list
|
|
1929
|
+
)
|
|
1930
|
+
)
|
|
1931
|
+
),
|
|
1932
|
+
seq(
|
|
1933
|
+
choice(
|
|
1934
|
+
$._type,
|
|
1935
|
+
$.inferred_type,
|
|
1936
|
+
),
|
|
1937
|
+
$.initialized_identifier_list
|
|
1938
|
+
)
|
|
1939
|
+
)
|
|
1940
|
+
),
|
|
1941
|
+
// | covariant late final 〈type〉? 〈identifierList〉
|
|
1942
|
+
// | covariant late? 〈varOrType〉 〈initializedIdentifierList〉
|
|
1943
|
+
seq(
|
|
1944
|
+
$._covariant,
|
|
1945
|
+
choice(
|
|
1946
|
+
seq(
|
|
1947
|
+
$._late_builtin,
|
|
1948
|
+
choice(
|
|
1949
|
+
seq(
|
|
1950
|
+
$.final_builtin,
|
|
1951
|
+
optional($._type),
|
|
1952
|
+
$.identifier_list
|
|
1953
|
+
),
|
|
1954
|
+
seq(
|
|
1955
|
+
choice(
|
|
1956
|
+
$._type,
|
|
1957
|
+
$.inferred_type,
|
|
1958
|
+
),
|
|
1959
|
+
$.initialized_identifier_list
|
|
1960
|
+
)
|
|
1961
|
+
)
|
|
1962
|
+
),
|
|
1963
|
+
seq(
|
|
1964
|
+
choice(
|
|
1965
|
+
$._type,
|
|
1966
|
+
$.inferred_type,
|
|
1967
|
+
),
|
|
1968
|
+
$.initialized_identifier_list
|
|
1969
|
+
)
|
|
1970
|
+
)
|
|
1971
|
+
),
|
|
1972
|
+
seq(
|
|
1973
|
+
optional($._late_builtin), $.final_builtin,
|
|
1974
|
+
optional($._type),
|
|
1975
|
+
$.initialized_identifier_list
|
|
1976
|
+
),
|
|
1977
|
+
seq(
|
|
1978
|
+
optional($._late_builtin),
|
|
1979
|
+
$._var_or_type,
|
|
1980
|
+
$.initialized_identifier_list
|
|
1981
|
+
)
|
|
1982
|
+
// TODO: add in the 'late' keyword from the informal draft spec:
|
|
1983
|
+
// |static late final〈type〉?〈initializedIdentifierList〉
|
|
1984
|
+
// |static late?〈varOrType〉 〈initializedIdentifierList〉
|
|
1985
|
+
// |covariant late?〈varOrType〉 〈initializedIdentifierList〉
|
|
1986
|
+
// |late?final〈type〉?〈initializedIdentifierList〉
|
|
1987
|
+
// |late?〈varOrType〉 〈initializedIdentifierList〉
|
|
1988
|
+
),
|
|
1989
|
+
|
|
1990
|
+
identifier_list: $ => commaSep1(
|
|
1991
|
+
$.identifier
|
|
1992
|
+
),
|
|
1993
|
+
initialized_identifier_list: $ => commaSep1(
|
|
1994
|
+
$.initialized_identifier
|
|
1995
|
+
),
|
|
1996
|
+
initialized_identifier: $ => seq(
|
|
1997
|
+
$.identifier,
|
|
1998
|
+
optional(seq(
|
|
1999
|
+
'=',
|
|
2000
|
+
$._expression
|
|
2001
|
+
))
|
|
2002
|
+
),
|
|
2003
|
+
static_final_declaration_list: $ => commaSep1(
|
|
2004
|
+
$.static_final_declaration
|
|
2005
|
+
),
|
|
2006
|
+
binary_operator: $ => choice(
|
|
2007
|
+
$.multiplicative_operator,
|
|
2008
|
+
$.additive_operator,
|
|
2009
|
+
$.shift_operator,
|
|
2010
|
+
$.relational_operator,
|
|
2011
|
+
'==',
|
|
2012
|
+
$.bitwise_operator
|
|
2013
|
+
),
|
|
2014
|
+
operator_signature: $ => seq(
|
|
2015
|
+
optional($._type),
|
|
2016
|
+
$._operator,
|
|
2017
|
+
choice(
|
|
2018
|
+
'~',
|
|
2019
|
+
$.binary_operator,
|
|
2020
|
+
'[]',
|
|
2021
|
+
'[]='
|
|
2022
|
+
),
|
|
2023
|
+
$.formal_parameter_list,
|
|
2024
|
+
optional($._native)
|
|
2025
|
+
),
|
|
2026
|
+
static_final_declaration: $ => seq(
|
|
2027
|
+
$.identifier,
|
|
2028
|
+
'=',
|
|
2029
|
+
$._expression
|
|
2030
|
+
),
|
|
2031
|
+
|
|
2032
|
+
_external_and_static: $ => seq(
|
|
2033
|
+
$._external,
|
|
2034
|
+
optional($._static)),
|
|
2035
|
+
_static_or_covariant: $ => choice(
|
|
2036
|
+
$._covariant,
|
|
2037
|
+
$._static
|
|
2038
|
+
),
|
|
2039
|
+
_final_or_const: $ => choice(
|
|
2040
|
+
$.final_builtin,
|
|
2041
|
+
$.const_builtin
|
|
2042
|
+
),
|
|
2043
|
+
|
|
2044
|
+
static_initializer: $ => seq(
|
|
2045
|
+
$._static,
|
|
2046
|
+
$.block
|
|
2047
|
+
),
|
|
2048
|
+
|
|
2049
|
+
initializers: $ => seq(
|
|
2050
|
+
':',
|
|
2051
|
+
commaSep1($.initializer_list_entry)
|
|
2052
|
+
),
|
|
2053
|
+
initializer_list_entry: $ => choice(
|
|
2054
|
+
seq($.super, $.arguments),
|
|
2055
|
+
seq($.super,
|
|
2056
|
+
seq('.', choice($.identifier, $._new_builtin), $.arguments),
|
|
2057
|
+
),
|
|
2058
|
+
$.field_initializer,
|
|
2059
|
+
$.assertion
|
|
2060
|
+
),
|
|
2061
|
+
|
|
2062
|
+
field_initializer: $ => seq(
|
|
2063
|
+
optional(seq($.this, '.')),
|
|
2064
|
+
$.identifier,
|
|
2065
|
+
'=',
|
|
2066
|
+
// $.conditional_expression,
|
|
2067
|
+
$._real_expression,
|
|
2068
|
+
repeat(
|
|
2069
|
+
$.cascade_section
|
|
2070
|
+
)
|
|
2071
|
+
),
|
|
2072
|
+
|
|
2073
|
+
// constructor_signature: $ => seq(
|
|
2074
|
+
// $._constructor_declarator,
|
|
2075
|
+
// // optional($.throws),
|
|
2076
|
+
// // field('body', choice(
|
|
2077
|
+
// // $.constructor_body,
|
|
2078
|
+
// // $._semicolon
|
|
2079
|
+
// // ))
|
|
2080
|
+
// ),
|
|
2081
|
+
|
|
2082
|
+
factory_constructor_signature: $ => seq(
|
|
2083
|
+
$._factory,
|
|
2084
|
+
sep1($.identifier, '.'),
|
|
2085
|
+
$.formal_parameter_list,
|
|
2086
|
+
),
|
|
2087
|
+
|
|
2088
|
+
redirecting_factory_constructor_signature: $ => seq(
|
|
2089
|
+
optional($.const_builtin),
|
|
2090
|
+
$._factory,
|
|
2091
|
+
sep1($.identifier, '.'),
|
|
2092
|
+
$.formal_parameter_list,
|
|
2093
|
+
'=',
|
|
2094
|
+
$._type_not_void,
|
|
2095
|
+
optional(seq('.', $.identifier)),
|
|
2096
|
+
),
|
|
2097
|
+
|
|
2098
|
+
redirection: $ => seq(
|
|
2099
|
+
':',
|
|
2100
|
+
$.this,
|
|
2101
|
+
optional(seq(
|
|
2102
|
+
'.',
|
|
2103
|
+
$._identifier_or_new
|
|
2104
|
+
)),
|
|
2105
|
+
$.arguments
|
|
2106
|
+
),
|
|
2107
|
+
|
|
2108
|
+
constructor_signature: $ => seq(
|
|
2109
|
+
field('name', seq($.identifier, optional(
|
|
2110
|
+
seq(
|
|
2111
|
+
'.',
|
|
2112
|
+
$._identifier_or_new
|
|
2113
|
+
)
|
|
2114
|
+
))),
|
|
2115
|
+
field('parameters', $.formal_parameter_list)
|
|
2116
|
+
),
|
|
2117
|
+
constant_constructor_signature: $ => seq(
|
|
2118
|
+
$.const_builtin,
|
|
2119
|
+
seq($.identifier, optional(seq('.', $._identifier_or_new))),
|
|
2120
|
+
$.formal_parameter_list
|
|
2121
|
+
),
|
|
2122
|
+
|
|
2123
|
+
constructor_body: $ => seq(
|
|
2124
|
+
'{',
|
|
2125
|
+
optional($.explicit_constructor_invocation),
|
|
2126
|
+
repeat($._statement),
|
|
2127
|
+
'}'
|
|
2128
|
+
),
|
|
2129
|
+
|
|
2130
|
+
explicit_constructor_invocation: $ => seq(
|
|
2131
|
+
choice(
|
|
2132
|
+
seq(
|
|
2133
|
+
field('type_arguments', optional($.type_arguments)),
|
|
2134
|
+
field('constructor', choice($.this, $.super)),
|
|
2135
|
+
),
|
|
2136
|
+
seq(
|
|
2137
|
+
field('object', choice($._ambiguous_name, $._primary)),
|
|
2138
|
+
'.',
|
|
2139
|
+
field('type_arguments', optional($.type_arguments)),
|
|
2140
|
+
field('constructor', $.super),
|
|
2141
|
+
)
|
|
2142
|
+
),
|
|
2143
|
+
field('arguments', $.arguments),
|
|
2144
|
+
$._semicolon
|
|
2145
|
+
),
|
|
2146
|
+
|
|
2147
|
+
_ambiguous_name: $ => choice(
|
|
2148
|
+
$.identifier,
|
|
2149
|
+
$.scoped_identifier
|
|
2150
|
+
),
|
|
2151
|
+
|
|
2152
|
+
scoped_identifier: $ => seq(
|
|
2153
|
+
field('scope', choice($.identifier, $.scoped_identifier)),
|
|
2154
|
+
'.',
|
|
2155
|
+
field('name', $.identifier)
|
|
2156
|
+
),
|
|
2157
|
+
|
|
2158
|
+
variable_declaration: $ => seq(
|
|
2159
|
+
$._declared_identifier,
|
|
2160
|
+
optional(seq(
|
|
2161
|
+
',',
|
|
2162
|
+
commaSep1($.identifier)
|
|
2163
|
+
))
|
|
2164
|
+
),
|
|
2165
|
+
|
|
2166
|
+
initialized_variable_definition: $ => seq(
|
|
2167
|
+
$._declared_identifier,
|
|
2168
|
+
optional(seq(
|
|
2169
|
+
prec(DART_PREC.BUILTIN, '='),
|
|
2170
|
+
field('value', $._expression)
|
|
2171
|
+
)),
|
|
2172
|
+
repeat(seq(',', $.initialized_identifier))
|
|
2173
|
+
),
|
|
2174
|
+
// initialized_identifier: $ => seq(
|
|
2175
|
+
// $.identifier,
|
|
2176
|
+
// optional(seq('=', $._expression))
|
|
2177
|
+
// ),
|
|
2178
|
+
|
|
2179
|
+
_declared_identifier: $ => seq(
|
|
2180
|
+
optional($._metadata),
|
|
2181
|
+
optional($._covariant),
|
|
2182
|
+
$._final_const_var_or_type,
|
|
2183
|
+
field('name', $.identifier)
|
|
2184
|
+
),
|
|
2185
|
+
|
|
2186
|
+
// Types
|
|
2187
|
+
|
|
2188
|
+
_final_const_var_or_type: $ => choice(
|
|
2189
|
+
seq(optional($._late_builtin), $.final_builtin, optional($._type)),
|
|
2190
|
+
seq($.const_builtin, optional(
|
|
2191
|
+
$._type
|
|
2192
|
+
)),
|
|
2193
|
+
seq(optional($._late_builtin),
|
|
2194
|
+
$._var_or_type)
|
|
2195
|
+
),
|
|
2196
|
+
|
|
2197
|
+
_type: $ => choice(
|
|
2198
|
+
seq(
|
|
2199
|
+
$.function_type,
|
|
2200
|
+
optional($.nullable_type)
|
|
2201
|
+
),
|
|
2202
|
+
$._type_not_function
|
|
2203
|
+
// $._function_type_tails,
|
|
2204
|
+
// seq(
|
|
2205
|
+
// $._type_not_function,
|
|
2206
|
+
// $._function_type_tails
|
|
2207
|
+
// ),
|
|
2208
|
+
// $._type_not_function
|
|
2209
|
+
// $._unannotated_type,
|
|
2210
|
+
// $.annotated_type
|
|
2211
|
+
),
|
|
2212
|
+
_type_not_function: $ => choice(
|
|
2213
|
+
$._type_not_void_not_function,
|
|
2214
|
+
seq($.record_type, optional($.nullable_type)),
|
|
2215
|
+
$.void_type
|
|
2216
|
+
),
|
|
2217
|
+
_type_not_void_not_function: $ => choice(
|
|
2218
|
+
seq(
|
|
2219
|
+
$._type_name,
|
|
2220
|
+
optional($.type_arguments),
|
|
2221
|
+
optional($.nullable_type)
|
|
2222
|
+
),
|
|
2223
|
+
// rewritten in accordance with the draft spec page 198
|
|
2224
|
+
seq(
|
|
2225
|
+
$._function_builtin_identifier,
|
|
2226
|
+
optional($.nullable_type)
|
|
2227
|
+
)
|
|
2228
|
+
),
|
|
2229
|
+
|
|
2230
|
+
function_type: $ => choice(
|
|
2231
|
+
$._function_type_tails,
|
|
2232
|
+
seq(
|
|
2233
|
+
$._type_not_function,
|
|
2234
|
+
$._function_type_tails
|
|
2235
|
+
)
|
|
2236
|
+
),
|
|
2237
|
+
_function_type_tails: $ => repeat1($._function_type_tail),
|
|
2238
|
+
|
|
2239
|
+
_function_type_tail: $ => seq(
|
|
2240
|
+
$._function_builtin_identifier,
|
|
2241
|
+
optional($.type_parameters),
|
|
2242
|
+
optional($.nullable_type),
|
|
2243
|
+
optional($.parameter_type_list),
|
|
2244
|
+
optional($.nullable_type),
|
|
2245
|
+
),
|
|
2246
|
+
|
|
2247
|
+
parameter_type_list: $ => seq(
|
|
2248
|
+
'(',
|
|
2249
|
+
optional(choice(
|
|
2250
|
+
commaSep1TrailingComma($.normal_parameter_type),
|
|
2251
|
+
seq(
|
|
2252
|
+
commaSep1($.normal_parameter_type),
|
|
2253
|
+
',',
|
|
2254
|
+
$.optional_parameter_types,
|
|
2255
|
+
),
|
|
2256
|
+
$.optional_parameter_types
|
|
2257
|
+
),),
|
|
2258
|
+
')'
|
|
2259
|
+
),
|
|
2260
|
+
|
|
2261
|
+
normal_parameter_type: $ => seq(
|
|
2262
|
+
optional($._metadata),
|
|
2263
|
+
choice(
|
|
2264
|
+
$.typed_identifier,
|
|
2265
|
+
$._type
|
|
2266
|
+
)
|
|
2267
|
+
),
|
|
2268
|
+
|
|
2269
|
+
optional_parameter_types: $ => choice(
|
|
2270
|
+
$.optional_positional_parameter_types,
|
|
2271
|
+
$.named_parameter_types
|
|
2272
|
+
),
|
|
2273
|
+
|
|
2274
|
+
optional_positional_parameter_types: $ => seq(
|
|
2275
|
+
'[',
|
|
2276
|
+
commaSep1TrailingComma($.normal_parameter_type),
|
|
2277
|
+
']'
|
|
2278
|
+
),
|
|
2279
|
+
named_parameter_types: $ => seq(
|
|
2280
|
+
'{',
|
|
2281
|
+
commaSep1TrailingComma($._named_parameter_type),
|
|
2282
|
+
'}'
|
|
2283
|
+
),
|
|
2284
|
+
|
|
2285
|
+
_named_parameter_type: $ => seq(
|
|
2286
|
+
optional($._metadata),
|
|
2287
|
+
optional($._required),
|
|
2288
|
+
$.typed_identifier
|
|
2289
|
+
),
|
|
2290
|
+
|
|
2291
|
+
_type_not_void: $ => choice(
|
|
2292
|
+
seq(
|
|
2293
|
+
$.function_type,
|
|
2294
|
+
optional($.nullable_type)
|
|
2295
|
+
),
|
|
2296
|
+
seq($.record_type, optional($.nullable_type)),
|
|
2297
|
+
// $.function_type,
|
|
2298
|
+
$._type_not_void_not_function
|
|
2299
|
+
// alias($.identifier, $.type_identifier),
|
|
2300
|
+
// // $.scoped_type_identifier,
|
|
2301
|
+
// $.generic_type
|
|
2302
|
+
),
|
|
2303
|
+
|
|
2304
|
+
record_type: $ => choice(
|
|
2305
|
+
seq('(', ')'),
|
|
2306
|
+
seq('(', commaSep1($.record_type_field), ',', '{' , commaSep1TrailingComma($.record_type_named_field), '}', ')'),
|
|
2307
|
+
seq('(', commaSep1TrailingComma($.record_type_field), ')'),
|
|
2308
|
+
seq('(','{', commaSep1TrailingComma($.record_type_named_field), '}', ')'),
|
|
2309
|
+
),
|
|
2310
|
+
|
|
2311
|
+
record_type_field: $ => seq(
|
|
2312
|
+
optional($._metadata),
|
|
2313
|
+
$._type,
|
|
2314
|
+
optional($.identifier),
|
|
2315
|
+
),
|
|
2316
|
+
|
|
2317
|
+
record_type_named_field: $ => seq(
|
|
2318
|
+
optional($._metadata),
|
|
2319
|
+
$.typed_identifier,
|
|
2320
|
+
),
|
|
2321
|
+
|
|
2322
|
+
_type_not_void_list: $ => commaSep1(
|
|
2323
|
+
$._type_not_void
|
|
2324
|
+
),
|
|
2325
|
+
|
|
2326
|
+
_type_name: $ => seq(
|
|
2327
|
+
alias(
|
|
2328
|
+
$.identifier,
|
|
2329
|
+
$.type_identifier
|
|
2330
|
+
),
|
|
2331
|
+
optional(
|
|
2332
|
+
$._type_dot_identifier
|
|
2333
|
+
),
|
|
2334
|
+
// optional($.nullable_type),
|
|
2335
|
+
),
|
|
2336
|
+
|
|
2337
|
+
// _type_name: $ => prec.right( // changed from above?
|
|
2338
|
+
// seq(
|
|
2339
|
+
// alias(
|
|
2340
|
+
// $.identifier,
|
|
2341
|
+
// $.type_identifier
|
|
2342
|
+
// ),
|
|
2343
|
+
// optional(
|
|
2344
|
+
// $._type_dot_identifier
|
|
2345
|
+
// ),
|
|
2346
|
+
// optional($.nullable_type),
|
|
2347
|
+
// )
|
|
2348
|
+
// ),
|
|
2349
|
+
|
|
2350
|
+
_type_dot_identifier: $ => prec.right(
|
|
2351
|
+
DART_PREC.IMPORT_EXPORT,
|
|
2352
|
+
seq(
|
|
2353
|
+
'.',
|
|
2354
|
+
alias(
|
|
2355
|
+
$.identifier,
|
|
2356
|
+
$.type_identifier
|
|
2357
|
+
)
|
|
2358
|
+
)
|
|
2359
|
+
),
|
|
2360
|
+
|
|
2361
|
+
typed_identifier: $ => seq(
|
|
2362
|
+
$._type,
|
|
2363
|
+
$.identifier
|
|
2364
|
+
),
|
|
2365
|
+
|
|
2366
|
+
nullable_type: $ => prec(DART_PREC.BUILTIN, '?'),
|
|
2367
|
+
nullable_selector: $ => prec(DART_PREC.BUILTIN, '?'),
|
|
2368
|
+
|
|
2369
|
+
floating_point_type: $ => token(
|
|
2370
|
+
'double'
|
|
2371
|
+
),
|
|
2372
|
+
|
|
2373
|
+
boolean_type: $ => prec(
|
|
2374
|
+
DART_PREC.BUILTIN,
|
|
2375
|
+
'bool',
|
|
2376
|
+
),
|
|
2377
|
+
|
|
2378
|
+
void_type: $ => token('void'),
|
|
2379
|
+
|
|
2380
|
+
_var_or_type: $ => choice(
|
|
2381
|
+
$._type,
|
|
2382
|
+
seq(
|
|
2383
|
+
$.inferred_type,
|
|
2384
|
+
optional($._type)
|
|
2385
|
+
)
|
|
2386
|
+
),
|
|
2387
|
+
|
|
2388
|
+
_final_var_or_type: $ => choice($.inferred_type, $.final_builtin, seq(optional($.final_builtin), $._type)),
|
|
2389
|
+
|
|
2390
|
+
inferred_type: $ => prec(
|
|
2391
|
+
DART_PREC.BUILTIN,
|
|
2392
|
+
'var',
|
|
2393
|
+
),
|
|
2394
|
+
|
|
2395
|
+
function_body: $ => choice(
|
|
2396
|
+
seq(
|
|
2397
|
+
optional('async'),
|
|
2398
|
+
'=>',
|
|
2399
|
+
$._expression,
|
|
2400
|
+
$._semicolon
|
|
2401
|
+
),
|
|
2402
|
+
seq(
|
|
2403
|
+
optional(choice(
|
|
2404
|
+
'async',
|
|
2405
|
+
'async*',
|
|
2406
|
+
'sync*',
|
|
2407
|
+
)),
|
|
2408
|
+
$.block
|
|
2409
|
+
)
|
|
2410
|
+
),
|
|
2411
|
+
|
|
2412
|
+
function_expression_body: $ => choice(
|
|
2413
|
+
seq(
|
|
2414
|
+
optional('async'),
|
|
2415
|
+
'=>',
|
|
2416
|
+
$._expression
|
|
2417
|
+
),
|
|
2418
|
+
seq(
|
|
2419
|
+
optional(choice(
|
|
2420
|
+
'async',
|
|
2421
|
+
'async*',
|
|
2422
|
+
'sync*',
|
|
2423
|
+
)),
|
|
2424
|
+
$.block
|
|
2425
|
+
)
|
|
2426
|
+
),
|
|
2427
|
+
function_signature: $ => seq(
|
|
2428
|
+
// optional($._metadata),
|
|
2429
|
+
optional($._type),
|
|
2430
|
+
field('name', choice(
|
|
2431
|
+
alias(
|
|
2432
|
+
$._get,
|
|
2433
|
+
$.identifier, // this way the syntax still highlights consistently.
|
|
2434
|
+
),
|
|
2435
|
+
alias(
|
|
2436
|
+
$._set,
|
|
2437
|
+
$.identifier, // this way the syntax still highlights consistently.
|
|
2438
|
+
),
|
|
2439
|
+
// $._get,
|
|
2440
|
+
// $._set,
|
|
2441
|
+
$.identifier
|
|
2442
|
+
)),
|
|
2443
|
+
$._formal_parameter_part,
|
|
2444
|
+
optional($._native),
|
|
2445
|
+
),
|
|
2446
|
+
|
|
2447
|
+
// _get_identifier: $ => alias(
|
|
2448
|
+
// $.identifier, // this way the syntax still highlights consistently.
|
|
2449
|
+
// $._get
|
|
2450
|
+
// ),
|
|
2451
|
+
|
|
2452
|
+
_formal_parameter_part: $ => seq(
|
|
2453
|
+
optional($.type_parameters),
|
|
2454
|
+
$.formal_parameter_list
|
|
2455
|
+
),
|
|
2456
|
+
|
|
2457
|
+
|
|
2458
|
+
formal_parameter_list: $ => $._strict_formal_parameter_list,
|
|
2459
|
+
|
|
2460
|
+
_strict_formal_parameter_list: $ => choice(
|
|
2461
|
+
seq(
|
|
2462
|
+
'(',
|
|
2463
|
+
')'
|
|
2464
|
+
),
|
|
2465
|
+
seq(
|
|
2466
|
+
'(',
|
|
2467
|
+
$._normal_formal_parameters,
|
|
2468
|
+
optional(
|
|
2469
|
+
','
|
|
2470
|
+
),
|
|
2471
|
+
')'
|
|
2472
|
+
),
|
|
2473
|
+
seq(
|
|
2474
|
+
'(',
|
|
2475
|
+
$._normal_formal_parameters,
|
|
2476
|
+
',',
|
|
2477
|
+
$.optional_formal_parameters,
|
|
2478
|
+
')'
|
|
2479
|
+
),
|
|
2480
|
+
seq(
|
|
2481
|
+
'(',
|
|
2482
|
+
$.optional_formal_parameters,
|
|
2483
|
+
')'
|
|
2484
|
+
)
|
|
2485
|
+
),
|
|
2486
|
+
|
|
2487
|
+
_normal_formal_parameters: $ => commaSep1($.formal_parameter),
|
|
2488
|
+
optional_formal_parameters: $ => choice(
|
|
2489
|
+
$._optional_postional_formal_parameters,
|
|
2490
|
+
$._named_formal_parameters
|
|
2491
|
+
),
|
|
2492
|
+
|
|
2493
|
+
positional_parameters: $ => seq(
|
|
2494
|
+
'[',
|
|
2495
|
+
commaSep1(
|
|
2496
|
+
$._default_formal_parameter
|
|
2497
|
+
),
|
|
2498
|
+
']'
|
|
2499
|
+
),
|
|
2500
|
+
|
|
2501
|
+
_optional_postional_formal_parameters: $ => seq(
|
|
2502
|
+
'[',
|
|
2503
|
+
commaSep1TrailingComma(
|
|
2504
|
+
$._default_formal_parameter
|
|
2505
|
+
),
|
|
2506
|
+
']'
|
|
2507
|
+
),
|
|
2508
|
+
_named_formal_parameters: $ => seq(
|
|
2509
|
+
'{',
|
|
2510
|
+
commaSep1TrailingComma(
|
|
2511
|
+
$._default_named_parameter
|
|
2512
|
+
),
|
|
2513
|
+
'}'
|
|
2514
|
+
),
|
|
2515
|
+
|
|
2516
|
+
formal_parameter: $ => $._normal_formal_parameter,
|
|
2517
|
+
|
|
2518
|
+
_default_formal_parameter: $ => seq(
|
|
2519
|
+
$.formal_parameter,
|
|
2520
|
+
optional(
|
|
2521
|
+
seq(
|
|
2522
|
+
'=',
|
|
2523
|
+
$._expression
|
|
2524
|
+
)
|
|
2525
|
+
)
|
|
2526
|
+
),
|
|
2527
|
+
_default_named_parameter: $ => choice(
|
|
2528
|
+
seq(
|
|
2529
|
+
optional(
|
|
2530
|
+
$._metadata
|
|
2531
|
+
),
|
|
2532
|
+
optional(
|
|
2533
|
+
$._required
|
|
2534
|
+
),
|
|
2535
|
+
$.formal_parameter,
|
|
2536
|
+
optional(
|
|
2537
|
+
seq(
|
|
2538
|
+
'=',
|
|
2539
|
+
$._expression
|
|
2540
|
+
)
|
|
2541
|
+
)
|
|
2542
|
+
),
|
|
2543
|
+
seq(
|
|
2544
|
+
optional(
|
|
2545
|
+
$._metadata
|
|
2546
|
+
),
|
|
2547
|
+
optional(
|
|
2548
|
+
$._required
|
|
2549
|
+
),
|
|
2550
|
+
$.formal_parameter,
|
|
2551
|
+
optional(
|
|
2552
|
+
seq(
|
|
2553
|
+
':',
|
|
2554
|
+
$._expression
|
|
2555
|
+
)
|
|
2556
|
+
)
|
|
2557
|
+
)
|
|
2558
|
+
),
|
|
2559
|
+
|
|
2560
|
+
_normal_formal_parameter: $ => seq(
|
|
2561
|
+
optional(
|
|
2562
|
+
$._metadata
|
|
2563
|
+
),
|
|
2564
|
+
choice(
|
|
2565
|
+
$._function_formal_parameter,
|
|
2566
|
+
$._simple_formal_parameter,
|
|
2567
|
+
$.constructor_param,
|
|
2568
|
+
$.super_formal_parameter
|
|
2569
|
+
)
|
|
2570
|
+
),
|
|
2571
|
+
|
|
2572
|
+
_function_formal_parameter: $ => seq(
|
|
2573
|
+
optional(
|
|
2574
|
+
$._covariant
|
|
2575
|
+
),
|
|
2576
|
+
optional(
|
|
2577
|
+
$._type
|
|
2578
|
+
),
|
|
2579
|
+
$.identifier,
|
|
2580
|
+
$._formal_parameter_part,
|
|
2581
|
+
optional($.nullable_type)
|
|
2582
|
+
),
|
|
2583
|
+
|
|
2584
|
+
_simple_formal_parameter: $ => choice(
|
|
2585
|
+
$._declared_identifier,
|
|
2586
|
+
seq(
|
|
2587
|
+
optional(
|
|
2588
|
+
$._covariant
|
|
2589
|
+
),
|
|
2590
|
+
$.identifier
|
|
2591
|
+
)
|
|
2592
|
+
),
|
|
2593
|
+
|
|
2594
|
+
// see https://github.com/dart-lang/language/blob/31f3d2bd6fd83b2e5f5019adb276c23fd2900941/working/1855%20-%20super%20parameters/proposal.md
|
|
2595
|
+
super_formal_parameter: $ => seq(
|
|
2596
|
+
optional($._final_const_var_or_type),
|
|
2597
|
+
$.super,
|
|
2598
|
+
'.',
|
|
2599
|
+
$.identifier,
|
|
2600
|
+
optional($._formal_parameter_part)
|
|
2601
|
+
),
|
|
2602
|
+
|
|
2603
|
+
//constructor param = field formal parameter
|
|
2604
|
+
constructor_param: $ => seq(
|
|
2605
|
+
optional($._final_const_var_or_type),
|
|
2606
|
+
$.this,
|
|
2607
|
+
'.',
|
|
2608
|
+
$.identifier,
|
|
2609
|
+
optional($._formal_parameter_part)
|
|
2610
|
+
),
|
|
2611
|
+
|
|
2612
|
+
local_variable_declaration: $ => choice(
|
|
2613
|
+
seq(
|
|
2614
|
+
optional($._metadata),
|
|
2615
|
+
$.initialized_variable_definition,
|
|
2616
|
+
$._semicolon
|
|
2617
|
+
),
|
|
2618
|
+
seq(
|
|
2619
|
+
optional($._metadata),
|
|
2620
|
+
$.pattern_variable_declaration,
|
|
2621
|
+
$._semicolon
|
|
2622
|
+
)
|
|
2623
|
+
),
|
|
2624
|
+
|
|
2625
|
+
script_tag: $ => seq('#!', /.+/, '\n'),
|
|
2626
|
+
|
|
2627
|
+
library_name: $ => seq(optional($._metadata), 'library', $.dotted_identifier_list, $._semicolon),
|
|
2628
|
+
|
|
2629
|
+
dotted_identifier_list: $ => sep1($.identifier, '.'),
|
|
2630
|
+
|
|
2631
|
+
_identifier_or_new: $ => choice($.identifier, $._new_builtin),
|
|
2632
|
+
|
|
2633
|
+
qualified: $ =>choice(
|
|
2634
|
+
seq($._type_name, '.', $._identifier_or_new),
|
|
2635
|
+
seq($._type_name, '.', $._type_name, '.', $._identifier_or_new),
|
|
2636
|
+
),
|
|
2637
|
+
|
|
2638
|
+
// Built in identifier tokens: These should be tokenized.
|
|
2639
|
+
//assert,break,case,
|
|
2640
|
+
// catch,
|
|
2641
|
+
// class,
|
|
2642
|
+
// const,
|
|
2643
|
+
// continue,
|
|
2644
|
+
// default,
|
|
2645
|
+
// do,
|
|
2646
|
+
// else,
|
|
2647
|
+
// enum,
|
|
2648
|
+
// extends,
|
|
2649
|
+
// false,
|
|
2650
|
+
// final,
|
|
2651
|
+
// finally,
|
|
2652
|
+
// for,
|
|
2653
|
+
// if,
|
|
2654
|
+
// in,
|
|
2655
|
+
// is,
|
|
2656
|
+
// new,
|
|
2657
|
+
// null,
|
|
2658
|
+
// rethrow,
|
|
2659
|
+
// return,
|
|
2660
|
+
// super,
|
|
2661
|
+
// switch,
|
|
2662
|
+
// this,
|
|
2663
|
+
// throw,
|
|
2664
|
+
// true,
|
|
2665
|
+
// try,
|
|
2666
|
+
// var,
|
|
2667
|
+
// void,
|
|
2668
|
+
// while,
|
|
2669
|
+
// with
|
|
2670
|
+
|
|
2671
|
+
_as: $ => prec(
|
|
2672
|
+
DART_PREC.BUILTIN,
|
|
2673
|
+
'as',
|
|
2674
|
+
),
|
|
2675
|
+
break_builtin: $ => token('break'),
|
|
2676
|
+
assert_builtin: $ => token('assert'),
|
|
2677
|
+
case_builtin: $ => token('case'),
|
|
2678
|
+
rethrow_builtin: $ => token('rethrow'),
|
|
2679
|
+
part_of_builtin: $ => token('part of'),
|
|
2680
|
+
_covariant: $ => prec(
|
|
2681
|
+
DART_PREC.BUILTIN,
|
|
2682
|
+
'covariant',
|
|
2683
|
+
),
|
|
2684
|
+
_deferred: $ => prec(
|
|
2685
|
+
DART_PREC.BUILTIN,
|
|
2686
|
+
'deferred',
|
|
2687
|
+
),
|
|
2688
|
+
_dynamic: $ => prec(
|
|
2689
|
+
DART_PREC.BUILTIN,
|
|
2690
|
+
'dynamic',
|
|
2691
|
+
),
|
|
2692
|
+
_export: $ => prec(
|
|
2693
|
+
DART_PREC.BUILTIN,
|
|
2694
|
+
'export',
|
|
2695
|
+
),
|
|
2696
|
+
_external: $ => $._external_builtin,
|
|
2697
|
+
_factory: $ => prec(
|
|
2698
|
+
DART_PREC.BUILTIN,
|
|
2699
|
+
'factory',
|
|
2700
|
+
),
|
|
2701
|
+
_function_builtin_identifier: $ => prec(
|
|
2702
|
+
DART_PREC.BUILTIN,
|
|
2703
|
+
'Function',
|
|
2704
|
+
),
|
|
2705
|
+
_get: $ => prec(
|
|
2706
|
+
DART_PREC.BUILTIN,
|
|
2707
|
+
'get',
|
|
2708
|
+
),
|
|
2709
|
+
_native: $ => seq(
|
|
2710
|
+
'native', optional($.string_literal)
|
|
2711
|
+
),
|
|
2712
|
+
_implements: $ => prec(
|
|
2713
|
+
DART_PREC.BUILTIN,
|
|
2714
|
+
'implements',
|
|
2715
|
+
),
|
|
2716
|
+
_import: $ => prec(
|
|
2717
|
+
DART_PREC.BUILTIN,
|
|
2718
|
+
'import',
|
|
2719
|
+
),
|
|
2720
|
+
interface: $ => prec(
|
|
2721
|
+
DART_PREC.BUILTIN,
|
|
2722
|
+
'interface',
|
|
2723
|
+
),
|
|
2724
|
+
base: $ => prec(
|
|
2725
|
+
DART_PREC.BUILTIN,
|
|
2726
|
+
'base',
|
|
2727
|
+
),
|
|
2728
|
+
abstract: $ => prec(
|
|
2729
|
+
DART_PREC.BUILTIN,
|
|
2730
|
+
'abstract',
|
|
2731
|
+
),
|
|
2732
|
+
sealed: $ => prec(
|
|
2733
|
+
DART_PREC.BUILTIN,
|
|
2734
|
+
'sealed',
|
|
2735
|
+
),
|
|
2736
|
+
_library: $ => prec(
|
|
2737
|
+
DART_PREC.BUILTIN,
|
|
2738
|
+
'library',
|
|
2739
|
+
),
|
|
2740
|
+
_operator: $ => prec(
|
|
2741
|
+
DART_PREC.BUILTIN,
|
|
2742
|
+
'operator',
|
|
2743
|
+
),
|
|
2744
|
+
mixin: $ => prec(
|
|
2745
|
+
DART_PREC.BUILTIN,
|
|
2746
|
+
'mixin',
|
|
2747
|
+
),
|
|
2748
|
+
_part: $ => prec(
|
|
2749
|
+
DART_PREC.BUILTIN,
|
|
2750
|
+
'part',
|
|
2751
|
+
),
|
|
2752
|
+
_required: $ => prec(
|
|
2753
|
+
DART_PREC.BUILTIN,
|
|
2754
|
+
'required',
|
|
2755
|
+
),
|
|
2756
|
+
_set: $ => prec(
|
|
2757
|
+
DART_PREC.BUILTIN,
|
|
2758
|
+
'set',
|
|
2759
|
+
),
|
|
2760
|
+
_static: $ => prec(
|
|
2761
|
+
DART_PREC.BUILTIN,
|
|
2762
|
+
'static',
|
|
2763
|
+
),
|
|
2764
|
+
_typedef: $ => prec(
|
|
2765
|
+
DART_PREC.BUILTIN,
|
|
2766
|
+
'typedef',
|
|
2767
|
+
),
|
|
2768
|
+
_new_builtin: $ => prec(
|
|
2769
|
+
DART_PREC.BUILTIN,
|
|
2770
|
+
'new',
|
|
2771
|
+
),
|
|
2772
|
+
logical_and_operator: $ => prec(
|
|
2773
|
+
DART_PREC.BUILTIN,
|
|
2774
|
+
'&&',
|
|
2775
|
+
),
|
|
2776
|
+
logical_or_operator: $ => prec(
|
|
2777
|
+
DART_PREC.BUILTIN,
|
|
2778
|
+
'||'
|
|
2779
|
+
),
|
|
2780
|
+
const_builtin: $ => token('const'),
|
|
2781
|
+
final_builtin: $ => token('final'),
|
|
2782
|
+
_late_builtin: $ => prec(
|
|
2783
|
+
DART_PREC.BUILTIN,
|
|
2784
|
+
'late',
|
|
2785
|
+
),
|
|
2786
|
+
|
|
2787
|
+
_external_builtin: $ => prec(
|
|
2788
|
+
DART_PREC.BUILTIN,
|
|
2789
|
+
'external',
|
|
2790
|
+
),
|
|
2791
|
+
|
|
2792
|
+
this: $ => prec(
|
|
2793
|
+
DART_PREC.BUILTIN,
|
|
2794
|
+
'this',
|
|
2795
|
+
),
|
|
2796
|
+
|
|
2797
|
+
super: $ => prec(
|
|
2798
|
+
DART_PREC.BUILTIN,
|
|
2799
|
+
'super',
|
|
2800
|
+
),
|
|
2801
|
+
|
|
2802
|
+
label: $ => seq($.identifier, ':'),
|
|
2803
|
+
|
|
2804
|
+
_semicolon: $ => token(';'),
|
|
2805
|
+
|
|
2806
|
+
identifier: $ => /[a-zA-Z_$][\w$]*/,
|
|
2807
|
+
identifier_dollar_escaped: $ => /([a-zA-Z_]|(\\\$))([\w]|(\\\$))*/,
|
|
2808
|
+
//TODO: add support for triple-slash comments as a special category.
|
|
2809
|
+
// Trying to add support for nested multiline comments.
|
|
2810
|
+
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
|
2811
|
+
|
|
2812
|
+
// _line_comment: $ => token(seq(
|
|
2813
|
+
// '//', /[^\/].*/
|
|
2814
|
+
// )),
|
|
2815
|
+
// _documentation_line_comment: $ => token(seq('///', /.*/)),
|
|
2816
|
+
|
|
2817
|
+
comment: $ => choice(
|
|
2818
|
+
$._block_comment,
|
|
2819
|
+
seq('//', /([^/\n].*)?/),
|
|
2820
|
+
seq(
|
|
2821
|
+
'/*',
|
|
2822
|
+
/[^*]*\*+([^/*][^*]*\*+)*/,
|
|
2823
|
+
'/'
|
|
2824
|
+
)
|
|
2825
|
+
),
|
|
2826
|
+
//added nesting comments.
|
|
2827
|
+
documentation_comment: $ =>
|
|
2828
|
+
choice(
|
|
2829
|
+
$._documentation_block_comment,
|
|
2830
|
+
seq('///', /.*/),
|
|
2831
|
+
)
|
|
2832
|
+
,
|
|
2833
|
+
}
|
|
2834
|
+
});
|
|
2835
|
+
|
|
2836
|
+
function sep1(rule, separator) {
|
|
2837
|
+
return seq(rule, repeat(seq(separator, rule)));
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
function sep2(rule, separator) {
|
|
2841
|
+
return seq(rule, repeat1(seq(separator, rule)));
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
function commaSep1(rule) {
|
|
2845
|
+
return seq(rule, repeat(seq(',', rule)))
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
function commaSep(rule) {
|
|
2849
|
+
return optional(commaSep1(rule))
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
function commaSep2TrailingComma(rule) {
|
|
2853
|
+
return seq(rule, repeat1(seq(',', rule)), optional(','))
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
function commaSep1TrailingComma(rule) {
|
|
2857
|
+
return seq(rule, repeat(seq(',', rule)), optional(','))
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
function commaSepTrailingComma(rule) {
|
|
2861
|
+
return optional(commaSep1TrailingComma(rule))
|
|
2862
|
+
}
|
|
2863
|
+
|
|
2864
|
+
function pureBinaryRun(rule, separator, precedence){
|
|
2865
|
+
return prec.left(
|
|
2866
|
+
precedence,
|
|
2867
|
+
choice(
|
|
2868
|
+
sep2(
|
|
2869
|
+
rule,
|
|
2870
|
+
separator
|
|
2871
|
+
)))
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
function binaryRunLeft(rule, separator, superItem, precedence) {
|
|
2875
|
+
return prec.left( //left
|
|
2876
|
+
precedence,
|
|
2877
|
+
choice(
|
|
2878
|
+
sep2(
|
|
2879
|
+
// $.bitwise_xor_expression,
|
|
2880
|
+
rule,
|
|
2881
|
+
separator
|
|
2882
|
+
),
|
|
2883
|
+
seq(
|
|
2884
|
+
superItem,
|
|
2885
|
+
repeat1(
|
|
2886
|
+
seq(
|
|
2887
|
+
separator,
|
|
2888
|
+
rule,
|
|
2889
|
+
// $.bitwise_xor_expression
|
|
2890
|
+
)
|
|
2891
|
+
)
|
|
2892
|
+
)
|
|
2893
|
+
)
|
|
2894
|
+
)
|
|
2895
|
+
}
|