@@ -290,8 +290,7 @@ void ansi_c_scanner_init()
290
290
<GRAMMAR ,GCC_ATTRIBUTE3 >{string_lit } {
291
291
PARSER.string_literal .clear ();
292
292
PARSER.string_literal .append (yytext);
293
- newstack (yyansi_clval);
294
- PARSER.set_source_location (stack (yyansi_clval));
293
+ loc ();
295
294
// String literals can be continued in
296
295
// the next line
297
296
yy_push_state (STRING_LITERAL);
@@ -381,6 +380,23 @@ void ansi_c_scanner_init()
381
380
<GRAMMAR >{cppstart }" define" {ws }. * { /* ignore */ }
382
381
<GRAMMAR >{cppstart }" undef" {ws }. * { /* ignore */ }
383
382
383
+ <GRAMMAR >{cppstart }" asm" {
384
+ if (PARSER.mode ==configt::ansi_ct::flavourt::GCC) // really, this is BCC
385
+ {
386
+ BEGIN (ASM_BLOCK);
387
+ PARSER.string_literal .clear ();
388
+ loc ();
389
+ return ' {' ;
390
+ }
391
+ else
392
+ return make_identifier ();
393
+ }
394
+
395
+ <GRAMMAR >{cppstart }" endasm" {
396
+ loc ();
397
+ return ' }' ;
398
+ }
399
+
384
400
<GRAMMAR >{cppdirective } {
385
401
yyansi_cerror (" Preprocessor directive found" );
386
402
return TOK_SCANNER_ERROR;
@@ -1374,7 +1390,11 @@ __decltype { if(PARSER.cpp98 &&
1374
1390
1375
1391
" {" {
1376
1392
PARSER.tag_following =false ;
1377
- if (PARSER.asm_block_following ) { BEGIN (ASM_BLOCK); }
1393
+ if (PARSER.asm_block_following )
1394
+ {
1395
+ BEGIN (ASM_BLOCK);
1396
+ PARSER.string_literal .clear ();
1397
+ }
1378
1398
loc ();
1379
1399
return yytext[0 ];
1380
1400
}
@@ -1392,7 +1412,12 @@ __decltype { if(PARSER.cpp98 &&
1392
1412
<MSC_ANNOTATION >" ]" { BEGIN (GRAMMAR); }
1393
1413
<MSC_ANNOTATION >. { /* ignore */ }
1394
1414
1395
- <MSC_ASM >{ws }" {" { BEGIN (ASM_BLOCK); loc (); return ' {' ; }
1415
+ <MSC_ASM >{ws }" {" {
1416
+ BEGIN (ASM_BLOCK);
1417
+ PARSER.string_literal .clear ();
1418
+ loc ();
1419
+ return ' {' ;
1420
+ }
1396
1421
<MSC_ASM >[^ {^}^ \n ]* { loc ();
1397
1422
source_locationt l=stack (yyansi_clval).source_location ();
1398
1423
stack (yyansi_clval)=string_constantt (yytext);
@@ -1401,13 +1426,20 @@ __decltype { if(PARSER.cpp98 &&
1401
1426
return TOK_ASM_STRING;
1402
1427
}
1403
1428
1404
- <ASM_BLOCK >[^ } ]* { loc ();
1405
- source_locationt l=stack (yyansi_clval).source_location ();
1406
- stack (yyansi_clval)=string_constantt (yytext);
1407
- stack (yyansi_clval).add_source_location ()=l;
1408
- return TOK_ASM_STRING; }
1409
- <ASM_BLOCK >" }" { PARSER.asm_block_following =false ;
1410
- BEGIN (GRAMMAR); loc (); return ' }' ; }
1429
+ <ASM_BLOCK >{
1430
+ {ws } { /* ignore */ }
1431
+ {newline } { /* ignore */ }
1432
+ [^ #} \n ][^ \n } ]* [\n ] { PARSER.string_literal .append (yytext); }
1433
+ [^ #} \n ][^ \n } ]* { PARSER.string_literal .append (yytext); }
1434
+ . { // anything else: back to normal
1435
+ PARSER.asm_block_following =false ;
1436
+ loc ();
1437
+ stack (yyansi_clval)=string_constantt (PARSER.string_literal );
1438
+ BEGIN (GRAMMAR);
1439
+ yyless (0 ); // put back
1440
+ return TOK_ASM_STRING;
1441
+ }
1442
+ }
1411
1443
1412
1444
<IGNORE_PARENS >" )" { PARSER.parenthesis_counter --;
1413
1445
if (PARSER.parenthesis_counter ==0 )
0 commit comments