+++ /dev/null
-/* $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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#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 <file>\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;
-}
#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
*/
}
#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)
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++;
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
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);
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;
}
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);
}
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;
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);
-/* 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 <stdlib.h>
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
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"
}
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"
}