@@ -63,13 +63,14 @@ module.exports = grammar({
63
63
$ . _template_chars_single ,
64
64
$ . _template_chars_double_single ,
65
65
$ . _template_chars_single_single ,
66
- $ . _template_chars_raw_slash
66
+ $ . _template_chars_raw_slash ,
67
+ $ . _block_comment ,
68
+ $ . _documentation_block_comment ,
67
69
] ,
68
70
69
71
extras : $ => [
70
72
$ . comment ,
71
73
$ . documentation_comment ,
72
- // $.multiline_comment,
73
74
/ \s /
74
75
] ,
75
76
@@ -155,6 +156,7 @@ module.exports = grammar({
155
156
[ $ . _type_not_void_not_function , $ . _function_type_tail ] ,
156
157
[ $ . _type_not_void ] ,
157
158
[ $ . _type_not_void_not_function ] ,
159
+ [ $ . super_formal_parameter , $ . unconditional_assignable_selector ] ,
158
160
[ $ . function_signature ]
159
161
] ,
160
162
@@ -237,7 +239,7 @@ module.exports = grammar({
237
239
) ,
238
240
seq (
239
241
optional ( $ . _late_builtin ) ,
240
- choice ( $ . _type , $ . inferred_type ) ,
242
+ choice ( $ . _type , seq ( $ . inferred_type , optional ( $ . _type ) ) ) ,
241
243
$ . initialized_identifier_list ,
242
244
$ . _semicolon
243
245
)
@@ -1188,7 +1190,7 @@ module.exports = grammar({
1188
1190
$ . yield_each_statement ,
1189
1191
$ . expression_statement ,
1190
1192
$ . assert_statement ,
1191
- $ . labeled_statement ,
1193
+ // $.labeled_statement,
1192
1194
$ . lambda_expression
1193
1195
) ,
1194
1196
@@ -1207,11 +1209,15 @@ module.exports = grammar({
1207
1209
1208
1210
assert_statement : $ => seq ( $ . assertion , ';' ) ,
1209
1211
1210
- assertion : $ => seq ( $ . _assert_builtin , '(' , $ . _expression , optional ( seq (
1211
- ',' ,
1212
- $ . _expression ,
1213
- optional ( ',' )
1214
- ) ) , ')' ) ,
1212
+ assertion : $ => seq ( $ . _assert_builtin , '(' , $ . _expression ,
1213
+ optional (
1214
+ seq (
1215
+ ',' ,
1216
+ $ . _expression
1217
+ )
1218
+ ) ,
1219
+ optional ( ',' ) ,
1220
+ ')' ) ,
1215
1221
1216
1222
switch_statement : $ => seq (
1217
1223
'switch' ,
@@ -1225,10 +1231,20 @@ module.exports = grammar({
1225
1231
'}'
1226
1232
) ,
1227
1233
1228
- switch_label : $ => choice (
1234
+ switch_case : $ => choice (
1235
+ seq ( repeat ( $ . label ) , $ . case_builtin , $ . _expression , ':' , repeat1 ( $ . _statement ) ) ,
1236
+ ) ,
1237
+
1238
+ default_case : $ => choice (
1239
+ seq ( repeat ( $ . label ) , 'default' , ':' , repeat1 ( $ . _statement ) ) ,
1240
+ ) ,
1241
+
1242
+ switch_label : $ => seq (
1243
+ repeat ( $ . label ) ,
1244
+ choice (
1229
1245
seq ( $ . case_builtin , $ . _expression , ':' ) ,
1230
1246
seq ( 'default' , ':' )
1231
- ) ,
1247
+ ) ) ,
1232
1248
1233
1249
do_statement : $ => seq (
1234
1250
'do' ,
@@ -1593,6 +1609,12 @@ module.exports = grammar({
1593
1609
alias (
1594
1610
$ . identifier ,
1595
1611
$ . type_identifier ) ,
1612
+ // This is a comment
1613
+ // comment with a link made in https://github.com/flutter/flutter/pull/48547
1614
+ // Changes made in https://github.com/flutter/flutter/pull/48547
1615
+ /* This is also a comment */
1616
+ /* this comment /* // /** ends here: */
1617
+
1596
1618
optional ( $ . _nullable_type ) ,
1597
1619
optional ( $ . type_bound )
1598
1620
) ,
@@ -1844,10 +1866,6 @@ module.exports = grammar({
1844
1866
//$.arguements
1845
1867
$ . arguments
1846
1868
) ,
1847
- seq ( 'super' ,
1848
- //$.arguements
1849
- $ . arguments
1850
- ) ,
1851
1869
$ . field_initializer ,
1852
1870
$ . assertion
1853
1871
) ,
@@ -1985,8 +2003,8 @@ module.exports = grammar({
1985
2003
) ) ,
1986
2004
seq ( optional ( $ . _late_builtin ) ,
1987
2005
choice (
2006
+ $ . _type ,
1988
2007
$ . inferred_type ,
1989
- $ . _type
1990
2008
) )
1991
2009
) ,
1992
2010
@@ -2053,9 +2071,12 @@ module.exports = grammar({
2053
2071
')'
2054
2072
) ,
2055
2073
2056
- normal_parameter_type : $ => choice (
2057
- $ . typed_identifier ,
2058
- $ . _type
2074
+ normal_parameter_type : $ => seq (
2075
+ optional ( $ . _metadata ) ,
2076
+ choice (
2077
+ $ . typed_identifier ,
2078
+ $ . _type
2079
+ )
2059
2080
) ,
2060
2081
2061
2082
optional_parameter_types : $ => choice (
@@ -2070,10 +2091,16 @@ module.exports = grammar({
2070
2091
) ,
2071
2092
named_parameter_types : $ => seq (
2072
2093
'{' ,
2073
- commaSep1TrailingComma ( $ . typed_identifier ) ,
2094
+ commaSep1TrailingComma ( $ . _named_parameter_type ) ,
2074
2095
'}'
2075
2096
) ,
2076
2097
2098
+ _named_parameter_type : $ => seq (
2099
+ optional ( $ . _metadata ) ,
2100
+ optional ( $ . _required ) ,
2101
+ $ . typed_identifier
2102
+ ) ,
2103
+
2077
2104
_type_not_void : $ => choice (
2078
2105
seq (
2079
2106
$ . function_type ,
@@ -2126,7 +2153,6 @@ module.exports = grammar({
2126
2153
) ,
2127
2154
2128
2155
typed_identifier : $ => seq (
2129
- optional ( $ . _metadata ) ,
2130
2156
$ . _type ,
2131
2157
$ . identifier
2132
2158
) ,
@@ -2300,7 +2326,7 @@ module.exports = grammar({
2300
2326
_default_named_parameter : $ => choice (
2301
2327
seq (
2302
2328
optional (
2303
- 'required'
2329
+ $ . _required
2304
2330
) ,
2305
2331
$ . formal_parameter ,
2306
2332
optional (
@@ -2312,7 +2338,7 @@ module.exports = grammar({
2312
2338
) ,
2313
2339
seq (
2314
2340
optional (
2315
- 'required'
2341
+ $ . _required
2316
2342
) ,
2317
2343
$ . formal_parameter ,
2318
2344
optional (
@@ -2331,8 +2357,8 @@ module.exports = grammar({
2331
2357
choice (
2332
2358
$ . _function_formal_parameter ,
2333
2359
$ . _simple_formal_parameter ,
2334
- $ . constructor_param
2335
- // $.field_formal_parameter
2360
+ $ . constructor_param ,
2361
+ $ . super_formal_parameter
2336
2362
)
2337
2363
) ,
2338
2364
@@ -2357,6 +2383,16 @@ module.exports = grammar({
2357
2383
$ . identifier
2358
2384
)
2359
2385
) ,
2386
+
2387
+ // see https://github.com/dart-lang/language/blob/31f3d2bd6fd83b2e5f5019adb276c23fd2900941/working/1855%20-%20super%20parameters/proposal.md
2388
+ super_formal_parameter : $ => seq (
2389
+ optional ( $ . _final_const_var_or_type ) ,
2390
+ $ . super ,
2391
+ '.' ,
2392
+ $ . identifier ,
2393
+ optional ( $ . _formal_parameter_part )
2394
+ ) ,
2395
+
2360
2396
//constructor param = field formal parameter
2361
2397
constructor_param : $ => seq (
2362
2398
optional ( $ . _final_const_var_or_type ) ,
@@ -2501,6 +2537,10 @@ module.exports = grammar({
2501
2537
DART_PREC . BUILTIN ,
2502
2538
'part' ,
2503
2539
) ,
2540
+ _required : $ => prec (
2541
+ DART_PREC . BUILTIN ,
2542
+ 'required' ,
2543
+ ) ,
2504
2544
_set : $ => prec (
2505
2545
DART_PREC . BUILTIN ,
2506
2546
'set' ,
@@ -2564,83 +2604,35 @@ module.exports = grammar({
2564
2604
2565
2605
label : $ => seq ( $ . identifier , ':' ) ,
2566
2606
2567
- _semicolon : $ => seq ( ';' , optional ( $ . _automatic_semicolon ) ) ,
2607
+ _semicolon : $ => seq ( ';' ) ,
2568
2608
2569
2609
identifier : $ => / [ a - z A - Z _ $ ] [ \w $ ] * / ,
2570
2610
identifier_dollar_escaped : $ => / ( [ a - z A - Z _ ] | ( \\ \$ ) ) ( [ \w ] | ( \\ \$ ) ) * / ,
2571
2611
//TODO: add support for triple-slash comments as a special category.
2572
2612
// Trying to add support for nested multiline comments.
2573
2613
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
2574
- comment : $ => token ( choice (
2575
- seq ( '//' , / [ ^ / ] .* / ) ,
2614
+
2615
+ // _line_comment: $ => token(seq(
2616
+ // '//', /[^\/].*/
2617
+ // )),
2618
+ // _documentation_line_comment: $ => token(seq('///', /.*/)),
2619
+
2620
+ comment : $ => choice (
2621
+ $ . _block_comment ,
2622
+ seq ( '//' , / ( [ ^ / \n ] .* ) ? / ) ,
2576
2623
seq (
2577
2624
'/*' ,
2578
2625
/ [ ^ * ] * \* + ( [ ^ / * ] [ ^ * ] * \* + ) * / ,
2579
2626
'/'
2580
2627
)
2581
- ) ) ,
2628
+ ) ,
2582
2629
//added nesting comments.
2583
- documentation_comment : $ => token (
2630
+ documentation_comment : $ =>
2584
2631
choice (
2632
+ $ . _documentation_block_comment ,
2585
2633
seq ( '///' , / .* / ) ,
2586
- // seq(
2587
- // '/**',
2588
- // repeat(
2589
- // choice(
2590
- // /[^*]*\*+([^/*][^*]*\*+)*/,
2591
- // // $.comment
2592
- // // ,
2593
- // /.*/,
2594
- // $._multiline_comment,
2595
- // $.documentation_comment
2596
- // )
2597
- // ),
2598
- // '*/'
2599
- // )
2600
2634
)
2601
- ) ,
2602
- // multiline_comment: $ => seq(
2603
- // $._multiline_comment_begin,
2604
- // $._multiline_comment_core,
2605
- // // repeat(
2606
- // // choice(
2607
- // // $._multiline_comment_core,
2608
- // // $.multiline_comment
2609
- // // )
2610
- // // ),
2611
- // $._multiline_comment_end
2612
- // ),
2613
- // _multiline_comment_end: $ => token('*/'),
2614
- // _multiline_comment_begin: $ => token('/*'),
2615
- //
2616
- // _nested_multiline_comment: $ => seq(
2617
- // $._multiline_comment_begin,
2618
- // repeat(
2619
- // choice(
2620
- // /([^\/*]*|\/[^*]|\*[^\/])+/,
2621
- // $._nested_multiline_comment
2622
- // // seq(
2623
- // // $._multiline_comment_begin,
2624
- // // $._multiline_comment_core,
2625
- // // )
2626
- // )
2627
- // ),
2628
- // $._multiline_comment_end
2629
- // ),
2630
- //
2631
- // _multiline_comment_core: $ => seq(
2632
- // repeat1(
2633
- // choice(
2634
- // /([^\/*]*|\/[^*]|\*[^\/])+/,
2635
- // $._nested_multiline_comment
2636
- // // seq(
2637
- // // $._multiline_comment_begin,
2638
- // // $._multiline_comment_core,
2639
- // // )
2640
- // )
2641
- // ),
2642
- // // $._multiline_comment_end
2643
- // ),
2635
+ ,
2644
2636
}
2645
2637
} ) ;
2646
2638
0 commit comments