@@ -911,16 +911,20 @@ module.exports = grammar({
911
911
$ . compound_literal_expression ,
912
912
$ . identifier ,
913
913
$ . number_literal ,
914
- $ . string_literal ,
914
+ $ . _string ,
915
915
$ . true ,
916
916
$ . false ,
917
917
$ . null ,
918
- $ . concatenated_string ,
919
918
$ . char_literal ,
920
919
$ . parenthesized_expression ,
921
920
$ . gnu_asm_expression ,
922
921
) ,
923
922
923
+ _string : $ => prec . left ( choice (
924
+ $ . string_literal ,
925
+ $ . concatenated_string ,
926
+ ) ) ,
927
+
924
928
comma_expression : $ => seq (
925
929
field ( 'left' , $ . _expression ) ,
926
930
',' ,
@@ -1070,7 +1074,7 @@ module.exports = grammar({
1070
1074
choice ( 'asm' , '__asm__' ) ,
1071
1075
repeat ( $ . gnu_asm_qualifier ) ,
1072
1076
'(' ,
1073
- field ( 'assembly_code' , choice ( $ . string_literal , $ . concatenated_string ) ) ,
1077
+ field ( 'assembly_code' , $ . _string ) ,
1074
1078
optional ( seq (
1075
1079
field ( 'output_operands' , $ . gnu_asm_output_operand_list ) ,
1076
1080
optional ( seq (
@@ -1232,10 +1236,15 @@ module.exports = grammar({
1232
1236
'\'' ,
1233
1237
) ,
1234
1238
1239
+ // Must concatenate at least 2 nodes, one of which must be a string_literal.
1240
+ // Identifier is added to parse macros that are strings, like PRIu64.
1235
1241
concatenated_string : $ => prec . right ( seq (
1236
- choice ( $ . identifier , $ . string_literal ) ,
1237
- $ . string_literal ,
1238
- repeat ( choice ( $ . string_literal , $ . identifier ) ) , // Identifier is added to parse macros that are strings, like PRIu64
1242
+ choice (
1243
+ seq ( $ . identifier , $ . string_literal ) ,
1244
+ seq ( $ . string_literal , $ . string_literal ) ,
1245
+ seq ( $ . string_literal , $ . identifier ) ,
1246
+ ) ,
1247
+ repeat ( choice ( $ . string_literal , $ . identifier ) ) ,
1239
1248
) ) ,
1240
1249
1241
1250
string_literal : $ => seq (
0 commit comments