@@ -68,6 +68,7 @@ module.exports = grammar({
6868 // preprocessor statements
6969 / \s | \\ \r ? \n / ,
7070 $ . comment ,
71+ $ . multiline_preproc_comment ,
7172 '&' ,
7273 ] ,
7374
@@ -241,7 +242,8 @@ module.exports = grammar({
241242 ')' ,
242243 ) ,
243244
244- preproc_comment : $ => / \/ \* .* \* \/ / ,
245+ inline_preproc_comment : $ => / \/ \/ .* / ,
246+ multiline_preproc_comment : $ => / \/ \* ( [ ^ * ] | \* + [ ^ * / ] ) * \* + \/ / ,
245247
246248 preproc_binary_expression : $ => {
247249 const table = [
@@ -1240,7 +1242,9 @@ module.exports = grammar({
12401242 data_value : $ => seq (
12411243 '/' ,
12421244 commaSep1 ( seq (
1243- optional ( prec ( 1 , seq ( field ( 'repeat' , $ . number_literal ) , '*' ) ) ) ,
1245+ optional ( prec ( 1 ,
1246+ seq ( field ( 'repeat' , choice ( $ . number_literal , $ . identifier ) ) , '*' )
1247+ ) ) ,
12441248 choice (
12451249 $ . number_literal ,
12461250 $ . complex_literal ,
@@ -2436,37 +2440,51 @@ function preprocIf(suffix, content, precedence = 0) {
24362440 ) ;
24372441 }
24382442
2443+ /**
2444+ *
2445+ * @param {GrammarSymbols<string> } $
2446+ *
2447+ * @return {ChoiceRule }
2448+ *
2449+ */
2450+ function preprocComment ( $ ) {
2451+ return choice (
2452+ $ . inline_preproc_comment ,
2453+ $ . multiline_preproc_comment ,
2454+ ) ;
2455+ }
2456+
24392457 return {
24402458 [ 'preproc_if' + suffix ] : $ => prec ( precedence , seq (
24412459 preprocessor ( 'if' ) ,
24422460 field ( 'condition' , $ . _preproc_expression ) ,
2443- optional ( $ . preproc_comment ) ,
2461+ optional ( preprocComment ( $ ) ) ,
24442462 '\n' ,
24452463 content ( $ ) ,
24462464 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
24472465 preprocessor ( 'endif' ) ,
2448- optional ( $ . preproc_comment ) ,
2466+ optional ( preprocComment ( $ ) ) ,
24492467 ) ) ,
24502468
24512469 [ 'preproc_ifdef' + suffix ] : $ => prec ( precedence , seq (
24522470 choice ( preprocessor ( 'ifdef' ) , preprocessor ( 'ifndef' ) ) ,
24532471 field ( 'name' , $ . identifier ) ,
2454- optional ( $ . preproc_comment ) ,
2472+ optional ( preprocComment ( $ ) ) ,
24552473 content ( $ ) ,
24562474 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
24572475 preprocessor ( 'endif' ) ,
2458- optional ( $ . preproc_comment ) ,
2476+ optional ( preprocComment ( $ ) ) ,
24592477 ) ) ,
24602478
24612479 [ 'preproc_else' + suffix ] : $ => prec ( precedence , seq (
24622480 preprocessor ( 'else' ) ,
2463- optional ( $ . preproc_comment ) ,
2481+ optional ( preprocComment ( $ ) ) ,
24642482 content ( $ ) ,
24652483 ) ) ,
24662484
24672485 [ 'preproc_elif' + suffix ] : $ => prec ( precedence , seq (
24682486 preprocessor ( 'elif' ) ,
2469- optional ( $ . preproc_comment ) ,
2487+ optional ( preprocComment ( $ ) ) ,
24702488 field ( 'condition' , $ . _preproc_expression ) ,
24712489 '\n' ,
24722490 content ( $ ) ,
@@ -2476,7 +2494,7 @@ function preprocIf(suffix, content, precedence = 0) {
24762494 [ 'preproc_elifdef' + suffix ] : $ => prec ( precedence , seq (
24772495 choice ( preprocessor ( 'elifdef' ) , preprocessor ( 'elifndef' ) ) ,
24782496 field ( 'name' , $ . identifier ) ,
2479- optional ( $ . preproc_comment ) ,
2497+ optional ( preprocComment ( $ ) ) ,
24802498 content ( $ ) ,
24812499 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
24822500 ) ) ,
0 commit comments