From 675152c652d4237f065cfecc70072315cb4ee192 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Thu, 26 Jul 2018 11:35:38 +1000 Subject: [PATCH] Similarly, move most piece_* stuff from parse.c.patch into parse.y, and tidy up --- src/parse.c | 435 ++++++++++++++++++----------------- src/parse.c.patch | 36 +-- src/parse.y | 36 +++ src/scan.c | 569 ++++++++++++++++++++++------------------------ src/scan.l | 6 +- 5 files changed, 543 insertions(+), 539 deletions(-) diff --git a/src/parse.c b/src/parse.c index 851dee5..5b4dbef 100644 --- a/src/parse.c +++ b/src/parse.c @@ -144,8 +144,30 @@ int previous_continued_action; /* whether the previous rule's action was '|' */ */ #define YYSTYPE int +/* Nick */ +extern char piece_temp[], *piece[]; +extern int piece0, piece1; +int piece2, piece3; +void piece_insert(int n, const void *str); +#if 0 /* not needed at the moment */ +void piece_peek(void); +#endif + +#define insert_before(n, str) \ + do { \ + piece_insert(piece2 + (n) * 2, (str)); \ + ++piece0; \ + ++piece3; \ + } while (0) +#define insert_after(n, str) \ + do { \ + piece_insert(piece2 + (n) * 2 + 1, (str)); \ + ++piece0; \ + ++piece3; \ + } while (0) + -#line 149 "parse.c" /* yacc.c:339 */ +#line 171 "parse.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -290,7 +312,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 294 "parse.c" /* yacc.c:358 */ +#line 316 "parse.c" /* yacc.c:358 */ #ifdef short # undef short @@ -592,16 +614,16 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 118, 118, 148, 155, 161, 166, 167, 171, 179, - 182, 186, 189, 192, 196, 199, 200, 203, 210, 215, - 222, 227, 232, 239, 244, 249, 253, 265, 303, 329, - 354, 359, 362, 368, 388, 401, 403, 405, 409, 436, - 492, 495, 540, 559, 567, 572, 599, 609, 612, 643, - 660, 685, 694, 702, 710, 741, 758, 780, 822, 840, - 850, 853, 861, 879, 885, 889, 894, 896, 905, 970, - 993, 1003, 1012, 1016, 1020, 1024, 1028, 1032, 1036, 1050, - 1054, 1058, 1062, 1066, 1081, 1085, 1089, 1093, 1097, 1101, - 1105, 1109, 1113, 1117, 1121, 1129, 1139, 1160 + 0, 140, 140, 170, 177, 183, 188, 189, 193, 201, + 204, 208, 211, 214, 218, 221, 222, 225, 232, 237, + 244, 249, 254, 261, 266, 271, 275, 287, 325, 351, + 376, 381, 384, 390, 410, 423, 425, 427, 431, 458, + 514, 517, 562, 581, 589, 594, 621, 631, 634, 665, + 682, 707, 716, 724, 732, 763, 780, 802, 844, 862, + 872, 875, 883, 901, 907, 911, 916, 918, 927, 992, + 1015, 1025, 1034, 1038, 1042, 1046, 1050, 1054, 1058, 1072, + 1076, 1080, 1084, 1088, 1103, 1107, 1111, 1115, 1119, 1123, + 1127, 1131, 1135, 1139, 1143, 1151, 1161, 1182 }; #endif @@ -1245,25 +1267,6 @@ int yynerrs; | yyparse. | `----------*/ -extern char piece_temp[]; -extern char *piece[]; -extern int piece0, piece1; -void piece_insert(int n, const void *str); -int piece2, piece3; -static void peek(void) { - if (yychar == YYEMPTY) - yychar = yylex(); - memmove(piece + piece3 + 3, piece + piece3 + 1, (piece1 - piece3 - 1) * sizeof(char *)); - piece[piece3 + 1] = strdup(""); - piece[piece3 + 2] = strdup(""); - piece3 += 2; - piece0 += 2; - piece1 += 2; -} -#define insert_before(n, str) \ - do { piece_insert(piece2 + (n) * 2, (str)); ++piece0; ++piece3; } while (0) -#define insert_after(n, str) \ - do { piece_insert(piece2 + (n) * 2 + 1, (str)); ++piece0; ++piece3; } while (0) int yyparse (void) { @@ -1511,7 +1514,7 @@ yyreduce: switch (yyn) { case 2: -#line 119 "parse.y" /* yacc.c:1646 */ +#line 141 "parse.y" /* yacc.c:1646 */ { /* add default rule */ int def_rule; @@ -1538,162 +1541,162 @@ yyreduce: add_action( ";\n\tYY_BREAK]]\n" ); } -#line 1512 "parse.c" /* yacc.c:1646 */ +#line 1534 "parse.c" /* yacc.c:1646 */ break; case 3: -#line 148 "parse.y" /* yacc.c:1646 */ +#line 170 "parse.y" /* yacc.c:1646 */ { /* initialize for processing rules */ /* Create default DFA start condition. */ scinstal( "INITIAL", false ); } -#line 1522 "parse.c" /* yacc.c:1646 */ +#line 1544 "parse.c" /* yacc.c:1646 */ break; case 4: -#line 156 "parse.y" /* yacc.c:1646 */ +#line 178 "parse.y" /* yacc.c:1646 */ { insert_after(2, ""); sprintf(piece_temp, "", xcluflg ? "true" : "false"); insert_before(1, piece_temp); } -#line 1532 "parse.c" /* yacc.c:1646 */ +#line 1554 "parse.c" /* yacc.c:1646 */ break; case 5: -#line 162 "parse.y" /* yacc.c:1646 */ +#line 184 "parse.y" /* yacc.c:1646 */ { insert_after(1, ""); insert_before(1, ""); } -#line 1541 "parse.c" /* yacc.c:1646 */ +#line 1563 "parse.c" /* yacc.c:1646 */ break; case 7: -#line 168 "parse.y" /* yacc.c:1646 */ +#line 190 "parse.y" /* yacc.c:1646 */ { synerr( _("unknown error processing section 1") ); } -#line 1547 "parse.c" /* yacc.c:1646 */ +#line 1569 "parse.c" /* yacc.c:1646 */ break; case 8: -#line 172 "parse.y" /* yacc.c:1646 */ +#line 194 "parse.y" /* yacc.c:1646 */ { check_options(); scon_stk = allocate_integer_array( lastsc + 1 ); scon_stk_ptr = 0; } -#line 1557 "parse.c" /* yacc.c:1646 */ +#line 1579 "parse.c" /* yacc.c:1646 */ break; case 9: -#line 180 "parse.y" /* yacc.c:1646 */ +#line 202 "parse.y" /* yacc.c:1646 */ { xcluflg = false; } -#line 1563 "parse.c" /* yacc.c:1646 */ +#line 1585 "parse.c" /* yacc.c:1646 */ break; case 10: -#line 183 "parse.y" /* yacc.c:1646 */ +#line 205 "parse.y" /* yacc.c:1646 */ { xcluflg = true; } -#line 1569 "parse.c" /* yacc.c:1646 */ +#line 1591 "parse.c" /* yacc.c:1646 */ break; case 11: -#line 187 "parse.y" /* yacc.c:1646 */ +#line 209 "parse.y" /* yacc.c:1646 */ { scinstal( nmstr, xcluflg ); } -#line 1575 "parse.c" /* yacc.c:1646 */ +#line 1597 "parse.c" /* yacc.c:1646 */ break; case 12: -#line 190 "parse.y" /* yacc.c:1646 */ +#line 212 "parse.y" /* yacc.c:1646 */ { scinstal( nmstr, xcluflg ); } -#line 1581 "parse.c" /* yacc.c:1646 */ +#line 1603 "parse.c" /* yacc.c:1646 */ break; case 13: -#line 193 "parse.y" /* yacc.c:1646 */ +#line 215 "parse.y" /* yacc.c:1646 */ { synerr( _("bad start condition list") ); } -#line 1587 "parse.c" /* yacc.c:1646 */ +#line 1609 "parse.c" /* yacc.c:1646 */ break; case 17: -#line 204 "parse.y" /* yacc.c:1646 */ +#line 226 "parse.y" /* yacc.c:1646 */ { outfilename = xstrdup(nmstr); did_outfilename = 1; insert_after(2, ""); insert_before(0,""); } -#line 1598 "parse.c" /* yacc.c:1646 */ +#line 1620 "parse.c" /* yacc.c:1646 */ break; case 18: -#line 211 "parse.y" /* yacc.c:1646 */ +#line 233 "parse.y" /* yacc.c:1646 */ { extra_type = xstrdup(nmstr); /*}*/ insert_after(2, ""); insert_before(0, ""); } -#line 1607 "parse.c" /* yacc.c:1646 */ +#line 1629 "parse.c" /* yacc.c:1646 */ break; case 19: -#line 216 "parse.y" /* yacc.c:1646 */ +#line 238 "parse.y" /* yacc.c:1646 */ { prefix = xstrdup(nmstr); if (strchr(prefix, '[') || strchr(prefix, ']')) flexerror(_("Prefix must not contain [ or ]")); /*}*/ insert_after(2, ""); insert_before(0, ""); } -#line 1618 "parse.c" /* yacc.c:1646 */ +#line 1640 "parse.c" /* yacc.c:1646 */ break; case 20: -#line 223 "parse.y" /* yacc.c:1646 */ +#line 245 "parse.y" /* yacc.c:1646 */ { yyclass = xstrdup(nmstr); /*}*/ insert_after(2, ""); insert_before(0, ""); } -#line 1627 "parse.c" /* yacc.c:1646 */ +#line 1649 "parse.c" /* yacc.c:1646 */ break; case 21: -#line 228 "parse.y" /* yacc.c:1646 */ +#line 250 "parse.y" /* yacc.c:1646 */ { headerfilename = xstrdup(nmstr); /*}*/ insert_after(2, ""); insert_before(0, ""); } -#line 1636 "parse.c" /* yacc.c:1646 */ +#line 1658 "parse.c" /* yacc.c:1646 */ break; case 22: -#line 233 "parse.y" /* yacc.c:1646 */ +#line 255 "parse.y" /* yacc.c:1646 */ { tablesext = true; tablesfilename = xstrdup(nmstr); /*}*/ insert_after(2, ""); insert_before(0, ""); } -#line 1645 "parse.c" /* yacc.c:1646 */ +#line 1667 "parse.c" /* yacc.c:1646 */ break; case 23: -#line 240 "parse.y" /* yacc.c:1646 */ +#line 262 "parse.y" /* yacc.c:1646 */ { scon_stk_ptr = (yyvsp[-3]); /*}*/ insert_after(4, ""); insert_before(1, ""); } -#line 1654 "parse.c" /* yacc.c:1646 */ +#line 1676 "parse.c" /* yacc.c:1646 */ break; case 24: -#line 245 "parse.y" /* yacc.c:1646 */ +#line 267 "parse.y" /* yacc.c:1646 */ { scon_stk_ptr = (yyvsp[-3]); /*}*/ insert_after(4, ""); insert_before(1, ""); } -#line 1663 "parse.c" /* yacc.c:1646 */ +#line 1685 "parse.c" /* yacc.c:1646 */ break; case 26: -#line 253 "parse.y" /* yacc.c:1646 */ +#line 275 "parse.y" /* yacc.c:1646 */ { /* Initialize for a parse of one rule. */ trlcontxt = variable_trail_rule = varlength = false; @@ -1704,11 +1707,11 @@ yyreduce: new_rule(); } -#line 1678 "parse.c" /* yacc.c:1646 */ +#line 1700 "parse.c" /* yacc.c:1646 */ break; case 27: -#line 266 "parse.y" /* yacc.c:1646 */ +#line 288 "parse.y" /* yacc.c:1646 */ { pat = (yyvsp[0]); finish_rule( pat, variable_trail_rule, @@ -1745,11 +1748,11 @@ yyreduce: insert_after(1, ""); insert_before(0, ""); } -#line 1719 "parse.c" /* yacc.c:1646 */ +#line 1741 "parse.c" /* yacc.c:1646 */ break; case 28: -#line 304 "parse.y" /* yacc.c:1646 */ +#line 326 "parse.y" /* yacc.c:1646 */ { pat = (yyvsp[0]); finish_rule( pat, variable_trail_rule, @@ -1774,11 +1777,11 @@ yyreduce: insert_after(0, ""); insert_before(0, ""); } -#line 1748 "parse.c" /* yacc.c:1646 */ +#line 1770 "parse.c" /* yacc.c:1646 */ break; case 29: -#line 330 "parse.y" /* yacc.c:1646 */ +#line 352 "parse.y" /* yacc.c:1646 */ { if ( scon_stk_ptr > 0 ) build_eof_action(); @@ -1802,32 +1805,32 @@ yyreduce: insert_after(0, ""); insert_before(0, ""); } -#line 1776 "parse.c" /* yacc.c:1646 */ +#line 1798 "parse.c" /* yacc.c:1646 */ break; case 30: -#line 355 "parse.y" /* yacc.c:1646 */ +#line 377 "parse.y" /* yacc.c:1646 */ { synerr( _("unrecognized rule") ); } -#line 1782 "parse.c" /* yacc.c:1646 */ +#line 1804 "parse.c" /* yacc.c:1646 */ break; case 31: -#line 359 "parse.y" /* yacc.c:1646 */ +#line 381 "parse.y" /* yacc.c:1646 */ { (yyval) = scon_stk_ptr; } -#line 1788 "parse.c" /* yacc.c:1646 */ +#line 1810 "parse.c" /* yacc.c:1646 */ break; case 32: -#line 363 "parse.y" /* yacc.c:1646 */ +#line 385 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-2]); /*}*/ insert_after(3, ""); insert_before(0, ""); } -#line 1797 "parse.c" /* yacc.c:1646 */ +#line 1819 "parse.c" /* yacc.c:1646 */ break; case 33: -#line 369 "parse.y" /* yacc.c:1646 */ +#line 391 "parse.y" /* yacc.c:1646 */ { (yyval) = scon_stk_ptr; @@ -1845,11 +1848,11 @@ yyreduce: insert_after(2, ""); insert_before(0, ""); } -#line 1819 "parse.c" /* yacc.c:1646 */ +#line 1841 "parse.c" /* yacc.c:1646 */ break; case 34: -#line 388 "parse.y" /* yacc.c:1646 */ +#line 410 "parse.y" /* yacc.c:1646 */ { (yyval) = scon_stk_ptr; /*}*/ /* in this case, want empty rule associated with stuff on the right of us */ /* therefore, move inter-token text from the right of us over to the left */ @@ -1861,17 +1864,17 @@ yyreduce: piece[piece2 - 1] = temp; insert_before(0, ""); } -#line 1835 "parse.c" /* yacc.c:1646 */ +#line 1857 "parse.c" /* yacc.c:1646 */ break; case 37: -#line 406 "parse.y" /* yacc.c:1646 */ +#line 428 "parse.y" /* yacc.c:1646 */ { synerr( _("bad start condition list") ); } -#line 1841 "parse.c" /* yacc.c:1646 */ +#line 1863 "parse.c" /* yacc.c:1646 */ break; case 38: -#line 410 "parse.y" /* yacc.c:1646 */ +#line 432 "parse.y" /* yacc.c:1646 */ { if ( (scnum = sclookup( nmstr )) == 0 ) format_pinpoint_message( @@ -1892,11 +1895,11 @@ yyreduce: scon_stk[++scon_stk_ptr] = scnum; } } -#line 1866 "parse.c" /* yacc.c:1646 */ +#line 1888 "parse.c" /* yacc.c:1646 */ break; case 39: -#line 437 "parse.y" /* yacc.c:1646 */ +#line 459 "parse.y" /* yacc.c:1646 */ { if ( transchar[lastst[(yyvsp[0])]] != SYM_EPSILON ) /* Provide final transition \now/ so it @@ -1951,17 +1954,17 @@ yyreduce: (yyval) = link_machines( (yyvsp[-1]), (yyvsp[0]) ); } -#line 1925 "parse.c" /* yacc.c:1646 */ +#line 1947 "parse.c" /* yacc.c:1646 */ break; case 40: -#line 493 "parse.y" /* yacc.c:1646 */ +#line 515 "parse.y" /* yacc.c:1646 */ { synerr( _("trailing context used twice") ); } -#line 1931 "parse.c" /* yacc.c:1646 */ +#line 1953 "parse.c" /* yacc.c:1646 */ break; case 41: -#line 496 "parse.y" /* yacc.c:1646 */ +#line 518 "parse.y" /* yacc.c:1646 */ { headcnt = 0; trailcnt = 1; @@ -2005,11 +2008,11 @@ yyreduce: insert_after(1, ""); insert_before(1, ""); } -#line 1979 "parse.c" /* yacc.c:1646 */ +#line 2001 "parse.c" /* yacc.c:1646 */ break; case 42: -#line 541 "parse.y" /* yacc.c:1646 */ +#line 563 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); @@ -2025,28 +2028,28 @@ yyreduce: } insert_after(0, ""); } -#line 1999 "parse.c" /* yacc.c:1646 */ +#line 2021 "parse.c" /* yacc.c:1646 */ break; case 43: -#line 560 "parse.y" /* yacc.c:1646 */ +#line 582 "parse.y" /* yacc.c:1646 */ { varlength = true; (yyval) = mkor( (yyvsp[-2]), (yyvsp[0]) ); insert_after(2, ""); insert_before(0, ""); } -#line 2010 "parse.c" /* yacc.c:1646 */ +#line 2032 "parse.c" /* yacc.c:1646 */ break; case 44: -#line 568 "parse.y" /* yacc.c:1646 */ +#line 590 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2016 "parse.c" /* yacc.c:1646 */ +#line 2038 "parse.c" /* yacc.c:1646 */ break; case 45: -#line 573 "parse.y" /* yacc.c:1646 */ +#line 595 "parse.y" /* yacc.c:1646 */ { /* This rule is written separately so the * reduction will occur before the trailing @@ -2071,11 +2074,11 @@ yyreduce: current_state_type = STATE_TRAILING_CONTEXT; (yyval) = (yyvsp[-1]); } -#line 2045 "parse.c" /* yacc.c:1646 */ +#line 2067 "parse.c" /* yacc.c:1646 */ break; case 46: -#line 600 "parse.y" /* yacc.c:1646 */ +#line 622 "parse.y" /* yacc.c:1646 */ { /* This is where concatenation of adjacent patterns * gets done. @@ -2084,17 +2087,17 @@ yyreduce: insert_after(1, ""); insert_before(0, ""); } -#line 2058 "parse.c" /* yacc.c:1646 */ +#line 2080 "parse.c" /* yacc.c:1646 */ break; case 47: -#line 610 "parse.y" /* yacc.c:1646 */ +#line 632 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2064 "parse.c" /* yacc.c:1646 */ +#line 2086 "parse.c" /* yacc.c:1646 */ break; case 48: -#line 613 "parse.y" /* yacc.c:1646 */ +#line 635 "parse.y" /* yacc.c:1646 */ { varlength = true; @@ -2124,11 +2127,11 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[-3]), (yyvsp[-1])); insert_before(0, piece_temp); } -#line 2098 "parse.c" /* yacc.c:1646 */ +#line 2120 "parse.c" /* yacc.c:1646 */ break; case 49: -#line 644 "parse.y" /* yacc.c:1646 */ +#line 666 "parse.y" /* yacc.c:1646 */ { varlength = true; @@ -2144,11 +2147,11 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[-2])); insert_before(0, piece_temp); } -#line 2118 "parse.c" /* yacc.c:1646 */ +#line 2140 "parse.c" /* yacc.c:1646 */ break; case 50: -#line 661 "parse.y" /* yacc.c:1646 */ +#line 683 "parse.y" /* yacc.c:1646 */ { /* The series could be something like "(foo)", * in which case we have no idea what its length @@ -2170,11 +2173,11 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[-1]), (yyvsp[-1])); insert_before(0, piece_temp); } -#line 2144 "parse.c" /* yacc.c:1646 */ +#line 2166 "parse.c" /* yacc.c:1646 */ break; case 51: -#line 686 "parse.y" /* yacc.c:1646 */ +#line 708 "parse.y" /* yacc.c:1646 */ { varlength = true; @@ -2182,33 +2185,33 @@ yyreduce: insert_after(1, ""); insert_before(0, ""); } -#line 2156 "parse.c" /* yacc.c:1646 */ +#line 2178 "parse.c" /* yacc.c:1646 */ break; case 52: -#line 695 "parse.y" /* yacc.c:1646 */ +#line 717 "parse.y" /* yacc.c:1646 */ { varlength = true; (yyval) = mkposcl( (yyvsp[-1]) ); insert_after(1, ""); insert_before(0, ""); } -#line 2167 "parse.c" /* yacc.c:1646 */ +#line 2189 "parse.c" /* yacc.c:1646 */ break; case 53: -#line 703 "parse.y" /* yacc.c:1646 */ +#line 725 "parse.y" /* yacc.c:1646 */ { varlength = true; (yyval) = mkopt( (yyvsp[-1]) ); insert_after(1, ""); insert_before(0, ""); } -#line 2178 "parse.c" /* yacc.c:1646 */ +#line 2200 "parse.c" /* yacc.c:1646 */ break; case 54: -#line 711 "parse.y" /* yacc.c:1646 */ +#line 733 "parse.y" /* yacc.c:1646 */ { varlength = true; @@ -2238,11 +2241,11 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[-3]), (yyvsp[-1])); insert_before(0, piece_temp); } -#line 2212 "parse.c" /* yacc.c:1646 */ +#line 2234 "parse.c" /* yacc.c:1646 */ break; case 55: -#line 742 "parse.y" /* yacc.c:1646 */ +#line 764 "parse.y" /* yacc.c:1646 */ { varlength = true; @@ -2258,11 +2261,11 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[-2])); insert_before(0, piece_temp); } -#line 2232 "parse.c" /* yacc.c:1646 */ +#line 2254 "parse.c" /* yacc.c:1646 */ break; case 56: -#line 759 "parse.y" /* yacc.c:1646 */ +#line 781 "parse.y" /* yacc.c:1646 */ { /* The singleton could be something like "(foo)", * in which case we have no idea what its length @@ -2283,11 +2286,11 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[-1]), (yyvsp[-1])); insert_before(0, piece_temp); } -#line 2257 "parse.c" /* yacc.c:1646 */ +#line 2279 "parse.c" /* yacc.c:1646 */ break; case 57: -#line 781 "parse.y" /* yacc.c:1646 */ +#line 803 "parse.y" /* yacc.c:1646 */ { if ( ! madeany ) { @@ -2328,11 +2331,11 @@ yyreduce: insert_before(0, ""); } } -#line 2302 "parse.c" /* yacc.c:1646 */ +#line 2324 "parse.c" /* yacc.c:1646 */ break; case 58: -#line 823 "parse.y" /* yacc.c:1646 */ +#line 845 "parse.y" /* yacc.c:1646 */ { /* Sort characters for fast searching. */ @@ -2349,11 +2352,11 @@ yyreduce: (yyval) = mkstate( -(yyvsp[0]) ); } -#line 2323 "parse.c" /* yacc.c:1646 */ +#line 2345 "parse.c" /* yacc.c:1646 */ break; case 59: -#line 841 "parse.y" /* yacc.c:1646 */ +#line 863 "parse.y" /* yacc.c:1646 */ { ++rulelen; @@ -2362,28 +2365,28 @@ yyreduce: (yyval) = mkstate( -(yyvsp[0]) ); } -#line 2336 "parse.c" /* yacc.c:1646 */ +#line 2358 "parse.c" /* yacc.c:1646 */ break; case 60: -#line 851 "parse.y" /* yacc.c:1646 */ +#line 873 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2342 "parse.c" /* yacc.c:1646 */ +#line 2364 "parse.c" /* yacc.c:1646 */ break; case 61: -#line 854 "parse.y" /* yacc.c:1646 */ +#line 876 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); /*}*/ #if 0 /* for now do things in the traditional lex way without subexpressions */ insert_after(2, ""); insert_before(0, ""); #endif } -#line 2353 "parse.c" /* yacc.c:1646 */ +#line 2375 "parse.c" /* yacc.c:1646 */ break; case 62: -#line 862 "parse.y" /* yacc.c:1646 */ +#line 884 "parse.y" /* yacc.c:1646 */ { ++rulelen; @@ -2399,48 +2402,48 @@ yyreduce: sprintf(piece_temp, "", (yyvsp[0]), (yyvsp[0]) + 1); insert_before(0, piece_temp); } -#line 2373 "parse.c" /* yacc.c:1646 */ +#line 2395 "parse.c" /* yacc.c:1646 */ break; case 63: -#line 879 "parse.y" /* yacc.c:1646 */ +#line 901 "parse.y" /* yacc.c:1646 */ { (yyval) = ccl_set_diff ((yyvsp[-2]), (yyvsp[0])); /*}*/ insert_after(2, ""); insert_after(2, ""); insert_before(2, ""); insert_before(0, ""); } -#line 2384 "parse.c" /* yacc.c:1646 */ +#line 2406 "parse.c" /* yacc.c:1646 */ break; case 64: -#line 885 "parse.y" /* yacc.c:1646 */ +#line 907 "parse.y" /* yacc.c:1646 */ { (yyval) = ccl_set_union ((yyvsp[-2]), (yyvsp[0])); /*}*/ insert_after(2, ""); insert_before(0, ""); } -#line 2393 "parse.c" /* yacc.c:1646 */ +#line 2415 "parse.c" /* yacc.c:1646 */ break; case 66: -#line 894 "parse.y" /* yacc.c:1646 */ +#line 916 "parse.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2399 "parse.c" /* yacc.c:1646 */ +#line 2421 "parse.c" /* yacc.c:1646 */ break; case 67: -#line 897 "parse.y" /* yacc.c:1646 */ +#line 919 "parse.y" /* yacc.c:1646 */ { cclnegate( (yyvsp[-1]) ); (yyval) = (yyvsp[-1]); insert_after(2, ""); insert_before(1, ""); } -#line 2410 "parse.c" /* yacc.c:1646 */ +#line 2432 "parse.c" /* yacc.c:1646 */ break; case 68: -#line 906 "parse.y" /* yacc.c:1646 */ +#line 928 "parse.y" /* yacc.c:1646 */ { if (sf_case_ins()) @@ -2504,11 +2507,11 @@ yyreduce: insert_before(1, piece_temp); insert_before(0, ""); } -#line 2478 "parse.c" /* yacc.c:1646 */ +#line 2500 "parse.c" /* yacc.c:1646 */ break; case 69: -#line 971 "parse.y" /* yacc.c:1646 */ +#line 993 "parse.y" /* yacc.c:1646 */ { ccladd( (yyvsp[-1]), (yyvsp[0]) ); cclsorted = cclsorted && ((yyvsp[0]) > lastchar); @@ -2530,11 +2533,11 @@ yyreduce: insert_before(1, piece_temp); insert_before(0, ""); } -#line 2504 "parse.c" /* yacc.c:1646 */ +#line 2526 "parse.c" /* yacc.c:1646 */ break; case 70: -#line 994 "parse.y" /* yacc.c:1646 */ +#line 1016 "parse.y" /* yacc.c:1646 */ { /* Too hard to properly maintain cclsorted. */ cclsorted = false; @@ -2542,76 +2545,76 @@ yyreduce: insert_after(1, ""); insert_before(0, ""); } -#line 2516 "parse.c" /* yacc.c:1646 */ +#line 2538 "parse.c" /* yacc.c:1646 */ break; case 71: -#line 1003 "parse.y" /* yacc.c:1646 */ +#line 1025 "parse.y" /* yacc.c:1646 */ { cclsorted = true; lastchar = 0; currccl = (yyval) = cclinit(); insert_before(0, ""); } -#line 2527 "parse.c" /* yacc.c:1646 */ +#line 2549 "parse.c" /* yacc.c:1646 */ break; case 72: -#line 1012 "parse.y" /* yacc.c:1646 */ +#line 1034 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isalnum); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2536 "parse.c" /* yacc.c:1646 */ +#line 2558 "parse.c" /* yacc.c:1646 */ break; case 73: -#line 1016 "parse.y" /* yacc.c:1646 */ +#line 1038 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isalpha); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2545 "parse.c" /* yacc.c:1646 */ +#line 2567 "parse.c" /* yacc.c:1646 */ break; case 74: -#line 1020 "parse.y" /* yacc.c:1646 */ +#line 1042 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(IS_BLANK); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2554 "parse.c" /* yacc.c:1646 */ +#line 2576 "parse.c" /* yacc.c:1646 */ break; case 75: -#line 1024 "parse.y" /* yacc.c:1646 */ +#line 1046 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(iscntrl); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2563 "parse.c" /* yacc.c:1646 */ +#line 2585 "parse.c" /* yacc.c:1646 */ break; case 76: -#line 1028 "parse.y" /* yacc.c:1646 */ +#line 1050 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isdigit); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2572 "parse.c" /* yacc.c:1646 */ +#line 2594 "parse.c" /* yacc.c:1646 */ break; case 77: -#line 1032 "parse.y" /* yacc.c:1646 */ +#line 1054 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isgraph); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2581 "parse.c" /* yacc.c:1646 */ +#line 2603 "parse.c" /* yacc.c:1646 */ break; case 78: -#line 1036 "parse.y" /* yacc.c:1646 */ +#line 1058 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(islower); if (sf_case_ins()) @@ -2626,47 +2629,47 @@ yyreduce: insert_before(0, ""); } } -#line 2600 "parse.c" /* yacc.c:1646 */ +#line 2622 "parse.c" /* yacc.c:1646 */ break; case 79: -#line 1050 "parse.y" /* yacc.c:1646 */ +#line 1072 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isprint); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2609 "parse.c" /* yacc.c:1646 */ +#line 2631 "parse.c" /* yacc.c:1646 */ break; case 80: -#line 1054 "parse.y" /* yacc.c:1646 */ +#line 1076 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(ispunct); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2618 "parse.c" /* yacc.c:1646 */ +#line 2640 "parse.c" /* yacc.c:1646 */ break; case 81: -#line 1058 "parse.y" /* yacc.c:1646 */ +#line 1080 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isspace); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2627 "parse.c" /* yacc.c:1646 */ +#line 2649 "parse.c" /* yacc.c:1646 */ break; case 82: -#line 1062 "parse.y" /* yacc.c:1646 */ +#line 1084 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isxdigit); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2636 "parse.c" /* yacc.c:1646 */ +#line 2658 "parse.c" /* yacc.c:1646 */ break; case 83: -#line 1066 "parse.y" /* yacc.c:1646 */ +#line 1088 "parse.y" /* yacc.c:1646 */ { CCL_EXPR(isupper); if (sf_case_ins()) @@ -2681,101 +2684,101 @@ yyreduce: insert_before(0, ""); } } -#line 2655 "parse.c" /* yacc.c:1646 */ +#line 2677 "parse.c" /* yacc.c:1646 */ break; case 84: -#line 1081 "parse.y" /* yacc.c:1646 */ +#line 1103 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isalnum); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2664 "parse.c" /* yacc.c:1646 */ +#line 2686 "parse.c" /* yacc.c:1646 */ break; case 85: -#line 1085 "parse.y" /* yacc.c:1646 */ +#line 1107 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isalpha); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2673 "parse.c" /* yacc.c:1646 */ +#line 2695 "parse.c" /* yacc.c:1646 */ break; case 86: -#line 1089 "parse.y" /* yacc.c:1646 */ +#line 1111 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(IS_BLANK); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2682 "parse.c" /* yacc.c:1646 */ +#line 2704 "parse.c" /* yacc.c:1646 */ break; case 87: -#line 1093 "parse.y" /* yacc.c:1646 */ +#line 1115 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(iscntrl); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2691 "parse.c" /* yacc.c:1646 */ +#line 2713 "parse.c" /* yacc.c:1646 */ break; case 88: -#line 1097 "parse.y" /* yacc.c:1646 */ +#line 1119 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isdigit); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2700 "parse.c" /* yacc.c:1646 */ +#line 2722 "parse.c" /* yacc.c:1646 */ break; case 89: -#line 1101 "parse.y" /* yacc.c:1646 */ +#line 1123 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isgraph); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2709 "parse.c" /* yacc.c:1646 */ +#line 2731 "parse.c" /* yacc.c:1646 */ break; case 90: -#line 1105 "parse.y" /* yacc.c:1646 */ +#line 1127 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isprint); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2718 "parse.c" /* yacc.c:1646 */ +#line 2740 "parse.c" /* yacc.c:1646 */ break; case 91: -#line 1109 "parse.y" /* yacc.c:1646 */ +#line 1131 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(ispunct); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2727 "parse.c" /* yacc.c:1646 */ +#line 2749 "parse.c" /* yacc.c:1646 */ break; case 92: -#line 1113 "parse.y" /* yacc.c:1646 */ +#line 1135 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isspace); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2736 "parse.c" /* yacc.c:1646 */ +#line 2758 "parse.c" /* yacc.c:1646 */ break; case 93: -#line 1117 "parse.y" /* yacc.c:1646 */ +#line 1139 "parse.y" /* yacc.c:1646 */ { CCL_NEG_EXPR(isxdigit); /*}*/ insert_after(0, ""); insert_before(0, ""); } -#line 2745 "parse.c" /* yacc.c:1646 */ +#line 2767 "parse.c" /* yacc.c:1646 */ break; case 94: -#line 1121 "parse.y" /* yacc.c:1646 */ +#line 1143 "parse.y" /* yacc.c:1646 */ { if ( sf_case_ins() ) lwarn(_("[:^lower:] is ambiguous in case insensitive scanner")); @@ -2784,11 +2787,11 @@ yyreduce: insert_after(0, ""); insert_before(0, ""); } -#line 2758 "parse.c" /* yacc.c:1646 */ +#line 2780 "parse.c" /* yacc.c:1646 */ break; case 95: -#line 1129 "parse.y" /* yacc.c:1646 */ +#line 1151 "parse.y" /* yacc.c:1646 */ { if ( sf_case_ins() ) lwarn(_("[:^upper:] ambiguous in case insensitive scanner")); @@ -2797,11 +2800,11 @@ yyreduce: insert_after(0, ""); insert_before(0, ""); } -#line 2771 "parse.c" /* yacc.c:1646 */ +#line 2793 "parse.c" /* yacc.c:1646 */ break; case 96: -#line 1140 "parse.y" /* yacc.c:1646 */ +#line 1162 "parse.y" /* yacc.c:1646 */ { if ( (yyvsp[0]) == nlch ) rule_has_nl[num_rules] = true; @@ -2820,19 +2823,19 @@ yyreduce: insert_before(1, piece_temp); insert_before(0, ""); } -#line 2794 "parse.c" /* yacc.c:1646 */ +#line 2816 "parse.c" /* yacc.c:1646 */ break; case 97: -#line 1160 "parse.y" /* yacc.c:1646 */ +#line 1182 "parse.y" /* yacc.c:1646 */ { (yyval) = mkstate( SYM_EPSILON ); /*}*/ insert_before(0, ""); } -#line 2802 "parse.c" /* yacc.c:1646 */ +#line 2824 "parse.c" /* yacc.c:1646 */ break; -#line 2806 "parse.c" /* yacc.c:1646 */ +#line 2828 "parse.c" /* yacc.c:1646 */ default: break; } int i; @@ -3077,7 +3080,7 @@ yyreturn: #endif return yyresult; } -#line 1166 "parse.y" /* yacc.c:1906 */ +#line 1188 "parse.y" /* yacc.c:1906 */ @@ -3212,3 +3215,17 @@ void yyerror( const char *msg ) { (void)msg; } + +/* Nick */ +#if 0 /* not needed at the moment */ +void piece_peek(void) { + if (yychar == YYEMPTY) + yychar = yylex(); + memmove(piece + piece3 + 3, piece + piece3 + 1, (piece1 - piece3 - 1) * sizeof(char *)); + piece[piece3 + 1] = strdup(""); + piece[piece3 + 2] = strdup(""); + piece3 += 2; + piece0 += 2; + piece1 += 2; +} +#endif diff --git a/src/parse.c.patch b/src/parse.c.patch index 26072fa..7d6fb7a 100644 --- a/src/parse.c.patch +++ b/src/parse.c.patch @@ -1,32 +1,6 @@ ---- parse.c.orig 2018-06-24 10:38:12.236834056 +1000 -+++ parse.c 2018-06-24 10:38:12.360834050 +1000 -@@ -1245,6 +1245,25 @@ - | yyparse. | - `----------*/ - -+extern char piece_temp[]; -+extern char *piece[]; -+extern int piece0, piece1; -+void piece_insert(int n, const void *str); -+int piece2, piece3; -+static void peek(void) { -+ if (yychar == YYEMPTY) -+ yychar = yylex(); -+ memmove(piece + piece3 + 3, piece + piece3 + 1, (piece1 - piece3 - 1) * sizeof(char *)); -+ piece[piece3 + 1] = strdup(""); -+ piece[piece3 + 2] = strdup(""); -+ piece3 += 2; -+ piece0 += 2; -+ piece1 += 2; -+} -+#define insert_before(n, str) \ -+ do { piece_insert(piece2 + (n) * 2, (str)); ++piece0; ++piece3; } while (0) -+#define insert_after(n, str) \ -+ do { piece_insert(piece2 + (n) * 2 + 1, (str)); ++piece0; ++piece3; } while (0) - int - yyparse (void) - { -@@ -1465,6 +1484,17 @@ +--- parse.c.orig 2018-07-26 11:33:54.877698719 +1000 ++++ parse.c 2018-07-26 11:34:17.953697908 +1000 +@@ -1487,6 +1487,17 @@ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; @@ -44,8 +18,8 @@ /* If YYLEN is nonzero, implement the default value of the action: '$$ = $1'. -@@ -2813,6 +2843,23 @@ - #line 2814 "parse.c" /* yacc.c:1646 */ +@@ -2827,6 +2838,23 @@ + #line 2828 "parse.c" /* yacc.c:1646 */ default: break; } + int i; diff --git a/src/parse.y b/src/parse.y index 72dd7f4..ce68687 100644 --- a/src/parse.y +++ b/src/parse.y @@ -112,6 +112,28 @@ int previous_continued_action; /* whether the previous rule's action was '|' */ */ #define YYSTYPE int +/* Nick */ +extern char piece_temp[], *piece[]; +extern int piece0, piece1; +int piece2, piece3; +void piece_insert(int n, const void *str); +#if 0 /* not needed at the moment */ +void piece_peek(void); +#endif + +#define insert_before(n, str) \ + do { \ + piece_insert(piece2 + (n) * 2, (str)); \ + ++piece0; \ + ++piece3; \ + } while (0) +#define insert_after(n, str) \ + do { \ + piece_insert(piece2 + (n) * 2 + 1, (str)); \ + ++piece0; \ + ++piece3; \ + } while (0) + %} %% @@ -1297,3 +1319,17 @@ void yyerror( const char *msg ) { (void)msg; } + +/* Nick */ +#if 0 /* not needed at the moment */ +void piece_peek(void) { + if (yychar == YYEMPTY) + yychar = yylex(); + memmove(piece + piece3 + 3, piece + piece3 + 1, (piece1 - piece3 - 1) * sizeof(char *)); + piece[piece3 + 1] = strdup(""); + piece[piece3 + 2] = strdup(""); + piece3 += 2; + piece0 += 2; + piece1 += 2; +} +#endif diff --git a/src/scan.c b/src/scan.c index 3de2210..a1b108c 100644 --- a/src/scan.c +++ b/src/scan.c @@ -7775,10 +7775,8 @@ static int real_flexscan(void); } while (0) /* Nick */ -char piece_temp[100]; -char *piece[10000]; -int piece0; -int piece1; +char piece_temp[100], *piece[10000]; +int piece0, piece1; void piece_append(const char *str); void piece_insert(int n, const char *str); @@ -7798,7 +7796,7 @@ static void markup_option(const char *name, int sense); -#line 7793 "scan.c" +#line 7791 "scan.c" #define INITIAL 0 #define SECT2 1 @@ -8022,7 +8020,7 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 190 "scan.l" +#line 188 "scan.l" static int bracelevel, didadef, indented_code; static int doing_rule_action = false; @@ -8033,7 +8031,7 @@ YY_DECL char nmdef[MAXLINE]; -#line 8028 "scan.c" +#line 8026 "scan.c" if ( !(yy_init) ) { @@ -8128,39 +8126,39 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 201 "scan.l" +#line 199 "scan.l" START_CODEBLOCK(true); piece_append(""); YY_BREAK case 2: YY_RULE_SETUP -#line 202 "scan.l" +#line 200 "scan.l" add_action("/*[""["); yy_push_state( COMMENT ); YY_BREAK case 3: YY_RULE_SETUP -#line 203 "scan.l" +#line 201 "scan.l" yy_push_state( LINEDIR ); YY_BREAK case 4: YY_RULE_SETUP -#line 204 "scan.l" +#line 202 "scan.l" return SCDECL; YY_BREAK case 5: YY_RULE_SETUP -#line 205 "scan.l" +#line 203 "scan.l" return XSCDECL; YY_BREAK case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 206 "scan.l" +#line 204 "scan.l" START_CODEBLOCK(false); piece_flush(strlen(yytext)); piece_append(""); YY_BREAK case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 207 "scan.l" +#line 205 "scan.l" { brace_start_line = linenum; ++linenum; @@ -8171,17 +8169,17 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 215 "scan.l" +#line 213 "scan.l" synerr( _("malformed '%top' directive") ); YY_BREAK case 9: YY_RULE_SETUP -#line 217 "scan.l" +#line 215 "scan.l" /* discard */ YY_BREAK case 10: YY_RULE_SETUP -#line 219 "scan.l" +#line 217 "scan.l" { sectnum = 2; bracelevel = 0; @@ -8203,42 +8201,42 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 237 "scan.l" -yytext_is_array = false; ++linenum; piece_append(""); { int i = strlen(yytext) - 1; piece_esc(yytext, i); yytext += i; } piece_append(""); +#line 235 "scan.l" +yytext_is_array = false; ++linenum; piece_append(""); piece_flush(strlen(yytext) - 1); piece_append(""); YY_BREAK case 12: /* rule 12 can match eol */ YY_RULE_SETUP -#line 238 "scan.l" -yytext_is_array = true; ++linenum; piece_append(""); { int i = strlen(yytext) - 1; piece_esc(yytext, i); yytext += i; } piece_append(""); +#line 236 "scan.l" +yytext_is_array = true; ++linenum; piece_append(""); piece_flush(strlen(yytext) - 1); piece_append(""); YY_BREAK case 13: YY_RULE_SETUP -#line 240 "scan.l" +#line 238 "scan.l" BEGIN(OPTION); return TOK_OPTION; YY_BREAK case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 242 "scan.l" +#line 240 "scan.l" ++linenum; /* ignore */ YY_BREAK case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 243 "scan.l" +#line 241 "scan.l" ++linenum; /* ignore */ YY_BREAK /* xgettext: no-c-format */ case 16: /* rule 16 can match eol */ YY_RULE_SETUP -#line 246 "scan.l" +#line 244 "scan.l" synerr( _( "unrecognized '%' directive" ) ); YY_BREAK case 17: YY_RULE_SETUP -#line 248 "scan.l" +#line 246 "scan.l" { if(yyleng < MAXLINE) { @@ -8256,51 +8254,51 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 263 "scan.l" +#line 261 "scan.l" RETURNNAME; YY_BREAK case 19: /* rule 19 can match eol */ YY_RULE_SETUP -#line 264 "scan.l" +#line 262 "scan.l" ++linenum; /* allows blank lines in section 1 */ YY_BREAK case 20: /* rule 20 can match eol */ YY_RULE_SETUP -#line 265 "scan.l" +#line 263 "scan.l" ACTION_ECHO; ++linenum; /* maybe end of comment line */ YY_BREAK /* */ case 21: YY_RULE_SETUP -#line 270 "scan.l" +#line 268 "scan.l" ACTION_ECHO; YY_BREAK case 22: YY_RULE_SETUP -#line 271 "scan.l" +#line 269 "scan.l" ACTION_ECHO; YY_BREAK case 23: /* rule 23 can match eol */ YY_RULE_SETUP -#line 273 "scan.l" +#line 271 "scan.l" ++linenum; ACTION_ECHO; YY_BREAK case 24: YY_RULE_SETUP -#line 276 "scan.l" +#line 274 "scan.l" add_action("*/]""]"); yy_pop_state(); YY_BREAK case 25: YY_RULE_SETUP -#line 279 "scan.l" +#line 277 "scan.l" ACTION_ECHO; yy_pop_state(); YY_BREAK @@ -8308,41 +8306,41 @@ ACTION_ECHO; yy_pop_state(); /* This is the same as COMMENT, but is discarded rather than output. */ case 26: YY_RULE_SETUP -#line 284 "scan.l" +#line 282 "scan.l" yy_pop_state(); YY_BREAK case 27: YY_RULE_SETUP -#line 285 "scan.l" +#line 283 "scan.l" ; YY_BREAK case 28: YY_RULE_SETUP -#line 286 "scan.l" +#line 284 "scan.l" ; YY_BREAK case 29: /* rule 29 can match eol */ YY_RULE_SETUP -#line 287 "scan.l" +#line 285 "scan.l" ++linenum; YY_BREAK case 30: YY_RULE_SETUP -#line 291 "scan.l" +#line 289 "scan.l" yy_pop_state(); YY_BREAK case 31: YY_RULE_SETUP -#line 292 "scan.l" +#line 290 "scan.l" ; YY_BREAK case 32: /* rule 32 can match eol */ YY_RULE_SETUP -#line 293 "scan.l" +#line 291 "scan.l" ++linenum; YY_BREAK @@ -8350,17 +8348,17 @@ YY_RULE_SETUP case 33: /* rule 33 can match eol */ YY_RULE_SETUP -#line 297 "scan.l" +#line 295 "scan.l" yy_pop_state(); YY_BREAK case 34: YY_RULE_SETUP -#line 298 "scan.l" +#line 296 "scan.l" linenum = myctoi( yytext ); YY_BREAK case 35: YY_RULE_SETUP -#line 300 "scan.l" +#line 298 "scan.l" { free(infilename); infilename = xstrdup(yytext + 1); @@ -8369,19 +8367,19 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 305 "scan.l" +#line 303 "scan.l" /* ignore spurious characters */ YY_BREAK case 37: YY_RULE_SETUP -#line 308 "scan.l" +#line 306 "scan.l" ACTION_ECHO_QSTART; YY_BREAK case 38: YY_RULE_SETUP -#line 309 "scan.l" +#line 307 "scan.l" ACTION_ECHO_QEND; YY_BREAK @@ -8389,23 +8387,23 @@ ACTION_ECHO_QEND; case 39: /* rule 39 can match eol */ YY_RULE_SETUP -#line 313 "scan.l" +#line 311 "scan.l" ++linenum; piece_append(""); piece_flush(strlen(yytext)); END_CODEBLOCK; YY_BREAK case 40: YY_RULE_SETUP -#line 314 "scan.l" +#line 312 "scan.l" ACTION_ECHO; YY_BREAK case 41: YY_RULE_SETUP -#line 315 "scan.l" +#line 313 "scan.l" ACTION_ECHO; YY_BREAK case 42: /* rule 42 can match eol */ YY_RULE_SETUP -#line 316 "scan.l" +#line 314 "scan.l" { ++linenum; ACTION_ECHO; @@ -8416,7 +8414,7 @@ YY_RULE_SETUP case 43: YY_RULE_SETUP -#line 324 "scan.l" +#line 322 "scan.l" { if( --brace_depth == 0){ /* TODO: Matched. */ @@ -8427,7 +8425,7 @@ YY_RULE_SETUP YY_BREAK case 44: YY_RULE_SETUP -#line 332 "scan.l" +#line 330 "scan.l" { brace_depth++; buf_strnappend(&top_buf, yytext, yyleng); @@ -8436,7 +8434,7 @@ YY_RULE_SETUP case 45: /* rule 45 can match eol */ YY_RULE_SETUP -#line 337 "scan.l" +#line 335 "scan.l" { ++linenum; buf_strnappend(&top_buf, yytext, yyleng); @@ -8444,23 +8442,23 @@ YY_RULE_SETUP YY_BREAK case 46: YY_RULE_SETUP -#line 342 "scan.l" +#line 340 "scan.l" buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart)); YY_BREAK case 47: YY_RULE_SETUP -#line 343 "scan.l" +#line 341 "scan.l" buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend)); YY_BREAK case 48: YY_RULE_SETUP -#line 344 "scan.l" +#line 342 "scan.l" { buf_strnappend(&top_buf, yytext, yyleng); } YY_BREAK case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE): -#line 348 "scan.l" +#line 346 "scan.l" { linenum = brace_start_line; synerr(_("Unmatched '{'")); @@ -8471,12 +8469,12 @@ case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE): case 49: YY_RULE_SETUP -#line 357 "scan.l" +#line 355 "scan.l" /* separates name and definition */ YY_BREAK case 50: YY_RULE_SETUP -#line 359 "scan.l" +#line 357 "scan.l" { if(yyleng < MAXLINE) { @@ -8502,7 +8500,7 @@ YY_RULE_SETUP case 51: /* rule 51 can match eol */ YY_RULE_SETUP -#line 381 "scan.l" +#line 379 "scan.l" { if ( ! didadef ) synerr( _( "incomplete name definition" ) ); @@ -8515,42 +8513,42 @@ YY_RULE_SETUP case 52: /* rule 52 can match eol */ YY_RULE_SETUP -#line 391 "scan.l" +#line 389 "scan.l" ++linenum; BEGIN(INITIAL); YY_BREAK case 53: YY_RULE_SETUP -#line 392 "scan.l" +#line 390 "scan.l" option_sense = true; YY_BREAK case 54: YY_RULE_SETUP -#line 394 "scan.l" +#line 392 "scan.l" return '='; YY_BREAK case 55: YY_RULE_SETUP -#line 396 "scan.l" +#line 394 "scan.l" option_sense = ! option_sense; YY_BREAK case 56: YY_RULE_SETUP -#line 398 "scan.l" +#line 396 "scan.l" csize = option_sense ? 128 : 256; markup_option("SevenBit", option_sense); YY_BREAK case 57: YY_RULE_SETUP -#line 399 "scan.l" +#line 397 "scan.l" csize = option_sense ? 256 : 128; markup_option("SevenBit", !option_sense); YY_BREAK case 58: YY_RULE_SETUP -#line 401 "scan.l" +#line 399 "scan.l" long_align = option_sense; markup_option("Align", option_sense); YY_BREAK case 59: YY_RULE_SETUP -#line 402 "scan.l" +#line 400 "scan.l" { ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense ); interactive = option_sense; @@ -8559,27 +8557,27 @@ YY_RULE_SETUP YY_BREAK case 60: YY_RULE_SETUP -#line 407 "scan.l" +#line 405 "scan.l" yytext_is_array = option_sense; markup_option("Array", option_sense); YY_BREAK case 61: YY_RULE_SETUP -#line 408 "scan.l" +#line 406 "scan.l" backing_up_report = option_sense; markup_option("Backup", option_sense); YY_BREAK case 62: YY_RULE_SETUP -#line 409 "scan.l" +#line 407 "scan.l" interactive = ! option_sense; markup_option("Interactive", !option_sense); YY_BREAK case 63: YY_RULE_SETUP -#line 410 "scan.l" +#line 408 "scan.l" bison_bridge_lval = option_sense; markup_option("BisonBridge", option_sense); YY_BREAK case 64: YY_RULE_SETUP -#line 411 "scan.l" +#line 409 "scan.l" { if((bison_bridge_lloc = option_sense)) bison_bridge_lval = true; markup_option("BisonLocations", option_sense); @@ -8587,37 +8585,37 @@ YY_RULE_SETUP YY_BREAK case 65: YY_RULE_SETUP -#line 415 "scan.l" +#line 413 "scan.l" C_plus_plus = option_sense; markup_option("CPlusPlus", option_sense); YY_BREAK case 66: YY_RULE_SETUP -#line 416 "scan.l" +#line 414 "scan.l" sf_set_case_ins(!option_sense); markup_option("Caseless", !option_sense); YY_BREAK case 67: YY_RULE_SETUP -#line 417 "scan.l" +#line 415 "scan.l" sf_set_case_ins(option_sense); markup_option("Caseless", option_sense); YY_BREAK case 68: YY_RULE_SETUP -#line 418 "scan.l" +#line 416 "scan.l" ddebug = option_sense; markup_option("Debug", option_sense); YY_BREAK case 69: YY_RULE_SETUP -#line 419 "scan.l" +#line 417 "scan.l" spprdflt = ! option_sense; markup_option("Default", option_sense); YY_BREAK case 70: YY_RULE_SETUP -#line 420 "scan.l" +#line 418 "scan.l" useecs = option_sense; markup_option("ECS", option_sense); YY_BREAK case 71: YY_RULE_SETUP -#line 421 "scan.l" +#line 419 "scan.l" { useecs = usemecs = false; use_read = fullspd = true; @@ -8626,7 +8624,7 @@ YY_RULE_SETUP YY_BREAK case 72: YY_RULE_SETUP -#line 426 "scan.l" +#line 424 "scan.l" { useecs = usemecs = false; use_read = fulltbl = true; @@ -8635,32 +8633,32 @@ YY_RULE_SETUP YY_BREAK case 73: YY_RULE_SETUP -#line 431 "scan.l" +#line 429 "scan.l" ACTION_IFDEF("YY_NO_INPUT", ! option_sense); markup_option("Input", option_sense); YY_BREAK case 74: YY_RULE_SETUP -#line 432 "scan.l" +#line 430 "scan.l" interactive = option_sense; markup_option("Interactive", option_sense); YY_BREAK case 75: YY_RULE_SETUP -#line 433 "scan.l" +#line 431 "scan.l" lex_compat = option_sense; markup_option("LexCompat", option_sense); YY_BREAK case 76: YY_RULE_SETUP -#line 434 "scan.l" +#line 432 "scan.l" posix_compat = option_sense; markup_option("PosixCompat", option_sense); YY_BREAK case 77: YY_RULE_SETUP -#line 435 "scan.l" +#line 433 "scan.l" gen_line_dirs = option_sense; markup_option("Line", option_sense); YY_BREAK case 78: YY_RULE_SETUP -#line 436 "scan.l" +#line 434 "scan.l" { ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense); /* Override yywrap */ @@ -8671,12 +8669,12 @@ YY_RULE_SETUP YY_BREAK case 79: YY_RULE_SETUP -#line 443 "scan.l" +#line 441 "scan.l" usemecs = option_sense; markup_option("MetaECS", option_sense); YY_BREAK case 80: YY_RULE_SETUP -#line 444 "scan.l" +#line 442 "scan.l" { ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense ); interactive = !option_sense; @@ -8685,237 +8683,237 @@ YY_RULE_SETUP YY_BREAK case 81: YY_RULE_SETUP -#line 449 "scan.l" +#line 447 "scan.l" performance_report += option_sense ? 1 : -1; markup_option("PerfReport", option_sense); YY_BREAK case 82: YY_RULE_SETUP -#line 450 "scan.l" +#line 448 "scan.l" yytext_is_array = ! option_sense; markup_option("Array", !option_sense); YY_BREAK case 83: YY_RULE_SETUP -#line 451 "scan.l" +#line 449 "scan.l" use_read = option_sense; markup_option("Read", option_sense); YY_BREAK case 84: YY_RULE_SETUP -#line 452 "scan.l" +#line 450 "scan.l" reentrant = option_sense; markup_option("Reentrant", option_sense); YY_BREAK case 85: YY_RULE_SETUP -#line 453 "scan.l" +#line 451 "scan.l" reject_really_used = option_sense; markup_option("Reject", option_sense); YY_BREAK case 86: YY_RULE_SETUP -#line 454 "scan.l" +#line 452 "scan.l" ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense ); markup_option("Stack", option_sense); YY_BREAK case 87: YY_RULE_SETUP -#line 455 "scan.l" +#line 453 "scan.l" do_stdinit = option_sense; markup_option("StdInit", option_sense); YY_BREAK case 88: YY_RULE_SETUP -#line 456 "scan.l" +#line 454 "scan.l" use_stdout = option_sense; markup_option("StdOut", option_sense); YY_BREAK case 89: YY_RULE_SETUP -#line 457 "scan.l" +#line 455 "scan.l" ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense); markup_option("UniStd", option_sense); YY_BREAK case 90: YY_RULE_SETUP -#line 458 "scan.l" +#line 456 "scan.l" ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense); markup_option("Unput", option_sense); YY_BREAK case 91: YY_RULE_SETUP -#line 459 "scan.l" +#line 457 "scan.l" printstats = option_sense; markup_option("Verbose", option_sense); YY_BREAK case 92: YY_RULE_SETUP -#line 460 "scan.l" +#line 458 "scan.l" nowarn = ! option_sense; markup_option("Warn", option_sense); YY_BREAK case 93: YY_RULE_SETUP -#line 461 "scan.l" +#line 459 "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 462 "scan.l" +#line 460 "scan.l" yymore_really_used = option_sense; markup_option("YYMore", option_sense); YY_BREAK case 95: YY_RULE_SETUP -#line 463 "scan.l" +#line 461 "scan.l" do_yywrap = option_sense; markup_option("YYWrap", option_sense); YY_BREAK case 96: YY_RULE_SETUP -#line 465 "scan.l" +#line 463 "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 466 "scan.l" +#line 464 "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 467 "scan.l" +#line 465 "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 469 "scan.l" +#line 467 "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 470 "scan.l" +#line 468 "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 471 "scan.l" +#line 469 "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 473 "scan.l" +#line 471 "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 474 "scan.l" +#line 472 "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 475 "scan.l" +#line 473 "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 477 "scan.l" +#line 475 "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 478 "scan.l" +#line 476 "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 479 "scan.l" +#line 477 "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 480 "scan.l" +#line 478 "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 481 "scan.l" +#line 479 "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 482 "scan.l" +#line 480 "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 483 "scan.l" +#line 481 "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 484 "scan.l" +#line 482 "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 485 "scan.l" +#line 483 "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 486 "scan.l" +#line 484 "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 487 "scan.l" +#line 485 "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 488 "scan.l" +#line 486 "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 489 "scan.l" +#line 487 "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 490 "scan.l" +#line 488 "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 491 "scan.l" +#line 489 "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 492 "scan.l" +#line 490 "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 494 "scan.l" +#line 492 "scan.l" return TOK_EXTRA_TYPE; YY_BREAK case 122: YY_RULE_SETUP -#line 495 "scan.l" +#line 493 "scan.l" return TOK_OUTFILE; YY_BREAK case 123: YY_RULE_SETUP -#line 496 "scan.l" +#line 494 "scan.l" return TOK_PREFIX; YY_BREAK case 124: YY_RULE_SETUP -#line 497 "scan.l" +#line 495 "scan.l" return TOK_YYCLASS; YY_BREAK case 125: YY_RULE_SETUP -#line 498 "scan.l" +#line 496 "scan.l" return TOK_HEADER_FILE; YY_BREAK case 126: YY_RULE_SETUP -#line 499 "scan.l" +#line 497 "scan.l" return TOK_TABLES_FILE; YY_BREAK case 127: YY_RULE_SETUP -#line 500 "scan.l" +#line 498 "scan.l" { tablesverify = option_sense; if(!tablesext && option_sense) @@ -8925,7 +8923,7 @@ YY_RULE_SETUP YY_BREAK case 128: YY_RULE_SETUP -#line 508 "scan.l" +#line 506 "scan.l" { if(yyleng-1 < MAXLINE) { @@ -8951,7 +8949,7 @@ YY_RULE_SETUP YY_BREAK case 129: YY_RULE_SETUP -#line 531 "scan.l" +#line 529 "scan.l" { format_synerr( _( "unrecognized %%option: %s" ), yytext ); @@ -8962,28 +8960,28 @@ YY_RULE_SETUP case 130: /* rule 130 can match eol */ YY_RULE_SETUP -#line 538 "scan.l" +#line 536 "scan.l" ++linenum; BEGIN(INITIAL); YY_BREAK case 131: YY_RULE_SETUP -#line 542 "scan.l" +#line 540 "scan.l" ++bracelevel; yyless( 2 ); /* eat only %{ */ YY_BREAK case 132: YY_RULE_SETUP -#line 543 "scan.l" +#line 541 "scan.l" --bracelevel; yyless( 2 ); /* eat only %} */ YY_BREAK case 133: YY_RULE_SETUP -#line 545 "scan.l" +#line 543 "scan.l" START_CODEBLOCK(true); piece_append(""); /* indented code in prolog */ YY_BREAK case 134: YY_RULE_SETUP -#line 547 "scan.l" +#line 545 "scan.l" { /* non-indented code */ if ( bracelevel <= 0 ) { @@ -9000,17 +8998,17 @@ YY_RULE_SETUP YY_BREAK case 135: YY_RULE_SETUP -#line 561 "scan.l" +#line 559 "scan.l" ACTION_ECHO; YY_BREAK case 136: /* rule 136 can match eol */ YY_RULE_SETUP -#line 562 "scan.l" +#line 560 "scan.l" ++linenum; ACTION_ECHO; YY_BREAK case YY_STATE_EOF(SECT2PROLOG): -#line 564 "scan.l" +#line 562 "scan.l" { mark_prolog(); sectnum = 0; @@ -9029,28 +9027,26 @@ case YY_STATE_EOF(SECT2PROLOG): case 137: /* rule 137 can match eol */ YY_RULE_SETUP -#line 579 "scan.l" +#line 577 "scan.l" ++linenum; /* allow blank lines in section 2 */ YY_BREAK case 138: YY_RULE_SETUP -#line 581 "scan.l" +#line 579 "scan.l" { indented_code = false; 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(""); - piece_flush(strlen(yytext)); + piece_flush(2); piece_append(""); } YY_BREAK case 139: YY_RULE_SETUP -#line 594 "scan.l" +#line 590 "scan.l" { /* Allow "<" to appear in (?x) patterns. */ if (!sf_skip_ws()) @@ -9060,12 +9056,12 @@ YY_RULE_SETUP YY_BREAK case 140: YY_RULE_SETUP -#line 600 "scan.l" +#line 596 "scan.l" return '^'; YY_BREAK case 141: YY_RULE_SETUP -#line 601 "scan.l" +#line 597 "scan.l" BEGIN(QUOTE); return '"'; YY_BREAK case 142: @@ -9073,7 +9069,7 @@ case 142: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 602 "scan.l" +#line 598 "scan.l" { BEGIN(NUM); if ( lex_compat || posix_compat ) @@ -9088,18 +9084,16 @@ case 143: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 609 "scan.l" +#line 605 "scan.l" return '$'; YY_BREAK case 144: YY_RULE_SETUP -#line 611 "scan.l" +#line 607 "scan.l" { bracelevel = 1; BEGIN(PERCENT_BRACE_ACTION); - int i = strlen(yytext) - 2; - piece_esc(yytext, i); - yytext += i; + piece_flush(strlen(yytext) - 2); piece_append(""); if ( in_rule ) @@ -9108,7 +9102,7 @@ YY_RULE_SETUP in_rule = false; #if 1 piece_pack(); - piece_esc(yytext, strlen(yytext)); + piece_esc(yytext, 2); piece_pack(); piece_append(""); return ~'\n'; @@ -9127,7 +9121,7 @@ YY_RULE_SETUP case 145: /* rule 145 can match eol */ YY_RULE_SETUP -#line 640 "scan.l" +#line 634 "scan.l" { if (sf_skip_ws()){ /* We're in the middle of a (?x: ) pattern. */ @@ -9143,8 +9137,7 @@ YY_RULE_SETUP int i; for (i = 0; yytext[i] == '\t' || yytext[i] == ' '; ++i) ; - piece_esc(yytext, i); - yytext += i; + piece_flush(i); piece_pack(); piece_append(""); piece_esc(yytext, strlen(yytext)); @@ -9159,7 +9152,7 @@ YY_RULE_SETUP YY_BREAK case 146: YY_RULE_SETUP -#line 669 "scan.l" +#line 662 "scan.l" { if (sf_skip_ws()){ @@ -9176,12 +9169,12 @@ YY_RULE_SETUP YY_BREAK case 147: YY_RULE_SETUP -#line 683 "scan.l" +#line 676 "scan.l" /* allow indented rules */ ; YY_BREAK case 148: YY_RULE_SETUP -#line 685 "scan.l" +#line 678 "scan.l" { if (sf_skip_ws()){ /* We're in the middle of a (?x: ) pattern. */ @@ -9215,7 +9208,7 @@ YY_RULE_SETUP case 149: /* rule 149 can match eol */ YY_RULE_SETUP -#line 715 "scan.l" +#line 708 "scan.l" { if (sf_skip_ws()){ /* We're in the middle of a (?x: ) pattern. */ @@ -9249,15 +9242,15 @@ YY_RULE_SETUP } YY_BREAK case 150: -#line 748 "scan.l" +#line 741 "scan.l" case 151: YY_RULE_SETUP -#line 748 "scan.l" +#line 741 "scan.l" return EOF_OP; YY_BREAK case 152: YY_RULE_SETUP -#line 750 "scan.l" +#line 743 "scan.l" { sectnum = 3; BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3); @@ -9277,7 +9270,7 @@ YY_RULE_SETUP YY_BREAK case 153: YY_RULE_SETUP -#line 767 "scan.l" +#line 760 "scan.l" { int cclval; @@ -9327,12 +9320,12 @@ YY_RULE_SETUP YY_BREAK case 154: YY_RULE_SETUP -#line 813 "scan.l" +#line 806 "scan.l" return CCL_OP_DIFF; YY_BREAK case 155: YY_RULE_SETUP -#line 814 "scan.l" +#line 807 "scan.l" return CCL_OP_UNION; YY_BREAK /* Check for :space: at the end of the rule so we don't @@ -9342,7 +9335,7 @@ return CCL_OP_UNION; case 156: /* rule 156 can match eol */ YY_RULE_SETUP -#line 821 "scan.l" +#line 814 "scan.l" { char *nmdefptr; int end_is_ws, end_ch; @@ -9397,7 +9390,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */ YY_BREAK case 157: YY_RULE_SETUP -#line 873 "scan.l" +#line 866 "scan.l" { if (sf_skip_ws()) yy_push_state(COMMENT_DISCARD); @@ -9410,7 +9403,7 @@ YY_RULE_SETUP YY_BREAK case 158: YY_RULE_SETUP -#line 883 "scan.l" +#line 876 "scan.l" { if (lex_compat || posix_compat){ /* Push back the "?#" and treat it like a normal parens. */ @@ -9424,7 +9417,7 @@ YY_RULE_SETUP YY_BREAK case 159: YY_RULE_SETUP -#line 893 "scan.l" +#line 886 "scan.l" { sf_push(); if (lex_compat || posix_compat) @@ -9437,12 +9430,12 @@ YY_RULE_SETUP YY_BREAK case 160: YY_RULE_SETUP -#line 902 "scan.l" +#line 895 "scan.l" sf_push(); return '('; YY_BREAK case 161: YY_RULE_SETUP -#line 903 "scan.l" +#line 896 "scan.l" { if (_sf_top_ix > 0) { sf_pop(); @@ -9453,17 +9446,17 @@ YY_RULE_SETUP YY_BREAK case 162: YY_RULE_SETUP -#line 911 "scan.l" +#line 904 "scan.l" return (unsigned char) yytext[0]; YY_BREAK case 163: YY_RULE_SETUP -#line 912 "scan.l" +#line 905 "scan.l" RETURNCHAR; YY_BREAK /* Nick added this rule for consistency with rest of scanner */ case YY_STATE_EOF(SECT2): -#line 915 "scan.l" +#line 908 "scan.l" { sectnum = 0; #if 1 @@ -9481,17 +9474,17 @@ case YY_STATE_EOF(SECT2): case 164: /* rule 164 can match eol */ YY_RULE_SETUP -#line 930 "scan.l" +#line 923 "scan.l" ++linenum; /* Allow blank lines & continuations */ YY_BREAK case 165: YY_RULE_SETUP -#line 931 "scan.l" +#line 924 "scan.l" return (unsigned char) yytext[0]; YY_BREAK case 166: YY_RULE_SETUP -#line 932 "scan.l" +#line 925 "scan.l" BEGIN(SECT2); return '>'; YY_BREAK case 167: @@ -9499,17 +9492,17 @@ case 167: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 933 "scan.l" +#line 926 "scan.l" BEGIN(CARETISBOL); return '>'; YY_BREAK case 168: YY_RULE_SETUP -#line 934 "scan.l" +#line 927 "scan.l" RETURNNAME; YY_BREAK case 169: YY_RULE_SETUP -#line 935 "scan.l" +#line 928 "scan.l" { format_synerr( _( "bad : %s" ), yytext ); @@ -9518,24 +9511,24 @@ YY_RULE_SETUP case 170: YY_RULE_SETUP -#line 941 "scan.l" +#line 934 "scan.l" BEGIN(SECT2); return '^'; YY_BREAK case 171: YY_RULE_SETUP -#line 945 "scan.l" +#line 938 "scan.l" RETURNCHAR; YY_BREAK case 172: YY_RULE_SETUP -#line 946 "scan.l" +#line 939 "scan.l" BEGIN(SECT2); return '"'; YY_BREAK case 173: /* rule 173 can match eol */ YY_RULE_SETUP -#line 948 "scan.l" +#line 941 "scan.l" { synerr( _( "missing quote" ) ); BEGIN(SECT2); @@ -9547,49 +9540,49 @@ YY_RULE_SETUP case 174: YY_RULE_SETUP -#line 957 "scan.l" +#line 950 "scan.l" BEGIN(SECT2); YY_BREAK case 175: YY_RULE_SETUP -#line 958 "scan.l" +#line 951 "scan.l" BEGIN(GROUP_MINUS_PARAMS); YY_BREAK case 176: YY_RULE_SETUP -#line 959 "scan.l" +#line 952 "scan.l" sf_set_case_ins(1); YY_BREAK case 177: YY_RULE_SETUP -#line 960 "scan.l" +#line 953 "scan.l" sf_set_dot_all(1); YY_BREAK case 178: YY_RULE_SETUP -#line 961 "scan.l" +#line 954 "scan.l" sf_set_skip_ws(1); YY_BREAK case 179: YY_RULE_SETUP -#line 964 "scan.l" +#line 957 "scan.l" BEGIN(SECT2); YY_BREAK case 180: YY_RULE_SETUP -#line 965 "scan.l" +#line 958 "scan.l" sf_set_case_ins(0); YY_BREAK case 181: YY_RULE_SETUP -#line 966 "scan.l" +#line 959 "scan.l" sf_set_dot_all(0); YY_BREAK case 182: YY_RULE_SETUP -#line 967 "scan.l" +#line 960 "scan.l" sf_set_skip_ws(0); YY_BREAK @@ -9599,7 +9592,7 @@ case 183: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 971 "scan.l" +#line 964 "scan.l" BEGIN(CCL); return '^'; YY_BREAK case 184: @@ -9607,12 +9600,12 @@ case 184: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 972 "scan.l" +#line 965 "scan.l" return '^'; YY_BREAK case 185: YY_RULE_SETUP -#line 973 "scan.l" +#line 966 "scan.l" BEGIN(CCL); RETURNCHAR; YY_BREAK @@ -9622,23 +9615,23 @@ case 186: (yy_c_buf_p) = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 977 "scan.l" +#line 970 "scan.l" return '-'; YY_BREAK case 187: YY_RULE_SETUP -#line 978 "scan.l" +#line 971 "scan.l" RETURNCHAR; YY_BREAK case 188: YY_RULE_SETUP -#line 979 "scan.l" +#line 972 "scan.l" BEGIN(SECT2); return ']'; YY_BREAK case 189: /* rule 189 can match eol */ YY_RULE_SETUP -#line 980 "scan.l" +#line 973 "scan.l" { synerr( _( "bad character class" ) ); BEGIN(SECT2); @@ -9649,127 +9642,127 @@ YY_RULE_SETUP case 190: YY_RULE_SETUP -#line 988 "scan.l" +#line 981 "scan.l" BEGIN(CCL); return CCE_ALNUM; YY_BREAK case 191: YY_RULE_SETUP -#line 989 "scan.l" +#line 982 "scan.l" BEGIN(CCL); return CCE_ALPHA; YY_BREAK case 192: YY_RULE_SETUP -#line 990 "scan.l" +#line 983 "scan.l" BEGIN(CCL); return CCE_BLANK; YY_BREAK case 193: YY_RULE_SETUP -#line 991 "scan.l" +#line 984 "scan.l" BEGIN(CCL); return CCE_CNTRL; YY_BREAK case 194: YY_RULE_SETUP -#line 992 "scan.l" +#line 985 "scan.l" BEGIN(CCL); return CCE_DIGIT; YY_BREAK case 195: YY_RULE_SETUP -#line 993 "scan.l" +#line 986 "scan.l" BEGIN(CCL); return CCE_GRAPH; YY_BREAK case 196: YY_RULE_SETUP -#line 994 "scan.l" +#line 987 "scan.l" BEGIN(CCL); return CCE_LOWER; YY_BREAK case 197: YY_RULE_SETUP -#line 995 "scan.l" +#line 988 "scan.l" BEGIN(CCL); return CCE_PRINT; YY_BREAK case 198: YY_RULE_SETUP -#line 996 "scan.l" +#line 989 "scan.l" BEGIN(CCL); return CCE_PUNCT; YY_BREAK case 199: YY_RULE_SETUP -#line 997 "scan.l" +#line 990 "scan.l" BEGIN(CCL); return CCE_SPACE; YY_BREAK case 200: YY_RULE_SETUP -#line 998 "scan.l" +#line 991 "scan.l" BEGIN(CCL); return CCE_UPPER; YY_BREAK case 201: YY_RULE_SETUP -#line 999 "scan.l" +#line 992 "scan.l" BEGIN(CCL); return CCE_XDIGIT; YY_BREAK case 202: YY_RULE_SETUP -#line 1001 "scan.l" +#line 994 "scan.l" BEGIN(CCL); return CCE_NEG_ALNUM; YY_BREAK case 203: YY_RULE_SETUP -#line 1002 "scan.l" +#line 995 "scan.l" BEGIN(CCL); return CCE_NEG_ALPHA; YY_BREAK case 204: YY_RULE_SETUP -#line 1003 "scan.l" +#line 996 "scan.l" BEGIN(CCL); return CCE_NEG_BLANK; YY_BREAK case 205: YY_RULE_SETUP -#line 1004 "scan.l" +#line 997 "scan.l" BEGIN(CCL); return CCE_NEG_CNTRL; YY_BREAK case 206: YY_RULE_SETUP -#line 1005 "scan.l" +#line 998 "scan.l" BEGIN(CCL); return CCE_NEG_DIGIT; YY_BREAK case 207: YY_RULE_SETUP -#line 1006 "scan.l" +#line 999 "scan.l" BEGIN(CCL); return CCE_NEG_GRAPH; YY_BREAK case 208: YY_RULE_SETUP -#line 1007 "scan.l" +#line 1000 "scan.l" BEGIN(CCL); return CCE_NEG_LOWER; YY_BREAK case 209: YY_RULE_SETUP -#line 1008 "scan.l" +#line 1001 "scan.l" BEGIN(CCL); return CCE_NEG_PRINT; YY_BREAK case 210: YY_RULE_SETUP -#line 1009 "scan.l" +#line 1002 "scan.l" BEGIN(CCL); return CCE_NEG_PUNCT; YY_BREAK case 211: YY_RULE_SETUP -#line 1010 "scan.l" +#line 1003 "scan.l" BEGIN(CCL); return CCE_NEG_SPACE; YY_BREAK case 212: YY_RULE_SETUP -#line 1011 "scan.l" +#line 1004 "scan.l" BEGIN(CCL); return CCE_NEG_UPPER; YY_BREAK case 213: YY_RULE_SETUP -#line 1012 "scan.l" +#line 1005 "scan.l" BEGIN(CCL); return CCE_NEG_XDIGIT; YY_BREAK case 214: YY_RULE_SETUP -#line 1013 "scan.l" +#line 1006 "scan.l" { format_synerr( _( "bad character class expression: %s" ), @@ -9781,7 +9774,7 @@ YY_RULE_SETUP case 215: YY_RULE_SETUP -#line 1022 "scan.l" +#line 1015 "scan.l" { yylval = myctoi( yytext ); return NUMBER; @@ -9789,12 +9782,12 @@ YY_RULE_SETUP YY_BREAK case 216: YY_RULE_SETUP -#line 1027 "scan.l" +#line 1020 "scan.l" return ','; YY_BREAK case 217: YY_RULE_SETUP -#line 1028 "scan.l" +#line 1021 "scan.l" { BEGIN(SECT2); if ( lex_compat || posix_compat ) @@ -9805,7 +9798,7 @@ YY_RULE_SETUP YY_BREAK case 218: YY_RULE_SETUP -#line 1036 "scan.l" +#line 1029 "scan.l" { synerr( _( "bad character inside {}'s" ) ); BEGIN(SECT2); @@ -9815,7 +9808,7 @@ YY_RULE_SETUP case 219: /* rule 219 can match eol */ YY_RULE_SETUP -#line 1042 "scan.l" +#line 1035 "scan.l" { synerr( _( "missing }" ) ); BEGIN(SECT2); @@ -9827,18 +9820,18 @@ YY_RULE_SETUP case 220: YY_RULE_SETUP -#line 1052 "scan.l" +#line 1045 "scan.l" bracelevel = 0; piece_append(""); YY_BREAK case 221: YY_RULE_SETUP -#line 1054 "scan.l" +#line 1047 "scan.l" ACTION_ECHO; yy_push_state( CODE_COMMENT ); YY_BREAK case 222: YY_RULE_SETUP -#line 1057 "scan.l" +#line 1050 "scan.l" { ACTION_ECHO; CHECK_REJECT(yytext); @@ -9846,7 +9839,7 @@ YY_RULE_SETUP YY_BREAK case 223: YY_RULE_SETUP -#line 1061 "scan.l" +#line 1054 "scan.l" { ACTION_ECHO; CHECK_YYMORE(yytext); @@ -9855,13 +9848,13 @@ YY_RULE_SETUP case 224: YY_RULE_SETUP -#line 1067 "scan.l" +#line 1060 "scan.l" ACTION_ECHO; YY_BREAK case 225: /* rule 225 can match eol */ YY_RULE_SETUP -#line 1068 "scan.l" +#line 1061 "scan.l" { ++linenum; ACTION_ECHO; @@ -9884,43 +9877,43 @@ YY_RULE_SETUP case 226: YY_RULE_SETUP -#line 1089 "scan.l" +#line 1082 "scan.l" ACTION_ECHO; ++bracelevel; YY_BREAK case 227: YY_RULE_SETUP -#line 1090 "scan.l" +#line 1083 "scan.l" ACTION_ECHO; --bracelevel; YY_BREAK case 228: YY_RULE_SETUP -#line 1091 "scan.l" +#line 1084 "scan.l" ACTION_ECHO; YY_BREAK case 229: YY_RULE_SETUP -#line 1092 "scan.l" +#line 1085 "scan.l" ACTION_ECHO; YY_BREAK case 230: YY_RULE_SETUP -#line 1093 "scan.l" +#line 1086 "scan.l" ACTION_ECHO; /* character constant */ YY_BREAK case 231: YY_RULE_SETUP -#line 1094 "scan.l" +#line 1087 "scan.l" ACTION_ECHO; BEGIN(CHARACTER_CONSTANT); YY_BREAK case 232: YY_RULE_SETUP -#line 1095 "scan.l" +#line 1088 "scan.l" ACTION_ECHO; BEGIN(ACTION_STRING); YY_BREAK case 233: /* rule 233 can match eol */ YY_RULE_SETUP -#line 1096 "scan.l" +#line 1089 "scan.l" { ++linenum; ACTION_ECHO; @@ -9939,31 +9932,31 @@ YY_RULE_SETUP YY_BREAK case 234: YY_RULE_SETUP -#line 1111 "scan.l" +#line 1104 "scan.l" ACTION_ECHO; YY_BREAK case 235: YY_RULE_SETUP -#line 1115 "scan.l" +#line 1108 "scan.l" ACTION_ECHO; YY_BREAK case 236: YY_RULE_SETUP -#line 1116 "scan.l" +#line 1109 "scan.l" ACTION_ECHO; BEGIN(ACTION); YY_BREAK case 237: YY_RULE_SETUP -#line 1119 "scan.l" +#line 1112 "scan.l" ACTION_ECHO; YY_BREAK case 238: YY_RULE_SETUP -#line 1120 "scan.l" +#line 1113 "scan.l" ACTION_ECHO; BEGIN(ACTION); YY_BREAK @@ -9971,24 +9964,24 @@ ACTION_ECHO; BEGIN(ACTION); case 239: /* rule 239 can match eol */ YY_RULE_SETUP -#line 1123 "scan.l" +#line 1116 "scan.l" ACTION_ECHO; YY_BREAK case 240: /* rule 240 can match eol */ YY_RULE_SETUP -#line 1124 "scan.l" +#line 1117 "scan.l" ACTION_ECHO; YY_BREAK case 241: /* rule 241 can match eol */ YY_RULE_SETUP -#line 1125 "scan.l" +#line 1118 "scan.l" ++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); piece_flush(strlen(yytext)); if (doing_rule_action) markup_action(""); } else { BEGIN(ACTION); } YY_BREAK case 242: YY_RULE_SETUP -#line 1126 "scan.l" +#line 1119 "scan.l" ACTION_ECHO; YY_BREAK @@ -9998,7 +9991,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 1129 "scan.l" +#line 1122 "scan.l" { synerr( _( "EOF encountered inside an action" ) ); yyterminate(); @@ -10007,7 +10000,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 1134 "scan.l" +#line 1127 "scan.l" { synerr( _( "EOF encountered inside pattern" ) ); yyterminate(); @@ -10015,7 +10008,7 @@ case YY_STATE_EOF(GROUP_MINUS_PARAMS): YY_BREAK case 243: YY_RULE_SETUP -#line 1139 "scan.l" +#line 1132 "scan.l" { yylval = myesc( (unsigned char *) yytext ); @@ -10028,27 +10021,27 @@ YY_RULE_SETUP case 244: YY_RULE_SETUP -#line 1149 "scan.l" +#line 1142 "scan.l" fputs(escaped_qstart, yyout); YY_BREAK case 245: YY_RULE_SETUP -#line 1150 "scan.l" +#line 1143 "scan.l" fputs(escaped_qend, yyout); YY_BREAK case 246: /* rule 246 can match eol */ YY_RULE_SETUP -#line 1151 "scan.l" +#line 1144 "scan.l" ECHO; YY_BREAK case 247: YY_RULE_SETUP -#line 1152 "scan.l" +#line 1145 "scan.l" ECHO; YY_BREAK case YY_STATE_EOF(SECT3): -#line 1153 "scan.l" +#line 1146 "scan.l" { sectnum = 0; #if 1 @@ -10065,27 +10058,27 @@ case YY_STATE_EOF(SECT3): case 248: YY_RULE_SETUP -#line 1166 "scan.l" +#line 1159 "scan.l" fprintf(yyout, "[""[%s]""]", escaped_qstart); YY_BREAK case 249: YY_RULE_SETUP -#line 1167 "scan.l" +#line 1160 "scan.l" fprintf(yyout, "[""[%s]""]", escaped_qend); YY_BREAK case 250: /* rule 250 can match eol */ YY_RULE_SETUP -#line 1168 "scan.l" +#line 1161 "scan.l" ECHO; YY_BREAK case 251: YY_RULE_SETUP -#line 1169 "scan.l" +#line 1162 "scan.l" ECHO; YY_BREAK case YY_STATE_EOF(SECT3_NOESCAPE): -#line 1170 "scan.l" +#line 1163 "scan.l" { sectnum = 0; #if 1 @@ -10102,15 +10095,15 @@ case YY_STATE_EOF(SECT3_NOESCAPE): case 252: /* rule 252 can match eol */ YY_RULE_SETUP -#line 1182 "scan.l" +#line 1175 "scan.l" format_synerr( _( "bad character: %s" ), yytext ); YY_BREAK case 253: YY_RULE_SETUP -#line 1184 "scan.l" +#line 1177 "scan.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 10100 "scan.c" +#line 10093 "scan.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(CODEBLOCK): case YY_STATE_EOF(PICKUPDEF): @@ -11158,7 +11151,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 1184 "scan.l" +#line 1177 "scan.l" @@ -11276,21 +11269,7 @@ int flexscan(void) { 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, "", result); - piece_append(piece_temp); - piece_esc(yytext, n); - piece_append(""); - } - else { - sprintf(piece_temp, "", result); - piece_append(piece_temp); - } -#endif piece_pack(); return result; } diff --git a/src/scan.l b/src/scan.l index 5fb0ebd..8f7c2f1 100644 --- a/src/scan.l +++ b/src/scan.l @@ -136,10 +136,8 @@ static int real_flexscan(void); } while (0) /* Nick */ -char piece_temp[100]; -char *piece[10000]; -int piece0; -int piece1; +char piece_temp[100], *piece[10000]; +int piece0, piece1; void piece_append(const char *str); void piece_insert(int n, const char *str); -- 2.34.1