]> granicus.if.org Git - re2c/commitdiff
Moved remaining option-sensitive code away from AST.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 6 Mar 2017 08:54:10 +0000 (08:54 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 6 Mar 2017 08:54:10 +0000 (08:54 +0000)
AST must be immutable and independent of options: it may be shared among
different blocks and conditions and reused with different options.

16 files changed:
re2c/bootstrap/src/ast/lex.cc
re2c/src/ast/ast.cc
re2c/src/ast/ast.h
re2c/src/ast/lex.re
re2c/src/ast/scanner.h
re2c/src/re/ast_to_re.cc
re2c/test/error10.c
re2c/test/unicode_blocks.8--encoding-policy(fail).c
re2c/test/unicode_blocks.u--encoding-policy(fail).c
re2c/test/unicode_blocks.x--encoding-policy(fail).c
re2c/test/unicode_group_C.8--encoding-policy(fail).c
re2c/test/unicode_group_C.u--encoding-policy(fail).c
re2c/test/unicode_group_C.x--encoding-policy(fail).c
re2c/test/unicode_group_Cs.8--encoding-policy(fail).c
re2c/test/unicode_group_Cs.u--encoding-policy(fail).c
re2c/test/unicode_group_Cs.x--encoding-policy(fail).c

index 7419224999cc12e6e1f975a484b2575b3794b450..d14053d8df69226bcb99863f46e129b0a29e5d0e 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.16 on Sun Mar  5 11:49:42 2017 */
+/* Generated by re2c 0.16 on Mon Mar  6 08:43:45 2017 */
 #line 1 "../src/ast/lex.re"
 #include "src/util/c99_stdint.h"
 #include <stddef.h>
@@ -981,7 +981,7 @@ start:
 yy159:
        ++YYCURSOR;
 yy160:
-#line 378 "../src/ast/lex.re"
+#line 375 "../src/ast/lex.re"
        {
                                        fatalf("unexpected character: '%c'", *tok);
                                        goto scan;
@@ -994,7 +994,7 @@ yy161:
        if (yybm[0+yych] & 16) {
                goto yy161;
        }
-#line 362 "../src/ast/lex.re"
+#line 359 "../src/ast/lex.re"
        {
                                        goto scan;
                                }
@@ -1009,7 +1009,7 @@ yy164:
                if (yych == '#') goto yy190;
        }
 yy165:
-#line 371 "../src/ast/lex.re"
+#line 368 "../src/ast/lex.re"
        {
                                        if (cur == eof) return 0;
                                        pos = cur;
@@ -1030,7 +1030,7 @@ yy168:
 yy169:
        ++YYCURSOR;
 #line 259 "../src/ast/lex.re"
-       { yylval.regexp = lex_str('"',  opts->bCaseInsensitive ||  opts->bCaseInverted); return TOKEN_REGEXP; }
+       { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; }
 #line 1035 "src/ast/lex.cc"
 yy171:
        yych = (YYCTYPE)*++YYCURSOR;
@@ -1039,7 +1039,7 @@ yy171:
 yy172:
        ++YYCURSOR;
 #line 258 "../src/ast/lex.re"
-       { yylval.regexp = lex_str('\'', opts->bCaseInsensitive || !opts->bCaseInverted); return TOKEN_REGEXP; }
+       { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; }
 #line 1044 "src/ast/lex.cc"
 yy174:
        yych = (YYCTYPE)*++YYCURSOR;
@@ -1047,7 +1047,7 @@ yy174:
        goto yy168;
 yy175:
        ++YYCURSOR;
-#line 357 "../src/ast/lex.re"
+#line 354 "../src/ast/lex.re"
        {
                                        yylval.regexp = ast_dot(cline, get_column());
                                        return TOKEN_REGEXP;
@@ -1209,21 +1209,18 @@ yy198:
                                                yylval.str = new std::string (tok, tok_len());
                                                return TOKEN_ID;
                                        } else {
-                                               const AST *r = NULL;
-                                               const bool casing = opts->bCaseInsensitive || opts->bCaseInverted;
+                                               std::vector<ASTChar> *str = new std::vector<ASTChar>;
                                                for (char *s = tok; s < cur; ++s) {
                                                        const uint32_t
-                                                               c = static_cast<uint8_t>(*s),
-                                                               column = static_cast<uint32_t>(s - pos);
-                                                       r = ast_cat(r, casing
-                                                               ? ast_ichar(cline, column, c)
-                                                               : ast_schar(cline, column, c));
+                                                               chr = static_cast<uint8_t>(*s),
+                                                               col = static_cast<uint32_t>(s - ptr);
+                                                       str->push_back(ASTChar(chr, col));
                                                }
-                                               yylval.regexp = r ? r : ast_nil(cline, get_column());
+                                               yylval.regexp = ast_str(cline, get_column(), str, false);
                                                return TOKEN_REGEXP;
                                        }
                                }
-#line 1227 "src/ast/lex.cc"
+#line 1224 "src/ast/lex.cc"
 yy200:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -1248,7 +1245,7 @@ yy202:
                                        yylval.str = new std::string (tok, tok_len ());
                                        return TOKEN_ID;
                                }
-#line 1252 "src/ast/lex.cc"
+#line 1249 "src/ast/lex.cc"
 yy204:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '>') goto yy221;
@@ -1259,7 +1256,7 @@ yy204:
                                        code_line = cline;
                                        goto code;
                                }
-#line 1263 "src/ast/lex.cc"
+#line 1260 "src/ast/lex.cc"
 yy206:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -1286,12 +1283,12 @@ yy208:
                yylval.regexp = ast_tag(cline, get_column(), name);
                return TOKEN_REGEXP;
        }
-#line 1290 "src/ast/lex.cc"
+#line 1287 "src/ast/lex.cc"
 yy209:
        ++YYCURSOR;
 #line 261 "../src/ast/lex.re"
        { yylval.regexp = lex_cls(true);  return TOKEN_REGEXP; }
-#line 1295 "src/ast/lex.cc"
+#line 1292 "src/ast/lex.cc"
 yy211:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '2') goto yy223;
@@ -1303,7 +1300,7 @@ yy213:
        {
                                        fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers");
                                }
-#line 1307 "src/ast/lex.cc"
+#line 1304 "src/ast/lex.cc"
 yy214:
        ++YYCURSOR;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
@@ -1369,7 +1366,7 @@ yy219:
                                                return TOKEN_ID;
                                        }
                                }
-#line 1373 "src/ast/lex.cc"
+#line 1370 "src/ast/lex.cc"
 yy221:
        ++YYCURSOR;
        YYCURSOR -= 2;
@@ -1377,7 +1374,7 @@ yy221:
        {
                                        return *tok;
                                }
-#line 1381 "src/ast/lex.cc"
+#line 1378 "src/ast/lex.cc"
 yy223:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == 'c') goto yy230;
@@ -1400,7 +1397,7 @@ yy225:
                                        yylval.bounds.max = yylval.bounds.min;
                                        return TOKEN_CLOSESIZE;
                                }
-#line 1404 "src/ast/lex.cc"
+#line 1401 "src/ast/lex.cc"
 yy227:
        ++YYCURSOR;
 #line 309 "../src/ast/lex.re"
@@ -1411,7 +1408,7 @@ yy227:
                                        yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
                                        return TOKEN_ID;
                                }
-#line 1415 "src/ast/lex.cc"
+#line 1412 "src/ast/lex.cc"
 yy229:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == 'n') goto yy235;
@@ -1439,7 +1436,7 @@ yy233:
                                        yylval.bounds.max = std::numeric_limits<uint32_t>::max();
                                        return TOKEN_CLOSESIZE;
                                }
-#line 1443 "src/ast/lex.cc"
+#line 1440 "src/ast/lex.cc"
 yy235:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == 'e') goto yy240;
@@ -1448,7 +1445,7 @@ yy236:
        ++YYCURSOR;
 #line 317 "../src/ast/lex.re"
        { lex_conf (); return TOKEN_CONF; }
-#line 1452 "src/ast/lex.cc"
+#line 1449 "src/ast/lex.cc"
 yy238:
        ++YYCURSOR;
 #line 283 "../src/ast/lex.re"
@@ -1464,7 +1461,7 @@ yy238:
                                        }
                                        return TOKEN_CLOSESIZE;
                                }
-#line 1468 "src/ast/lex.cc"
+#line 1465 "src/ast/lex.cc"
 yy240:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= '0') goto yy242;
@@ -1520,12 +1517,12 @@ yy245:
 yy247:
        ++YYCURSOR;
        YYCURSOR = YYCTXMARKER;
-#line 366 "../src/ast/lex.re"
+#line 363 "../src/ast/lex.re"
        {
                                        set_sourceline ();
                                        goto scan;
                                }
-#line 1529 "src/ast/lex.cc"
+#line 1526 "src/ast/lex.cc"
 yy249:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '\n') goto yy247;
@@ -1550,12 +1547,12 @@ yy253:
        if (yych == '\n') goto yy189;
        goto yy250;
 }
-#line 382 "../src/ast/lex.re"
+#line 379 "../src/ast/lex.re"
 
 
 flex_name:
 
-#line 1559 "src/ast/lex.cc"
+#line 1556 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
@@ -1564,32 +1561,32 @@ flex_name:
        if (yych == '\r') goto yy260;
        ++YYCURSOR;
 yy257:
-#line 393 "../src/ast/lex.re"
+#line 390 "../src/ast/lex.re"
        {
                YYCURSOR = tok;
                goto start;
        }
-#line 1573 "src/ast/lex.cc"
+#line 1570 "src/ast/lex.cc"
 yy258:
        ++YYCURSOR;
-#line 387 "../src/ast/lex.re"
+#line 384 "../src/ast/lex.re"
        {
                YYCURSOR = tok;
                lexer_state = LEX_NORMAL;
                return TOKEN_FID_END;
        }
-#line 1582 "src/ast/lex.cc"
+#line 1579 "src/ast/lex.cc"
 yy260:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '\n') goto yy258;
        goto yy257;
 }
-#line 397 "../src/ast/lex.re"
+#line 394 "../src/ast/lex.re"
 
 
 code:
 
-#line 1593 "src/ast/lex.cc"
+#line 1590 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
@@ -1650,7 +1647,7 @@ code:
        }
 yy263:
        ++YYCURSOR;
-#line 460 "../src/ast/lex.re"
+#line 457 "../src/ast/lex.re"
        {
                                        if (cur == eof)
                                        {
@@ -1662,15 +1659,15 @@ yy263:
                                        }
                                        goto code;
                                }
-#line 1666 "src/ast/lex.cc"
+#line 1663 "src/ast/lex.cc"
 yy265:
        ++YYCURSOR;
 yy266:
-#line 474 "../src/ast/lex.re"
+#line 471 "../src/ast/lex.re"
        {
                                        goto code;
                                }
-#line 1674 "src/ast/lex.cc"
+#line 1671 "src/ast/lex.cc"
 yy267:
        yyaccept = 0;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -1689,7 +1686,7 @@ yy267:
                }
        }
 yy268:
-#line 441 "../src/ast/lex.re"
+#line 438 "../src/ast/lex.re"
        {
                                        if (depth == 0)
                                        {
@@ -1709,7 +1706,7 @@ yy268:
                                        cline++;
                                        goto code;
                                }
-#line 1713 "src/ast/lex.cc"
+#line 1710 "src/ast/lex.cc"
 yy269:
        yyaccept = 1;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -1722,7 +1719,7 @@ yy270:
        goto yy287;
 yy271:
        ++YYCURSOR;
-#line 413 "../src/ast/lex.re"
+#line 410 "../src/ast/lex.re"
        {
                                        if (depth == 0)
                                        {
@@ -1734,10 +1731,10 @@ yy271:
                                        }
                                        goto code;
                                }
-#line 1738 "src/ast/lex.cc"
+#line 1735 "src/ast/lex.cc"
 yy273:
        ++YYCURSOR;
-#line 401 "../src/ast/lex.re"
+#line 398 "../src/ast/lex.re"
        {
                                        if (depth == 0)
                                        {
@@ -1750,7 +1747,7 @@ yy273:
                                        }
                                        goto code;
                                }
-#line 1754 "src/ast/lex.cc"
+#line 1751 "src/ast/lex.cc"
 yy275:
        yyaccept = 2;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -1762,7 +1759,7 @@ yy275:
        }
 yy276:
        YYCURSOR -= 1;
-#line 428 "../src/ast/lex.re"
+#line 425 "../src/ast/lex.re"
        {
                                        if (depth == 0)
                                        {
@@ -1776,7 +1773,7 @@ yy276:
                                        cline++;
                                        goto code;
                                }
-#line 1780 "src/ast/lex.cc"
+#line 1777 "src/ast/lex.cc"
 yy277:
        ++YYCURSOR;
        goto yy276;
@@ -1811,11 +1808,11 @@ yy282:
        if (yych >= '#') goto yy285;
 yy283:
        ++YYCURSOR;
-#line 471 "../src/ast/lex.re"
+#line 468 "../src/ast/lex.re"
        {
                                        goto code;
                                }
-#line 1819 "src/ast/lex.cc"
+#line 1816 "src/ast/lex.cc"
 yy285:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -1905,12 +1902,12 @@ yy299:
 yy301:
        ++YYCURSOR;
        YYCURSOR = YYCTXMARKER;
-#line 424 "../src/ast/lex.re"
+#line 421 "../src/ast/lex.re"
        {
                                        set_sourceline ();
                                        goto code;
                                }
-#line 1914 "src/ast/lex.cc"
+#line 1911 "src/ast/lex.cc"
 yy303:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '\n') goto yy301;
@@ -1939,12 +1936,12 @@ yy307:
        if (yych == '\n') goto yy280;
        goto yy304;
 }
-#line 477 "../src/ast/lex.re"
+#line 474 "../src/ast/lex.re"
 
 
 comment:
 
-#line 1948 "src/ast/lex.cc"
+#line 1945 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        static const unsigned char yybm[] = {
@@ -1991,7 +1988,7 @@ comment:
        }
        ++YYCURSOR;
 yy311:
-#line 509 "../src/ast/lex.re"
+#line 506 "../src/ast/lex.re"
        {
                                        if (cur == eof)
                                        {
@@ -1999,7 +1996,7 @@ yy311:
                                        }
                                        goto comment;
                                }
-#line 2003 "src/ast/lex.cc"
+#line 2000 "src/ast/lex.cc"
 yy312:
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
        if (yybm[0+yych] & 32) {
@@ -2007,7 +2004,7 @@ yy312:
        }
        if (yych == '#') goto yy319;
 yy313:
-#line 500 "../src/ast/lex.re"
+#line 497 "../src/ast/lex.re"
        {
                                        if (cur == eof)
                                        {
@@ -2017,7 +2014,7 @@ yy313:
                                        cline++;
                                        goto comment;
                                }
-#line 2021 "src/ast/lex.cc"
+#line 2018 "src/ast/lex.cc"
 yy314:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '/') goto yy321;
@@ -2051,7 +2048,7 @@ yy319:
        }
 yy321:
        ++YYCURSOR;
-#line 481 "../src/ast/lex.re"
+#line 478 "../src/ast/lex.re"
        {
                                        if (--depth == 0)
                                        {
@@ -2062,16 +2059,16 @@ yy321:
                                                goto comment;
                                        }
                                }
-#line 2066 "src/ast/lex.cc"
+#line 2063 "src/ast/lex.cc"
 yy323:
        ++YYCURSOR;
-#line 491 "../src/ast/lex.re"
+#line 488 "../src/ast/lex.re"
        {
                                        ++depth;
                                        fatal("ambiguous /* found");
                                        goto comment;
                                }
-#line 2075 "src/ast/lex.cc"
+#line 2072 "src/ast/lex.cc"
 yy325:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych != 'i') goto yy318;
@@ -2128,12 +2125,12 @@ yy333:
 yy335:
        ++YYCURSOR;
        YYCURSOR = YYCTXMARKER;
-#line 496 "../src/ast/lex.re"
+#line 493 "../src/ast/lex.re"
        {
                                        set_sourceline ();
                                        goto comment;
                                }
-#line 2137 "src/ast/lex.cc"
+#line 2134 "src/ast/lex.cc"
 yy337:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych == '\n') goto yy335;
@@ -2158,28 +2155,28 @@ yy341:
        if (yych == '\n') goto yy318;
        goto yy338;
 }
-#line 516 "../src/ast/lex.re"
+#line 513 "../src/ast/lex.re"
 
 
 nextLine:
 
-#line 2167 "src/ast/lex.cc"
+#line 2164 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = (YYCTYPE)*YYCURSOR;
        if (yych == '\n') goto yy346;
        ++YYCURSOR;
-#line 527 "../src/ast/lex.re"
+#line 524 "../src/ast/lex.re"
        {  if(cur == eof) {
                   return 0;
                }
                goto nextLine;
             }
-#line 2180 "src/ast/lex.cc"
+#line 2177 "src/ast/lex.cc"
 yy346:
        ++YYCURSOR;
-#line 520 "../src/ast/lex.re"
+#line 517 "../src/ast/lex.re"
        { if(cur == eof) {
                   return 0;
                }
@@ -2187,9 +2184,9 @@ yy346:
                cline++;
                goto scan;
             }
-#line 2191 "src/ast/lex.cc"
+#line 2188 "src/ast/lex.cc"
 }
-#line 532 "../src/ast/lex.re"
+#line 529 "../src/ast/lex.re"
 
 }
 
@@ -2209,40 +2206,41 @@ static void escape (std::string & dest, const std::string & src)
 
 const AST *Scanner::lex_cls(bool neg)
 {
-       const uint32_t column = get_column();
-       Range *r = NULL, *s;
-       uint32_t u, l;
+       std::vector<ASTRange> *cls = new std::vector<ASTRange>;
+       uint32_t u, l, c, c0 = get_column();
 fst:
+       tok = cur;
+       c = get_column();
        
-#line 2218 "src/ast/lex.cc"
+#line 2216 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = (YYCTYPE)*YYCURSOR;
        if (yych == ']') goto yy351;
-#line 557 "../src/ast/lex.re"
+#line 555 "../src/ast/lex.re"
        { l = lex_cls_chr(); goto snd; }
-#line 2226 "src/ast/lex.cc"
+#line 2224 "src/ast/lex.cc"
 yy351:
        ++YYCURSOR;
-#line 556 "../src/ast/lex.re"
-       { goto end; }
-#line 2231 "src/ast/lex.cc"
+#line 554 "../src/ast/lex.re"
+       { return ast_cls(cline, c0, cls, neg); }
+#line 2229 "src/ast/lex.cc"
 }
-#line 558 "../src/ast/lex.re"
+#line 556 "../src/ast/lex.re"
 
 snd:
        
-#line 2237 "src/ast/lex.cc"
+#line 2235 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
        yych = (YYCTYPE)*(YYMARKER = YYCURSOR);
        if (yych == '-') goto yy356;
 yy355:
-#line 561 "../src/ast/lex.re"
+#line 559 "../src/ast/lex.re"
        { u = l; goto add; }
-#line 2246 "src/ast/lex.cc"
+#line 2244 "src/ast/lex.cc"
 yy356:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych != ']') goto yy358;
@@ -2251,7 +2249,7 @@ yy356:
 yy358:
        ++YYCURSOR;
        YYCURSOR -= 1;
-#line 562 "../src/ast/lex.re"
+#line 560 "../src/ast/lex.re"
        {
                        u = lex_cls_chr();
                        if (l > u) {
@@ -2260,28 +2258,20 @@ yy358:
                        }
                        goto add;
                }
-#line 2264 "src/ast/lex.cc"
+#line 2262 "src/ast/lex.cc"
 }
-#line 570 "../src/ast/lex.re"
+#line 568 "../src/ast/lex.re"
 
 add:
-       if (!(s = opts->encoding.encodeRange(l, u))) {
-               fatalf ("Bad code point range: '0x%X - 0x%X'", l, u);
-       }
-       r = Range::add(r, s);
+       cls->push_back(ASTRange(l, u, c));
        goto fst;
-end:
-       if (neg) {
-               r = Range::sub(opts->encoding.fullRange(), r);
-       }
-       return ast_class(cline, column, r);
 }
 
 uint32_t Scanner::lex_cls_chr()
 {
        tok = cur;
        
-#line 2285 "src/ast/lex.cc"
+#line 2275 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
@@ -2290,14 +2280,14 @@ uint32_t Scanner::lex_cls_chr()
        if (yych == '\n') goto yy364;
        if (yych == '\\') goto yy366;
        ++YYCURSOR;
-#line 593 "../src/ast/lex.re"
+#line 583 "../src/ast/lex.re"
        { return static_cast<uint8_t>(tok[0]); }
-#line 2296 "src/ast/lex.cc"
+#line 2286 "src/ast/lex.cc"
 yy364:
        ++YYCURSOR;
-#line 588 "../src/ast/lex.re"
+#line 578 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error"); }
-#line 2301 "src/ast/lex.cc"
+#line 2291 "src/ast/lex.cc"
 yy366:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= '`') {
@@ -2346,31 +2336,31 @@ yy366:
                        }
                }
        }
-#line 591 "../src/ast/lex.re"
+#line 581 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error in escape sequence"); }
-#line 2352 "src/ast/lex.cc"
+#line 2342 "src/ast/lex.cc"
 yy368:
        ++YYCURSOR;
-#line 606 "../src/ast/lex.re"
+#line 596 "../src/ast/lex.re"
        {
                        warn.useless_escape(cline, get_column(), tok[1]);
                        return static_cast<uint8_t>(tok[1]);
                }
-#line 2360 "src/ast/lex.cc"
+#line 2350 "src/ast/lex.cc"
 yy370:
        ++YYCURSOR;
-#line 604 "../src/ast/lex.re"
+#line 594 "../src/ast/lex.re"
        { return static_cast<uint8_t>('-'); }
-#line 2365 "src/ast/lex.cc"
+#line 2355 "src/ast/lex.cc"
 yy372:
        yyaccept = 0;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
        if (yych <= '/') goto yy373;
        if (yych <= '7') goto yy397;
 yy373:
-#line 590 "../src/ast/lex.re"
+#line 580 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error in octal escape sequence"); }
-#line 2374 "src/ast/lex.cc"
+#line 2364 "src/ast/lex.cc"
 yy374:
        ++YYCURSOR;
        goto yy373;
@@ -2386,9 +2376,9 @@ yy375:
                if (yych <= 'f') goto yy399;
        }
 yy376:
-#line 589 "../src/ast/lex.re"
+#line 579 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error in hexadecimal escape sequence"); }
-#line 2392 "src/ast/lex.cc"
+#line 2382 "src/ast/lex.cc"
 yy377:
        yyaccept = 1;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -2404,49 +2394,49 @@ yy377:
        }
 yy378:
        ++YYCURSOR;
-#line 603 "../src/ast/lex.re"
+#line 593 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\\'); }
-#line 2410 "src/ast/lex.cc"
+#line 2400 "src/ast/lex.cc"
 yy380:
        ++YYCURSOR;
-#line 605 "../src/ast/lex.re"
+#line 595 "../src/ast/lex.re"
        { return static_cast<uint8_t>(']'); }
-#line 2415 "src/ast/lex.cc"
+#line 2405 "src/ast/lex.cc"
 yy382:
        ++YYCURSOR;
-#line 596 "../src/ast/lex.re"
+#line 586 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\a'); }
-#line 2420 "src/ast/lex.cc"
+#line 2410 "src/ast/lex.cc"
 yy384:
        ++YYCURSOR;
-#line 597 "../src/ast/lex.re"
+#line 587 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\b'); }
-#line 2425 "src/ast/lex.cc"
+#line 2415 "src/ast/lex.cc"
 yy386:
        ++YYCURSOR;
-#line 598 "../src/ast/lex.re"
+#line 588 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\f'); }
-#line 2430 "src/ast/lex.cc"
+#line 2420 "src/ast/lex.cc"
 yy388:
        ++YYCURSOR;
-#line 599 "../src/ast/lex.re"
+#line 589 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\n'); }
-#line 2435 "src/ast/lex.cc"
+#line 2425 "src/ast/lex.cc"
 yy390:
        ++YYCURSOR;
-#line 600 "../src/ast/lex.re"
+#line 590 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\r'); }
-#line 2440 "src/ast/lex.cc"
+#line 2430 "src/ast/lex.cc"
 yy392:
        ++YYCURSOR;
-#line 601 "../src/ast/lex.re"
+#line 591 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\t'); }
-#line 2445 "src/ast/lex.cc"
+#line 2435 "src/ast/lex.cc"
 yy394:
        ++YYCURSOR;
-#line 602 "../src/ast/lex.re"
+#line 592 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\v'); }
-#line 2450 "src/ast/lex.cc"
+#line 2440 "src/ast/lex.cc"
 yy396:
        yyaccept = 1;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -2509,9 +2499,9 @@ yy401:
        }
 yy402:
        ++YYCURSOR;
-#line 595 "../src/ast/lex.re"
+#line 585 "../src/ast/lex.re"
        { return unesc_oct(tok, cur); }
-#line 2515 "src/ast/lex.cc"
+#line 2505 "src/ast/lex.cc"
 yy404:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= '@') {
@@ -2538,9 +2528,9 @@ yy405:
        }
 yy406:
        ++YYCURSOR;
-#line 594 "../src/ast/lex.re"
+#line 584 "../src/ast/lex.re"
        { return unesc_hex(tok, cur); }
-#line 2544 "src/ast/lex.cc"
+#line 2534 "src/ast/lex.cc"
 yy408:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= '@') {
@@ -2564,7 +2554,7 @@ yy409:
                goto yy398;
        }
 }
-#line 610 "../src/ast/lex.re"
+#line 600 "../src/ast/lex.re"
 
 }
 
@@ -2573,7 +2563,7 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end)
        end = false;
        tok = cur;
        
-#line 2577 "src/ast/lex.cc"
+#line 2567 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        unsigned int yyaccept = 0;
@@ -2582,17 +2572,17 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end)
        if (yych == '\n') goto yy414;
        if (yych == '\\') goto yy416;
        ++YYCURSOR;
-#line 623 "../src/ast/lex.re"
+#line 613 "../src/ast/lex.re"
        {
                        end = tok[0] == quote;
                        return static_cast<uint8_t>(tok[0]);
                }
-#line 2591 "src/ast/lex.cc"
+#line 2581 "src/ast/lex.cc"
 yy414:
        ++YYCURSOR;
-#line 618 "../src/ast/lex.re"
+#line 608 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error"); }
-#line 2596 "src/ast/lex.cc"
+#line 2586 "src/ast/lex.cc"
 yy416:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= 'a') {
@@ -2638,28 +2628,28 @@ yy416:
                        }
                }
        }
-#line 621 "../src/ast/lex.re"
+#line 611 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error in escape sequence"); }
-#line 2644 "src/ast/lex.cc"
+#line 2634 "src/ast/lex.cc"
 yy418:
        ++YYCURSOR;
-#line 637 "../src/ast/lex.re"
+#line 627 "../src/ast/lex.re"
        {
                        if (tok[1] != quote) {
                                warn.useless_escape(cline, get_column(), tok[1]);
                        }
                        return static_cast<uint8_t>(tok[1]);
                }
-#line 2654 "src/ast/lex.cc"
+#line 2644 "src/ast/lex.cc"
 yy420:
        yyaccept = 0;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
        if (yych <= '/') goto yy421;
        if (yych <= '7') goto yy443;
 yy421:
-#line 620 "../src/ast/lex.re"
+#line 610 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error in octal escape sequence"); }
-#line 2663 "src/ast/lex.cc"
+#line 2653 "src/ast/lex.cc"
 yy422:
        ++YYCURSOR;
        goto yy421;
@@ -2675,9 +2665,9 @@ yy423:
                if (yych <= 'f') goto yy445;
        }
 yy424:
-#line 619 "../src/ast/lex.re"
+#line 609 "../src/ast/lex.re"
        { fatal (get_column() - tchar, "syntax error in hexadecimal escape sequence"); }
-#line 2681 "src/ast/lex.cc"
+#line 2671 "src/ast/lex.cc"
 yy425:
        yyaccept = 1;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -2693,44 +2683,44 @@ yy425:
        }
 yy426:
        ++YYCURSOR;
-#line 636 "../src/ast/lex.re"
+#line 626 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\\'); }
-#line 2699 "src/ast/lex.cc"
+#line 2689 "src/ast/lex.cc"
 yy428:
        ++YYCURSOR;
-#line 629 "../src/ast/lex.re"
+#line 619 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\a'); }
-#line 2704 "src/ast/lex.cc"
+#line 2694 "src/ast/lex.cc"
 yy430:
        ++YYCURSOR;
-#line 630 "../src/ast/lex.re"
+#line 620 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\b'); }
-#line 2709 "src/ast/lex.cc"
+#line 2699 "src/ast/lex.cc"
 yy432:
        ++YYCURSOR;
-#line 631 "../src/ast/lex.re"
+#line 621 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\f'); }
-#line 2714 "src/ast/lex.cc"
+#line 2704 "src/ast/lex.cc"
 yy434:
        ++YYCURSOR;
-#line 632 "../src/ast/lex.re"
+#line 622 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\n'); }
-#line 2719 "src/ast/lex.cc"
+#line 2709 "src/ast/lex.cc"
 yy436:
        ++YYCURSOR;
-#line 633 "../src/ast/lex.re"
+#line 623 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\r'); }
-#line 2724 "src/ast/lex.cc"
+#line 2714 "src/ast/lex.cc"
 yy438:
        ++YYCURSOR;
-#line 634 "../src/ast/lex.re"
+#line 624 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\t'); }
-#line 2729 "src/ast/lex.cc"
+#line 2719 "src/ast/lex.cc"
 yy440:
        ++YYCURSOR;
-#line 635 "../src/ast/lex.re"
+#line 625 "../src/ast/lex.re"
        { return static_cast<uint8_t>('\v'); }
-#line 2734 "src/ast/lex.cc"
+#line 2724 "src/ast/lex.cc"
 yy442:
        yyaccept = 1;
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
@@ -2793,9 +2783,9 @@ yy447:
        }
 yy448:
        ++YYCURSOR;
-#line 628 "../src/ast/lex.re"
+#line 618 "../src/ast/lex.re"
        { return unesc_oct(tok, cur); }
-#line 2799 "src/ast/lex.cc"
+#line 2789 "src/ast/lex.cc"
 yy450:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= '@') {
@@ -2822,9 +2812,9 @@ yy451:
        }
 yy452:
        ++YYCURSOR;
-#line 627 "../src/ast/lex.re"
+#line 617 "../src/ast/lex.re"
        { return unesc_hex(tok, cur); }
-#line 2828 "src/ast/lex.cc"
+#line 2818 "src/ast/lex.cc"
 yy454:
        yych = (YYCTYPE)*++YYCURSOR;
        if (yych <= '@') {
@@ -2848,21 +2838,18 @@ yy455:
                goto yy444;
        }
 }
-#line 643 "../src/ast/lex.re"
+#line 633 "../src/ast/lex.re"
 
 }
 
-const AST *Scanner::lex_str(char quote, bool casing)
+const AST *Scanner::lex_str(char quote)
 {
-       const AST *r = NULL;
+       const uint32_t column = get_column();
+       std::vector<ASTChar> *str = new std::vector<ASTChar>;
        for (bool end;;) {
                const uint32_t c = lex_str_chr(quote, end);
-               if (end) {
-                       return r ? r : ast_nil(cline, get_column());
-               }
-               r = ast_cat(r, casing
-                       ? ast_ichar(cline, get_column(), c)
-                       : ast_schar(cline, get_column(), c));
+               if (end) return ast_str(cline, column, str, quote == '\'');
+               str->push_back(ASTChar(c, get_column()));
        }
 }
 
@@ -2871,7 +2858,7 @@ void Scanner::set_sourceline ()
 sourceline:
        tok = cur;
 
-#line 2875 "src/ast/lex.cc"
+#line 2862 "src/ast/lex.cc"
 {
        YYCTYPE yych;
        static const unsigned char yybm[] = {
@@ -2920,14 +2907,14 @@ sourceline:
 yy458:
        ++YYCURSOR;
 yy459:
-#line 688 "../src/ast/lex.re"
+#line 675 "../src/ast/lex.re"
        {
                                        goto sourceline;
                                }
-#line 2928 "src/ast/lex.cc"
+#line 2915 "src/ast/lex.cc"
 yy460:
        ++YYCURSOR;
-#line 676 "../src/ast/lex.re"
+#line 663 "../src/ast/lex.re"
        {
                                        if (cur == eof)
                                        {
@@ -2940,7 +2927,7 @@ yy460:
                                        tok = cur;
                                        return; 
                                }
-#line 2944 "src/ast/lex.cc"
+#line 2931 "src/ast/lex.cc"
 yy462:
        yych = (YYCTYPE)*(YYMARKER = ++YYCURSOR);
        if (yych == '\n') goto yy459;
@@ -2952,7 +2939,7 @@ yy463:
        if (yybm[0+yych] & 64) {
                goto yy463;
        }
-#line 665 "../src/ast/lex.re"
+#line 652 "../src/ast/lex.re"
        {
                                        if (!s_to_u32_unsafe (tok, cur, cline))
                                        {
@@ -2960,7 +2947,7 @@ yy463:
                                        }
                                        goto sourceline; 
                                }
-#line 2964 "src/ast/lex.cc"
+#line 2951 "src/ast/lex.cc"
 yy466:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -2977,12 +2964,12 @@ yy468:
        goto yy459;
 yy469:
        ++YYCURSOR;
-#line 672 "../src/ast/lex.re"
+#line 659 "../src/ast/lex.re"
        {
                                        escape (in.file_name, std::string (tok + 1, tok_len () - 2)); // -2 to omit quotes
                                        goto sourceline; 
                                }
-#line 2986 "src/ast/lex.cc"
+#line 2973 "src/ast/lex.cc"
 yy471:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
@@ -2990,7 +2977,7 @@ yy471:
        if (yych == '\n') goto yy468;
        goto yy466;
 }
-#line 691 "../src/ast/lex.re"
+#line 678 "../src/ast/lex.re"
 
 }
 
index bf78d2b3b8550962003a50826ea5e9bc512a2c58..9727d7aa0be0c87ef29661bc4d1638e8dfa4b681 100644 (file)
@@ -22,6 +22,10 @@ AST::~AST()
                delete tag;
        } else if (type == REF) {
                delete ref.name;
+       } else if (type == STR) {
+               delete str.chars;
+       } else if (type == CLS) {
+               delete cls.ranges;
        }
 }
 
@@ -30,24 +34,19 @@ const AST *ast_nil(uint32_t l, uint32_t c)
        return new AST(l, c, AST::NIL);
 }
 
-const AST *ast_schar(uint32_t l, uint32_t c, uint32_t x)
+const AST *ast_str(uint32_t l, uint32_t c, std::vector<ASTChar> *chars, bool icase)
 {
-       AST *ast = new AST(l, c, AST::SCHAR);
-       ast->schar = x;
+       AST *ast = new AST(l, c, AST::STR);
+       ast->str.chars = chars;
+       ast->str.icase = icase;
        return ast;
 }
 
-const AST *ast_ichar(uint32_t l, uint32_t c, uint32_t x)
+const AST *ast_cls(uint32_t l, uint32_t c, std::vector<ASTRange> *ranges, bool negated)
 {
-       AST *ast = new AST(l, c, AST::ICHAR);
-       ast->ichar = x;
-       return ast;
-}
-
-const AST *ast_class(uint32_t l, uint32_t c, const Range *r)
-{
-       AST *ast = new AST(l, c, AST::CLASS);
-       ast->cls = r;
+       AST *ast = new AST(l, c, AST::CLS);
+       ast->cls.ranges = ranges;
+       ast->cls.negated = negated;
        return ast;
 }
 
@@ -125,9 +124,8 @@ bool ast_need_wrap(const AST *ast)
        switch (ast->type) {
                case AST::ITER:
                case AST::NIL:
-               case AST::SCHAR:
-               case AST::ICHAR:
-               case AST::CLASS:
+               case AST::STR:
+               case AST::CLS:
                case AST::DOT:
                case AST::DEFAULT:
                case AST::TAG:
index e63d6bcba28d6c4933196a10972344c1a16e7268..e5bd76890e6a9430e5dff1fb8e0d10fa6cdf42ff 100644 (file)
 namespace re2c
 {
 
+struct ASTChar
+{
+       uint32_t chr;
+       uint32_t column;
+       ASTChar(uint32_t x, uint32_t c)
+               : chr(x), column(c) {}
+};
+
+struct ASTRange
+{
+       uint32_t lower;
+       uint32_t upper;
+       uint32_t column;
+       ASTRange(uint32_t l, uint32_t u, uint32_t c)
+               : lower(l), upper(u), column(c) {}
+};
+
 /* AST must be immutable and independent of options */
 struct AST
 {
@@ -19,13 +36,17 @@ struct AST
        static const uint32_t MANY;
 
        enum type_t
-               { NIL, SCHAR, ICHAR, CLASS, DOT, DEFAULT
-               , ALT, CAT,   ITER,  DIFF,  TAG, CAP
-               , REF } type;
+               { NIL, STR,  CLS,  DOT,  DEFAULT, ALT
+               , CAT, ITER, DIFF, TAG,  CAP,     REF } type;
        union {
-               uint32_t schar;
-               uint32_t ichar;
-               const Range *cls;
+               struct {
+                       const std::vector<ASTChar> *chars;
+                       bool icase;
+               } str;
+               struct {
+                       const std::vector<ASTRange> *ranges;
+                       bool negated;
+               } cls;
                struct {
                        const AST *ast1;
                        const AST *ast2;
@@ -75,9 +96,8 @@ struct ASTBounds
 };
 
 const AST *ast_nil(uint32_t l, uint32_t c);
-const AST *ast_schar(uint32_t l, uint32_t c, uint32_t x);
-const AST *ast_ichar(uint32_t l, uint32_t c, uint32_t x);
-const AST *ast_class(uint32_t l, uint32_t c, const Range *r);
+const AST *ast_str(uint32_t l, uint32_t c, std::vector<ASTChar> *chars, bool icase);
+const AST *ast_cls(uint32_t l, uint32_t c, std::vector<ASTRange> *ranges, bool negated);
 const AST *ast_dot(uint32_t l, uint32_t c);
 const AST *ast_default(uint32_t l, uint32_t c);
 const AST *ast_alt(const AST *r1, const AST *r2);
index 18549bb91af37736d124b9624ca5f85c0d4e3bf5..c1a376466580a20983323fa6fdfcadbba8605dea 100644 (file)
@@ -255,8 +255,8 @@ start:
                                        return 0;
                                }
 
-       "'"  { yylval.regexp = lex_str('\'', opts->bCaseInsensitive || !opts->bCaseInverted); return TOKEN_REGEXP; }
-       "\"" { yylval.regexp = lex_str('"',  opts->bCaseInsensitive ||  opts->bCaseInverted); return TOKEN_REGEXP; }
+       "'"  { yylval.regexp = lex_str('\''); return TOKEN_REGEXP; }
+       "\"" { yylval.regexp = lex_str('"'); return TOKEN_REGEXP; }
        "["  { yylval.regexp = lex_cls(false); return TOKEN_REGEXP; }
        "[^" { yylval.regexp = lex_cls(true);  return TOKEN_REGEXP; }
 
@@ -339,17 +339,14 @@ start:
                                                yylval.str = new std::string (tok, tok_len());
                                                return TOKEN_ID;
                                        } else {
-                                               const AST *r = NULL;
-                                               const bool casing = opts->bCaseInsensitive || opts->bCaseInverted;
+                                               std::vector<ASTChar> *str = new std::vector<ASTChar>;
                                                for (char *s = tok; s < cur; ++s) {
                                                        const uint32_t
-                                                               c = static_cast<uint8_t>(*s),
-                                                               column = static_cast<uint32_t>(s - pos);
-                                                       r = ast_cat(r, casing
-                                                               ? ast_ichar(cline, column, c)
-                                                               : ast_schar(cline, column, c));
+                                                               chr = static_cast<uint8_t>(*s),
+                                                               col = static_cast<uint32_t>(s - ptr);
+                                                       str->push_back(ASTChar(chr, col));
                                                }
-                                               yylval.regexp = r ? r : ast_nil(cline, get_column());
+                                               yylval.regexp = ast_str(cline, get_column(), str, false);
                                                return TOKEN_REGEXP;
                                        }
                                }
@@ -548,12 +545,13 @@ static void escape (std::string & dest, const std::string & src)
 
 const AST *Scanner::lex_cls(bool neg)
 {
-       const uint32_t column = get_column();
-       Range *r = NULL, *s;
-       uint32_t u, l;
+       std::vector<ASTRange> *cls = new std::vector<ASTRange>;
+       uint32_t u, l, c, c0 = get_column();
 fst:
+       tok = cur;
+       c = get_column();
        /*!re2c
-               "]" { goto end; }
+               "]" { return ast_cls(cline, c0, cls, neg); }
                ""  { l = lex_cls_chr(); goto snd; }
        */
 snd:
@@ -569,16 +567,8 @@ snd:
                }
        */
 add:
-       if (!(s = opts->encoding.encodeRange(l, u))) {
-               fatalf ("Bad code point range: '0x%X - 0x%X'", l, u);
-       }
-       r = Range::add(r, s);
+       cls->push_back(ASTRange(l, u, c));
        goto fst;
-end:
-       if (neg) {
-               r = Range::sub(opts->encoding.fullRange(), r);
-       }
-       return ast_class(cline, column, r);
 }
 
 uint32_t Scanner::lex_cls_chr()
@@ -643,17 +633,14 @@ uint32_t Scanner::lex_str_chr(char quote, bool &end)
        */
 }
 
-const AST *Scanner::lex_str(char quote, bool casing)
+const AST *Scanner::lex_str(char quote)
 {
-       const AST *r = NULL;
+       const uint32_t column = get_column();
+       std::vector<ASTChar> *str = new std::vector<ASTChar>;
        for (bool end;;) {
                const uint32_t c = lex_str_chr(quote, end);
-               if (end) {
-                       return r ? r : ast_nil(cline, get_column());
-               }
-               r = ast_cat(r, casing
-                       ? ast_ichar(cline, get_column(), c)
-                       : ast_schar(cline, get_column(), c));
+               if (end) return ast_str(cline, column, str, quote == '\'');
+               str->push_back(ASTChar(c, get_column()));
        }
 }
 
index e34e743ea7756d1585af7246f0c045c0c242aa7d..0630cd2a8ed259801b2287fa5d2033aba870ff55 100644 (file)
@@ -66,7 +66,7 @@ private:
        uint32_t lex_cls_chr();
        uint32_t lex_str_chr(char quote, bool &end);
        const AST *lex_cls(bool neg);
-       const AST *lex_str(char quote, bool casing);
+       const AST *lex_str(char quote);
        void lex_conf ();
        void lex_conf_encoding_policy();
        void lex_conf_input();
index 2044c43f9f86b436091d68c7548b67125bc6b524..2cda9a925be071b8c649e117cded3b573119caf5 100644 (file)
@@ -31,11 +31,60 @@ static RE *ast_to_re(RESpec &spec, const AST *ast, size_t &ncap)
                default: assert(false);
                case AST::NIL:
                        return re_nil(alc);
+               case AST::STR: {
+                       const bool icase = opts->bCaseInsensitive
+                               || (ast->str.icase != opts->bCaseInverted);
+                       RE *x = NULL;
+                       std::vector<ASTChar>::const_iterator
+                               i = ast->str.chars->begin(),
+                               e = ast->str.chars->end();
+                       for (; i != e; ++i) {
+                               x = re_cat(alc, x, icase
+                                       ? re_ichar(alc, ast->line, i->column, i->chr, opts)
+                                       : re_schar(alc, ast->line, i->column, i->chr, opts));
+                       }
+                       return x ? x : re_nil(alc);
+               }
+               case AST::CLS: {
+                       Range *r = NULL;
+                       std::vector<ASTRange>::const_iterator
+                               i = ast->cls.ranges->begin(),
+                               e = ast->cls.ranges->end();
+                       for (; i != e; ++i) {
+                               Range *s = opts->encoding.encodeRange(i->lower, i->upper);
+                               if (!s) fatal_error(ast->line, i->column,
+                                       "bad code point range: '0x%X - 0x%X'", i->lower, i->upper);
+                               r = Range::add(r, s);
+                       }
+                       if (ast->cls.negated) {
+                               r = Range::sub(opts->encoding.fullRange(), r);
+                       }
+                       return re_class(alc, ast->line, ast->column, r, opts, warn);
+               }
+               case AST::DOT: {
+                       uint32_t c = '\n';
+                       if (!opts->encoding.encode(c)) {
+                               fatal_error(ast->line, ast->column, "bad code point: '0x%X'", c);
+                       }
+                       return re_class(alc, ast->line, ast->column,
+                               Range::sub(opts->encoding.fullRange(), Range::sym(c)), opts, warn);
+               }
+               case AST::DEFAULT:
+                       // see note [default regexp]
+                       return re_sym(alc, Range::ran(0, opts->encoding.nCodeUnits()));
                case AST::ALT: {
                        RE *x = ast_to_re(spec, ast->alt.ast1, ncap);
                        RE *y = ast_to_re(spec, ast->alt.ast2, ncap);
                        return re_alt(alc, x, y);
                }
+               case AST::DIFF: {
+                       RE *x = ast_to_re(spec, ast->diff.ast1, ncap);
+                       RE *y = ast_to_re(spec, ast->diff.ast2, ncap);
+                       if (x->type != RE::SYM || y->type != RE::SYM) {
+                               fatal_error(ast->line, ast->column, "can only difference char sets");
+                       }
+                       return re_class(alc, ast->line, ast->column, Range::sub(x->sym, y->sym), opts, warn);
+               }
                case AST::CAT: {
                        RE *x = ast_to_re(spec, ast->cat.ast1, ncap);
                        RE *y = ast_to_re(spec, ast->cat.ast2, ncap);
@@ -102,31 +151,6 @@ static RE *ast_to_re(RESpec &spec, const AST *ast, size_t &ncap)
                        }
                        return y;
                }
-               case AST::SCHAR:
-                       return re_schar(alc, ast->line, ast->column, ast->schar, opts);
-               case AST::ICHAR:
-                       return re_ichar(alc, ast->line, ast->column, ast->ichar, opts);
-               case AST::CLASS:
-                       return re_class(alc, ast->line, ast->column, ast->cls, opts, warn);
-               case AST::DIFF: {
-                       RE *x = ast_to_re(spec, ast->diff.ast1, ncap);
-                       RE *y = ast_to_re(spec, ast->diff.ast2, ncap);
-                       if (x->type != RE::SYM || y->type != RE::SYM) {
-                               fatal_error(ast->line, ast->column, "can only difference char sets");
-                       }
-                       return re_class(alc, ast->line, ast->column, Range::sub(x->sym, y->sym), opts, warn);
-               }
-               case AST::DOT: {
-                       uint32_t c = '\n';
-                       if (!opts->encoding.encode(c)) {
-                               fatal_error(ast->line, ast->column, "bad code point: '0x%X'", c);
-                       }
-                       return re_class(alc, ast->line, ast->column,
-                               Range::sub(opts->encoding.fullRange(), Range::sym(c)), opts, warn);
-               }
-               case AST::DEFAULT:
-                       // see note [default regexp]
-                       return re_sym(alc, Range::ran(0, opts->encoding.nCodeUnits()));
        }
 }
 
index 22627fc71b6cc23df37b24df67334ae5bc3b2556..6c0ae2789f0bfe78b179784c195f9d066f837835 100644 (file)
@@ -1 +1 @@
-re2c: error: line 2, column 1: Bad code point range: '0x900000 - 0x900000'
+re2c: error: line 2, column 1: bad code point range: '0x900000 - 0x900000'
index d275c4c29f9c6f1230c8df9f8e80c93a34303134..a6e6074b0d4f07e953f3c36d0b4f29287116eeec 100644 (file)
@@ -1 +1 @@
-re2c: error: line 322, column 21: Bad code point range: '0xD800 - 0xDB7F'
+re2c: error: line 322, column 21: bad code point range: '0xD800 - 0xDB7F'
index d275c4c29f9c6f1230c8df9f8e80c93a34303134..a6e6074b0d4f07e953f3c36d0b4f29287116eeec 100644 (file)
@@ -1 +1 @@
-re2c: error: line 322, column 21: Bad code point range: '0xD800 - 0xDB7F'
+re2c: error: line 322, column 21: bad code point range: '0xD800 - 0xDB7F'
index d275c4c29f9c6f1230c8df9f8e80c93a34303134..a6e6074b0d4f07e953f3c36d0b4f29287116eeec 100644 (file)
@@ -1 +1 @@
-re2c: error: line 322, column 21: Bad code point range: '0xD800 - 0xDB7F'
+re2c: error: line 322, column 21: bad code point range: '0xD800 - 0xDB7F'
index e2239a1d08443c204c838bcbea2e5a6ca02defe0..26c4a8d08903aa2242917525411dc48928c11282 100644 (file)
@@ -1 +1 @@
-re2c: error: line 11, column 7: Bad code point range: '0xD7FC - 0xF8FF'
+re2c: error: line 11, column 4428: bad code point range: '0xD7FC - 0xF8FF'
index e2239a1d08443c204c838bcbea2e5a6ca02defe0..26c4a8d08903aa2242917525411dc48928c11282 100644 (file)
@@ -1 +1 @@
-re2c: error: line 11, column 7: Bad code point range: '0xD7FC - 0xF8FF'
+re2c: error: line 11, column 4428: bad code point range: '0xD7FC - 0xF8FF'
index e2239a1d08443c204c838bcbea2e5a6ca02defe0..26c4a8d08903aa2242917525411dc48928c11282 100644 (file)
@@ -1 +1 @@
-re2c: error: line 11, column 7: Bad code point range: '0xD7FC - 0xF8FF'
+re2c: error: line 11, column 4428: bad code point range: '0xD7FC - 0xF8FF'
index dd77d193b5f354f71f63c3d5bdb1be89f4d10937..9247e4daaf155b8ed6dabc5ed37a6caabe954c33 100644 (file)
@@ -1 +1 @@
-re2c: error: line 11, column 8: Bad code point range: '0xD800 - 0xDFFF'
+re2c: error: line 11, column 8: bad code point range: '0xD800 - 0xDFFF'
index dd77d193b5f354f71f63c3d5bdb1be89f4d10937..9247e4daaf155b8ed6dabc5ed37a6caabe954c33 100644 (file)
@@ -1 +1 @@
-re2c: error: line 11, column 8: Bad code point range: '0xD800 - 0xDFFF'
+re2c: error: line 11, column 8: bad code point range: '0xD800 - 0xDFFF'
index dd77d193b5f354f71f63c3d5bdb1be89f4d10937..9247e4daaf155b8ed6dabc5ed37a6caabe954c33 100644 (file)
@@ -1 +1 @@
-re2c: error: line 11, column 8: Bad code point range: '0xD800 - 0xDFFF'
+re2c: error: line 11, column 8: bad code point range: '0xD800 - 0xDFFF'