Changeset 3426 for trunk/tools/wrc/parser.l
- Timestamp:
- Apr 19, 2000, 4:46:07 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/wrc/parser.l
r882 r3426 76 76 %x pp_false 77 77 /* Set when stripping c-junk */ 78 %x pp_stripe 78 79 %x pp_strips 79 80 %x pp_stripp … … 135 136 static int want_nl = 0; /* Set when newline needs to go to parser */ 136 137 static int want_ident = 0; /* Set is #ifdef, #ifndef or defined is seen */ 137 static int stripslevel = 0; /* Count {} during pp_strips mode */138 static int stripslevel = 0; /* Count {} during pp_strips/pp_stripe mode */ 138 139 static int stripplevel = 0; /* Count () during pp_strips mode */ 139 140 static char *substtext = NULL; /* Holds the substition text while getting a define */ … … 455 456 456 457 /* Conditional handling */ 457 <INITIAL,pp_strips,pp_strip p,pp_false>^{ws}*#{ws}*if{ws}* {458 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*if{ws}* { 458 459 if(YY_START == pp_false) 459 460 { … … 470 471 } 471 472 } 472 <INITIAL,pp_strips,pp_strip p,pp_false>^{ws}*#{ws}*ifdef{ws}* {473 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*ifdef{ws}* { 473 474 if(YY_START == pp_false) 474 475 { … … 486 487 } 487 488 } 488 <INITIAL,pp_strips,pp_strip p,pp_false>^{ws}*#{ws}*ifndef{ws}* {489 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*ifndef{ws}* { 489 490 if(YY_START == pp_false) 490 491 { … … 502 503 } 503 504 } 504 <INITIAL,pp_strips,pp_strip p,pp_false>^{ws}*#{ws}*elif{ws}* {505 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*elif{ws}* { 505 506 if(!isnevertrue_if()) 506 507 { … … 514 515 printf("(%d)#elif ignored\n", line_number); 515 516 } 516 <INITIAL,pp_strips,pp_strip p,pp_false>^{ws}*#{ws}*else{ws}* {517 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*else{ws}* { 517 518 if(!isnevertrue_if()) 518 519 { … … 524 525 printf("(%d)#else ignored\n", line_number); 525 526 } 526 <INITIAL,pp_strips,pp_strip p,pp_false>^{ws}*#{ws}*endif{ws}* {527 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*endif{ws}* { 527 528 if(!isnevertrue_if()) 528 529 { … … 539 540 540 541 /* The error directive */ 541 ^{ws}*#{ws}*error{ws}* push_to(pp_error); 542 <pp_error>[^\n]* yyerror("Error directive: %s", yytext); 542 <INITIAL,pp_strips,pp_stripe,pp_stripp>^{ws}*#{ws}*error{ws}* push_to(pp_error); 543 <pp_error>[^\n]* yyerror("Error directive: %s", yytext); 544 <pp_false>^{ws}*#{ws}*error[^\n]* { 545 if(yydebug) 546 printf("(%d)#error ignored\n", line_number); 547 } 543 548 544 549 /* preprocessor junk */ 545 ^{ws}*#{ws}*pragma[^\n]* ; /* Ignore #pragma */ 546 ^{ws}*#{ws}*line[^\n]* ; /* Ignore #line */ 550 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*pragma[^\n]* ; /* Ignore #pragma */ 551 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*ident[^\n]* ; /* Ignore #ident */ 552 <INITIAL,pp_strips,pp_stripe,pp_stripp,pp_false>^{ws}*#{ws}*line[^\n]* ; /* Ignore #line */ 547 553 /* We'll get an error on malformed #xxx statements 548 554 * by not recognising '#' at all. This helps tracking … … 556 562 <pp_strips>\/[^*\n] ; /* To catch comments */ 557 563 <pp_strips>[^\{\};\n#/]* ; /* Ignore rest */ 564 565 <pp_stripe>\{ stripslevel++; 566 <pp_stripe>\} { 567 stripslevel--; 568 if(!stripslevel) pop_start(); 569 } 570 <pp_stripe>; if(!stripslevel) pop_start(); 571 <pp_stripe>\/[^*\n] ; /* To catch comments */ 572 <pp_stripe>[^\{\};\n#/]* ; /* Ignore rest */ 558 573 559 574 <pp_stripp>\( stripplevel++; … … 758 773 <yystr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */ 759 774 <yystr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */ 760 <yystr>. yywarning("Matched %c" );775 <yystr>. yywarning("Matched %c", *yytext); 761 776 762 777 … … 782 797 <yyrcd>. yyerror("Malformed data-line"); 783 798 784 <INITIAL,pp_ignore,pp_def_s,pp_strips,pp_strip p>"/*" push_to(comment); /* Eat comment */799 <INITIAL,pp_ignore,pp_def_s,pp_strips,pp_stripe,pp_stripp>"/*" push_to(comment); /* Eat comment */ 785 800 <comment>[^*\n]* ; 786 801 <comment>"*"+[^*/\n]* ; … … 791 806 <INITIAL,pp_ignore,pp_def_s>"//"[^\n]* ; /* Eat comment */ 792 807 793 <INITIAL,yywf,pp_false,pp_strips,pp_strip p>\n {808 <INITIAL,yywf,pp_false,pp_strips,pp_stripe,pp_stripp>\n { 794 809 if(YY_START == yywf) 795 810 pop_start(); … … 809 824 if(!pop_buffer()) 810 825 { 811 if(YY_START == pp_strips || YY_START == pp_strip p || YY_START == pp_stripp_final)826 if(YY_START == pp_strips || YY_START == pp_stripe || YY_START == pp_stripp || YY_START == pp_stripp_final) 812 827 yyerror("Unexpected end of file during c-junk scanning (started at %d)", cjunk_tagline); 813 828 else … … 824 839 char_number = 1; 825 840 } 826 yywarning("Unmatched text '%c' (0x%02x) YY_START=%d ",827 isprint(*yytext) ? *yytext : '.', *yytext, YY_START );841 yywarning("Unmatched text '%c' (0x%02x) YY_START=%d stripslevel=%d", 842 isprint(*yytext) ? *yytext : '.', *yytext, YY_START,stripslevel); 828 843 } 829 844 … … 959 974 960 975 /* Called from the parser to kill c-junk */ 976 void strip_extern(void) 977 { 978 cjunk_tagline = line_number; 979 push_to(pp_stripe); 980 } 981 961 982 void strip_til_semicolon(void) 962 983 { … … 972 993 } 973 994 974
Note:
See TracChangeset
for help on using the changeset viewer.