@@ -75,6 +75,7 @@ module.exports = grammar({
7575 // preprocessor statements
7676 / \s | \\ \r ? \n / ,
7777 $ . comment ,
78+ $ . multiline_preproc_comment ,
7879 '&' ,
7980 ] ,
8081
@@ -248,7 +249,8 @@ module.exports = grammar({
248249 ')' ,
249250 ) ,
250251
251- preproc_comment : $ => choice ( / \/ \* .* \* \/ / , / \/ \/ .* / ) ,
252+ inline_preproc_comment : $ => / \/ \/ .* / ,
253+ multiline_preproc_comment : $ => / \/ \* ( [ ^ * ] | \* + [ ^ * / ] ) * \* + \/ / ,
252254
253255 preproc_binary_expression : $ => {
254256 const table = [
@@ -2466,36 +2468,50 @@ function preprocIf(suffix, content, precedence = 0) {
24662468 ) ;
24672469 }
24682470
2471+ /**
2472+ *
2473+ * @param {GrammarSymbols<string> } $
2474+ *
2475+ * @return {ChoiceRule }
2476+ *
2477+ */
2478+ function preprocComment ( $ ) {
2479+ return choice (
2480+ $ . inline_preproc_comment ,
2481+ $ . multiline_preproc_comment ,
2482+ ) ;
2483+ }
2484+
24692485 return {
24702486 [ 'preproc_if' + suffix ] : $ => prec ( precedence , seq (
24712487 preprocessor ( 'if' ) ,
24722488 field ( 'condition' , $ . _preproc_expression ) ,
2473- optional ( $ . preproc_comment ) ,
2489+ optional ( preprocComment ( $ ) ) ,
24742490 field ( 'content' , content ( $ ) ) ,
24752491 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
24762492 preprocessor ( 'endif' ) ,
2477- optional ( $ . preproc_comment ) ,
2493+ optional ( preprocComment ( $ ) ) ,
24782494 ) ) ,
24792495
24802496 [ 'preproc_ifdef' + suffix ] : $ => prec ( precedence , seq (
24812497 choice ( preprocessor ( 'ifdef' ) , preprocessor ( 'ifndef' ) ) ,
24822498 field ( 'name' , $ . identifier ) ,
2483- optional ( $ . preproc_comment ) ,
2499+ optional ( preprocComment ( $ ) ) ,
24842500 field ( 'content' , content ( $ ) ) ,
24852501 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
24862502 preprocessor ( 'endif' ) ,
2487- optional ( $ . preproc_comment ) ,
2503+ optional ( preprocComment ( $ ) ) ,
24882504 ) ) ,
24892505
24902506 [ 'preproc_else' + suffix ] : $ => prec ( precedence , seq (
24912507 preprocessor ( 'else' ) ,
2492- optional ( $ . preproc_comment ) ,
2508+ optional ( preprocComment ( $ ) ) ,
24932509 field ( 'content' , content ( $ ) ) ,
24942510 ) ) ,
24952511
24962512 [ 'preproc_elif' + suffix ] : $ => prec ( precedence , seq (
24972513 preprocessor ( 'elif' ) ,
2498- optional ( $ . preproc_comment ) ,
2514+ optional ( preprocComment ( $ ) ) ,
24992515 field ( 'condition' , $ . _preproc_expression ) ,
25002516 field ( 'content' , content ( $ ) ) ,
25012517 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
@@ -2504,7 +2520,7 @@ function preprocIf(suffix, content, precedence = 0) {
25042520 [ 'preproc_elifdef' + suffix ] : $ => prec ( precedence , seq (
25052521 choice ( preprocessor ( 'elifdef' ) , preprocessor ( 'elifndef' ) ) ,
25062522 field ( 'name' , $ . identifier ) ,
2507- optional ( $ . preproc_comment ) ,
2523+ optional ( preprocComment ( $ ) ) ,
25082524 field ( 'content' , content ( $ ) ) ,
25092525 field ( 'alternative' , optional ( alternativeBlock ( $ ) ) ) ,
25102526 ) ) ,
0 commit comments