Tidy up the piece_*() functions, make flush() a function piece_flush(size_t n)
authorNick Downing <downing.nick@gmail.com>
Thu, 26 Jul 2018 01:15:26 +0000 (11:15 +1000)
committerNick Downing <downing.nick@gmail.com>
Thu, 26 Jul 2018 01:20:04 +0000 (11:20 +1000)
src/scan.c
src/scan.l

index 5f1846b..3de2210 100644 (file)
@@ -7706,8 +7706,14 @@ extern const char *escaped_qstart, *escaped_qend;
 
 #define MARK_END_OF_PROLOG mark_prolog();
 
+#if 1
+static int real_flexscan(void);
+#define YY_DECL \
+       static int real_flexscan(void)
+#else
 #define YY_DECL \
        int flexscan(void)
+#endif
 
 #define RETURNCHAR \
        yylval = (unsigned char) yytext[0]; \
@@ -7773,107 +7779,16 @@ char piece_temp[100];
 char *piece[10000];
 int piece0;
 int piece1;
-void piece_append(const char *str) {
- piece[piece1++] = strdup(str);
-}
-void piece_insert(int n, const char *str) {
- memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
- piece[n] = strdup(str);
- ++piece1;
-}
 
-#define flush() \
- do { \
-  piece_esc(yytext, yy_c_buf_p - yytext); \
-  yytext = yy_c_buf_p; \
- } while (0)
+void piece_append(const char *str);
+void piece_insert(int n, const char *str);
+void piece_esc(const char *p, size_t n);
+void piece_flush(size_t n);
+void piece_pack();
 
 static void markup_action(const char *text);
 static void markup_option(const char *name, int sense);
 
-static int real_yylex(void);
-static void piece_esc(const char *p, size_t n) {
- size_t i, j = 0;
- for (i = 0; i < n; ++i)
-  switch (p[i]) {
-  case '<':
-  case '>':
-   j += 4;
-   break;
-  case '&':
-   j += 5;
-   break;
-  default:
-   ++j;
-   break;
-  }
- char *q = malloc(j + 1);
- j = 0;
- for (i = 0; i < n; ++i)
-  switch (p[i]) {
-  case '<':
-   memcpy(q + j, "&lt;", 4);
-   j += 4;
-   break;
-  case '>':
-   memcpy(q + j, "&gt;", 4);
-   j += 4;
-   break;
-  case '&':
-   memcpy(q + j, "&amp;", 5);
-   j += 5;
-   break;
-  default:
-   q[j++] = p[i];
-   break;
-  }
- q[j] = 0;
- piece[piece1++] = q;
-}
-static void piece_pack() {
- int i;
- size_t j = 0;
- for (i = piece0; i < piece1; ++i)
-  j += strlen(piece[i]);
- char *q = malloc(j + 1);
- j = 0;
- for (i = piece0; i < piece1; ++i) {
-  int k = strlen(piece[i]);
-  memcpy(q + j, piece[i], k);
-  free(piece[i]);
-  j += k;
- }
- q[j] = 0;
- piece[piece0++] = q;
- piece1 = piece0;
-}
-YY_DECL
-{
- int result = real_yylex();
- if (result < 0)
-  return ~result;
- piece_pack();
-#if 1
- piece_esc(yytext, strlen(yytext));
-#else
- size_t n = strlen(yytext);
- if (n) {
-  sprintf(piece_temp, "<token value=\"%d\">", result);
-  piece_append(piece_temp);
-  piece_esc(yytext, n);
-  piece_append("</token>");
- }
- else {
-  sprintf(piece_temp, "<token value=\"%d\" />", result);
-  piece_append(piece_temp);
- }
-#endif
- piece_pack();
- return result;
-}
-#undef YY_DECL
-#define YY_DECL static int real_yylex(void)
-
 
 
 
@@ -7883,7 +7798,7 @@ YY_DECL
 
 
 
-#line 7878 "scan.c"
+#line 7793 "scan.c"
 
 #define INITIAL 0
 #define SECT2 1
@@ -8107,7 +8022,7 @@ YY_DECL
        register char *yy_cp, *yy_bp;
        register int yy_act;
     
-#line 275 "scan.l"
+#line 190 "scan.l"
 
        static int bracelevel, didadef, indented_code;
        static int doing_rule_action = false;
@@ -8118,7 +8033,7 @@ YY_DECL
        char nmdef[MAXLINE];
 
 
-#line 8113 "scan.c"
+#line 8028 "scan.c"
 
        if ( !(yy_init) )
                {
@@ -8213,39 +8128,39 @@ do_action:      /* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 286 "scan.l"
+#line 201 "scan.l"
 START_CODEBLOCK(true); piece_append("<PLex_Text>");
        YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 287 "scan.l"
+#line 202 "scan.l"
 add_action("/*[""["); yy_push_state( COMMENT );
        YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 288 "scan.l"
+#line 203 "scan.l"
 yy_push_state( LINEDIR );
        YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 289 "scan.l"
+#line 204 "scan.l"
 return SCDECL;
        YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 290 "scan.l"
+#line 205 "scan.l"
 return XSCDECL;
        YY_BREAK
 case 6:
 /* rule 6 can match eol */
 YY_RULE_SETUP
-#line 291 "scan.l"
-START_CODEBLOCK(false); flush(); piece_append("<PLex_Text>");
+#line 206 "scan.l"
+START_CODEBLOCK(false); piece_flush(strlen(yytext)); piece_append("<PLex_Text>");
        YY_BREAK
 case 7:
 /* rule 7 can match eol */
 YY_RULE_SETUP
-#line 292 "scan.l"
+#line 207 "scan.l"
 {
                 brace_start_line = linenum;
                 ++linenum;
@@ -8256,17 +8171,17 @@ YY_RULE_SETUP
        YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 300 "scan.l"
+#line 215 "scan.l"
 synerr( _("malformed '%top' directive") );
        YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 302 "scan.l"
+#line 217 "scan.l"
 /* discard */
        YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 304 "scan.l"
+#line 219 "scan.l"
 {
                        sectnum = 2;
                        bracelevel = 0;
@@ -8288,42 +8203,42 @@ YY_RULE_SETUP
 case 11:
 /* rule 11 can match eol */
 YY_RULE_SETUP
-#line 322 "scan.l"
+#line 237 "scan.l"
 yytext_is_array = false; ++linenum; piece_append("<PLex_Section1_Options><PLex_Section1_Options_Array>"); { int i = strlen(yytext) - 1; piece_esc(yytext, i); yytext += i; } piece_append("</PLex_Section1_Options_Array></PLex_Section1_Options>"); 
        YY_BREAK
 case 12:
 /* rule 12 can match eol */
 YY_RULE_SETUP
-#line 323 "scan.l"
+#line 238 "scan.l"
 yytext_is_array = true; ++linenum; piece_append("<PLex_Section1_Options><PLex_Section1_Options_Array value=\"true\">"); { int i = strlen(yytext) - 1; piece_esc(yytext, i); yytext += i; } piece_append("</PLex_Section1_Options_Array></PLex_Section1_Options>");
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 325 "scan.l"
+#line 240 "scan.l"
 BEGIN(OPTION); return TOK_OPTION;
        YY_BREAK
 case 14:
 /* rule 14 can match eol */
 YY_RULE_SETUP
-#line 327 "scan.l"
+#line 242 "scan.l"
 ++linenum; /* ignore */
        YY_BREAK
 case 15:
 /* rule 15 can match eol */
 YY_RULE_SETUP
-#line 328 "scan.l"
+#line 243 "scan.l"
 ++linenum;     /* ignore */
        YY_BREAK
 /* xgettext: no-c-format */
 case 16:
 /* rule 16 can match eol */
 YY_RULE_SETUP
-#line 331 "scan.l"
+#line 246 "scan.l"
 synerr( _( "unrecognized '%' directive" ) );
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 333 "scan.l"
+#line 248 "scan.l"
 {
                        if(yyleng < MAXLINE)
                         {
@@ -8341,51 +8256,51 @@ YY_RULE_SETUP
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 348 "scan.l"
+#line 263 "scan.l"
 RETURNNAME;
        YY_BREAK
 case 19:
 /* rule 19 can match eol */
 YY_RULE_SETUP
-#line 349 "scan.l"
+#line 264 "scan.l"
 ++linenum; /* allows blank lines in section 1 */
        YY_BREAK
 case 20:
 /* rule 20 can match eol */
 YY_RULE_SETUP
-#line 350 "scan.l"
+#line 265 "scan.l"
 ACTION_ECHO; ++linenum; /* maybe end of comment line */
        YY_BREAK
 
 /* */
 case 21:
 YY_RULE_SETUP
-#line 355 "scan.l"
+#line 270 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 356 "scan.l"
+#line 271 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 23:
 /* rule 23 can match eol */
 YY_RULE_SETUP
-#line 358 "scan.l"
+#line 273 "scan.l"
 ++linenum; ACTION_ECHO;
        YY_BREAK
 
 
 case 24:
 YY_RULE_SETUP
-#line 361 "scan.l"
+#line 276 "scan.l"
 add_action("*/]""]"); yy_pop_state();
        YY_BREAK
 
 
 case 25:
 YY_RULE_SETUP
-#line 364 "scan.l"
+#line 279 "scan.l"
 ACTION_ECHO; yy_pop_state();
        YY_BREAK
 
@@ -8393,41 +8308,41 @@ ACTION_ECHO; yy_pop_state();
 /* This is the same as COMMENT, but is discarded rather than output. */
 case 26:
 YY_RULE_SETUP
-#line 369 "scan.l"
+#line 284 "scan.l"
 yy_pop_state();
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 370 "scan.l"
+#line 285 "scan.l"
 ;
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 371 "scan.l"
+#line 286 "scan.l"
 ;
        YY_BREAK
 case 29:
 /* rule 29 can match eol */
 YY_RULE_SETUP
-#line 372 "scan.l"
+#line 287 "scan.l"
 ++linenum;
        YY_BREAK
 
 
 case 30:
 YY_RULE_SETUP
-#line 376 "scan.l"
+#line 291 "scan.l"
 yy_pop_state();
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 377 "scan.l"
+#line 292 "scan.l"
 ;
        YY_BREAK
 case 32:
 /* rule 32 can match eol */
 YY_RULE_SETUP
-#line 378 "scan.l"
+#line 293 "scan.l"
 ++linenum;
        YY_BREAK
 
@@ -8435,17 +8350,17 @@ YY_RULE_SETUP
 case 33:
 /* rule 33 can match eol */
 YY_RULE_SETUP
-#line 382 "scan.l"
+#line 297 "scan.l"
 yy_pop_state();
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 383 "scan.l"
+#line 298 "scan.l"
 linenum = myctoi( yytext );
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 385 "scan.l"
+#line 300 "scan.l"
 {
                        free(infilename);
                        infilename = xstrdup(yytext + 1);
@@ -8454,19 +8369,19 @@ YY_RULE_SETUP
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 390 "scan.l"
+#line 305 "scan.l"
 /* ignore spurious characters */
        YY_BREAK
 
 
 case 37:
 YY_RULE_SETUP
-#line 393 "scan.l"
+#line 308 "scan.l"
 ACTION_ECHO_QSTART;
        YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 394 "scan.l"
+#line 309 "scan.l"
 ACTION_ECHO_QEND;
        YY_BREAK
 
@@ -8474,34 +8389,34 @@ ACTION_ECHO_QEND;
 case 39:
 /* rule 39 can match eol */
 YY_RULE_SETUP
-#line 398 "scan.l"
-++linenum; piece_append("</PLex_Text>"); flush(); END_CODEBLOCK;
+#line 313 "scan.l"
+++linenum; piece_append("</PLex_Text>"); piece_flush(strlen(yytext)); END_CODEBLOCK;
        YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 399 "scan.l"
+#line 314 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 400 "scan.l"
+#line 315 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 42:
 /* rule 42 can match eol */
 YY_RULE_SETUP
-#line 401 "scan.l"
+#line 316 "scan.l"
 {
                        ++linenum;
                        ACTION_ECHO;
-                       if ( indented_code ) { flush(); piece_append("</PLex_Text>"); END_CODEBLOCK; }
+                       if ( indented_code ) { piece_flush(strlen(yytext)); piece_append("</PLex_Text>"); END_CODEBLOCK; }
                        }
        YY_BREAK
 
 
 case 43:
 YY_RULE_SETUP
-#line 409 "scan.l"
+#line 324 "scan.l"
 {
                 if( --brace_depth == 0){
                     /* TODO: Matched. */
@@ -8512,7 +8427,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 417 "scan.l"
+#line 332 "scan.l"
 {
                 brace_depth++;
                 buf_strnappend(&top_buf, yytext, yyleng);
@@ -8521,7 +8436,7 @@ YY_RULE_SETUP
 case 45:
 /* rule 45 can match eol */
 YY_RULE_SETUP
-#line 422 "scan.l"
+#line 337 "scan.l"
 {
                 ++linenum;
                 buf_strnappend(&top_buf, yytext, yyleng);
@@ -8529,23 +8444,23 @@ YY_RULE_SETUP
        YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 427 "scan.l"
+#line 342 "scan.l"
 buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart));
        YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 428 "scan.l"
+#line 343 "scan.l"
 buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend));
        YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 429 "scan.l"
+#line 344 "scan.l"
 {
        buf_strnappend(&top_buf, yytext, yyleng);
     }
        YY_BREAK
 case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE):
-#line 433 "scan.l"
+#line 348 "scan.l"
 {
                 linenum = brace_start_line;
                 synerr(_("Unmatched '{'"));
@@ -8556,12 +8471,12 @@ case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE):
 
 case 49:
 YY_RULE_SETUP
-#line 442 "scan.l"
+#line 357 "scan.l"
 /* separates name and definition */
        YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 444 "scan.l"
+#line 359 "scan.l"
 {
                        if(yyleng < MAXLINE)
                         {
@@ -8587,7 +8502,7 @@ YY_RULE_SETUP
 case 51:
 /* rule 51 can match eol */
 YY_RULE_SETUP
-#line 466 "scan.l"
+#line 381 "scan.l"
 {
                        if ( ! didadef )
                                synerr( _( "incomplete name definition" ) );
@@ -8600,42 +8515,42 @@ YY_RULE_SETUP
 case 52:
 /* rule 52 can match eol */
 YY_RULE_SETUP
-#line 476 "scan.l"
+#line 391 "scan.l"
 ++linenum; BEGIN(INITIAL);
        YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 477 "scan.l"
+#line 392 "scan.l"
 option_sense = true;
        YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 479 "scan.l"
+#line 394 "scan.l"
 return '=';
        YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 481 "scan.l"
+#line 396 "scan.l"
 option_sense = ! option_sense;
        YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 483 "scan.l"
+#line 398 "scan.l"
 csize = option_sense ? 128 : 256; markup_option("SevenBit", option_sense);
        YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 484 "scan.l"
+#line 399 "scan.l"
 csize = option_sense ? 256 : 128; markup_option("SevenBit", !option_sense);
        YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 486 "scan.l"
+#line 401 "scan.l"
 long_align = option_sense; markup_option("Align", option_sense);
        YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 487 "scan.l"
+#line 402 "scan.l"
 {
                        ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
             interactive = option_sense;
@@ -8644,27 +8559,27 @@ YY_RULE_SETUP
        YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 492 "scan.l"
+#line 407 "scan.l"
 yytext_is_array = option_sense; markup_option("Array", option_sense);
        YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 493 "scan.l"
+#line 408 "scan.l"
 backing_up_report = option_sense; markup_option("Backup", option_sense);
        YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 494 "scan.l"
+#line 409 "scan.l"
 interactive = ! option_sense; markup_option("Interactive", !option_sense);
        YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 495 "scan.l"
+#line 410 "scan.l"
 bison_bridge_lval = option_sense; markup_option("BisonBridge", option_sense);
        YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 496 "scan.l"
+#line 411 "scan.l"
 { if((bison_bridge_lloc = option_sense))
                             bison_bridge_lval = true;
  markup_option("BisonLocations", option_sense);
@@ -8672,37 +8587,37 @@ YY_RULE_SETUP
        YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 500 "scan.l"
+#line 415 "scan.l"
 C_plus_plus = option_sense; markup_option("CPlusPlus", option_sense);
        YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 501 "scan.l"
+#line 416 "scan.l"
 sf_set_case_ins(!option_sense); markup_option("Caseless", !option_sense);
        YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 502 "scan.l"
+#line 417 "scan.l"
 sf_set_case_ins(option_sense); markup_option("Caseless", option_sense);
        YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 503 "scan.l"
+#line 418 "scan.l"
 ddebug = option_sense; markup_option("Debug", option_sense);
        YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 504 "scan.l"
+#line 419 "scan.l"
 spprdflt = ! option_sense; markup_option("Default", option_sense);
        YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 505 "scan.l"
+#line 420 "scan.l"
 useecs = option_sense; markup_option("ECS", option_sense);
        YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 506 "scan.l"
+#line 421 "scan.l"
 {
                        useecs = usemecs = false;
                        use_read = fullspd = true;
@@ -8711,7 +8626,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 72:
 YY_RULE_SETUP
-#line 511 "scan.l"
+#line 426 "scan.l"
 {
                        useecs = usemecs = false;
                        use_read = fulltbl = true;
@@ -8720,32 +8635,32 @@ YY_RULE_SETUP
        YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 516 "scan.l"
+#line 431 "scan.l"
 ACTION_IFDEF("YY_NO_INPUT", ! option_sense); markup_option("Input", option_sense);
        YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 517 "scan.l"
+#line 432 "scan.l"
 interactive = option_sense; markup_option("Interactive", option_sense);
        YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 518 "scan.l"
+#line 433 "scan.l"
 lex_compat = option_sense; markup_option("LexCompat", option_sense);
        YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 519 "scan.l"
+#line 434 "scan.l"
 posix_compat = option_sense; markup_option("PosixCompat", option_sense);
        YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 520 "scan.l"
+#line 435 "scan.l"
 gen_line_dirs = option_sense; markup_option("Line", option_sense);
        YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 521 "scan.l"
+#line 436 "scan.l"
 {
                        ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
             /* Override yywrap */
@@ -8756,12 +8671,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 79:
 YY_RULE_SETUP
-#line 528 "scan.l"
+#line 443 "scan.l"
 usemecs = option_sense; markup_option("MetaECS", option_sense);
        YY_BREAK
 case 80:
 YY_RULE_SETUP
-#line 529 "scan.l"
+#line 444 "scan.l"
 {
                        ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense );
             interactive = !option_sense;
@@ -8770,237 +8685,237 @@ YY_RULE_SETUP
        YY_BREAK
 case 81:
 YY_RULE_SETUP
-#line 534 "scan.l"
+#line 449 "scan.l"
 performance_report += option_sense ? 1 : -1; markup_option("PerfReport", option_sense);
        YY_BREAK
 case 82:
 YY_RULE_SETUP
-#line 535 "scan.l"
+#line 450 "scan.l"
 yytext_is_array = ! option_sense; markup_option("Array", !option_sense);
        YY_BREAK
 case 83:
 YY_RULE_SETUP
-#line 536 "scan.l"
+#line 451 "scan.l"
 use_read = option_sense; markup_option("Read", option_sense);
        YY_BREAK
 case 84:
 YY_RULE_SETUP
-#line 537 "scan.l"
+#line 452 "scan.l"
 reentrant = option_sense; markup_option("Reentrant", option_sense);
        YY_BREAK
 case 85:
 YY_RULE_SETUP
-#line 538 "scan.l"
+#line 453 "scan.l"
 reject_really_used = option_sense; markup_option("Reject", option_sense);
        YY_BREAK
 case 86:
 YY_RULE_SETUP
-#line 539 "scan.l"
+#line 454 "scan.l"
 ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense ); markup_option("Stack", option_sense);
        YY_BREAK
 case 87:
 YY_RULE_SETUP
-#line 540 "scan.l"
+#line 455 "scan.l"
 do_stdinit = option_sense; markup_option("StdInit", option_sense);
        YY_BREAK
 case 88:
 YY_RULE_SETUP
-#line 541 "scan.l"
+#line 456 "scan.l"
 use_stdout = option_sense; markup_option("StdOut", option_sense);
        YY_BREAK
 case 89:
 YY_RULE_SETUP
-#line 542 "scan.l"
+#line 457 "scan.l"
 ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); markup_option("UniStd", option_sense);
        YY_BREAK
 case 90:
 YY_RULE_SETUP
-#line 543 "scan.l"
+#line 458 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense); markup_option("Unput", option_sense);
        YY_BREAK
 case 91:
 YY_RULE_SETUP
-#line 544 "scan.l"
+#line 459 "scan.l"
 printstats = option_sense; markup_option("Verbose", option_sense);
        YY_BREAK
 case 92:
 YY_RULE_SETUP
-#line 545 "scan.l"
+#line 460 "scan.l"
 nowarn = ! option_sense; markup_option("Warn", option_sense);
        YY_BREAK
 case 93:
 YY_RULE_SETUP
-#line 546 "scan.l"
+#line 461 "scan.l"
 do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense); markup_option("YYLineNo", option_sense);
        YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 547 "scan.l"
+#line 462 "scan.l"
 yymore_really_used = option_sense; markup_option("YYMore", option_sense);
        YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 548 "scan.l"
+#line 463 "scan.l"
 do_yywrap = option_sense; markup_option("YYWrap", option_sense);
        YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 550 "scan.l"
+#line 465 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense); markup_option("YYPushState", option_sense);
        YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 551 "scan.l"
+#line 466 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense); markup_option("YYPopState", option_sense);
        YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 552 "scan.l"
+#line 467 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_TOP_STATE", ! option_sense); markup_option("YYTopState", option_sense);
        YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 554 "scan.l"
+#line 469 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BUFFER", ! option_sense); markup_option("YYScanBuffer", option_sense);
        YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 555 "scan.l"
+#line 470 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense); markup_option("YYScanBytes", option_sense);
        YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 556 "scan.l"
+#line 471 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense); markup_option("YYScanString", option_sense);
        YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 558 "scan.l"
+#line 473 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense); markup_option("YYAlloc", option_sense);
        YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 559 "scan.l"
+#line 474 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense); markup_option("YYRealloc", option_sense);
        YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 560 "scan.l"
+#line 475 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense); markup_option("YYFree", option_sense);
        YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 562 "scan.l"
+#line 477 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense); markup_option("YYGetDebug", option_sense);
        YY_BREAK
 case 106:
 YY_RULE_SETUP
-#line 563 "scan.l"
+#line 478 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense); markup_option("YYSetDebug", option_sense);
        YY_BREAK
 case 107:
 YY_RULE_SETUP
-#line 564 "scan.l"
+#line 479 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense); markup_option("YYGetExtra", option_sense);
        YY_BREAK
 case 108:
 YY_RULE_SETUP
-#line 565 "scan.l"
+#line 480 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense); markup_option("YYSetExtra", option_sense);
        YY_BREAK
 case 109:
 YY_RULE_SETUP
-#line 566 "scan.l"
+#line 481 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense); markup_option("YYGetLeng", option_sense);
        YY_BREAK
 case 110:
 YY_RULE_SETUP
-#line 567 "scan.l"
+#line 482 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense); markup_option("YYGetText", option_sense);
        YY_BREAK
 case 111:
 YY_RULE_SETUP
-#line 568 "scan.l"
+#line 483 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense); markup_option("YYGetLineNo", option_sense);
        YY_BREAK
 case 112:
 YY_RULE_SETUP
-#line 569 "scan.l"
+#line 484 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense); markup_option("YYSetLineNo", option_sense);
        YY_BREAK
 case 113:
 YY_RULE_SETUP
-#line 570 "scan.l"
+#line 485 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense); markup_option("YYGetIn", option_sense);
        YY_BREAK
 case 114:
 YY_RULE_SETUP
-#line 571 "scan.l"
+#line 486 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense); markup_option("YYSetIn", option_sense);
        YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 572 "scan.l"
+#line 487 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense); markup_option("YYGetOut", option_sense);
        YY_BREAK
 case 116:
 YY_RULE_SETUP
-#line 573 "scan.l"
+#line 488 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense); markup_option("YYSetOut", option_sense);
        YY_BREAK
 case 117:
 YY_RULE_SETUP
-#line 574 "scan.l"
+#line 489 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense); markup_option("YYGetLVal", option_sense);
        YY_BREAK
 case 118:
 YY_RULE_SETUP
-#line 575 "scan.l"
+#line 490 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense); markup_option("YYSetLVal", option_sense);
        YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 576 "scan.l"
+#line 491 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense); markup_option("YYGetLLoc", option_sense);
        YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 577 "scan.l"
+#line 492 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense); markup_option("YYSetLLoc", option_sense);
        YY_BREAK
 case 121:
 YY_RULE_SETUP
-#line 579 "scan.l"
+#line 494 "scan.l"
 return TOK_EXTRA_TYPE;
        YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 580 "scan.l"
+#line 495 "scan.l"
 return TOK_OUTFILE;
        YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 581 "scan.l"
+#line 496 "scan.l"
 return TOK_PREFIX;
        YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 582 "scan.l"
+#line 497 "scan.l"
 return TOK_YYCLASS;
        YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 583 "scan.l"
+#line 498 "scan.l"
 return TOK_HEADER_FILE;
        YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 584 "scan.l"
+#line 499 "scan.l"
 return TOK_TABLES_FILE;
        YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 585 "scan.l"
+#line 500 "scan.l"
 {
                     tablesverify = option_sense;
                     if(!tablesext && option_sense)
@@ -9010,7 +8925,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 593 "scan.l"
+#line 508 "scan.l"
 {
                        if(yyleng-1 < MAXLINE)
                         {
@@ -9036,7 +8951,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 616 "scan.l"
+#line 531 "scan.l"
 {
                        format_synerr( _( "unrecognized %%option: %s" ),
                                yytext );
@@ -9047,28 +8962,28 @@ YY_RULE_SETUP
 case 130:
 /* rule 130 can match eol */
 YY_RULE_SETUP
-#line 623 "scan.l"
+#line 538 "scan.l"
 ++linenum; BEGIN(INITIAL);
        YY_BREAK
 
 case 131:
 YY_RULE_SETUP
-#line 627 "scan.l"
+#line 542 "scan.l"
 ++bracelevel; yyless( 2 );     /* eat only %{ */
        YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 628 "scan.l"
+#line 543 "scan.l"
 --bracelevel; yyless( 2 );     /* eat only %} */
        YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 630 "scan.l"
+#line 545 "scan.l"
 START_CODEBLOCK(true); piece_append("<PLex_Text>"); /* indented code in prolog */
        YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 632 "scan.l"
+#line 547 "scan.l"
 {
         /* non-indented code */
                if ( bracelevel <= 0 ) {
@@ -9085,17 +9000,17 @@ YY_RULE_SETUP
        YY_BREAK
 case 135:
 YY_RULE_SETUP
-#line 646 "scan.l"
+#line 561 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 136:
 /* rule 136 can match eol */
 YY_RULE_SETUP
-#line 647 "scan.l"
+#line 562 "scan.l"
 ++linenum; ACTION_ECHO;
        YY_BREAK
 case YY_STATE_EOF(SECT2PROLOG):
-#line 649 "scan.l"
+#line 564 "scan.l"
 {
                        mark_prolog();
                        sectnum = 0;
@@ -9114,12 +9029,12 @@ case YY_STATE_EOF(SECT2PROLOG):
 case 137:
 /* rule 137 can match eol */
 YY_RULE_SETUP
-#line 664 "scan.l"
+#line 579 "scan.l"
 ++linenum; /* allow blank lines in section 2 */
        YY_BREAK
 case 138:
 YY_RULE_SETUP
-#line 666 "scan.l"
+#line 581 "scan.l"
 {
                        indented_code = false;
                        doing_codeblock = true;
@@ -9129,13 +9044,13 @@ YY_RULE_SETUP
  piece_esc(yytext, i);
  yytext += i;
  piece_append("<PLex_Section1Or2_CodeBlock>");
flush();
piece_flush(strlen(yytext));
  piece_append("<PLex_Text>");
                        }
        YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 679 "scan.l"
+#line 594 "scan.l"
 {
                         /* Allow "<" to appear in (?x) patterns. */
                         if (!sf_skip_ws())
@@ -9145,12 +9060,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 685 "scan.l"
+#line 600 "scan.l"
 return '^';
        YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 686 "scan.l"
+#line 601 "scan.l"
 BEGIN(QUOTE); return '"';
        YY_BREAK
 case 142:
@@ -9158,7 +9073,7 @@ case 142:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 687 "scan.l"
+#line 602 "scan.l"
 {
                        BEGIN(NUM);
                        if ( lex_compat || posix_compat )
@@ -9173,12 +9088,12 @@ case 143:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 694 "scan.l"
+#line 609 "scan.l"
 return '$';
        YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 696 "scan.l"
+#line 611 "scan.l"
 {
                        bracelevel = 1;
                        BEGIN(PERCENT_BRACE_ACTION);
@@ -9204,7 +9119,7 @@ YY_RULE_SETUP
 #if 1 /* don't think this can really happen */
  abort();
 #else
flush();
piece_flush(strlen(yytext));
  piece_append("<PLex_Text>");
 #endif
                        }
@@ -9212,7 +9127,7 @@ YY_RULE_SETUP
 case 145:
 /* rule 145 can match eol */
 YY_RULE_SETUP
-#line 725 "scan.l"
+#line 640 "scan.l"
 {
                         if (sf_skip_ws()){
                             /* We're in the middle of a (?x: ) pattern. */
@@ -9244,7 +9159,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 146:
 YY_RULE_SETUP
-#line 754 "scan.l"
+#line 669 "scan.l"
 {
 
                 if (sf_skip_ws()){
@@ -9261,12 +9176,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 147:
 YY_RULE_SETUP
-#line 768 "scan.l"
+#line 683 "scan.l"
 /* allow indented rules */ ;
        YY_BREAK
 case 148:
 YY_RULE_SETUP
-#line 770 "scan.l"
+#line 685 "scan.l"
 {
             if (sf_skip_ws()){
                 /* We're in the middle of a (?x: ) pattern. */
@@ -9300,7 +9215,7 @@ YY_RULE_SETUP
 case 149:
 /* rule 149 can match eol */
 YY_RULE_SETUP
-#line 800 "scan.l"
+#line 715 "scan.l"
 {
             if (sf_skip_ws()){
                 /* We're in the middle of a (?x: ) pattern. */
@@ -9334,15 +9249,15 @@ YY_RULE_SETUP
                        }
        YY_BREAK
 case 150:
-#line 833 "scan.l"
+#line 748 "scan.l"
 case 151:
 YY_RULE_SETUP
-#line 833 "scan.l"
+#line 748 "scan.l"
 return EOF_OP;
        YY_BREAK
 case 152:
 YY_RULE_SETUP
-#line 835 "scan.l"
+#line 750 "scan.l"
 {
                        sectnum = 3;
                        BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3);
@@ -9362,7 +9277,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 153:
 YY_RULE_SETUP
-#line 852 "scan.l"
+#line 767 "scan.l"
 {
                        int cclval;
 
@@ -9412,12 +9327,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 154:
 YY_RULE_SETUP
-#line 898 "scan.l"
+#line 813 "scan.l"
 return CCL_OP_DIFF;
        YY_BREAK
 case 155:
 YY_RULE_SETUP
-#line 899 "scan.l"
+#line 814 "scan.l"
 return CCL_OP_UNION;
        YY_BREAK
 /* Check for :space: at the end of the rule so we don't
@@ -9427,7 +9342,7 @@ return CCL_OP_UNION;
 case 156:
 /* rule 156 can match eol */
 YY_RULE_SETUP
-#line 906 "scan.l"
+#line 821 "scan.l"
 {
                        char *nmdefptr;
             int end_is_ws, end_ch;
@@ -9482,7 +9397,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
        YY_BREAK
 case 157:
 YY_RULE_SETUP
-#line 958 "scan.l"
+#line 873 "scan.l"
 {
                     if (sf_skip_ws())
                         yy_push_state(COMMENT_DISCARD);
@@ -9495,7 +9410,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 158:
 YY_RULE_SETUP
-#line 968 "scan.l"
+#line 883 "scan.l"
 {
                     if (lex_compat || posix_compat){
                         /* Push back the "?#" and treat it like a normal parens. */
@@ -9509,7 +9424,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 159:
 YY_RULE_SETUP
-#line 978 "scan.l"
+#line 893 "scan.l"
 {
                     sf_push();
                     if (lex_compat || posix_compat)
@@ -9522,12 +9437,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 160:
 YY_RULE_SETUP
-#line 987 "scan.l"
+#line 902 "scan.l"
 sf_push(); return '(';
        YY_BREAK
 case 161:
 YY_RULE_SETUP
-#line 988 "scan.l"
+#line 903 "scan.l"
 {
                     if (_sf_top_ix > 0) {
                         sf_pop();
@@ -9538,17 +9453,17 @@ YY_RULE_SETUP
        YY_BREAK
 case 162:
 YY_RULE_SETUP
-#line 996 "scan.l"
+#line 911 "scan.l"
 return (unsigned char) yytext[0];
        YY_BREAK
 case 163:
 YY_RULE_SETUP
-#line 997 "scan.l"
+#line 912 "scan.l"
 RETURNCHAR;
        YY_BREAK
 /* Nick added this rule for consistency with rest of scanner */
 case YY_STATE_EOF(SECT2):
-#line 1000 "scan.l"
+#line 915 "scan.l"
 {
                        sectnum = 0;
 #if 1
@@ -9566,17 +9481,17 @@ case YY_STATE_EOF(SECT2):
 case 164:
 /* rule 164 can match eol */
 YY_RULE_SETUP
-#line 1015 "scan.l"
+#line 930 "scan.l"
 ++linenum;     /* Allow blank lines & continuations */
        YY_BREAK
 case 165:
 YY_RULE_SETUP
-#line 1016 "scan.l"
+#line 931 "scan.l"
 return (unsigned char) yytext[0];
        YY_BREAK
 case 166:
 YY_RULE_SETUP
-#line 1017 "scan.l"
+#line 932 "scan.l"
 BEGIN(SECT2); return '>';
        YY_BREAK
 case 167:
@@ -9584,17 +9499,17 @@ case 167:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 1018 "scan.l"
+#line 933 "scan.l"
 BEGIN(CARETISBOL); return '>';
        YY_BREAK
 case 168:
 YY_RULE_SETUP
-#line 1019 "scan.l"
+#line 934 "scan.l"
 RETURNNAME;
        YY_BREAK
 case 169:
 YY_RULE_SETUP
-#line 1020 "scan.l"
+#line 935 "scan.l"
 {
                        format_synerr( _( "bad <start condition>: %s" ),
                                yytext );
@@ -9603,24 +9518,24 @@ YY_RULE_SETUP
 
 case 170:
 YY_RULE_SETUP
-#line 1026 "scan.l"
+#line 941 "scan.l"
 BEGIN(SECT2); return '^';
        YY_BREAK
 
 case 171:
 YY_RULE_SETUP
-#line 1030 "scan.l"
+#line 945 "scan.l"
 RETURNCHAR;
        YY_BREAK
 case 172:
 YY_RULE_SETUP
-#line 1031 "scan.l"
+#line 946 "scan.l"
 BEGIN(SECT2); return '"';
        YY_BREAK
 case 173:
 /* rule 173 can match eol */
 YY_RULE_SETUP
-#line 1033 "scan.l"
+#line 948 "scan.l"
 {
                        synerr( _( "missing quote" ) );
                        BEGIN(SECT2);
@@ -9632,49 +9547,49 @@ YY_RULE_SETUP
 
 case 174:
 YY_RULE_SETUP
-#line 1042 "scan.l"
+#line 957 "scan.l"
 BEGIN(SECT2);
        YY_BREAK
 case 175:
 YY_RULE_SETUP
-#line 1043 "scan.l"
+#line 958 "scan.l"
 BEGIN(GROUP_MINUS_PARAMS);
        YY_BREAK
 case 176:
 YY_RULE_SETUP
-#line 1044 "scan.l"
+#line 959 "scan.l"
 sf_set_case_ins(1);
        YY_BREAK
 case 177:
 YY_RULE_SETUP
-#line 1045 "scan.l"
+#line 960 "scan.l"
 sf_set_dot_all(1);
        YY_BREAK
 case 178:
 YY_RULE_SETUP
-#line 1046 "scan.l"
+#line 961 "scan.l"
 sf_set_skip_ws(1);
        YY_BREAK
 
 
 case 179:
 YY_RULE_SETUP
-#line 1049 "scan.l"
+#line 964 "scan.l"
 BEGIN(SECT2);
        YY_BREAK
 case 180:
 YY_RULE_SETUP
-#line 1050 "scan.l"
+#line 965 "scan.l"
 sf_set_case_ins(0);
        YY_BREAK
 case 181:
 YY_RULE_SETUP
-#line 1051 "scan.l"
+#line 966 "scan.l"
 sf_set_dot_all(0);
        YY_BREAK
 case 182:
 YY_RULE_SETUP
-#line 1052 "scan.l"
+#line 967 "scan.l"
 sf_set_skip_ws(0);
        YY_BREAK
 
@@ -9684,7 +9599,7 @@ case 183:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 1056 "scan.l"
+#line 971 "scan.l"
 BEGIN(CCL); return '^';
        YY_BREAK
 case 184:
@@ -9692,12 +9607,12 @@ case 184:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 1057 "scan.l"
+#line 972 "scan.l"
 return '^';
        YY_BREAK
 case 185:
 YY_RULE_SETUP
-#line 1058 "scan.l"
+#line 973 "scan.l"
 BEGIN(CCL); RETURNCHAR;
        YY_BREAK
 
@@ -9707,23 +9622,23 @@ case 186:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 1062 "scan.l"
+#line 977 "scan.l"
 return '-';
        YY_BREAK
 case 187:
 YY_RULE_SETUP
-#line 1063 "scan.l"
+#line 978 "scan.l"
 RETURNCHAR;
        YY_BREAK
 case 188:
 YY_RULE_SETUP
-#line 1064 "scan.l"
+#line 979 "scan.l"
 BEGIN(SECT2); return ']';
        YY_BREAK
 case 189:
 /* rule 189 can match eol */
 YY_RULE_SETUP
-#line 1065 "scan.l"
+#line 980 "scan.l"
 {
                        synerr( _( "bad character class" ) );
                        BEGIN(SECT2);
@@ -9734,127 +9649,127 @@ YY_RULE_SETUP
 
 case 190:
 YY_RULE_SETUP
-#line 1073 "scan.l"
+#line 988 "scan.l"
 BEGIN(CCL); return CCE_ALNUM;
        YY_BREAK
 case 191:
 YY_RULE_SETUP
-#line 1074 "scan.l"
+#line 989 "scan.l"
 BEGIN(CCL); return CCE_ALPHA;
        YY_BREAK
 case 192:
 YY_RULE_SETUP
-#line 1075 "scan.l"
+#line 990 "scan.l"
 BEGIN(CCL); return CCE_BLANK;
        YY_BREAK
 case 193:
 YY_RULE_SETUP
-#line 1076 "scan.l"
+#line 991 "scan.l"
 BEGIN(CCL); return CCE_CNTRL;
        YY_BREAK
 case 194:
 YY_RULE_SETUP
-#line 1077 "scan.l"
+#line 992 "scan.l"
 BEGIN(CCL); return CCE_DIGIT;
        YY_BREAK
 case 195:
 YY_RULE_SETUP
-#line 1078 "scan.l"
+#line 993 "scan.l"
 BEGIN(CCL); return CCE_GRAPH;
        YY_BREAK
 case 196:
 YY_RULE_SETUP
-#line 1079 "scan.l"
+#line 994 "scan.l"
 BEGIN(CCL); return CCE_LOWER;
        YY_BREAK
 case 197:
 YY_RULE_SETUP
-#line 1080 "scan.l"
+#line 995 "scan.l"
 BEGIN(CCL); return CCE_PRINT;
        YY_BREAK
 case 198:
 YY_RULE_SETUP
-#line 1081 "scan.l"
+#line 996 "scan.l"
 BEGIN(CCL); return CCE_PUNCT;
        YY_BREAK
 case 199:
 YY_RULE_SETUP
-#line 1082 "scan.l"
+#line 997 "scan.l"
 BEGIN(CCL); return CCE_SPACE;
        YY_BREAK
 case 200:
 YY_RULE_SETUP
-#line 1083 "scan.l"
+#line 998 "scan.l"
 BEGIN(CCL); return CCE_UPPER;
        YY_BREAK
 case 201:
 YY_RULE_SETUP
-#line 1084 "scan.l"
+#line 999 "scan.l"
 BEGIN(CCL); return CCE_XDIGIT;
        YY_BREAK
 case 202:
 YY_RULE_SETUP
-#line 1086 "scan.l"
+#line 1001 "scan.l"
 BEGIN(CCL); return CCE_NEG_ALNUM;
        YY_BREAK
 case 203:
 YY_RULE_SETUP
-#line 1087 "scan.l"
+#line 1002 "scan.l"
 BEGIN(CCL); return CCE_NEG_ALPHA;
        YY_BREAK
 case 204:
 YY_RULE_SETUP
-#line 1088 "scan.l"
+#line 1003 "scan.l"
 BEGIN(CCL); return CCE_NEG_BLANK;
        YY_BREAK
 case 205:
 YY_RULE_SETUP
-#line 1089 "scan.l"
+#line 1004 "scan.l"
 BEGIN(CCL); return CCE_NEG_CNTRL;
        YY_BREAK
 case 206:
 YY_RULE_SETUP
-#line 1090 "scan.l"
+#line 1005 "scan.l"
 BEGIN(CCL); return CCE_NEG_DIGIT;
        YY_BREAK
 case 207:
 YY_RULE_SETUP
-#line 1091 "scan.l"
+#line 1006 "scan.l"
 BEGIN(CCL); return CCE_NEG_GRAPH;
        YY_BREAK
 case 208:
 YY_RULE_SETUP
-#line 1092 "scan.l"
+#line 1007 "scan.l"
 BEGIN(CCL); return CCE_NEG_LOWER;
        YY_BREAK
 case 209:
 YY_RULE_SETUP
-#line 1093 "scan.l"
+#line 1008 "scan.l"
 BEGIN(CCL); return CCE_NEG_PRINT;
        YY_BREAK
 case 210:
 YY_RULE_SETUP
-#line 1094 "scan.l"
+#line 1009 "scan.l"
 BEGIN(CCL); return CCE_NEG_PUNCT;
        YY_BREAK
 case 211:
 YY_RULE_SETUP
-#line 1095 "scan.l"
+#line 1010 "scan.l"
 BEGIN(CCL); return CCE_NEG_SPACE;
        YY_BREAK
 case 212:
 YY_RULE_SETUP
-#line 1096 "scan.l"
+#line 1011 "scan.l"
 BEGIN(CCL); return CCE_NEG_UPPER;
        YY_BREAK
 case 213:
 YY_RULE_SETUP
-#line 1097 "scan.l"
+#line 1012 "scan.l"
 BEGIN(CCL); return CCE_NEG_XDIGIT;
        YY_BREAK
 case 214:
 YY_RULE_SETUP
-#line 1098 "scan.l"
+#line 1013 "scan.l"
 {
                        format_synerr(
                                _( "bad character class expression: %s" ),
@@ -9866,7 +9781,7 @@ YY_RULE_SETUP
 
 case 215:
 YY_RULE_SETUP
-#line 1107 "scan.l"
+#line 1022 "scan.l"
 {
                        yylval = myctoi( yytext );
                        return NUMBER;
@@ -9874,12 +9789,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 216:
 YY_RULE_SETUP
-#line 1112 "scan.l"
+#line 1027 "scan.l"
 return ',';
        YY_BREAK
 case 217:
 YY_RULE_SETUP
-#line 1113 "scan.l"
+#line 1028 "scan.l"
 {
                        BEGIN(SECT2);
                        if ( lex_compat || posix_compat )
@@ -9890,7 +9805,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 218:
 YY_RULE_SETUP
-#line 1121 "scan.l"
+#line 1036 "scan.l"
 {
                        synerr( _( "bad character inside {}'s" ) );
                        BEGIN(SECT2);
@@ -9900,7 +9815,7 @@ YY_RULE_SETUP
 case 219:
 /* rule 219 can match eol */
 YY_RULE_SETUP
-#line 1127 "scan.l"
+#line 1042 "scan.l"
 {
                        synerr( _( "missing }" ) );
                        BEGIN(SECT2);
@@ -9912,18 +9827,18 @@ YY_RULE_SETUP
 
 case 220:
 YY_RULE_SETUP
-#line 1137 "scan.l"
+#line 1052 "scan.l"
 bracelevel = 0; piece_append("</PLex_Text>");
        YY_BREAK
 case 221:
 YY_RULE_SETUP
-#line 1139 "scan.l"
+#line 1054 "scan.l"
 ACTION_ECHO; yy_push_state( CODE_COMMENT );
        YY_BREAK
 
 case 222:
 YY_RULE_SETUP
-#line 1142 "scan.l"
+#line 1057 "scan.l"
 {
             ACTION_ECHO;
             CHECK_REJECT(yytext);
@@ -9931,7 +9846,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 223:
 YY_RULE_SETUP
-#line 1146 "scan.l"
+#line 1061 "scan.l"
 {
             ACTION_ECHO;
             CHECK_YYMORE(yytext);
@@ -9940,13 +9855,13 @@ YY_RULE_SETUP
 
 case 224:
 YY_RULE_SETUP
-#line 1152 "scan.l"
+#line 1067 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 225:
 /* rule 225 can match eol */
 YY_RULE_SETUP
-#line 1153 "scan.l"
+#line 1068 "scan.l"
 {
                ++linenum;
                ACTION_ECHO;
@@ -9954,7 +9869,7 @@ YY_RULE_SETUP
             if ( doing_rule_action )
                 add_action( "\tYY_BREAK]""]\n" );
 
flush();
piece_flush(strlen(yytext));
  if (doing_codeblock)
   piece_append("</PLex_Section1Or2_CodeBlock>");
  else
@@ -9969,43 +9884,43 @@ YY_RULE_SETUP
 
 case 226:
 YY_RULE_SETUP
-#line 1174 "scan.l"
+#line 1089 "scan.l"
 ACTION_ECHO; ++bracelevel;
        YY_BREAK
 case 227:
 YY_RULE_SETUP
-#line 1175 "scan.l"
+#line 1090 "scan.l"
 ACTION_ECHO; --bracelevel;
        YY_BREAK
 case 228:
 YY_RULE_SETUP
-#line 1176 "scan.l"
+#line 1091 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 229:
 YY_RULE_SETUP
-#line 1177 "scan.l"
+#line 1092 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 230:
 YY_RULE_SETUP
-#line 1178 "scan.l"
+#line 1093 "scan.l"
 ACTION_ECHO; /* character constant */
        YY_BREAK
 case 231:
 YY_RULE_SETUP
-#line 1179 "scan.l"
+#line 1094 "scan.l"
 ACTION_ECHO; BEGIN(CHARACTER_CONSTANT);
        YY_BREAK
 case 232:
 YY_RULE_SETUP
-#line 1180 "scan.l"
+#line 1095 "scan.l"
 ACTION_ECHO; BEGIN(ACTION_STRING);
        YY_BREAK
 case 233:
 /* rule 233 can match eol */
 YY_RULE_SETUP
-#line 1181 "scan.l"
+#line 1096 "scan.l"
 {
                 ++linenum;
                 ACTION_ECHO;
@@ -10013,7 +9928,7 @@ YY_RULE_SETUP
                    if ( doing_rule_action )
  {
                       add_action( "\tYY_BREAK]""]\n" );
-  flush();
+  piece_flush(strlen(yytext));
   markup_action("</PLex_Text></PLex_Section2_Rule_Action>");
  }
 
@@ -10024,31 +9939,31 @@ YY_RULE_SETUP
        YY_BREAK
 case 234:
 YY_RULE_SETUP
-#line 1196 "scan.l"
+#line 1111 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 
 
 case 235:
 YY_RULE_SETUP
-#line 1200 "scan.l"
+#line 1115 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 236:
 YY_RULE_SETUP
-#line 1201 "scan.l"
+#line 1116 "scan.l"
 ACTION_ECHO; BEGIN(ACTION);
        YY_BREAK
 
 
 case 237:
 YY_RULE_SETUP
-#line 1204 "scan.l"
+#line 1119 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 238:
 YY_RULE_SETUP
-#line 1205 "scan.l"
+#line 1120 "scan.l"
 ACTION_ECHO; BEGIN(ACTION);
        YY_BREAK
 
@@ -10056,24 +9971,24 @@ ACTION_ECHO; BEGIN(ACTION);
 case 239:
 /* rule 239 can match eol */
 YY_RULE_SETUP
-#line 1208 "scan.l"
+#line 1123 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 240:
 /* rule 240 can match eol */
 YY_RULE_SETUP
-#line 1209 "scan.l"
+#line 1124 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 241:
 /* rule 241 can match eol */
 YY_RULE_SETUP
-#line 1210 "scan.l"
-++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); flush(); if (doing_rule_action) markup_action("</PLex_Text></PLex_Section2_Rule_Action>"); } else { BEGIN(ACTION); }
+#line 1125 "scan.l"
+++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); piece_flush(strlen(yytext)); if (doing_rule_action) markup_action("</PLex_Text></PLex_Section2_Rule_Action>"); } else { BEGIN(ACTION); }
        YY_BREAK
 case 242:
 YY_RULE_SETUP
-#line 1211 "scan.l"
+#line 1126 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 
@@ -10083,7 +9998,7 @@ case YY_STATE_EOF(COMMENT_DISCARD):
 case YY_STATE_EOF(ACTION):
 case YY_STATE_EOF(ACTION_STRING):
 case YY_STATE_EOF(CHARACTER_CONSTANT):
-#line 1214 "scan.l"
+#line 1129 "scan.l"
 {
                        synerr( _( "EOF encountered inside an action" ) );
                        yyterminate();
@@ -10092,7 +10007,7 @@ case YY_STATE_EOF(CHARACTER_CONSTANT):
 case YY_STATE_EOF(EXTENDED_COMMENT):
 case YY_STATE_EOF(GROUP_WITH_PARAMS):
 case YY_STATE_EOF(GROUP_MINUS_PARAMS):
-#line 1219 "scan.l"
+#line 1134 "scan.l"
 {
                        synerr( _( "EOF encountered inside pattern" ) );
                        yyterminate();
@@ -10100,7 +10015,7 @@ case YY_STATE_EOF(GROUP_MINUS_PARAMS):
        YY_BREAK
 case 243:
 YY_RULE_SETUP
-#line 1224 "scan.l"
+#line 1139 "scan.l"
 {
                        yylval = myesc( (unsigned char *) yytext );
 
@@ -10113,27 +10028,27 @@ YY_RULE_SETUP
 
 case 244:
 YY_RULE_SETUP
-#line 1234 "scan.l"
+#line 1149 "scan.l"
 fputs(escaped_qstart, yyout);
        YY_BREAK
 case 245:
 YY_RULE_SETUP
-#line 1235 "scan.l"
+#line 1150 "scan.l"
 fputs(escaped_qend, yyout);
        YY_BREAK
 case 246:
 /* rule 246 can match eol */
 YY_RULE_SETUP
-#line 1236 "scan.l"
+#line 1151 "scan.l"
 ECHO;
        YY_BREAK
 case 247:
 YY_RULE_SETUP
-#line 1237 "scan.l"
+#line 1152 "scan.l"
 ECHO;
        YY_BREAK
 case YY_STATE_EOF(SECT3):
-#line 1238 "scan.l"
+#line 1153 "scan.l"
 {
         sectnum = 0;
 #if 1
@@ -10150,27 +10065,27 @@ case YY_STATE_EOF(SECT3):
 
 case 248:
 YY_RULE_SETUP
-#line 1251 "scan.l"
+#line 1166 "scan.l"
 fprintf(yyout, "[""[%s]""]", escaped_qstart);
        YY_BREAK
 case 249:
 YY_RULE_SETUP
-#line 1252 "scan.l"
+#line 1167 "scan.l"
 fprintf(yyout, "[""[%s]""]", escaped_qend);
        YY_BREAK
 case 250:
 /* rule 250 can match eol */
 YY_RULE_SETUP
-#line 1253 "scan.l"
+#line 1168 "scan.l"
 ECHO;
        YY_BREAK
 case 251:
 YY_RULE_SETUP
-#line 1254 "scan.l"
+#line 1169 "scan.l"
 ECHO;
        YY_BREAK
 case YY_STATE_EOF(SECT3_NOESCAPE):
-#line 1255 "scan.l"
+#line 1170 "scan.l"
 {
        sectnum = 0;
 #if 1
@@ -10187,15 +10102,15 @@ case YY_STATE_EOF(SECT3_NOESCAPE):
 case 252:
 /* rule 252 can match eol */
 YY_RULE_SETUP
-#line 1267 "scan.l"
+#line 1182 "scan.l"
 format_synerr( _( "bad character: %s" ), yytext );
        YY_BREAK
 case 253:
 YY_RULE_SETUP
-#line 1269 "scan.l"
+#line 1184 "scan.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
        YY_BREAK
-#line 10185 "scan.c"
+#line 10100 "scan.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(CODEBLOCK):
 case YY_STATE_EOF(PICKUPDEF):
@@ -11243,7 +11158,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 1269 "scan.l"
+#line 1184 "scan.l"
 
 
 
@@ -11284,6 +11199,102 @@ void set_input_file( char *file )
        }
 
 /* Nick */
+void piece_append(const char *str) {
+ piece[piece1++] = strdup(str);
+}
+
+void piece_insert(int n, const char *str) {
+ memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
+ piece[n] = strdup(str);
+ ++piece1;
+}
+
+void piece_esc(const char *p, size_t n) {
+ size_t i, j = 0;
+ for (i = 0; i < n; ++i)
+  switch (p[i]) {
+  case '<':
+  case '>':
+   j += 4;
+   break;
+  case '&':
+   j += 5;
+   break;
+  default:
+   ++j;
+   break;
+  }
+ char *q = malloc(j + 1);
+ j = 0;
+ for (i = 0; i < n; ++i)
+  switch (p[i]) {
+  case '<':
+   memcpy(q + j, "&lt;", 4);
+   j += 4;
+   break;
+  case '>':
+   memcpy(q + j, "&gt;", 4);
+   j += 4;
+   break;
+  case '&':
+   memcpy(q + j, "&amp;", 5);
+   j += 5;
+   break;
+  default:
+   q[j++] = p[i];
+   break;
+  }
+ q[j] = 0;
+ piece[piece1++] = q;
+}
+
+void piece_flush(size_t n) {
+ piece_esc(yytext, n);
+ yytext += n;
+}
+
+void piece_pack() {
+ int i;
+ size_t j = 0;
+ for (i = piece0; i < piece1; ++i)
+  j += strlen(piece[i]);
+ char *q = malloc(j + 1);
+ j = 0;
+ for (i = piece0; i < piece1; ++i) {
+  int k = strlen(piece[i]);
+  memcpy(q + j, piece[i], k);
+  free(piece[i]);
+  j += k;
+ }
+ q[j] = 0;
+ piece[piece0++] = q;
+ piece1 = piece0;
+}
+
+int flexscan(void) {
+ int result = real_flexscan();
+ if (result < 0)
+  return ~result;
+ piece_pack();
+#if 1
+ piece_esc(yytext, strlen(yytext));
+#else
+ size_t n = strlen(yytext);
+ if (n) {
+  sprintf(piece_temp, "<token value=\"%d\">", result);
+  piece_append(piece_temp);
+  piece_esc(yytext, n);
+  piece_append("</token>");
+ }
+ else {
+  sprintf(piece_temp, "<token value=\"%d\" />", result);
+  piece_append(piece_temp);
+ }
+#endif
+ piece_pack();
+ return result;
+}
+
 static void markup_action(const char *text) {
  /* append to last token text so it appears inside <PLex_Section2_Rule>..</PLex_Section2_Rule> */
  /* a problem here is that Rule has already been reduced (marked up), */
@@ -11306,7 +11317,7 @@ static void markup_option(const char *name, int sense) {
   ;
  sprintf(piece_temp, "<PLex_Section1_Options_%s%s>", name, sense ? " value=\"true\"" : "");
  piece_insert(i + 1, piece_temp);
flush();
piece_flush(strlen(yytext));
  sprintf(piece_temp, "</PLex_Section1_Options_%s>", name);
  piece_append(piece_temp);
  /* append to last token text so it appears inside <PLex_Section1_Options>..</PLex_Section1_Options> */
index 557c097..5fb0ebd 100644 (file)
@@ -67,8 +67,14 @@ extern const char *escaped_qstart, *escaped_qend;
 
 #define MARK_END_OF_PROLOG mark_prolog();
 
+#if 1
+static int real_flexscan(void);
+#define YY_DECL \
+       static int real_flexscan(void)
+#else
 #define YY_DECL \
        int flexscan(void)
+#endif
 
 #define RETURNCHAR \
        yylval = (unsigned char) yytext[0]; \
@@ -134,107 +140,16 @@ char piece_temp[100];
 char *piece[10000];
 int piece0;
 int piece1;
-void piece_append(const char *str) {
- piece[piece1++] = strdup(str);
-}
-void piece_insert(int n, const char *str) {
- memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
- piece[n] = strdup(str);
- ++piece1;
-}
 
-#define flush() \
- do { \
-  piece_esc(yytext, yy_c_buf_p - yytext); \
-  yytext = yy_c_buf_p; \
- } while (0)
+void piece_append(const char *str);
+void piece_insert(int n, const char *str);
+void piece_esc(const char *p, size_t n);
+void piece_flush(size_t n);
+void piece_pack();
 
 static void markup_action(const char *text);
 static void markup_option(const char *name, int sense);
 
-static int real_yylex(void);
-static void piece_esc(const char *p, size_t n) {
- size_t i, j = 0;
- for (i = 0; i < n; ++i)
-  switch (p[i]) {
-  case '<':
-  case '>':
-   j += 4;
-   break;
-  case '&':
-   j += 5;
-   break;
-  default:
-   ++j;
-   break;
-  }
- char *q = malloc(j + 1);
- j = 0;
- for (i = 0; i < n; ++i)
-  switch (p[i]) {
-  case '<':
-   memcpy(q + j, "&lt;", 4);
-   j += 4;
-   break;
-  case '>':
-   memcpy(q + j, "&gt;", 4);
-   j += 4;
-   break;
-  case '&':
-   memcpy(q + j, "&amp;", 5);
-   j += 5;
-   break;
-  default:
-   q[j++] = p[i];
-   break;
-  }
- q[j] = 0;
- piece[piece1++] = q;
-}
-static void piece_pack() {
- int i;
- size_t j = 0;
- for (i = piece0; i < piece1; ++i)
-  j += strlen(piece[i]);
- char *q = malloc(j + 1);
- j = 0;
- for (i = piece0; i < piece1; ++i) {
-  int k = strlen(piece[i]);
-  memcpy(q + j, piece[i], k);
-  free(piece[i]);
-  j += k;
- }
- q[j] = 0;
- piece[piece0++] = q;
- piece1 = piece0;
-}
-YY_DECL
-{
- int result = real_yylex();
- if (result < 0)
-  return ~result;
- piece_pack();
-#if 1
- piece_esc(yytext, strlen(yytext));
-#else
- size_t n = strlen(yytext);
- if (n) {
-  sprintf(piece_temp, "<token value=\"%d\">", result);
-  piece_append(piece_temp);
-  piece_esc(yytext, n);
-  piece_append("</token>");
- }
- else {
-  sprintf(piece_temp, "<token value=\"%d\" />", result);
-  piece_append(piece_temp);
- }
-#endif
- piece_pack();
- return result;
-}
-#undef YY_DECL
-#define YY_DECL static int real_yylex(void)
-
 %}
 
 %option caseless nodefault noreject stack noyy_top_state
@@ -288,7 +203,7 @@ M4QEND      "]""]"
        ^#{OPTWS}line{WS}       yy_push_state( LINEDIR );
        ^"%s"{NAME}?    return SCDECL;
        ^"%x"{NAME}?    return XSCDECL;
-       ^"%{".*{NL}     START_CODEBLOCK(false); flush(); piece_append("<PLex_Text>");
+       ^"%{".*{NL}     START_CODEBLOCK(false); piece_flush(strlen(yytext)); piece_append("<PLex_Text>");
     ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL}    {
                 brace_start_line = linenum;
                 ++linenum;
@@ -319,8 +234,8 @@ M4QEND      "]""]"
 #endif
                        }
 
-       ^"%pointer".*{NL}       yytext_is_array = false; ++linenum; piece_append("<PLex_Section1_Options><PLex_Section1_Options_Array>"); { int i = strlen(yytext) - 1; piece_esc(yytext, i); yytext += i; } piece_append("</PLex_Section1_Options_Array></PLex_Section1_Options>"); 
-       ^"%array".*{NL}         yytext_is_array = true; ++linenum; piece_append("<PLex_Section1_Options><PLex_Section1_Options_Array value=\"true\">"); { int i = strlen(yytext) - 1; piece_esc(yytext, i); yytext += i; } piece_append("</PLex_Section1_Options_Array></PLex_Section1_Options>");
+       ^"%pointer".*{NL}       yytext_is_array = false; ++linenum; piece_append("<PLex_Section1_Options><PLex_Section1_Options_Array>"); piece_flush(strlen(yytext) - 1); piece_append("</PLex_Section1_Options_Array></PLex_Section1_Options>"); 
+       ^"%array".*{NL}         yytext_is_array = true; ++linenum; piece_append("<PLex_Section1_Options><PLex_Section1_Options_Array value=\"true\">"); piece_flush(strlen(yytext) - 1); piece_append("</PLex_Section1_Options_Array></PLex_Section1_Options>");
 
        ^"%option"      BEGIN(OPTION); return TOK_OPTION;
 
@@ -395,13 +310,13 @@ M4QEND      "]""]"
 }
 
 <CODEBLOCK>{
-       ^"%}".*{NL}     ++linenum; piece_append("</PLex_Text>"); flush(); END_CODEBLOCK;
+       ^"%}".*{NL}     ++linenum; piece_append("</PLex_Text>"); piece_flush(strlen(yytext)); END_CODEBLOCK;
        [^\n%\[\]]*         ACTION_ECHO;
         .              ACTION_ECHO;
        {NL}            {
                        ++linenum;
                        ACTION_ECHO;
-                       if ( indented_code ) { flush(); piece_append("</PLex_Text>"); END_CODEBLOCK; }
+                       if ( indented_code ) { piece_flush(strlen(yytext)); piece_append("</PLex_Text>"); END_CODEBLOCK; }
                        }
 }
 
@@ -668,11 +583,9 @@ M4QEND      "]""]"
                        doing_codeblock = true;
                        bracelevel = 1;
                        BEGIN(PERCENT_BRACE_ACTION);
- int i = strlen(yytext) - 2;
- piece_esc(yytext, i);
- yytext += i;
+ piece_flush(strlen(yytext) - 2);
  piece_append("<PLex_Section1Or2_CodeBlock>");
flush();
piece_flush(2);
  piece_append("<PLex_Text>");
                        }
 
@@ -696,9 +609,7 @@ M4QEND      "]""]"
        {WS}"%{"                {
                        bracelevel = 1;
                        BEGIN(PERCENT_BRACE_ACTION);
- int i = strlen(yytext) - 2;
- piece_esc(yytext, i);
- yytext += i;
+ piece_flush(strlen(yytext) - 2);
  piece_append("<PLex_Section2_Rule_Action>");
 
                        if ( in_rule )
@@ -707,7 +618,7 @@ M4QEND      "]""]"
                                in_rule = false;
 #if 1
  piece_pack();
- piece_esc(yytext, strlen(yytext));
+ piece_esc(yytext, 2);
  piece_pack();
  piece_append("<PLex_Text>");
  return ~'\n';
@@ -718,7 +629,7 @@ M4QEND      "]""]"
 #if 1 /* don't think this can really happen */
  abort();
 #else
flush();
piece_flush(strlen(yytext));
  piece_append("<PLex_Text>");
 #endif
                        }
@@ -737,8 +648,7 @@ M4QEND      "]""]"
  int i;
  for (i = 0; yytext[i] == '\t' || yytext[i] == ' '; ++i)
   ;
- piece_esc(yytext, i);
- yytext += i;
+ piece_flush(i);
  piece_pack();
  piece_append("<PLex_Section2_Rule_Action continued=\"true\">");
  piece_esc(yytext, strlen(yytext));
@@ -1157,7 +1067,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
             if ( doing_rule_action )
                 add_action( "\tYY_BREAK]""]\n" );
 
flush();
piece_flush(strlen(yytext));
  if (doing_codeblock)
   piece_append("</PLex_Section1Or2_CodeBlock>");
  else
@@ -1185,7 +1095,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
                    if ( doing_rule_action )
  {
                       add_action( "\tYY_BREAK]""]\n" );
-  flush();
+  piece_flush(strlen(yytext));
   markup_action("</PLex_Text></PLex_Section2_Rule_Action>");
  }
 
@@ -1207,7 +1117,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
 <ACTION_STRING,CHARACTER_CONSTANT>{
         (\\\n)*         ACTION_ECHO;
        \\(\\\n)*.      ACTION_ECHO;
-       {NL}    ++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); flush(); if (doing_rule_action) markup_action("</PLex_Text></PLex_Section2_Rule_Action>"); } else { BEGIN(ACTION); }
+       {NL}    ++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); piece_flush(strlen(yytext)); if (doing_rule_action) markup_action("</PLex_Text></PLex_Section2_Rule_Action>"); } else { BEGIN(ACTION); }
         .      ACTION_ECHO;
 }
 
@@ -1305,6 +1215,88 @@ void set_input_file( char *file )
        }
 
 /* Nick */
+void piece_append(const char *str) {
+ piece[piece1++] = strdup(str);
+}
+
+void piece_insert(int n, const char *str) {
+ memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
+ piece[n] = strdup(str);
+ ++piece1;
+}
+
+void piece_esc(const char *p, size_t n) {
+ size_t i, j = 0;
+ for (i = 0; i < n; ++i)
+  switch (p[i]) {
+  case '<':
+  case '>':
+   j += 4;
+   break;
+  case '&':
+   j += 5;
+   break;
+  default:
+   ++j;
+   break;
+  }
+ char *q = malloc(j + 1);
+ j = 0;
+ for (i = 0; i < n; ++i)
+  switch (p[i]) {
+  case '<':
+   memcpy(q + j, "&lt;", 4);
+   j += 4;
+   break;
+  case '>':
+   memcpy(q + j, "&gt;", 4);
+   j += 4;
+   break;
+  case '&':
+   memcpy(q + j, "&amp;", 5);
+   j += 5;
+   break;
+  default:
+   q[j++] = p[i];
+   break;
+  }
+ q[j] = 0;
+ piece[piece1++] = q;
+}
+
+void piece_flush(size_t n) {
+ piece_esc(yytext, n);
+ yytext += n;
+}
+
+void piece_pack() {
+ int i;
+ size_t j = 0;
+ for (i = piece0; i < piece1; ++i)
+  j += strlen(piece[i]);
+ char *q = malloc(j + 1);
+ j = 0;
+ for (i = piece0; i < piece1; ++i) {
+  int k = strlen(piece[i]);
+  memcpy(q + j, piece[i], k);
+  free(piece[i]);
+  j += k;
+ }
+ q[j] = 0;
+ piece[piece0++] = q;
+ piece1 = piece0;
+}
+
+int flexscan(void) {
+ int result = real_flexscan();
+ if (result < 0)
+  return ~result;
+ piece_pack();
+ piece_esc(yytext, strlen(yytext));
+ piece_pack();
+ return result;
+}
+
 static void markup_action(const char *text) {
  /* append to last token text so it appears inside <PLex_Section2_Rule>..</PLex_Section2_Rule> */
  /* a problem here is that Rule has already been reduced (marked up), */
@@ -1327,7 +1319,7 @@ static void markup_option(const char *name, int sense) {
   ;
  sprintf(piece_temp, "<PLex_Section1_Options_%s%s>", name, sense ? " value=\"true\"" : "");
  piece_insert(i + 1, piece_temp);
flush();
piece_flush(strlen(yytext));
  sprintf(piece_temp, "</PLex_Section1_Options_%s>", name);
  piece_append(piece_temp);
  /* append to last token text so it appears inside <PLex_Section1_Options>..</PLex_Section1_Options> */