From: helly Date: Sun, 1 Jan 2006 18:29:47 +0000 (+0000) Subject: - Added ability to control indendation string X-Git-Tag: 0.13.6~516 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d2acf84499a7d9d6f818b5b1f71e19f91e8d9010;p=re2c - Added ability to control indendation string --- diff --git a/actions.cc b/actions.cc index 16c624d7..3356dd56 100644 --- a/actions.cc +++ b/actions.cc @@ -695,6 +695,25 @@ uint Scanner::unescape(SubStr &s) const } } +std::string& Scanner::unescape(SubStr & in, std::string & out) const +{ + out.clear(); + + while(in.len) + { + uint c = unescape(in); + + if (c > 0xFF) + { + fatal(in.ofs(), "Illegal character"); + } + + out += static_cast(c); + } + + return out; +} + Range * Scanner::getRange(SubStr &s) const { uint lb = unescape(s), ub, xlb, xub, c; diff --git a/bootstrap/parser.cc b/bootstrap/parser.cc index 8a241d56..17047c7f 100644 --- a/bootstrap/parser.cc +++ b/bootstrap/parser.cc @@ -1204,12 +1204,12 @@ yyreduce: case 6: #line 96 "parser.y" - { in->config((yyvsp[-3].str), (yyvsp[-1].str)); } + { in->config(*(yyvsp[-3].str), *(yyvsp[-1].str)); } break; case 7: #line 98 "parser.y" - { in->config((yyvsp[-3].str), (yyvsp[-1].number)); } + { in->config(*(yyvsp[-3].str), (yyvsp[-1].number)); } break; case 8: diff --git a/bootstrap/scanner.cc b/bootstrap/scanner.cc index f8c9d8a9..ec984666 100644 --- a/bootstrap/scanner.cc +++ b/bootstrap/scanner.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.10.0.dev on Sun Jan 1 14:19:20 2006 */ +/* Generated by re2c 0.10.0.dev on Sun Jan 1 19:19:49 2006 */ #line 1 "scanner.re" /* $Id$ */ #include @@ -71,7 +71,7 @@ char *Scanner::fill(char *cursor) return cursor; } -#line 89 "scanner.re" +#line 90 "scanner.re" int Scanner::echo(std::ostream &out){ @@ -111,7 +111,7 @@ yy2: if(yych == '*') goto yy12; goto yy3; yy3: -#line 135 "scanner.re" +#line 136 "scanner.re" { goto echo; } @@ -124,7 +124,7 @@ yy5: ++YYCURSOR; goto yy6; yy6: -#line 124 "scanner.re" +#line 125 "scanner.re" { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); tok = pos = cursor; cline++; oline++; @@ -135,7 +135,7 @@ yy7: ++YYCURSOR; goto yy8; yy8: -#line 129 "scanner.re" +#line 130 "scanner.re" { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok) - 1); // -1 so we don't write out the \0 if(cursor == eof) { @@ -150,7 +150,7 @@ yy10: ++YYCURSOR; goto yy11; yy11: -#line 115 "scanner.re" +#line 116 "scanner.re" { if (ignore_eoc) { ignore_eoc = false; @@ -195,7 +195,7 @@ yy19: ++YYCURSOR; goto yy20; yy20: -#line 104 "scanner.re" +#line 105 "scanner.re" { out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok)); tok = cursor; @@ -230,7 +230,7 @@ yy27: ++YYCURSOR; goto yy28; yy28: -#line 109 "scanner.re" +#line 110 "scanner.re" { out << "#define YYMAXFILL " << maxFill << std::endl; tok = pos = cursor; @@ -239,7 +239,7 @@ yy28: } #line 241 "scanner.cc" } -#line 138 "scanner.re" +#line 139 "scanner.re" } @@ -341,7 +341,7 @@ yy31: goto yy32; } yy32: -#line 160 "scanner.re" +#line 161 "scanner.re" { depth = 1; goto code; } @@ -351,7 +351,7 @@ yy33: if((yych = *YYCURSOR) == '*') goto yy92; goto yy34; yy34: -#line 190 "scanner.re" +#line 191 "scanner.re" { RETURN(*tok); } #line 357 "scanner.cc" yy35: @@ -359,7 +359,7 @@ yy35: if((yych = *YYCURSOR) == '/') goto yy90; goto yy36; yy36: -#line 192 "scanner.re" +#line 193 "scanner.re" { yylval.op = *tok; RETURN(CLOSE); } #line 366 "scanner.cc" @@ -369,7 +369,7 @@ yy37: if(yych != 0x0A) goto yy86; goto yy38; yy38: -#line 177 "scanner.re" +#line 178 "scanner.re" { fatal("unterminated string constant (missing \")"); } #line 375 "scanner.cc" yy39: @@ -378,7 +378,7 @@ yy39: if(yych != 0x0A) goto yy81; goto yy40; yy40: -#line 178 "scanner.re" +#line 179 "scanner.re" { fatal("unterminated string constant (missing ')"); } #line 384 "scanner.cc" yy41: @@ -388,7 +388,7 @@ yy41: if(yych == '^') goto yy72; goto yy71; yy42: -#line 188 "scanner.re" +#line 189 "scanner.re" { fatal("unterminated range (missing ])"); } #line 394 "scanner.cc" yy43: @@ -402,7 +402,7 @@ yy45: yych = *YYCURSOR; goto yy62; yy46: -#line 212 "scanner.re" +#line 213 "scanner.re" { cur = cursor; yylval.symbol = Symbol::find(token()); return ID; } @@ -415,7 +415,7 @@ yy48: ++YYCURSOR; goto yy49; yy49: -#line 223 "scanner.re" +#line 224 "scanner.re" { cur = cursor; yylval.regexp = mkDot(); return RANGE; @@ -426,14 +426,14 @@ yy50: yych = *YYCURSOR; goto yy59; yy51: -#line 228 "scanner.re" +#line 229 "scanner.re" { goto scan; } #line 432 "scanner.cc" yy52: ++YYCURSOR; goto yy53; yy53: -#line 230 "scanner.re" +#line 231 "scanner.re" { if(cursor == eof) RETURN(0); pos = cursor; cline++; goto scan; @@ -444,7 +444,7 @@ yy54: if((yych = *YYCURSOR) == 0x0A) goto yy57; goto yy55; yy55: -#line 235 "scanner.re" +#line 236 "scanner.re" { std::cerr << "line " << tline << ", column " << (tchar + 1) << ": unexpected character: "; if (isprint(*tok)) @@ -525,25 +525,30 @@ yy67: yych = *YYCURSOR; goto yy68; yy68: - if(yych <= '@') { + if(yych <= 'Z') { if(yych <= '/') goto yy69; - if(yych <= '9') goto yy67; + if(yych <= ':') goto yy67; + if(yych >= 'A') goto yy67; goto yy69; } else { - if(yych <= 'Z') goto yy67; - if(yych <= '`') goto yy69; - if(yych <= 'z') goto yy67; - goto yy69; + if(yych <= '_') { + if(yych >= '_') goto yy67; + goto yy69; + } else { + if(yych <= '`') goto yy69; + if(yych <= 'z') goto yy67; + goto yy69; + } } yy69: -#line 216 "scanner.re" +#line 217 "scanner.re" { cur = cursor; tok+= 5; /* skip "re2c:" */ iscfg = 1; yylval.str = new Str(token()); return CONFIG; } -#line 547 "scanner.cc" +#line 552 "scanner.cc" yy70: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -582,11 +587,11 @@ yy75: ++YYCURSOR; goto yy76; yy76: -#line 184 "scanner.re" +#line 185 "scanner.re" { cur = cursor; yylval.regexp = ranToRE(token()); return RANGE; } -#line 590 "scanner.cc" +#line 595 "scanner.cc" yy77: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -597,11 +602,11 @@ yy78: ++YYCURSOR; goto yy79; yy79: -#line 180 "scanner.re" +#line 181 "scanner.re" { cur = cursor; yylval.regexp = invToRE(token()); return RANGE; } -#line 605 "scanner.cc" +#line 610 "scanner.cc" yy80: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -626,11 +631,11 @@ yy83: ++YYCURSOR; goto yy84; yy84: -#line 173 "scanner.re" +#line 174 "scanner.re" { cur = cursor; yylval.regexp = strToCaseInsensitiveRE(token()); return STRING; } -#line 634 "scanner.cc" +#line 639 "scanner.cc" yy85: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -655,27 +660,27 @@ yy88: ++YYCURSOR; goto yy89; yy89: -#line 169 "scanner.re" +#line 170 "scanner.re" { cur = cursor; yylval.regexp = strToRE(token()); return STRING; } -#line 663 "scanner.cc" +#line 668 "scanner.cc" yy90: ++YYCURSOR; goto yy91; yy91: -#line 166 "scanner.re" +#line 167 "scanner.re" { tok = cursor; RETURN(0); } -#line 671 "scanner.cc" +#line 676 "scanner.cc" yy92: ++YYCURSOR; goto yy93; yy93: -#line 163 "scanner.re" +#line 164 "scanner.re" { depth = 1; goto comment; } -#line 679 "scanner.cc" +#line 684 "scanner.cc" yy94: yych = *++YYCURSOR; if(yych == ',') goto yy108; @@ -698,18 +703,18 @@ yy97: ++YYCURSOR; goto yy98; yy98: -#line 210 "scanner.re" +#line 211 "scanner.re" { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 704 "scanner.cc" +#line 709 "scanner.cc" yy99: ++YYCURSOR; goto yy100; yy100: -#line 198 "scanner.re" +#line 199 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = atoi((char *)tok+1); RETURN(CLOSESIZE); } -#line 713 "scanner.cc" +#line 718 "scanner.cc" yy101: yyaccept = 5; yych = *(YYMARKER = ++YYCURSOR); @@ -721,11 +726,11 @@ yy102: ++YYCURSOR; goto yy103; yy103: -#line 206 "scanner.re" +#line 207 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = -1; RETURN(CLOSESIZE); } -#line 729 "scanner.cc" +#line 734 "scanner.cc" yy104: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -740,11 +745,11 @@ yy106: ++YYCURSOR; goto yy107; yy107: -#line 202 "scanner.re" +#line 203 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); RETURN(CLOSESIZE); } -#line 748 "scanner.cc" +#line 753 "scanner.cc" yy108: yyaccept = 5; yych = *(YYMARKER = ++YYCURSOR); @@ -756,17 +761,17 @@ yy109: ++YYCURSOR; goto yy110; yy110: -#line 195 "scanner.re" +#line 196 "scanner.re" { yylval.op = '*'; RETURN(CLOSE); } -#line 763 "scanner.cc" +#line 768 "scanner.cc" } -#line 247 "scanner.re" +#line 248 "scanner.re" code: -#line 770 "scanner.cc" +#line 775 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -797,39 +802,39 @@ yy113: ++YYCURSOR; goto yy114; yy114: -#line 251 "scanner.re" +#line 252 "scanner.re" { if(--depth == 0){ cur = cursor; yylval.token = new Token(token(), tline); return CODE; } goto code; } -#line 808 "scanner.cc" +#line 813 "scanner.cc" yy115: ++YYCURSOR; goto yy116; yy116: -#line 257 "scanner.re" +#line 258 "scanner.re" { ++depth; goto code; } -#line 816 "scanner.cc" +#line 821 "scanner.cc" yy117: ++YYCURSOR; goto yy118; yy118: -#line 259 "scanner.re" +#line 260 "scanner.re" { if(cursor == eof) fatal("missing '}'"); pos = cursor; cline++; goto code; } -#line 826 "scanner.cc" +#line 831 "scanner.cc" yy119: ++YYCURSOR; goto yy120; yy120: -#line 263 "scanner.re" +#line 264 "scanner.re" { goto code; } -#line 833 "scanner.cc" +#line 838 "scanner.cc" yy121: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); @@ -886,12 +891,12 @@ yy129: if(yych == 0x0A) goto yy125; goto yy127; } -#line 264 "scanner.re" +#line 265 "scanner.re" comment: -#line 895 "scanner.cc" +#line 900 "scanner.cc" { YYCTYPE yych; goto yy130; @@ -912,9 +917,9 @@ yy132: if((yych = *YYCURSOR) == '/') goto yy140; goto yy133; yy133: -#line 279 "scanner.re" +#line 280 "scanner.re" { goto comment; } -#line 918 "scanner.cc" +#line 923 "scanner.cc" yy134: yych = *++YYCURSOR; if(yych == '*') goto yy138; @@ -923,12 +928,12 @@ yy135: ++YYCURSOR; goto yy136; yy136: -#line 275 "scanner.re" +#line 276 "scanner.re" { if(cursor == eof) RETURN(0); tok = pos = cursor; cline++; goto comment; } -#line 932 "scanner.cc" +#line 937 "scanner.cc" yy137: yych = *++YYCURSOR; goto yy133; @@ -936,28 +941,28 @@ yy138: ++YYCURSOR; goto yy139; yy139: -#line 272 "scanner.re" +#line 273 "scanner.re" { ++depth; fatal("ambiguous /* found"); goto comment; } -#line 944 "scanner.cc" +#line 949 "scanner.cc" yy140: ++YYCURSOR; goto yy141; yy141: -#line 268 "scanner.re" +#line 269 "scanner.re" { if(--depth == 0) goto scan; else goto comment; } -#line 954 "scanner.cc" +#line 959 "scanner.cc" } -#line 280 "scanner.re" +#line 281 "scanner.re" config: -#line 961 "scanner.cc" +#line 966 "scanner.cc" { YYCTYPE yych; goto yy142; @@ -978,27 +983,27 @@ yy144: yych = *YYCURSOR; goto yy153; yy145: -#line 284 "scanner.re" +#line 285 "scanner.re" { goto config; } -#line 984 "scanner.cc" +#line 989 "scanner.cc" yy146: ++YYCURSOR; yych = *YYCURSOR; goto yy151; yy147: -#line 285 "scanner.re" +#line 286 "scanner.re" { iscfg = 2; cur = cursor; RETURN('='); } -#line 995 "scanner.cc" +#line 1000 "scanner.cc" yy148: ++YYCURSOR; goto yy149; yy149: -#line 289 "scanner.re" +#line 290 "scanner.re" { fatal("missing '='"); } -#line 1002 "scanner.cc" +#line 1007 "scanner.cc" yy150: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1018,12 +1023,12 @@ yy153: if(yych == ' ') goto yy152; goto yy145; } -#line 290 "scanner.re" +#line 291 "scanner.re" value: -#line 1027 "scanner.cc" +#line 1032 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -1063,13 +1068,13 @@ yy154: } } yy156: -#line 299 "scanner.re" +#line 300 "scanner.re" { cur = cursor; yylval.str = new Str(token()); iscfg = 0; return VALUE; } -#line 1073 "scanner.cc" +#line 1078 "scanner.cc" yy157: ++YYCURSOR; if((yych = *YYCURSOR) <= 0x0D) { @@ -1087,13 +1092,13 @@ yy157: } } yy158: -#line 294 "scanner.re" +#line 295 "scanner.re" { cur = cursor; yylval.number = atoi(token().to_string().c_str()); iscfg = 0; return NUMBER; } -#line 1097 "scanner.cc" +#line 1102 "scanner.cc" yy159: yych = *++YYCURSOR; if(yych <= '0') goto yy163; @@ -1292,7 +1297,7 @@ yy177: if(yych == 0x0A) goto yy170; goto yy174; } -#line 304 "scanner.re" +#line 305 "scanner.re" } @@ -1308,13 +1313,13 @@ void Scanner::fatal(const char *msg) const fatal(0, msg); } -void Scanner::config(const Str* cfg, int num) +void Scanner::config(const Str& cfg, int num) { - if (cfg->to_string() == "indent") + if (cfg.to_string() == "indent:top") { if (num < 0) { - fatal("configuration 'indent' must be a positive integer"); + fatal("configuration 'indent:top' must be a positive integer"); } topIndent = num; return; @@ -1322,8 +1327,22 @@ void Scanner::config(const Str* cfg, int num) fatal("unrecognized configuration name or illegal integer value"); } -void Scanner::config(const Str*, const Str*) +void Scanner::config(const Str& cfg, const Str& val) { + if (cfg.to_string() == "indent:string") + { + if (val.len >= 2 && val.str[0] == val.str[val.len-1] + && (val.str[0] == '"' || val.str[0] == '\'')) + { + SubStr tmp(val.str + 1, val.len - 2); + unescape(tmp, indString); + } + else + { + indString = val.to_string(); + } + return; + } fatal("unrecognized configuration name or illegal string value"); } diff --git a/code.cc b/code.cc index ecb2d4fd..689d6708 100644 --- a/code.cc +++ b/code.cc @@ -22,7 +22,7 @@ std::string indent(uint ind) while (ind-- > 0) { - str += "\t"; + str += indString; } return str; } diff --git a/globals.h b/globals.h index 3010acc4..ea67f6ef 100644 --- a/globals.h +++ b/globals.h @@ -5,6 +5,7 @@ #include "basics.h" #include #include +#include namespace re2c { @@ -22,6 +23,7 @@ extern bool bUsedYYAccept; extern unsigned int oline; extern uint maxFill; extern uint topIndent; +extern std::string indString; extern uint asc2ebc[256]; extern uint ebc2asc[256]; diff --git a/main.cc b/main.cc index 764bcf3b..6c3da1f9 100644 --- a/main.cc +++ b/main.cc @@ -30,6 +30,7 @@ bool bUsedYYAccept = false; unsigned int oline = 1; uint maxFill = 1; uint topIndent = 0; +std::string indString("\t"); uint nRealChars = 256; int vFillIndexes = -1; diff --git a/parser.y b/parser.y index 4b29951e..050736b0 100644 --- a/parser.y +++ b/parser.y @@ -93,9 +93,9 @@ decl : ID '=' expr ';' in->fatal("sym already defined"); $1->re = $3; } | CONFIG '=' VALUE ';' - { in->config($1, $3); } + { in->config(*$1, *$3); } | CONFIG '=' NUMBER ';' - { in->config($1, $3); } + { in->config(*$1, $3); } ; rule : expr look CODE diff --git a/re2c.1.in b/re2c.1.in index 1a1b3d61..a1c52a5f 100644 --- a/re2c.1.in +++ b/re2c.1.in @@ -7,6 +7,9 @@ .ds rx regular expression .ds lx \fIl\fP-expression \"$Log$ +\"Revision 1.34 2006/01/01 18:29:46 helly +\"- Added ability to control indendation string +\" \"Revision 1.33 2006/01/01 17:13:56 helly \"- Added support for c/c++ compatible \u and \U unicode notation. \" @@ -474,10 +477,13 @@ Those grouped together have equal precedence. .SH "INPLACE CONFIGURATION" .LP It is possible to configure code generation inside re2c blocks. The following -lists the available configurations (without "\fBre2c:\fP" prefix): -.LP -\fIindent\fP -Specifies the minimum number of tabs to use for indendation. +lists the available configurations: +.TP +\fIre2c:indent:top\fP +Specifies the minimum number of indendation to use (default is 0). +.TP +\fIre2c:indent:string\fP +Specifies the string to use for indendation (default is "\\t"). .SH "A LARGER EXAMPLE" .LP diff --git a/scanner.h b/scanner.h index f951a108..4bcb87a2 100644 --- a/scanner.h +++ b/scanner.h @@ -3,6 +3,7 @@ #define _scanner_h #include +#include #include "token.h" #include "re.h" #include "globals.h" @@ -27,14 +28,20 @@ public: Scanner(std::istream&); int echo(std::ostream&); int scan(); + void fatal(const char*) const; void fatal(uint, const char*) const; - void config(const Str*, const Str *); - void config(const Str*, int); + + void config(const Str&, int); + void config(const Str&, const Str&); + SubStr token() const; uint line() const; uint xlat(uint c) const; + uint unescape(SubStr &s) const; + std::string& unescape(SubStr & in, std::string & out) const; + Range * getRange(SubStr &s) const; RegExp * matchChar(uint c) const; RegExp * strToName(SubStr s) const; diff --git a/scanner.re b/scanner.re index abb9d592..a95494d3 100644 --- a/scanner.re +++ b/scanner.re @@ -82,9 +82,10 @@ letter = [a-zA-Z]; digit = [0-9]; number = "0" | ("-"? [1-9] digit*); name = letter (letter|digit)*; +cname = letter (letter|digit|[:_])*; space = [ \t]; eol = ("\r\n" | "\n"); -config = "re2c:" name; +config = "re2c:" cname; value = [^\r\n; \t]* | dstring | sstring; */ @@ -316,13 +317,13 @@ void Scanner::fatal(const char *msg) const fatal(0, msg); } -void Scanner::config(const Str* cfg, int num) +void Scanner::config(const Str& cfg, int num) { - if (cfg->to_string() == "indent") + if (cfg.to_string() == "indent:top") { if (num < 0) { - fatal("configuration 'indent' must be a positive integer"); + fatal("configuration 'indent:top' must be a positive integer"); } topIndent = num; return; @@ -330,8 +331,22 @@ void Scanner::config(const Str* cfg, int num) fatal("unrecognized configuration name or illegal integer value"); } -void Scanner::config(const Str*, const Str*) +void Scanner::config(const Str& cfg, const Str& val) { + if (cfg.to_string() == "indent:string") + { + if (val.len >= 2 && val.str[0] == val.str[val.len-1] + && (val.str[0] == '"' || val.str[0] == '\'')) + { + SubStr tmp(val.str + 1, val.len - 2); + unescape(tmp, indString); + } + else + { + indString = val.to_string(); + } + return; + } fatal("unrecognized configuration name or illegal string value"); } diff --git a/test/config1.re b/test/config1.re index afc0abb9..f1a6dd60 100755 --- a/test/config1.re +++ b/test/config1.re @@ -9,7 +9,7 @@ char *scan0(char *p) { char *q; /*!re2c - re2c:indent = 0; + re2c:indent:top = 0; [0-9]+ { return YYCURSOR; } [\000-\377] { return NULL; } */ @@ -19,7 +19,7 @@ char *scan1(char *p) { char *q; /*!re2c - re2c:indent = 1; + re2c:indent:top = 1; [0-9]+ { return YYCURSOR; } [\000-\377] { return NULL; } */ diff --git a/test/config2.s.c b/test/config2.s.c new file mode 100755 index 00000000..a871b52e --- /dev/null +++ b/test/config2.s.c @@ -0,0 +1,191 @@ +/* Generated by re2c */ +#line 1 "config2.s.re" +#define NULL ((char*) 0) +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT p +#define YYMARKER q +#define YYFILL(n) + +char *scan0(char *p) +{ + char *q; + +#line 15 "" +{ + YYCTYPE yych; + goto yy0; + ++YYCURSOR; +yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= 'b') { + if(yych <= '`') goto yy10; + if(yych >= 'b') goto yy4; + goto yy2; + } else { + if(yych <= 'c') goto yy6; + if(yych <= 'd') goto yy8; + goto yy10; + } +yy2: + ++YYCURSOR; + goto yy3; +yy3: +#line 13 "config2.s.re" + { return YYCURSOR; } +#line 38 "" +yy4: + ++YYCURSOR; + goto yy5; +yy5: +#line 14 "config2.s.re" + { return YYCURSOR; } +#line 45 "" +yy6: + ++YYCURSOR; + goto yy7; +yy7: +#line 15 "config2.s.re" + { return YYCURSOR; } +#line 52 "" +yy8: + ++YYCURSOR; + goto yy9; +yy9: +#line 16 "config2.s.re" + { return YYCURSOR; } +#line 59 "" +yy10: + ++YYCURSOR; + goto yy11; +yy11: +#line 17 "config2.s.re" + { return NULL; } +#line 66 "" +} +#line 18 "config2.s.re" + +} + +char *scan1(char *p) +{ + char *q; + +#line 76 "" +{ + YYCTYPE yych; + goto yy12; + ++YYCURSOR; +yy12: + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if(yych <= 'b') { + if(yych <= '`') goto yy22; + if(yych >= 'b') goto yy16; + goto yy14; + } else { + if(yych <= 'c') goto yy18; + if(yych <= 'd') goto yy20; + goto yy22; + } +yy14: + ++YYCURSOR; + goto yy15; +yy15: +#line 26 "config2.s.re" + { return YYCURSOR; } +#line 99 "" +yy16: + ++YYCURSOR; + goto yy17; +yy17: +#line 27 "config2.s.re" + { return YYCURSOR; } +#line 106 "" +yy18: + ++YYCURSOR; + goto yy19; +yy19: +#line 28 "config2.s.re" + { return YYCURSOR; } +#line 113 "" +yy20: + ++YYCURSOR; + goto yy21; +yy21: +#line 29 "config2.s.re" + { return YYCURSOR; } +#line 120 "" +yy22: + ++YYCURSOR; + goto yy23; +yy23: +#line 30 "config2.s.re" + { return NULL; } +#line 127 "" +} +#line 31 "config2.s.re" + +} + +char *scan(char *p) +{ + char *q; + +#line 137 "" +{ +YYCTYPE yych; +goto yy24; +++YYCURSOR; +yy24: +if(YYLIMIT == YYCURSOR) YYFILL(1); +yych = *YYCURSOR; +if(yych <= 'b') { +if(yych <= '`') goto yy34; +if(yych >= 'b') goto yy28; +goto yy26; +} else { +if(yych <= 'c') goto yy30; +if(yych <= 'd') goto yy32; +goto yy34; +} +yy26: +++YYCURSOR; +goto yy27; +yy27: +#line 39 "config2.s.re" +{ return YYCURSOR; } +#line 160 "" +yy28: +++YYCURSOR; +goto yy29; +yy29: +#line 40 "config2.s.re" +{ return YYCURSOR; } +#line 167 "" +yy30: +++YYCURSOR; +goto yy31; +yy31: +#line 41 "config2.s.re" +{ return YYCURSOR; } +#line 174 "" +yy32: +++YYCURSOR; +goto yy33; +yy33: +#line 42 "config2.s.re" +{ return YYCURSOR; } +#line 181 "" +yy34: +++YYCURSOR; +goto yy35; +yy35: +#line 43 "config2.s.re" +{ return NULL; } +#line 188 "" +} +#line 44 "config2.s.re" + +} diff --git a/test/config2.s.re b/test/config2.s.re new file mode 100755 index 00000000..8203f99d --- /dev/null +++ b/test/config2.s.re @@ -0,0 +1,45 @@ +#define NULL ((char*) 0) +#define YYCTYPE char +#define YYCURSOR p +#define YYLIMIT p +#define YYMARKER q +#define YYFILL(n) + +char *scan0(char *p) +{ + char *q; +/*!re2c + re2c:indent:string = " "; + [a] { return YYCURSOR; } + [b] { return YYCURSOR; } + [c] { return YYCURSOR; } + [d] { return YYCURSOR; } + [\000-\377] { return NULL; } +*/ +} + +char *scan1(char *p) +{ + char *q; +/*!re2c + re2c:indent:string = "\t"; + [a] { return YYCURSOR; } + [b] { return YYCURSOR; } + [c] { return YYCURSOR; } + [d] { return YYCURSOR; } + [\000-\377] { return NULL; } +*/ +} + +char *scan(char *p) +{ + char *q; +/*!re2c + re2c:indent:string = ""; + [a] { return YYCURSOR; } + [b] { return YYCURSOR; } + [c] { return YYCURSOR; } + [d] { return YYCURSOR; } + [\000-\377] { return NULL; } +*/ +}