From 1702e9d8334c99843e633686e7210ba636e614bf Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 9 Oct 2005 07:11:45 +0000 Subject: [PATCH] Continue re2c updates. This one gets rid of the unused label warnings. Going ahead and removing the cleanup script; a later commit will get rid of the remaining unused variable warnings that the cleanup script took care of as well. svn path=/trunk/yasm/; revision=1273 --- modules/arch/lc3b/Makefile.inc | 3 +- modules/arch/x86/Makefile.inc | 3 +- modules/parsers/gas/Makefile.inc | 3 +- modules/parsers/nasm/Makefile.inc | 3 +- tools/re2c/Makefile.inc | 10 +- tools/re2c/basics.h | 2 + tools/re2c/cleanup.c | 197 ------- tools/re2c/code.c | 73 ++- tools/re2c/globals.h | 2 + tools/re2c/main.c | 57 +- tools/re2c/scanner.c | 869 +++++++++++++++++++----------- tools/re2c/scanner.re | 10 +- 12 files changed, 660 insertions(+), 572 deletions(-) delete mode 100644 tools/re2c/cleanup.c diff --git a/modules/arch/lc3b/Makefile.inc b/modules/arch/lc3b/Makefile.inc index 85da54e3..6fbc60ce 100644 --- a/modules/arch/lc3b/Makefile.inc +++ b/modules/arch/lc3b/Makefile.inc @@ -7,9 +7,8 @@ libyasm_a_SOURCES += lc3bid.c YASM_MODULES += arch_lc3b -lc3bid.c: $(srcdir)/modules/arch/lc3b/lc3bid.re re2c$(EXEEXT) cleanup$(EXEEXT) +lc3bid.c: $(srcdir)/modules/arch/lc3b/lc3bid.re re2c$(EXEEXT) $(top_builddir)/re2c$(EXEEXT) -s -o $@ $(srcdir)/modules/arch/lc3b/lc3bid.re - $(top_builddir)/cleanup$(EXEEXT) $@ BUILT_SOURCES += lc3bid.c diff --git a/modules/arch/x86/Makefile.inc b/modules/arch/x86/Makefile.inc index a2b6ad82..b50caf80 100644 --- a/modules/arch/x86/Makefile.inc +++ b/modules/arch/x86/Makefile.inc @@ -8,9 +8,8 @@ libyasm_a_SOURCES += x86id.c YASM_MODULES += arch_x86 -x86id.c: $(srcdir)/modules/arch/x86/x86id.re re2c$(EXEEXT) cleanup$(EXEEXT) +x86id.c: $(srcdir)/modules/arch/x86/x86id.re re2c$(EXEEXT) $(top_builddir)/re2c$(EXEEXT) -s -o $@ $(srcdir)/modules/arch/x86/x86id.re - $(top_builddir)/cleanup$(EXEEXT) $@ BUILT_SOURCES += x86id.c diff --git a/modules/parsers/gas/Makefile.inc b/modules/parsers/gas/Makefile.inc index 8ca77e4b..84fd0547 100644 --- a/modules/parsers/gas/Makefile.inc +++ b/modules/parsers/gas/Makefile.inc @@ -9,9 +9,8 @@ libyasm_a_SOURCES += gas-token.c YASM_MODULES += parser_gas -gas-token.c: $(srcdir)/modules/parsers/gas/gas-token.re re2c$(EXEEXT) cleanup$(EXEEXT) +gas-token.c: $(srcdir)/modules/parsers/gas/gas-token.re re2c$(EXEEXT) $(top_builddir)/re2c$(EXEEXT) -b -o $@ $(srcdir)/modules/parsers/gas/gas-token.re - $(top_builddir)/cleanup$(EXEEXT) $@ BUILT_SOURCES += gas-bison.c BUILT_SOURCES += gas-bison.h diff --git a/modules/parsers/nasm/Makefile.inc b/modules/parsers/nasm/Makefile.inc index e5eba58a..4a57f65c 100644 --- a/modules/parsers/nasm/Makefile.inc +++ b/modules/parsers/nasm/Makefile.inc @@ -9,9 +9,8 @@ libyasm_a_SOURCES += nasm-token.c YASM_MODULES += parser_nasm -nasm-token.c: $(srcdir)/modules/parsers/nasm/nasm-token.re re2c$(EXEEXT) cleanup$(EXEEXT) +nasm-token.c: $(srcdir)/modules/parsers/nasm/nasm-token.re re2c$(EXEEXT) $(top_builddir)/re2c$(EXEEXT) -b -o $@ $(srcdir)/modules/parsers/nasm/nasm-token.re - $(top_builddir)/cleanup$(EXEEXT) $@ BUILT_SOURCES += nasm-bison.c BUILT_SOURCES += nasm-bison.h diff --git a/tools/re2c/Makefile.inc b/tools/re2c/Makefile.inc index 178643e9..5efc4d7c 100644 --- a/tools/re2c/Makefile.inc +++ b/tools/re2c/Makefile.inc @@ -3,7 +3,7 @@ # These utility programs have to be built for BUILD host in cross-build. # This makes things rather non-standard automake -noinst_PROGRAMS += re2c cleanup +noinst_PROGRAMS += re2c re2c_SOURCES = EXTRA_DIST += tools/re2c/main.c @@ -89,14 +89,6 @@ re2c-parser.h: re2c-parser.c $(MAKE) re2c-parser.c; \ else :; fi -cleanup_SOURCES = -EXTRA_DIST += tools/re2c/cleanup.c -cleanup_LDADD = cleanup.$(OBJEXT) -cleanup_LINK = $(CCLD_FOR_BUILD) -o $@ - -cleanup.$(OBJEXT): tools/re2c/cleanup.c - $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(INCLUDES) -c -o $@ `test -f tools/re2c/cleanup.c || echo '$(srcdir)/'`tools/re2c/cleanup.c - BUILT_SOURCES += re2c-parser.c BUILT_SOURCES += re2c-parser.h diff --git a/tools/re2c/basics.h b/tools/re2c/basics.h index 6eae65a9..1531e759 100644 --- a/tools/re2c/basics.h +++ b/tools/re2c/basics.h @@ -9,4 +9,6 @@ typedef unsigned char byte; typedef unsigned short word; typedef unsigned long dword; +#define PACKAGE_VERSION "1.0.0" + #endif diff --git a/tools/re2c/cleanup.c b/tools/re2c/cleanup.c deleted file mode 100644 index 6c0ba77d..00000000 --- a/tools/re2c/cleanup.c +++ /dev/null @@ -1,197 +0,0 @@ -/* $Id$ - * - * Clean up re2c output to avoid compiler warnings. - * - * Copyright (C) 2004 Peter Johnson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#include -#include - -#define MAXLINE 1024 - -static char * -mystrdup(const char *str) -{ - size_t len; - char *copy; - - len = strlen(str) + 1; - copy = malloc(len); - memcpy(copy, str, len); - return (copy); -} - -int -main(int argc, char *argv[]) -{ - char str[MAXLINE]; - size_t alloclines = 1000; - size_t numlines = 0; - char **inlines; - size_t alloclabel = 100; - unsigned char *usedlabel; - size_t allocvar = 1000; - unsigned char *usedvar; - int lastusedvarline = 0; - int level = 0; - size_t line; - unsigned long value; - char *pos; - size_t span1, span2; - FILE *f; - - if (argc < 2) { - fputs("Usage: cleanup \n", stderr); - return EXIT_FAILURE; - } - - f = fopen(argv[1], "rt"); - if (!f) { - fprintf(stderr, "Could not open %s for reading.\n", argv[1]); - return EXIT_FAILURE; - } - - inlines = malloc(alloclines * sizeof(char *)); - if (!inlines) { - fputs("Out of memory.\n", stderr); - return EXIT_FAILURE; - } - - while (fgets(str, MAXLINE, f)) { - /* check array bounds */ - if (numlines >= alloclines) { - alloclines *= 2; - inlines = realloc(inlines, alloclines * sizeof(char *)); - if (!inlines) { - fputs("Out of memory.\n", stderr); - return EXIT_FAILURE; - } - } - inlines[numlines] = mystrdup(str); - numlines++; - } - - usedlabel = calloc(alloclabel, 1); - usedvar = calloc(allocvar, 1); - if (!usedlabel || !usedvar) { - fputs("Out of memory.\n", stderr); - return EXIT_FAILURE; - } - - for (line = 1; line <= numlines; line++) { - /* look for goto yy[0-9]+ statements */ - if ((pos = strstr(inlines[line-1], "goto")) && - (span1 = strspn(&pos[4], " \t")) > 0 && - strncmp(&pos[4+span1], "yy", 2) == 0 && - (span2 = strspn(&pos[6+span1], "0123456789")) > 0 && - strspn(&pos[6+span1+span2], " \t;") > 0) { - /* convert label to integer */ - value = strtoul(&pos[6+span1], NULL, 10); - /* check array bounds */ - while (value >= alloclabel) { - usedlabel = realloc(usedlabel, alloclabel * 2); - if (!usedlabel) { - fputs("Out of memory.\n", stderr); - return EXIT_FAILURE; - } - memset(usedlabel + alloclabel, 0, alloclabel); - alloclabel *= 2; - } - usedlabel[value] = 1; - } - - /* keep track of the brace level of the code (approximately) */ - pos = inlines[line-1]; - while ((pos = strchr(pos, '{'))) { - level++; - pos++; - } - pos = inlines[line-1]; - while ((pos = strchr(pos, '}'))) { - level--; - pos++; - } - - /* check for leaving the scope of the last used yyaccept variable */ - if (level < usedvar[lastusedvarline]) - lastusedvarline = 0; - - /* check for int yyaccept variable declaration / usage */ - if ((pos = strstr(inlines[line-1], "int")) && - (span1 = strspn(&pos[3], " \t")) > 0 && - strncmp(&pos[3+span1], "yyaccept", 8) == 0 && - strspn(&pos[11+span1], " \t;") > 0) { - /* declaration */ - /* check array bounds */ - while (line >= allocvar) { - usedvar = realloc(usedvar, allocvar * 2); - if (!usedvar) { - fputs("Out of memory.\n", stderr); - return EXIT_FAILURE; - } - memset(usedvar + allocvar, 0, allocvar); - allocvar *= 2; - } - usedvar[line] = level; - lastusedvarline = line; - } else if (strstr(inlines[line-1], "yyaccept")) - usedvar[lastusedvarline] = 255; /* used */ - } - - fclose(f); - - f = fopen(argv[1], "wt"); - if (!f) { - fprintf(stderr, "Could not open %s for writing.\n", argv[1]); - return EXIT_FAILURE; - } - - for (line = 1; line <= numlines; line++) { - pos = inlines[line-1]; - /* look for yy[0-9]+ labels */ - if (strncmp(pos, "yy", 2) == 0 && - (span1 = strspn(&pos[2], "0123456789")) > 0 && - pos[2+span1] == ':') { - value = strtoul(&pos[2], NULL, 10); - /* delete unused yy[0-9]+ labels */ - if (value >= alloclabel || !usedlabel[value]) - pos = &pos[2+span1+1]; - } - if (line < allocvar && usedvar[line] != 0 && usedvar[line] != 255) - putc('\n', f); - else - fputs(pos, f); - } - - free(usedvar); - free(usedlabel); - for (line = 0; line < numlines; line++) - free(inlines[line]); - free(inlines); - - fclose(f); - - return EXIT_SUCCESS; -} diff --git a/tools/re2c/code.c b/tools/re2c/code.c index f0664351..bf6ce429 100644 --- a/tools/re2c/code.c +++ b/tools/re2c/code.c @@ -5,6 +5,19 @@ #include "tools/re2c/globals.h" #include "tools/re2c/dfa.h" +static void useLabel(size_t value) { + while (value >= vUsedLabelAlloc) { + vUsedLabels = realloc(vUsedLabels, vUsedLabelAlloc * 2); + if (!vUsedLabels) { + fputs("Out of memory.\n", stderr); + exit(EXIT_FAILURE); + } + memset(vUsedLabels + vUsedLabelAlloc, 0, vUsedLabelAlloc); + vUsedLabelAlloc *= 2; + } + vUsedLabels[value] = 1; +} + /* there must be at least one span in list; all spans must cover * same range */ @@ -163,16 +176,18 @@ void BitMap_stats(void){ } #endif -static void genGoTo(FILE *o, State *from, State *to, int *readCh) +static void genGoTo(FILE *o, State *from, State *to, int *readCh, + const char *indent) { #if 0 if (*readCh && from->label + 1 != to->label) { - fputs("\tyych = *YYCURSOR;\n", o); oline++; + fputs("%syych = *YYCURSOR;\n", indent, o); oline++; *readCh = 0; } #endif - fprintf(o, "\tgoto yy%u;\n", to->label); oline++; + fprintf(o, "%sgoto yy%u;\n", indent, to->label); oline++; + useLabel(to->label); } static void genIf(FILE *o, const char *cmp, unsigned int v, int *readCh) @@ -267,7 +282,7 @@ Action_emit(Action *a, FILE *o, int *readCh) fputs("\tswitch(yyaccept){\n", o); oline+=2; } fprintf(o, "\tcase %u:", a->d.Accept.saves[i]); - genGoTo(o, a->state, a->d.Accept.rules[i], readCh); + genGoTo(o, a->state, a->d.Accept.rules[i], readCh, "\t"); } if(!first) { fputs("\t}\n", o); oline++; @@ -307,37 +322,37 @@ static void doLinear(FILE *o, unsigned int i, Span *s, unsigned int n, if(s[1].to == next && n == 3){ indent(o, i); genIf(o, "!=", s[0].ub, readCh); - genGoTo(o, from, bg, readCh); + genGoTo(o, from, bg, readCh, "\t"); indent(o, i); - genGoTo(o, from, next, readCh); + genGoTo(o, from, next, readCh, "\t"); return; } else { indent(o, i); genIf(o, "==", s[0].ub, readCh); - genGoTo(o, from, s[1].to, readCh); + genGoTo(o, from, s[1].to, readCh, "\t"); } n -= 2; s += 2; } if(n == 1){ indent(o, i); - genGoTo(o, from, s[0].to, readCh); + genGoTo(o, from, s[0].to, readCh, "\t"); return; } else if(n == 2 && bg == next){ indent(o, i); genIf(o, ">=", s[0].ub, readCh); - genGoTo(o, from, s[1].to, readCh); + genGoTo(o, from, s[1].to, readCh, "\t"); indent(o, i); - genGoTo(o, from, next, readCh); + genGoTo(o, from, next, readCh, "\t"); return; } else { indent(o, i); genIf(o, "<=", s[0].ub - 1, readCh); - genGoTo(o, from, bg, readCh); + genGoTo(o, from, bg, readCh, "\t"); n -= 1; s += 1; } } indent(o, i); - genGoTo(o, from, next, readCh); + genGoTo(o, from, next, readCh, "\t"); } void @@ -392,11 +407,11 @@ Go_genSwitch(Go *g, FILE *o, State *from, State *next, int *readCh){ else *(r++) = *s; } - genGoTo(o, from, to, readCh); + genGoTo(o, from, to, readCh, "\t"); t = r; } fputs("\tdefault:", o); - genGoTo(o, from, def, readCh); + genGoTo(o, from, def, readCh, "\t"); fputs("\t}\n", o); oline++; free(sP); @@ -468,9 +483,16 @@ Go_genGoto(Go *g, FILE *o, State *from, State *next, int *readCh){ Go go; go.span = malloc(sizeof(Span)*g->nSpans); Go_unmap(&go, g, to); - fprintf(o, "\tif(yybm[%u+yych] & %u)", b->i, - (unsigned int) b->m); - genGoTo(o, from, to, readCh); + fprintf(o, "\tif(yybm[%u+", b->i); +#if 0 + if (*readCh) + fputs("(yych = *YYCURSOR)", o); + else +#endif + fputs("yych", o); + fprintf(o, "] & %u) {\n", (unsigned int) b->m); oline++; + genGoTo(o, from, to, readCh, "\t\t"); + fputs("\t}\n", o); oline++; Go_genBase(&go, o, from, next, readCh); free(go.span); return; @@ -482,7 +504,8 @@ Go_genGoto(Go *g, FILE *o, State *from, State *next, int *readCh){ } void State_emit(State *s, FILE *o, int *readCh){ - fprintf(o, "yy%u:", s->label); + if (vUsedLabels[s->label]) + fprintf(o, "yy%u:", s->label); Action_emit(s->action, o, readCh); } @@ -658,9 +681,11 @@ void DFA_emit(DFA *d, FILE *o){ unsigned int nRules = 0; unsigned int nSaves = 0; unsigned int *saves; + unsigned int nOrgOline; State **rules; State *accept = NULL; Span *span; + FILE *tmpo; DFA_findSCCs(d); d->head->link = d->head; @@ -767,11 +792,23 @@ void DFA_emit(DFA *d, FILE *o){ BitMap_gen(o, d->lbChar, d->ubChar); fprintf(o, "\tgoto yy%u;\n", label); oline++; + useLabel(label); Action_new_Enter(d->head, label++); for(s = d->head; s; s = s->next) s->label = label++; + nOrgOline = oline; + tmpo = fopen("re2c.tmp", "wt"); + for(s = d->head; s; s = s->next){ + int readCh = 0; + State_emit(s, tmpo, &readCh); + Go_genGoto(&s->go, o, s, s->next, &readCh); + } + fclose(tmpo); + unlink("re2c.tmp"); + oline = nOrgOline; + for(s = d->head; s; s = s->next){ int readCh = 0; State_emit(s, o, &readCh); diff --git a/tools/re2c/globals.h b/tools/re2c/globals.h index 82f99375..9f88f69c 100644 --- a/tools/re2c/globals.h +++ b/tools/re2c/globals.h @@ -8,6 +8,8 @@ extern const char *outputFileName; extern int sFlag; extern int bFlag; extern unsigned int oline; +extern unsigned char *vUsedLabels; +extern unsigned int vUsedLabelAlloc; extern unsigned char asc2ebc[256]; extern unsigned char ebc2asc[256]; diff --git a/tools/re2c/main.c b/tools/re2c/main.c index c5fa362a..aa1199d6 100644 --- a/tools/re2c/main.c +++ b/tools/re2c/main.c @@ -11,6 +11,8 @@ const char *outputFileName = 0; int sFlag = 0; int bFlag = 0; unsigned int oline = 1; +unsigned char *vUsedLabels; +unsigned int vUsedLabelAlloc = 1000; static char *opt_arg = NULL; static int opt_ind = 1; @@ -22,29 +24,32 @@ static const mbo_opt_struct OPTIONS[] = { {'h', 0, "help"}, {'s', 0, "nested-ifs"}, {'o', 1, "output"}, - {'v', 0, "version"} + {'v', 0, "version"}, + {'-', 0, NULL} /* end of args */ }; static void usage() { - fprintf(stderr, "usage: re2c [-esbvh] file\n" - "\n" - "-? -h --help Display this info.\n" - "\n" - "-b --bit-vectors Implies -s. Use bit vectors as well in the attempt to\n" - " coax better code out of the compiler. Most useful for\n" - " specifications with more than a few keywords (e.g. for\n" - " most programming languages).\n" - "\n" - "-e --ecb Cross-compile from an ASCII platform to\n" - " an EBCDIC one.\n" - "\n" - "-s --nested-ifs Generate nested ifs for some switches. Many compilers\n" - " need this assist to generate better code.\n" - "\n" - "-o --output=output Specify the output file instead of stdout\n" - "\n" - "-v --version Show version information.\n"); + fprintf(stderr, + "usage: re2c [-esbvh] file\n" + "\n" + "-? -h --help Display this info.\n" + "\n" + "-b --bit-vectors Implies -s. Use bit vectors as well in the attempt to\n" + " coax better code out of the compiler. Most useful for\n" + " specifications with more than a few keywords (e.g. for\n" + " most programming languages).\n" + "\n" + "-e --ecb Cross-compile from an ASCII platform to\n" + " an EBCDIC one.\n" + "\n" + "-s --nested-ifs Generate nested ifs for some switches. Many compilers\n" + " need this assist to generate better code.\n" + "\n" + "-o --output=output Specify the output file instead of stdout\n" + "\n" + "-v --version Show version information.\n" + "-V --vernum Show version as one number.\n"); } int main(int argc, char *argv[]) @@ -76,8 +81,14 @@ int main(int argc, char *argv[]) outputFileName = opt_arg; break; case 'v': - fputs("re2c\n", stderr); + fputs("re2c " PACKAGE_VERSION "\n", stdout); break; + case 'V': { + int v1, v2, v3; + sscanf(PACKAGE_VERSION, "%d.%d.%d", &v1, &v2, &v3); + fprintf(stdout, "%02d%02d%02d\n", v1, v2, v3); + return 2; + } case 'h': case '?': default: @@ -93,6 +104,12 @@ int main(int argc, char *argv[]) return 2; } + vUsedLabels = calloc(vUsedLabelAlloc, 1); + if (!vUsedLabels) { + fputs("Out of memory.\n", stderr); + return 1; + } + /* set up the input stream */ if(fileName[0] == '-' && fileName[1] == '\0'){ fileName = ""; diff --git a/tools/re2c/scanner.c b/tools/re2c/scanner.c index 8bdb61f0..6991fdda 100644 --- a/tools/re2c/scanner.c +++ b/tools/re2c/scanner.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.1-C on Sat Oct 8 22:50:57 2005 +/* Generated by re2c 0.9.1-C on Sun Oct 9 00:12:08 2005 */ #line 1 "scanner.re" #include @@ -61,14 +61,14 @@ fill(Scanner *s, unsigned char *cursor) s->bot = buf; } if((cnt = fread(s->lim, 1, BSIZE, s->in)) != BSIZE){ - s->eof = &s->lim[cnt]; *s->eof++ = '\n'; + s->eof = &s->lim[cnt]; *s->eof++ = '\0'; } s->lim += cnt; } return cursor; } -#line 77 "scanner.re" +#line 78 "scanner.re" int @@ -88,61 +88,96 @@ echo: YYCTYPE yych; unsigned int yyaccept; goto yy0; + if(yych <= '\n'){ + if(yych <= '\000') goto yy6; + if(yych <= '\t') goto yy8; + goto yy4; + } else { + if(yych != '/') goto yy8; + goto yy2; + } + if(yych == '*') goto yy9; + goto yy3; + goto yy5; + goto yy7; + goto yy3; + if(yych == '!') goto yy11; + goto yy10; + if(yych != 'r') goto yy10; + goto yy12; + if(yych != 'e') goto yy10; + goto yy13; + if(yych != '2') goto yy10; + goto yy14; + if(yych != 'c') goto yy10; + goto yy15; + goto yy16; ++YYCURSOR; yy0: if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; - if(yych == '\n') goto yy4; - if(yych != '/') goto yy6; - goto yy2; + if(yych <= '\n'){ + if(yych <= '\000') goto yy6; + if(yych <= '\t') goto yy8; + goto yy4; + } else { + if(yych != '/') goto yy8; + goto yy2; + } yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == '*') goto yy7; + if(yych == '*') goto yy9; goto yy3; yy3: -#line 98 "scanner.re" +#line 100 "scanner.re" { goto echo; } -#line 106 "scanner.c" +#line 111 "scanner.c" yy4: yych = *++YYCURSOR; goto yy5; yy5: -#line 94 "scanner.re" -{ if(cursor == s->eof) RETURN(0); - fwrite(s->tok, 1, cursor - s->tok, out); +#line 95 "scanner.re" +{ fwrite(s->tok, 1, cursor - s->tok, out); s->tok = s->pos = cursor; s->cline++; oline++; goto echo; } -#line 115 "scanner.c" +#line 119 "scanner.c" yy6: yych = *++YYCURSOR; + goto yy7; +yy7: +#line 98 "scanner.re" +{ fwrite(s->tok, 1, cursor - s->tok - 1, out); /* -1 so we don't write out the \0 */ + if(cursor == s->eof) { RETURN(0); } } +#line 126 "scanner.c" +yy8: yych = *++YYCURSOR; goto yy3; -yy7: yych = *++YYCURSOR; - if(yych == '!') goto yy9; - goto yy8; -yy8: YYCURSOR = YYMARKER; +yy9: yych = *++YYCURSOR; + if(yych == '!') goto yy11; + goto yy10; +yy10: YYCURSOR = YYMARKER; switch(yyaccept){ case 0: goto yy3; } -yy9: yych = *++YYCURSOR; - if(yych != 'r') goto yy8; - goto yy10; -yy10: yych = *++YYCURSOR; - if(yych != 'e') goto yy8; - goto yy11; yy11: yych = *++YYCURSOR; - if(yych != '2') goto yy8; + if(yych != 'r') goto yy10; goto yy12; yy12: yych = *++YYCURSOR; - if(yych != 'c') goto yy8; + if(yych != 'e') goto yy10; goto yy13; yy13: yych = *++YYCURSOR; + if(yych != '2') goto yy10; goto yy14; -yy14: -#line 91 "scanner.re" +yy14: yych = *++YYCURSOR; + if(yych != 'c') goto yy10; + goto yy15; +yy15: yych = *++YYCURSOR; + goto yy16; +yy16: +#line 92 "scanner.re" { fwrite(s->tok, 1, &cursor[-7] - s->tok, out); s->tok = cursor; RETURN(1); } -#line 144 "scanner.c" +#line 155 "scanner.c" } -#line 99 "scanner.re" +#line 101 "scanner.re" } @@ -158,487 +193,689 @@ scan: s->tline = s->cline; s->tok = cursor; -#line 162 "scanner.c" +#line 173 "scanner.c" { YYCTYPE yych; unsigned int yyaccept; - goto yy15; + goto yy17; + if(yych <= '/'){ + if(yych <= '"'){ + if(yych <= '\n'){ + if(yych <= '\b') goto yy39; + if(yych <= '\t') goto yy35; + goto yy37; + } else { + if(yych == ' ') goto yy35; + if(yych <= '!') goto yy39; + goto yy25; + } + } else { + if(yych <= ')'){ + if(yych <= '&') goto yy39; + if(yych <= '\'') goto yy27; + goto yy31; + } else { + if(yych <= '*') goto yy23; + if(yych <= '+') goto yy32; + if(yych <= '.') goto yy39; + goto yy21; + } + } + } else { + if(yych <= '@'){ + if(yych <= '<'){ + if(yych == ';') goto yy31; + goto yy39; + } else { + if(yych <= '=') goto yy31; + if(yych == '?') goto yy32; + goto yy39; + } + } else { + if(yych <= '`'){ + if(yych <= 'Z') goto yy33; + if(yych <= '[') goto yy29; + if(yych <= '\\') goto yy31; + goto yy39; + } else { + if(yych <= 'z') goto yy33; + if(yych <= '{') goto yy19; + if(yych <= '|') goto yy31; + goto yy39; + } + } + } + if(yych <= '/') goto yy20; + if(yych <= '9') goto yy65; + goto yy20; + if(yych == '*') goto yy63; + goto yy22; + if(yych == '/') goto yy61; + goto yy24; + if(yych != '\n') goto yy57; + goto yy26; + if(yych != '\n') goto yy52; + goto yy28; + if(yych != '\n') goto yy46; + goto yy30; + goto yy22; + goto yy24; + goto yy44; + goto yy42; + goto yy38; + goto yy40; + goto yy42; + if(yych == '\t') goto yy41; + if(yych == ' ') goto yy41; + goto yy36; + goto yy44; + if(yych <= '@'){ + if(yych <= '/') goto yy34; + if(yych <= '9') goto yy43; + goto yy34; + } else { + if(yych <= 'Z') goto yy43; + if(yych <= '`') goto yy34; + if(yych <= 'z') goto yy43; + goto yy34; + } + goto yy46; + if(yych <= '['){ + if(yych != '\n') goto yy45; + goto yy47; + } else { + if(yych <= '\\') goto yy48; + if(yych <= ']') goto yy49; + goto yy45; + } + if(yych == '\n') goto yy47; + goto yy45; + goto yy50; + goto yy52; + if(yych <= '&'){ + if(yych == '\n') goto yy47; + goto yy51; + } else { + if(yych <= '\'') goto yy54; + if(yych != '\\') goto yy51; + goto yy53; + } + if(yych == '\n') goto yy47; + goto yy51; + goto yy55; + goto yy57; + if(yych <= '!'){ + if(yych == '\n') goto yy47; + goto yy56; + } else { + if(yych <= '"') goto yy59; + if(yych != '\\') goto yy56; + goto yy58; + } + if(yych == '\n') goto yy47; + goto yy56; + goto yy60; + goto yy62; + goto yy64; + goto yy66; + if(yych <= '/'){ + if(yych == ',') goto yy69; + goto yy47; + } else { + if(yych <= '9') goto yy65; + if(yych != '}') goto yy47; + goto yy67; + } + goto yy68; + if(yych != '}') goto yy73; + goto yy70; + goto yy71; + goto yy73; + if(yych <= '/') goto yy47; + if(yych <= '9') goto yy72; + if(yych != '}') goto yy47; + goto yy74; + goto yy75; ++YYCURSOR; -yy15: +yy17: if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if(yych <= '/'){ if(yych <= '"'){ if(yych <= '\n'){ - if(yych <= '\b') goto yy37; - if(yych <= '\t') goto yy33; - goto yy35; + if(yych <= '\b') goto yy39; + if(yych <= '\t') goto yy35; + goto yy37; } else { - if(yych == ' ') goto yy33; - if(yych <= '!') goto yy37; - goto yy23; + if(yych == ' ') goto yy35; + if(yych <= '!') goto yy39; + goto yy25; } } else { if(yych <= ')'){ - if(yych <= '&') goto yy37; - if(yych <= '\'') goto yy25; - goto yy29; + if(yych <= '&') goto yy39; + if(yych <= '\'') goto yy27; + goto yy31; } else { - if(yych <= '*') goto yy21; - if(yych <= '+') goto yy30; - if(yych <= '.') goto yy37; - goto yy19; + if(yych <= '*') goto yy23; + if(yych <= '+') goto yy32; + if(yych <= '.') goto yy39; + goto yy21; } } } else { if(yych <= '@'){ if(yych <= '<'){ - if(yych == ';') goto yy29; - goto yy37; + if(yych == ';') goto yy31; + goto yy39; } else { - if(yych <= '=') goto yy29; - if(yych == '?') goto yy30; - goto yy37; + if(yych <= '=') goto yy31; + if(yych == '?') goto yy32; + goto yy39; } } else { if(yych <= '`'){ - if(yych <= 'Z') goto yy31; - if(yych <= '[') goto yy27; - if(yych <= '\\') goto yy29; - goto yy37; + if(yych <= 'Z') goto yy33; + if(yych <= '[') goto yy29; + if(yych <= '\\') goto yy31; + goto yy39; } else { - if(yych <= 'z') goto yy31; - if(yych <= '{') goto yy17; - if(yych <= '|') goto yy29; - goto yy37; + if(yych <= 'z') goto yy33; + if(yych <= '{') goto yy19; + if(yych <= '|') goto yy31; + goto yy39; } } } -yy17: yyaccept = 0; +yy19: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych <= '/') goto yy18; - if(yych <= '9') goto yy63; - goto yy18; -yy18: -#line 114 "scanner.re" + if(yych <= '/') goto yy20; + if(yych <= '9') goto yy65; + goto yy20; +yy20: +#line 116 "scanner.re" { depth = 1; goto code; } -#line 228 "scanner.c" -yy19: yych = *++YYCURSOR; - if(yych == '*') goto yy61; - goto yy20; -yy20: -#line 140 "scanner.re" -{ RETURN(*s->tok); } -#line 235 "scanner.c" +#line 239 "scanner.c" yy21: yych = *++YYCURSOR; - if(yych == '/') goto yy59; + if(yych == '*') goto yy63; goto yy22; yy22: #line 142 "scanner.re" -{ yylval.op = *s->tok; - RETURN(CLOSE); } -#line 243 "scanner.c" -yy23: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if(yych != '\n') goto yy55; +{ RETURN(*s->tok); } +#line 246 "scanner.c" +yy23: yych = *++YYCURSOR; + if(yych == '/') goto yy61; goto yy24; yy24: -#line 131 "scanner.re" -{ Scanner_fatal(s, "unterminated string constant (missing \")"); } -#line 251 "scanner.c" -yy25: yyaccept = 2; +#line 144 "scanner.re" +{ yylval.op = *s->tok; + RETURN(CLOSE); } +#line 254 "scanner.c" +yy25: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); - if(yych != '\n') goto yy50; + if(yych != '\n') goto yy57; goto yy26; yy26: -#line 132 "scanner.re" -{ Scanner_fatal(s, "unterminated string constant (missing ')"); } -#line 259 "scanner.c" -yy27: yyaccept = 3; +#line 133 "scanner.re" +{ Scanner_fatal(s, "unterminated string constant (missing \")"); } +#line 262 "scanner.c" +yy27: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); - if(yych != '\n') goto yy44; + if(yych != '\n') goto yy52; goto yy28; yy28: -#line 138 "scanner.re" +#line 134 "scanner.re" +{ Scanner_fatal(s, "unterminated string constant (missing ')"); } +#line 270 "scanner.c" +yy29: yyaccept = 3; + yych = *(YYMARKER = ++YYCURSOR); + if(yych != '\n') goto yy46; + goto yy30; +yy30: +#line 140 "scanner.re" { Scanner_fatal(s, "unterminated range (missing ])"); } -#line 267 "scanner.c" -yy29: yych = *++YYCURSOR; - goto yy20; -yy30: yych = *++YYCURSOR; - goto yy22; +#line 278 "scanner.c" yy31: yych = *++YYCURSOR; - goto yy42; -yy32: -#line 157 "scanner.re" + goto yy22; +yy32: yych = *++YYCURSOR; + goto yy24; +yy33: yych = *++YYCURSOR; + goto yy44; +yy34: +#line 159 "scanner.re" { SubStr substr; s->cur = cursor; substr = Scanner_token(s); yylval.symbol = Symbol_find(&substr); return ID; } -#line 281 "scanner.c" -yy33: yych = *++YYCURSOR; - goto yy40; -yy34: -#line 163 "scanner.re" -{ goto scan; } -#line 287 "scanner.c" +#line 292 "scanner.c" yy35: yych = *++YYCURSOR; - goto yy36; + goto yy42; yy36: #line 165 "scanner.re" +{ goto scan; } +#line 298 "scanner.c" +yy37: yych = *++YYCURSOR; + goto yy38; +yy38: +#line 167 "scanner.re" { if(cursor == s->eof) RETURN(0); s->pos = cursor; s->cline++; goto scan; } -#line 296 "scanner.c" -yy37: yych = *++YYCURSOR; - goto yy38; -yy38: -#line 170 "scanner.re" +#line 307 "scanner.c" +yy39: yych = *++YYCURSOR; + goto yy40; +yy40: +#line 172 "scanner.re" { fprintf(stderr, "unexpected character: '%c'\n", *s->tok); goto scan; } -#line 304 "scanner.c" -yy39: ++YYCURSOR; - if(YYLIMIT == YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - goto yy40; -yy40: if(yych == '\t') goto yy39; - if(yych == ' ') goto yy39; - goto yy34; +#line 315 "scanner.c" yy41: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; goto yy42; -yy42: if(yych <= '@'){ - if(yych <= '/') goto yy32; - if(yych <= '9') goto yy41; - goto yy32; - } else { - if(yych <= 'Z') goto yy41; - if(yych <= '`') goto yy32; - if(yych <= 'z') goto yy41; - goto yy32; - } +yy42: if(yych == '\t') goto yy41; + if(yych == ' ') goto yy41; + goto yy36; yy43: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; goto yy44; -yy44: if(yych <= '['){ - if(yych != '\n') goto yy43; - goto yy45; +yy44: if(yych <= '@'){ + if(yych <= '/') goto yy34; + if(yych <= '9') goto yy43; + goto yy34; + } else { + if(yych <= 'Z') goto yy43; + if(yych <= '`') goto yy34; + if(yych <= 'z') goto yy43; + goto yy34; + } +yy45: ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + goto yy46; +yy46: if(yych <= '['){ + if(yych != '\n') goto yy45; + goto yy47; } else { - if(yych <= '\\') goto yy46; - if(yych <= ']') goto yy47; - goto yy43; + if(yych <= '\\') goto yy48; + if(yych <= ']') goto yy49; + goto yy45; } -yy45: YYCURSOR = YYMARKER; +yy47: YYCURSOR = YYMARKER; switch(yyaccept){ - case 0: goto yy18; - case 1: goto yy24; - case 2: goto yy26; - case 3: goto yy28; + case 0: goto yy20; + case 1: goto yy26; + case 2: goto yy28; + case 3: goto yy30; } -yy46: ++YYCURSOR; +yy48: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if(yych == '\n') goto yy45; - goto yy43; -yy47: yych = *++YYCURSOR; - goto yy48; -yy48: -#line 134 "scanner.re" + if(yych == '\n') goto yy47; + goto yy45; +yy49: yych = *++YYCURSOR; + goto yy50; +yy50: +#line 136 "scanner.re" { s->cur = cursor; yylval.regexp = ranToRE(Scanner_token(s)); return RANGE; } -#line 357 "scanner.c" -yy49: ++YYCURSOR; +#line 368 "scanner.c" +yy51: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy50; -yy50: if(yych <= '&'){ - if(yych == '\n') goto yy45; - goto yy49; - } else { - if(yych <= '\'') goto yy52; - if(yych != '\\') goto yy49; + goto yy52; +yy52: if(yych <= '&'){ + if(yych == '\n') goto yy47; goto yy51; + } else { + if(yych <= '\'') goto yy54; + if(yych != '\\') goto yy51; + goto yy53; } -yy51: ++YYCURSOR; +yy53: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if(yych == '\n') goto yy45; - goto yy49; -yy52: yych = *++YYCURSOR; - goto yy53; -yy53: -#line 127 "scanner.re" + if(yych == '\n') goto yy47; + goto yy51; +yy54: yych = *++YYCURSOR; + goto yy55; +yy55: +#line 129 "scanner.re" { s->cur = cursor; yylval.regexp = strToCaseInsensitiveRE(Scanner_token(s)); return STRING; } -#line 382 "scanner.c" -yy54: ++YYCURSOR; +#line 393 "scanner.c" +yy56: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy55; -yy55: if(yych <= '!'){ - if(yych == '\n') goto yy45; - goto yy54; - } else { - if(yych <= '"') goto yy57; - if(yych != '\\') goto yy54; + goto yy57; +yy57: if(yych <= '!'){ + if(yych == '\n') goto yy47; goto yy56; + } else { + if(yych <= '"') goto yy59; + if(yych != '\\') goto yy56; + goto yy58; } -yy56: ++YYCURSOR; +yy58: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if(yych == '\n') goto yy45; - goto yy54; -yy57: yych = *++YYCURSOR; - goto yy58; -yy58: -#line 123 "scanner.re" -{ s->cur = cursor; - yylval.regexp = strToRE(Scanner_token(s)); - return STRING; } -#line 407 "scanner.c" + if(yych == '\n') goto yy47; + goto yy56; yy59: yych = *++YYCURSOR; goto yy60; yy60: -#line 120 "scanner.re" -{ s->tok = cursor; - RETURN(0); } -#line 414 "scanner.c" +#line 125 "scanner.re" +{ s->cur = cursor; + yylval.regexp = strToRE(Scanner_token(s)); + return STRING; } +#line 418 "scanner.c" yy61: yych = *++YYCURSOR; goto yy62; yy62: -#line 117 "scanner.re" +#line 122 "scanner.re" +{ s->tok = cursor; + RETURN(0); } +#line 425 "scanner.c" +yy63: yych = *++YYCURSOR; + goto yy64; +yy64: +#line 119 "scanner.re" { depth = 1; goto comment; } -#line 421 "scanner.c" -yy63: ++YYCURSOR; +#line 432 "scanner.c" +yy65: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy64; -yy64: if(yych <= '/'){ - if(yych == ',') goto yy67; - goto yy45; + goto yy66; +yy66: if(yych <= '/'){ + if(yych == ',') goto yy69; + goto yy47; } else { - if(yych <= '9') goto yy63; - if(yych != '}') goto yy45; - goto yy65; + if(yych <= '9') goto yy65; + if(yych != '}') goto yy47; + goto yy67; } -yy65: yych = *++YYCURSOR; - goto yy66; -yy66: -#line 145 "scanner.re" +yy67: yych = *++YYCURSOR; + goto yy68; +yy68: +#line 147 "scanner.re" { yylval.extop.minsize = atoi((char *)s->tok+1); yylval.extop.maxsize = atoi((char *)s->tok+1); RETURN(CLOSESIZE); } -#line 441 "scanner.c" -yy67: yych = *++YYCURSOR; - if(yych != '}') goto yy71; - goto yy68; -yy68: yych = *++YYCURSOR; - goto yy69; -yy69: -#line 153 "scanner.re" +#line 452 "scanner.c" +yy69: yych = *++YYCURSOR; + if(yych != '}') goto yy73; + goto yy70; +yy70: yych = *++YYCURSOR; + goto yy71; +yy71: +#line 155 "scanner.re" { yylval.extop.minsize = atoi((char *)s->tok+1); yylval.extop.maxsize = -1; RETURN(CLOSESIZE); } -#line 452 "scanner.c" -yy70: ++YYCURSOR; +#line 463 "scanner.c" +yy72: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy71; -yy71: if(yych <= '/') goto yy45; - if(yych <= '9') goto yy70; - if(yych != '}') goto yy45; - goto yy72; -yy72: yych = *++YYCURSOR; goto yy73; -yy73: -#line 149 "scanner.re" +yy73: if(yych <= '/') goto yy47; + if(yych <= '9') goto yy72; + if(yych != '}') goto yy47; + goto yy74; +yy74: yych = *++YYCURSOR; + goto yy75; +yy75: +#line 151 "scanner.re" { yylval.extop.minsize = atoi((char *)s->tok+1); yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)s->tok, ',')+1)); RETURN(CLOSESIZE); } -#line 468 "scanner.c" +#line 479 "scanner.c" } -#line 173 "scanner.re" +#line 175 "scanner.re" code: -#line 475 "scanner.c" +#line 486 "scanner.c" { YYCTYPE yych; unsigned int yyaccept; - goto yy74; + goto yy76; + if(yych <= '&'){ + if(yych <= '\n'){ + if(yych <= '\t') goto yy84; + goto yy82; + } else { + if(yych == '"') goto yy86; + goto yy84; + } + } else { + if(yych <= '{'){ + if(yych <= '\'') goto yy87; + if(yych <= 'z') goto yy84; + goto yy80; + } else { + if(yych != '}') goto yy84; + goto yy78; + } + } + goto yy79; + goto yy81; + goto yy83; + goto yy85; + if(yych == '\n') goto yy85; + goto yy93; + if(yych == '\n') goto yy85; + goto yy89; + goto yy89; + if(yych <= '&'){ + if(yych != '\n') goto yy88; + goto yy90; + } else { + if(yych <= '\'') goto yy84; + if(yych == '\\') goto yy91; + goto yy88; + } + if(yych == '\n') goto yy90; + goto yy88; + goto yy93; + if(yych <= '!'){ + if(yych == '\n') goto yy90; + goto yy92; + } else { + if(yych <= '"') goto yy84; + if(yych != '\\') goto yy92; + goto yy94; + } + if(yych == '\n') goto yy90; + goto yy92; ++YYCURSOR; -yy74: +yy76: if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if(yych <= '&'){ if(yych <= '\n'){ - if(yych <= '\t') goto yy82; - goto yy80; - } else { - if(yych == '"') goto yy84; + if(yych <= '\t') goto yy84; goto yy82; + } else { + if(yych == '"') goto yy86; + goto yy84; } } else { if(yych <= '{'){ - if(yych <= '\'') goto yy85; - if(yych <= 'z') goto yy82; - goto yy78; + if(yych <= '\'') goto yy87; + if(yych <= 'z') goto yy84; + goto yy80; } else { - if(yych != '}') goto yy82; - goto yy76; + if(yych != '}') goto yy84; + goto yy78; } } -yy76: yych = *++YYCURSOR; - goto yy77; -yy77: -#line 177 "scanner.re" +yy78: yych = *++YYCURSOR; + goto yy79; +yy79: +#line 179 "scanner.re" { if(--depth == 0){ s->cur = cursor; yylval.token = Token_new(Scanner_token(s), s->tline); return CODE; } goto code; } -#line 512 "scanner.c" -yy78: yych = *++YYCURSOR; - goto yy79; -yy79: -#line 183 "scanner.re" -{ ++depth; - goto code; } -#line 519 "scanner.c" +#line 523 "scanner.c" yy80: yych = *++YYCURSOR; goto yy81; yy81: #line 185 "scanner.re" +{ ++depth; + goto code; } +#line 530 "scanner.c" +yy82: yych = *++YYCURSOR; + goto yy83; +yy83: +#line 187 "scanner.re" { if(cursor == s->eof) Scanner_fatal(s, "missing '}'"); s->pos = cursor; s->cline++; goto code; } -#line 528 "scanner.c" -yy82: yych = *++YYCURSOR; - goto yy83; -yy83: -#line 189 "scanner.re" +#line 539 "scanner.c" +yy84: yych = *++YYCURSOR; + goto yy85; +yy85: +#line 191 "scanner.re" { goto code; } -#line 534 "scanner.c" -yy84: yyaccept = 0; +#line 545 "scanner.c" +yy86: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == '\n') goto yy83; - goto yy91; -yy85: yyaccept = 0; + if(yych == '\n') goto yy85; + goto yy93; +yy87: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych == '\n') goto yy83; - goto yy87; -yy86: ++YYCURSOR; + if(yych == '\n') goto yy85; + goto yy89; +yy88: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy87; -yy87: if(yych <= '&'){ - if(yych != '\n') goto yy86; - goto yy88; + goto yy89; +yy89: if(yych <= '&'){ + if(yych != '\n') goto yy88; + goto yy90; } else { - if(yych <= '\'') goto yy82; - if(yych == '\\') goto yy89; - goto yy86; + if(yych <= '\'') goto yy84; + if(yych == '\\') goto yy91; + goto yy88; } -yy88: YYCURSOR = YYMARKER; +yy90: YYCURSOR = YYMARKER; switch(yyaccept){ - case 0: goto yy83; + case 0: goto yy85; } -yy89: ++YYCURSOR; +yy91: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if(yych == '\n') goto yy88; - goto yy86; -yy90: ++YYCURSOR; + if(yych == '\n') goto yy90; + goto yy88; +yy92: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy91; -yy91: if(yych <= '!'){ - if(yych == '\n') goto yy88; - goto yy90; - } else { - if(yych <= '"') goto yy82; - if(yych != '\\') goto yy90; + goto yy93; +yy93: if(yych <= '!'){ + if(yych == '\n') goto yy90; goto yy92; + } else { + if(yych <= '"') goto yy84; + if(yych != '\\') goto yy92; + goto yy94; } -yy92: ++YYCURSOR; +yy94: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - if(yych == '\n') goto yy88; - goto yy90; + if(yych == '\n') goto yy90; + goto yy92; } -#line 190 "scanner.re" +#line 192 "scanner.re" comment: -#line 587 "scanner.c" +#line 598 "scanner.c" { YYCTYPE yych; unsigned int yyaccept; - goto yy93; + goto yy95; + if(yych <= ')'){ + if(yych == '\n') goto yy100; + goto yy102; + } else { + if(yych <= '*') goto yy97; + if(yych == '/') goto yy99; + goto yy102; + } + if(yych == '/') goto yy105; + goto yy98; + if(yych == '*') goto yy103; + goto yy98; + goto yy101; + goto yy98; + goto yy104; + goto yy106; ++YYCURSOR; -yy93: +yy95: if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; if(yych <= ')'){ - if(yych == '\n') goto yy98; - goto yy100; + if(yych == '\n') goto yy100; + goto yy102; } else { - if(yych <= '*') goto yy95; - if(yych == '/') goto yy97; - goto yy100; + if(yych <= '*') goto yy97; + if(yych == '/') goto yy99; + goto yy102; } -yy95: yych = *++YYCURSOR; - if(yych == '/') goto yy103; - goto yy96; -yy96: -#line 204 "scanner.re" -{ goto comment; } -#line 610 "scanner.c" yy97: yych = *++YYCURSOR; - if(yych == '*') goto yy101; - goto yy96; -yy98: yych = *++YYCURSOR; - goto yy99; -yy99: -#line 200 "scanner.re" + if(yych == '/') goto yy105; + goto yy98; +yy98: +#line 206 "scanner.re" +{ goto comment; } +#line 621 "scanner.c" +yy99: yych = *++YYCURSOR; + if(yych == '*') goto yy103; + goto yy98; +yy100: yych = *++YYCURSOR; + goto yy101; +yy101: +#line 202 "scanner.re" { if(cursor == s->eof) RETURN(0); s->tok = s->pos = cursor; s->cline++; goto comment; } -#line 622 "scanner.c" -yy100: yych = *++YYCURSOR; - goto yy96; -yy101: yych = *++YYCURSOR; - goto yy102; -yy102: -#line 198 "scanner.re" -{ ++depth; - goto comment; } -#line 631 "scanner.c" +#line 633 "scanner.c" +yy102: yych = *++YYCURSOR; + goto yy98; yy103: yych = *++YYCURSOR; goto yy104; yy104: -#line 194 "scanner.re" +#line 200 "scanner.re" +{ ++depth; + goto comment; } +#line 642 "scanner.c" +yy105: yych = *++YYCURSOR; + goto yy106; +yy106: +#line 196 "scanner.re" { if(--depth == 0) goto scan; else goto comment; } -#line 640 "scanner.c" +#line 651 "scanner.c" } -#line 205 "scanner.re" +#line 207 "scanner.re" } diff --git a/tools/re2c/scanner.re b/tools/re2c/scanner.re index 980c2685..676d856a 100644 --- a/tools/re2c/scanner.re +++ b/tools/re2c/scanner.re @@ -58,7 +58,7 @@ fill(Scanner *s, unsigned char *cursor) s->bot = buf; } if((cnt = fread(s->lim, 1, BSIZE, s->in)) != BSIZE){ - s->eof = &s->lim[cnt]; *s->eof++ = '\n'; + s->eof = &s->lim[cnt]; *s->eof++ = '\0'; } s->lim += cnt; } @@ -66,6 +66,7 @@ fill(Scanner *s, unsigned char *cursor) } /*!re2c +zero = "\000"; any = [\000-\377]; dot = any \ [\n]; esc = dot \ [\\]; @@ -91,11 +92,12 @@ echo: "/*!re2c" { fwrite(s->tok, 1, &cursor[-7] - s->tok, out); s->tok = cursor; RETURN(1); } - "\n" { if(cursor == s->eof) RETURN(0); - fwrite(s->tok, 1, cursor - s->tok, out); + "\n" { fwrite(s->tok, 1, cursor - s->tok, out); s->tok = s->pos = cursor; s->cline++; oline++; goto echo; } - any { goto echo; } + zero { fwrite(s->tok, 1, cursor - s->tok - 1, out); /* -1 so we don't write out the \0 */ + if(cursor == s->eof) { RETURN(0); } } + any { goto echo; } */ } -- 2.40.0