From: helly Date: Mon, 17 Apr 2006 00:18:46 +0000 (+0000) Subject: - When ignoring more then a single line's content the we need to write a X-Git-Tag: 0.13.6~377 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a63f36d69285272c06b2782f44842f949701a79e;p=re2c - When ignoring more then a single line's content the we need to write a #line directive. --- diff --git a/bootstrap/scanner.cc b/bootstrap/scanner.cc index db242b72..8b945350 100644 --- a/bootstrap/scanner.cc +++ b/bootstrap/scanner.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.10.2.dev on Sun Apr 16 18:19:25 2006 */ +/* Generated by re2c 0.10.2.dev on Sun Apr 16 20:12:14 2006 */ #line 1 "scanner.re" /* $Id$ */ #include @@ -83,6 +83,7 @@ int Scanner::echo() { char *cursor = cur; bool ignore_eoc = false; + int ignore_cnt = 0; if (eof && cursor == eof) // Catch EOF { @@ -92,7 +93,7 @@ int Scanner::echo() tok = cursor; echo: -#line 96 "scanner.cc" +#line 97 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -111,29 +112,31 @@ echo: yych = *(YYMARKER = ++YYCURSOR); if(yych == '*') goto yy16; yy3: -#line 172 "scanner.re" +#line 184 "scanner.re" { goto echo; } -#line 119 "scanner.cc" +#line 120 "scanner.cc" yy4: yych = *++YYCURSOR; if(yych == '/') goto yy10; goto yy3; yy5: ++YYCURSOR; -#line 157 "scanner.re" +#line 167 "scanner.re" { - if (!ignore_eoc) { + if (ignore_eoc) { + ignore_cnt++; + } else { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); } tok = pos = cursor; cline++; goto echo; } -#line 134 "scanner.cc" +#line 137 "scanner.cc" yy7: ++YYCURSOR; -#line 164 "scanner.re" +#line 176 "scanner.re" { if (!ignore_eoc) { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok) - 1); // -1 so we don't write out the \0 @@ -142,7 +145,7 @@ yy7: RETURN(0); } } -#line 146 "scanner.cc" +#line 149 "scanner.cc" yy9: yych = *++YYCURSOR; goto yy3; @@ -152,17 +155,21 @@ yy10: if(yych == 0x0A) goto yy14; if(yych == 0x0D) goto yy12; yy11: -#line 148 "scanner.re" +#line 154 "scanner.re" { if (ignore_eoc) { + if (ignore_cnt) { + out << "\n" << sourceFileInfo; + } ignore_eoc = false; + ignore_cnt = 0; } else { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); } tok = pos = cursor; goto echo; } -#line 166 "scanner.cc" +#line 173 "scanner.cc" yy12: yych = *++YYCURSOR; if(yych == 0x0A) goto yy14; @@ -174,17 +181,22 @@ yy13: } yy14: ++YYCURSOR; -#line 139 "scanner.re" +#line 140 "scanner.re" { + cline++; if (ignore_eoc) { + if (ignore_cnt) { + out << sourceFileInfo; + } ignore_eoc = false; + ignore_cnt = 0; } else { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); } - tok = pos = cursor; cline++; + tok = pos = cursor; goto echo; } -#line 188 "scanner.cc" +#line 200 "scanner.cc" yy16: yych = *++YYCURSOR; if(yych != '!') goto yy13; @@ -216,7 +228,7 @@ yy21: yych = *++YYCURSOR; if(yych != 'c') goto yy13; ++YYCURSOR; -#line 110 "scanner.re" +#line 111 "scanner.re" { if (bUsedYYMaxFill && bSinglePass) { fatal("found scanner block after YYMAXFILL declaration"); @@ -225,7 +237,7 @@ yy21: tok = cursor; RETURN(1); } -#line 229 "scanner.cc" +#line 241 "scanner.cc" yy26: yych = *++YYCURSOR; if(yych != 'x') goto yy13; @@ -240,7 +252,7 @@ yy26: yych = *++YYCURSOR; if(yych != 'c') goto yy13; ++YYCURSOR; -#line 118 "scanner.re" +#line 119 "scanner.re" { if (bUsedYYMaxFill) { fatal("cannot generate YYMAXFILL twice"); @@ -251,7 +263,7 @@ yy26: bUsedYYMaxFill = true; goto echo; } -#line 255 "scanner.cc" +#line 267 "scanner.cc" yy34: yych = *++YYCURSOR; if(yych != 't') goto yy13; @@ -276,14 +288,14 @@ yy34: yych = *++YYCURSOR; if(yych != 'c') goto yy13; ++YYCURSOR; -#line 128 "scanner.re" +#line 129 "scanner.re" { tok = pos = cursor; genGetState(out, topIndent, 0); ignore_eoc = true; goto echo; } -#line 287 "scanner.cc" +#line 299 "scanner.cc" yy47: yych = *++YYCURSOR; if(yych != 'n') goto yy13; @@ -304,15 +316,15 @@ yy47: yych = *++YYCURSOR; if(yych != 'c') goto yy13; ++YYCURSOR; -#line 134 "scanner.re" +#line 135 "scanner.re" { tok = pos = cursor; ignore_eoc = true; goto echo; } -#line 314 "scanner.cc" +#line 326 "scanner.cc" } -#line 175 "scanner.re" +#line 187 "scanner.re" } @@ -335,7 +347,7 @@ scan: goto value; } -#line 339 "scanner.cc" +#line 351 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -409,42 +421,42 @@ yy60: if(yych <= '9') goto yy124; } yy61: -#line 197 "scanner.re" +#line 209 "scanner.re" { depth = 1; goto code; } -#line 417 "scanner.cc" +#line 429 "scanner.cc" yy62: ++YYCURSOR; if((yych = *YYCURSOR) == '*') goto yy121; yy63: -#line 227 "scanner.re" +#line 239 "scanner.re" { RETURN(*tok); } -#line 424 "scanner.cc" +#line 436 "scanner.cc" yy64: ++YYCURSOR; if((yych = *YYCURSOR) == '/') goto yy119; yy65: -#line 229 "scanner.re" +#line 241 "scanner.re" { yylval.op = *tok; RETURN(CLOSE); } -#line 432 "scanner.cc" +#line 444 "scanner.cc" yy66: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if(yych != 0x0A) goto yy115; yy67: -#line 214 "scanner.re" +#line 226 "scanner.re" { fatal("unterminated string constant (missing \")"); } -#line 440 "scanner.cc" +#line 452 "scanner.cc" yy68: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); if(yych != 0x0A) goto yy110; yy69: -#line 215 "scanner.re" +#line 227 "scanner.re" { fatal("unterminated string constant (missing ')"); } -#line 448 "scanner.cc" +#line 460 "scanner.cc" yy70: yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); @@ -452,9 +464,9 @@ yy70: if(yych == '^') goto yy101; goto yy100; yy71: -#line 225 "scanner.re" +#line 237 "scanner.re" { fatal("unterminated range (missing ])"); } -#line 458 "scanner.cc" +#line 470 "scanner.cc" yy72: yych = *++YYCURSOR; goto yy63; @@ -466,51 +478,51 @@ yy74: if((yych = *YYCURSOR) == 'e') goto yy91; goto yy90; yy75: -#line 256 "scanner.re" +#line 268 "scanner.re" { cur = cursor; yylval.symbol = Symbol::find(token()); return ID; } -#line 474 "scanner.cc" +#line 486 "scanner.cc" yy76: yych = *++YYCURSOR; goto yy90; yy77: ++YYCURSOR; -#line 260 "scanner.re" +#line 272 "scanner.re" { cur = cursor; yylval.regexp = mkDot(); return RANGE; } -#line 485 "scanner.cc" +#line 497 "scanner.cc" yy79: ++YYCURSOR; yych = *YYCURSOR; goto yy88; yy80: -#line 265 "scanner.re" +#line 277 "scanner.re" { goto scan; } -#line 493 "scanner.cc" +#line 505 "scanner.cc" yy81: ++YYCURSOR; yy82: -#line 267 "scanner.re" +#line 279 "scanner.re" { if(cursor == eof) RETURN(0); pos = cursor; cline++; goto scan; } -#line 502 "scanner.cc" +#line 514 "scanner.cc" yy83: ++YYCURSOR; if((yych = *YYCURSOR) == 0x0A) goto yy86; yy84: -#line 272 "scanner.re" +#line 284 "scanner.re" { std::ostringstream msg; msg << "unexpected character: "; prtChOrHex(msg, *tok); fatal(msg.str().c_str()); goto scan; } -#line 514 "scanner.cc" +#line 526 "scanner.cc" yy85: yych = *++YYCURSOR; goto yy84; @@ -588,14 +600,14 @@ yy96: } } yy98: -#line 249 "scanner.re" +#line 261 "scanner.re" { cur = cursor; tok+= 5; /* skip "re2c:" */ iscfg = 1; yylval.str = new Str(token()); return CONFIG; } -#line 599 "scanner.cc" +#line 611 "scanner.cc" yy99: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -629,11 +641,11 @@ yy103: goto yy99; yy104: ++YYCURSOR; -#line 221 "scanner.re" +#line 233 "scanner.re" { cur = cursor; yylval.regexp = ranToRE(token()); return RANGE; } -#line 637 "scanner.cc" +#line 649 "scanner.cc" yy106: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -642,11 +654,11 @@ yy106: goto yy101; yy107: ++YYCURSOR; -#line 217 "scanner.re" +#line 229 "scanner.re" { cur = cursor; yylval.regexp = invToRE(token()); return RANGE; } -#line 650 "scanner.cc" +#line 662 "scanner.cc" yy109: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -666,11 +678,11 @@ yy110: goto yy109; yy112: ++YYCURSOR; -#line 210 "scanner.re" +#line 222 "scanner.re" { cur = cursor; yylval.regexp = strToCaseInsensitiveRE(token()); return STRING; } -#line 674 "scanner.cc" +#line 686 "scanner.cc" yy114: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -690,23 +702,23 @@ yy115: goto yy114; yy117: ++YYCURSOR; -#line 206 "scanner.re" +#line 218 "scanner.re" { cur = cursor; yylval.regexp = strToRE(token()); return STRING; } -#line 698 "scanner.cc" +#line 710 "scanner.cc" yy119: ++YYCURSOR; -#line 203 "scanner.re" +#line 215 "scanner.re" { tok = cursor; RETURN(0); } -#line 704 "scanner.cc" +#line 716 "scanner.cc" yy121: ++YYCURSOR; -#line 200 "scanner.re" +#line 212 "scanner.re" { depth = 1; goto comment; } -#line 710 "scanner.cc" +#line 722 "scanner.cc" yy123: yych = *++YYCURSOR; if(yych == ',') goto yy137; @@ -727,16 +739,16 @@ yy125: yy126: ++YYCURSOR; yy127: -#line 247 "scanner.re" +#line 259 "scanner.re" { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 733 "scanner.cc" +#line 745 "scanner.cc" yy128: ++YYCURSOR; -#line 235 "scanner.re" +#line 247 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = atoi((char *)tok+1); RETURN(CLOSESIZE); } -#line 740 "scanner.cc" +#line 752 "scanner.cc" yy130: yyaccept = 6; yych = *(YYMARKER = ++YYCURSOR); @@ -744,11 +756,11 @@ yy130: if(yych <= '9') goto yy133; if(yych != '}') goto yy127; ++YYCURSOR; -#line 243 "scanner.re" +#line 255 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = -1; RETURN(CLOSESIZE); } -#line 752 "scanner.cc" +#line 764 "scanner.cc" yy133: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -757,11 +769,11 @@ yy133: if(yych <= '9') goto yy133; if(yych != '}') goto yy95; ++YYCURSOR; -#line 239 "scanner.re" +#line 251 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); RETURN(CLOSESIZE); } -#line 765 "scanner.cc" +#line 777 "scanner.cc" yy137: yyaccept = 6; yych = *(YYMARKER = ++YYCURSOR); @@ -769,17 +781,17 @@ yy137: if(yych <= '9') goto yy133; if(yych != '}') goto yy127; ++YYCURSOR; -#line 232 "scanner.re" +#line 244 "scanner.re" { yylval.op = '*'; RETURN(CLOSE); } -#line 776 "scanner.cc" +#line 788 "scanner.cc" } -#line 278 "scanner.re" +#line 290 "scanner.re" code: -#line 783 "scanner.cc" +#line 795 "scanner.cc" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -802,34 +814,34 @@ code: } } ++YYCURSOR; -#line 282 "scanner.re" +#line 294 "scanner.re" { if(--depth == 0){ cur = cursor; yylval.token = new Token(token(), tline); return CODE; } goto code; } -#line 813 "scanner.cc" +#line 825 "scanner.cc" yy144: ++YYCURSOR; -#line 288 "scanner.re" +#line 300 "scanner.re" { ++depth; goto code; } -#line 819 "scanner.cc" +#line 831 "scanner.cc" yy146: ++YYCURSOR; -#line 290 "scanner.re" +#line 302 "scanner.re" { if(cursor == eof) fatal("missing '}'"); pos = cursor; cline++; goto code; } -#line 827 "scanner.cc" +#line 839 "scanner.cc" yy148: ++YYCURSOR; yy149: -#line 294 "scanner.re" +#line 306 "scanner.re" { goto code; } -#line 833 "scanner.cc" +#line 845 "scanner.cc" yy150: yych = *(YYMARKER = ++YYCURSOR); if(yych == 0x0A) goto yy149; @@ -877,12 +889,12 @@ yy157: if(yych == 0x0A) goto yy154; goto yy156; } -#line 295 "scanner.re" +#line 307 "scanner.re" comment: -#line 886 "scanner.cc" +#line 898 "scanner.cc" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -899,47 +911,47 @@ yy161: ++YYCURSOR; if((yych = *YYCURSOR) == '/') goto yy169; yy162: -#line 310 "scanner.re" +#line 322 "scanner.re" { if(cursor == eof) RETURN(0); goto comment; } -#line 906 "scanner.cc" +#line 918 "scanner.cc" yy163: yych = *++YYCURSOR; if(yych == '*') goto yy167; goto yy162; yy164: ++YYCURSOR; -#line 306 "scanner.re" +#line 318 "scanner.re" { if(cursor == eof) RETURN(0); tok = pos = cursor; cline++; goto comment; } -#line 918 "scanner.cc" +#line 930 "scanner.cc" yy166: yych = *++YYCURSOR; goto yy162; yy167: ++YYCURSOR; -#line 303 "scanner.re" +#line 315 "scanner.re" { ++depth; fatal("ambiguous /* found"); goto comment; } -#line 928 "scanner.cc" +#line 940 "scanner.cc" yy169: ++YYCURSOR; -#line 299 "scanner.re" +#line 311 "scanner.re" { if(--depth == 0) goto scan; else goto comment; } -#line 936 "scanner.cc" +#line 948 "scanner.cc" } -#line 312 "scanner.re" +#line 324 "scanner.re" config: -#line 943 "scanner.cc" +#line 955 "scanner.cc" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -956,25 +968,25 @@ yy173: yych = *YYCURSOR; goto yy182; yy174: -#line 316 "scanner.re" +#line 328 "scanner.re" { goto config; } -#line 962 "scanner.cc" +#line 974 "scanner.cc" yy175: ++YYCURSOR; yych = *YYCURSOR; goto yy180; yy176: -#line 317 "scanner.re" +#line 329 "scanner.re" { iscfg = 2; cur = cursor; RETURN('='); } -#line 973 "scanner.cc" +#line 985 "scanner.cc" yy177: ++YYCURSOR; -#line 321 "scanner.re" +#line 333 "scanner.re" { fatal("missing '='"); } -#line 978 "scanner.cc" +#line 990 "scanner.cc" yy179: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -992,12 +1004,12 @@ yy182: if(yych == ' ') goto yy181; goto yy174; } -#line 322 "scanner.re" +#line 334 "scanner.re" value: -#line 1001 "scanner.cc" +#line 1013 "scanner.cc" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -1030,13 +1042,13 @@ value: } } yy185: -#line 331 "scanner.re" +#line 343 "scanner.re" { cur = cursor; yylval.str = new Str(token()); iscfg = 0; return VALUE; } -#line 1040 "scanner.cc" +#line 1052 "scanner.cc" yy186: ++YYCURSOR; if((yych = *YYCURSOR) <= 0x0D) { @@ -1051,13 +1063,13 @@ yy186: } } yy187: -#line 326 "scanner.re" +#line 338 "scanner.re" { cur = cursor; yylval.number = atoi(token().to_string().c_str()); iscfg = 0; return NUMBER; } -#line 1061 "scanner.cc" +#line 1073 "scanner.cc" yy188: yych = *++YYCURSOR; if(yych <= '0') goto yy192; @@ -1231,7 +1243,7 @@ yy206: if(yych == 0x0A) goto yy199; goto yy203; } -#line 336 "scanner.re" +#line 348 "scanner.re" } diff --git a/lessons/001_upn_calculator/calc_001.c b/lessons/001_upn_calculator/calc_001.c index d565c5d6..8a9c2e93 100755 --- a/lessons/001_upn_calculator/calc_001.c +++ b/lessons/001_upn_calculator/calc_001.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_001.re" /* re2c lesson_001, calc_001, (c) M. Boerger 2006 */ +#line 43 "calc_001.re" #include #include @@ -19,7 +20,7 @@ int scan(char *s, int l) for(;;) { -#line 23 "" +#line 24 "" { YYCTYPE yych; @@ -59,7 +60,7 @@ yy2: yy3: #line 64 "calc_001.re" { printf("Num\n"); continue; } -#line 63 "" +#line 64 "" yy4: ++YYCURSOR; yych = *YYCURSOR; @@ -67,27 +68,27 @@ yy4: yy5: #line 63 "calc_001.re" { printf("Num\n"); continue; } -#line 71 "" +#line 72 "" yy6: ++YYCURSOR; #line 65 "calc_001.re" { printf("+\n"); continue; } -#line 76 "" +#line 77 "" yy8: ++YYCURSOR; #line 66 "calc_001.re" { printf("-\n"); continue; } -#line 81 "" +#line 82 "" yy10: ++YYCURSOR; #line 67 "calc_001.re" { printf("EOF\n"); return 0; } -#line 86 "" +#line 87 "" yy12: ++YYCURSOR; #line 68 "calc_001.re" { printf("ERR\n"); return 1; } -#line 91 "" +#line 92 "" yy14: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -126,7 +127,7 @@ yy16: yy18: #line 62 "calc_001.re" { printf("Oct\n"); continue; } -#line 130 "" +#line 131 "" } #line 69 "calc_001.re" diff --git a/lessons/001_upn_calculator/calc_002.c b/lessons/001_upn_calculator/calc_002.c index 4ecca471..c1810aee 100755 --- a/lessons/001_upn_calculator/calc_002.c +++ b/lessons/001_upn_calculator/calc_002.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_002.re" /* re2c lesson_001, calc_002, (c) M. Boerger 2006 */ +#line 19 "calc_002.re" #include #include @@ -27,7 +28,7 @@ int scan(char *s) for(;;) { -#line 31 "" +#line 32 "" { YYCTYPE yych; @@ -67,7 +68,7 @@ yy2: yy3: #line 48 "calc_002.re" { printf("Num\n"); continue; } -#line 71 "" +#line 72 "" yy4: ++YYCURSOR; yych = *YYCURSOR; @@ -75,27 +76,27 @@ yy4: yy5: #line 47 "calc_002.re" { printf("Num\n"); continue; } -#line 79 "" +#line 80 "" yy6: ++YYCURSOR; #line 49 "calc_002.re" { printf("+\n"); continue; } -#line 84 "" +#line 85 "" yy8: ++YYCURSOR; #line 50 "calc_002.re" { printf("+\n"); continue; } -#line 89 "" +#line 90 "" yy10: ++YYCURSOR; #line 51 "calc_002.re" { printf("EOF\n"); return 0; } -#line 94 "" +#line 95 "" yy12: ++YYCURSOR; #line 52 "calc_002.re" { printf("ERR\n"); return 1; } -#line 99 "" +#line 100 "" yy14: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -134,7 +135,7 @@ yy16: yy18: #line 46 "calc_002.re" { printf("Oct\n"); continue; } -#line 138 "" +#line 139 "" } #line 53 "calc_002.re" diff --git a/lessons/001_upn_calculator/calc_003.c b/lessons/001_upn_calculator/calc_003.c index 64f3f2e2..763e5eb3 100755 --- a/lessons/001_upn_calculator/calc_003.c +++ b/lessons/001_upn_calculator/calc_003.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_003.re" /* re2c lesson_001, calc_003, (c) M. Boerger 2006 */ +#line 19 "calc_003.re" #include #include @@ -19,7 +20,7 @@ int scan(char *s, int l) for(;;) { -#line 23 "" +#line 24 "" { YYCTYPE yych; @@ -59,7 +60,7 @@ yy2: yy3: #line 40 "calc_003.re" { printf("Num\n"); continue; } -#line 63 "" +#line 64 "" yy4: ++YYCURSOR; yych = *YYCURSOR; @@ -67,27 +68,27 @@ yy4: yy5: #line 39 "calc_003.re" { printf("Num\n"); continue; } -#line 71 "" +#line 72 "" yy6: ++YYCURSOR; #line 41 "calc_003.re" { printf("+\n"); continue; } -#line 76 "" +#line 77 "" yy8: ++YYCURSOR; #line 42 "calc_003.re" { printf("+\n"); continue; } -#line 81 "" +#line 82 "" yy10: ++YYCURSOR; #line 43 "calc_003.re" { printf("EOF\n"); return 0; } -#line 86 "" +#line 87 "" yy12: ++YYCURSOR; #line 44 "calc_003.re" { printf("ERR\n"); return 1; } -#line 91 "" +#line 92 "" yy14: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -126,7 +127,7 @@ yy16: yy18: #line 38 "calc_003.re" { printf("Oct\n"); continue; } -#line 130 "" +#line 131 "" } #line 45 "calc_003.re" diff --git a/lessons/001_upn_calculator/calc_004.c b/lessons/001_upn_calculator/calc_004.c index 994c534a..d830ef21 100755 --- a/lessons/001_upn_calculator/calc_004.c +++ b/lessons/001_upn_calculator/calc_004.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_004.re" /* re2c lesson_001, calc_004, (c) M. Boerger 2006 */ +#line 20 "calc_004.re" #include #include @@ -31,7 +32,7 @@ int scan(char *s, int l) { t = p; -#line 35 "" +#line 36 "" { YYCTYPE yych; @@ -71,7 +72,7 @@ yy2: yy3: #line 57 "calc_004.re" { t = tokendup(t, p); printf("Num: %s\n", t); free(t); continue; } -#line 75 "" +#line 76 "" yy4: yych = *++YYCURSOR; goto yy14; @@ -79,22 +80,22 @@ yy5: ++YYCURSOR; #line 58 "calc_004.re" { printf("+\n"); continue; } -#line 83 "" +#line 84 "" yy7: ++YYCURSOR; #line 59 "calc_004.re" { printf("+\n"); continue; } -#line 88 "" +#line 89 "" yy9: ++YYCURSOR; #line 60 "calc_004.re" { printf("EOF\n"); return 0; } -#line 93 "" +#line 94 "" yy11: ++YYCURSOR; #line 61 "calc_004.re" { printf("ERR\n"); return 1; } -#line 98 "" +#line 99 "" yy13: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -133,7 +134,7 @@ yy15: yy17: #line 56 "calc_004.re" { t = tokendup(t, p); printf("Oct: %s\n", t); free(t); continue; } -#line 137 "" +#line 138 "" } #line 62 "calc_004.re" diff --git a/lessons/001_upn_calculator/calc_005.c b/lessons/001_upn_calculator/calc_005.c index 9c4f624e..6babb634 100755 --- a/lessons/001_upn_calculator/calc_005.c +++ b/lessons/001_upn_calculator/calc_005.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_005.re" /* re2c lesson_001, calc_005, (c) M. Boerger 2006 */ +#line 19 "calc_005.re" #include #include @@ -66,7 +67,7 @@ int scan(char *s, int l) { t = p; -#line 70 "" +#line 71 "" { YYCTYPE yych; @@ -96,7 +97,7 @@ yy2: yy3: #line 91 "calc_005.re" { continue; } -#line 100 "" +#line 101 "" yy4: ++YYCURSOR; switch((yych = *YYCURSOR)) { @@ -115,7 +116,7 @@ yy4: yy5: #line 93 "calc_005.re" { res = push_num(t, p, 10); continue; } -#line 119 "" +#line 120 "" yy6: yych = *++YYCURSOR; goto yy14; @@ -123,17 +124,17 @@ yy7: ++YYCURSOR; #line 94 "calc_005.re" { res = stack_add(); continue; } -#line 127 "" +#line 128 "" yy9: ++YYCURSOR; #line 95 "calc_005.re" { res = stack_sub(); continue; } -#line 132 "" +#line 133 "" yy11: ++YYCURSOR; #line 96 "calc_005.re" { res = 1; continue; } -#line 137 "" +#line 138 "" yy13: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -172,7 +173,7 @@ yy15: yy17: #line 92 "calc_005.re" { res = push_num(t, p, 8); continue; } -#line 176 "" +#line 177 "" yy18: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); diff --git a/lessons/001_upn_calculator/calc_006.s.c b/lessons/001_upn_calculator/calc_006.s.c index f383e3e2..66b4e292 100755 --- a/lessons/001_upn_calculator/calc_006.s.c +++ b/lessons/001_upn_calculator/calc_006.s.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_006.s.re" /* re2c lesson_001, calc_006, (c) M. Boerger 2006 */ +#line 34 "calc_006.s.re" #include #include @@ -64,7 +65,7 @@ int scan(char *s) { t = p; -#line 68 "" +#line 69 "" { YYCTYPE yych; @@ -94,7 +95,7 @@ int scan(char *s) yy3: #line 105 "calc_006.s.re" { continue; } -#line 98 "" +#line 99 "" yy4: ++YYCURSOR; if((yych = *YYCURSOR) <= '/') goto yy5; @@ -102,7 +103,7 @@ yy4: yy5: #line 107 "calc_006.s.re" { res = push_num(t, p, 10); continue; } -#line 106 "" +#line 107 "" yy6: yych = *++YYCURSOR; goto yy16; @@ -110,22 +111,22 @@ yy7: ++YYCURSOR; #line 108 "calc_006.s.re" { res = stack_add(); continue; } -#line 114 "" +#line 115 "" yy9: ++YYCURSOR; #line 109 "calc_006.s.re" { res = stack_sub(); continue; } -#line 119 "" +#line 120 "" yy11: ++YYCURSOR; #line 110 "calc_006.s.re" { res = depth == 1 ? 0 : 2; continue; } -#line 124 "" +#line 125 "" yy13: ++YYCURSOR; #line 111 "calc_006.s.re" { res = 1; continue; } -#line 129 "" +#line 130 "" yy15: ++YYCURSOR; yych = *YYCURSOR; @@ -141,7 +142,7 @@ yy17: yy19: #line 106 "calc_006.s.re" { res = push_num(t, p, 8); continue; } -#line 145 "" +#line 146 "" yy20: ++YYCURSOR; yych = *YYCURSOR; diff --git a/lessons/001_upn_calculator/calc_007.b.c b/lessons/001_upn_calculator/calc_007.b.c index 3e47b860..66d5b368 100755 --- a/lessons/001_upn_calculator/calc_007.b.c +++ b/lessons/001_upn_calculator/calc_007.b.c @@ -1,6 +1,7 @@ /* Generated by re2c */ #line 1 "calc_007.b.re" /* re2c lesson_001, calc_007, (c) M. Boerger 2006 */ +#line 8 "calc_007.b.re" #include #include @@ -99,7 +100,7 @@ int scan(char *s) 0, 0, 0, 0, 0, 0, 0, 0, }; -#line 103 "" +#line 104 "" { YYCTYPE yych; @@ -129,7 +130,7 @@ int scan(char *s) yy3: #line 79 "calc_007.b.re" { continue; } -#line 133 "" +#line 134 "" yy4: ++YYCURSOR; if((yych = *YYCURSOR) <= '/') goto yy5; @@ -137,7 +138,7 @@ yy4: yy5: #line 81 "calc_007.b.re" { res = push_num(t, p, 10); continue; } -#line 141 "" +#line 142 "" yy6: yych = *++YYCURSOR; goto yy16; @@ -145,22 +146,22 @@ yy7: ++YYCURSOR; #line 82 "calc_007.b.re" { res = stack_add(); continue; } -#line 149 "" +#line 150 "" yy9: ++YYCURSOR; #line 83 "calc_007.b.re" { res = stack_sub(); continue; } -#line 154 "" +#line 155 "" yy11: ++YYCURSOR; #line 84 "calc_007.b.re" { res = depth == 1 ? 0 : 2; continue; } -#line 159 "" +#line 160 "" yy13: ++YYCURSOR; #line 85 "calc_007.b.re" { res = 1; continue; } -#line 164 "" +#line 165 "" yy15: ++YYCURSOR; yych = *YYCURSOR; @@ -177,7 +178,7 @@ yy17: yy19: #line 80 "calc_007.b.re" { res = push_num(t, p, 8); continue; } -#line 181 "" +#line 182 "" yy20: ++YYCURSOR; yych = *YYCURSOR; diff --git a/scanner.re b/scanner.re index 28071b64..3f0cc30b 100644 --- a/scanner.re +++ b/scanner.re @@ -98,6 +98,7 @@ int Scanner::echo() { char *cursor = cur; bool ignore_eoc = false; + int ignore_cnt = 0; if (eof && cursor == eof) // Catch EOF { @@ -137,17 +138,26 @@ echo: goto echo; } "*" "/" "\r"? "\n" { + cline++; if (ignore_eoc) { + if (ignore_cnt) { + out << sourceFileInfo; + } ignore_eoc = false; + ignore_cnt = 0; } else { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); } - tok = pos = cursor; cline++; + tok = pos = cursor; goto echo; } "*" "/" { if (ignore_eoc) { + if (ignore_cnt) { + out << "\n" << sourceFileInfo; + } ignore_eoc = false; + ignore_cnt = 0; } else { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); } @@ -155,7 +165,9 @@ echo: goto echo; } "\n" { - if (!ignore_eoc) { + if (ignore_eoc) { + ignore_cnt++; + } else { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); } tok = pos = cursor; cline++; diff --git a/test/config5.c b/test/config5.c index 6305bde7..42d0a6e5 100755 --- a/test/config5.c +++ b/test/config5.c @@ -1,9 +1,10 @@ /* Generated by re2c */ #line 1 "config5.re" // ignored +#line 7 "config5.re" // code -#line 7 "" +#line 8 "" { YYCTYPE yych; @@ -22,7 +23,7 @@ yy2: yy3: #line 11 "config5.re" { return 0; } -#line 26 "" +#line 27 "" yy4: yych = *++YYCURSOR; goto yy3; @@ -54,11 +55,13 @@ yy10: ++YYCURSOR; #line 10 "config5.re" { return 1; } -#line 58 "" +#line 59 "" } #line 13 "config5.re" // ignored +#line 20 "config5.re" // max #define YYMAXFILL 3 -// eof \ No newline at end of file +#line 26 "config5.re" +// eof diff --git a/test/config5.re b/test/config5.re index 7d8c7d02..a6cfc5ff 100755 --- a/test/config5.re +++ b/test/config5.re @@ -23,4 +23,4 @@ Ignored... */ -// eof \ No newline at end of file +// eof