-/* Generated by re2c 0.9.1-C on Mon Apr 8 22:47:58 2002 */
+/* Generated by re2c 0.9.1-C on Tue Aug 6 18:54:36 2002
+ */
#line 1 "scanner.re"
+#include <config.h>
+
#include <stdlib.h>
#include <string.h>
#include "scanner.h"
+#include "parse.h"
#include "parser.h"
-#include "y.tab.h"
extern YYSTYPE yylval;
s->pos = &buf[s->pos - s->bot];
s->lim = &buf[s->lim - s->bot];
s->top = &s->lim[BSIZE];
- free(s->bot);
+ if (s->bot)
+ free(s->bot);
s->bot = buf;
}
if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){
return cursor;
}
-#line 73
+#line 76
int
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '*') goto yy7;
yy3:
-#line 89
+#line 92
{ goto echo; }
yy4: yych = *++YYCURSOR;
yy5:
-#line 85
+#line 88
{ if(cursor == s->eof) RETURN(0);
fwrite(s->tok, 1, cursor - s->tok, out);
s->tok = s->pos = cursor; s->cline++;
if(yych != 'c') goto yy8;
yy13: yych = *++YYCURSOR;
yy14:
-#line 82
+#line 85
{ fwrite(s->tok, 1, &cursor[-7] - s->tok, out);
s->tok = cursor;
RETURN(1); }
}
-#line 90
+#line 93
}
}
yy17: yych = *++YYCURSOR;
yy18:
-#line 105
+#line 108
{ depth = 1;
goto code;
}
yy19: yych = *++YYCURSOR;
if(yych == '*') goto yy54;
yy20:
-#line 124
+#line 127
{ RETURN(*s->tok); }
yy21: yych = *++YYCURSOR;
if(yych == '/') goto yy52;
yy22:
-#line 126
+#line 129
{ yylval.op = *s->tok;
RETURN(CLOSE); }
yy23: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy48;
yy24:
-#line 117
+#line 120
{ Scanner_fatal(s, "bad string"); }
yy25: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy42;
yy26:
-#line 122
+#line 125
{ Scanner_fatal(s, "bad character constant"); }
yy27: yych = *++YYCURSOR;
goto yy20;
yy29: yych = *++YYCURSOR;
goto yy40;
yy30:
-#line 129
+#line 132
{ SubStr substr;
s->cur = cursor;
substr = Scanner_token(s);
yy31: yych = *++YYCURSOR;
goto yy38;
yy32:
-#line 135
+#line 138
{ goto scan; }
yy33: yych = *++YYCURSOR;
yy34:
-#line 137
+#line 140
{ if(cursor == s->eof) RETURN(0);
s->pos = cursor; s->cline++;
goto scan;
}
yy35: yych = *++YYCURSOR;
yy36:
-#line 142
+#line 145
{ fprintf(stderr, "unexpected character: '%c'\n", *s->tok);
goto scan;
}
goto yy41;
yy45: yych = *++YYCURSOR;
yy46:
-#line 119
+#line 122
{ s->cur = cursor;
yylval.regexp = ranToRE(Scanner_token(s));
return RANGE; }
goto yy47;
yy50: yych = *++YYCURSOR;
yy51:
-#line 114
+#line 117
{ s->cur = cursor;
yylval.regexp = strToRE(Scanner_token(s));
return STRING; }
yy52: yych = *++YYCURSOR;
yy53:
-#line 111
+#line 114
{ s->tok = cursor;
RETURN(0); }
yy54: yych = *++YYCURSOR;
yy55:
-#line 108
+#line 111
{ depth = 1;
goto comment; }
}
-#line 145
+#line 148
code:
}
yy58: yych = *++YYCURSOR;
yy59:
-#line 149
+#line 152
{ if(--depth == 0){
s->cur = cursor;
yylval.token = Token_new(Scanner_token(s), s->tline);
goto code; }
yy60: yych = *++YYCURSOR;
yy61:
-#line 155
+#line 158
{ ++depth;
goto code; }
yy62: yych = *++YYCURSOR;
yy63:
-#line 157
+#line 160
{ if(cursor == s->eof) Scanner_fatal(s, "missing '}'");
s->pos = cursor; s->cline++;
goto code;
}
yy64: yych = *++YYCURSOR;
yy65:
-#line 161
+#line 164
{ goto code; }
yy66: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '\n') goto yy70;
goto yy72;
}
-#line 162
+#line 165
comment:
yy77: yych = *++YYCURSOR;
if(yych == '/') goto yy85;
yy78:
-#line 176
+#line 179
{ goto comment; }
yy79: yych = *++YYCURSOR;
if(yych == '*') goto yy83;
goto yy78;
yy80: yych = *++YYCURSOR;
yy81:
-#line 172
+#line 175
{ if(cursor == s->eof) RETURN(0);
s->tok = s->pos = cursor; s->cline++;
goto comment;
goto yy78;
yy83: yych = *++YYCURSOR;
yy84:
-#line 170
+#line 173
{ ++depth;
goto comment; }
yy85: yych = *++YYCURSOR;
yy86:
-#line 166
+#line 169
{ if(--depth == 0)
goto scan;
else
goto comment; }
}
-#line 177
+#line 180
}
void
State_delete(State *s)
{
- free(s->kernel);
- free(s->go.span);
+ if (s->kernel)
+ free(s->kernel);
+ if (s->go.span)
+ free(s->go.span);
free(s);
}
-/* Generated by re2c 0.9.1-C on Thu Apr 11 22:20:20 2002
+/* Generated by re2c 0.9.1-C on Tue Aug 6 18:54:36 2002
*/
#line 1 "scanner.re"
#include <config.h>
s->pos = &buf[s->pos - s->bot];
s->lim = &buf[s->lim - s->bot];
s->top = &s->lim[BSIZE];
- free(s->bot);
+ if (s->bot)
+ free(s->bot);
s->bot = buf;
}
if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){
return cursor;
}
-#line 75
+#line 76
int
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '*') goto yy7;
yy3:
-#line 91
+#line 92
{ goto echo; }
yy4: yych = *++YYCURSOR;
yy5:
-#line 87
+#line 88
{ if(cursor == s->eof) RETURN(0);
fwrite(s->tok, 1, cursor - s->tok, out);
s->tok = s->pos = cursor; s->cline++;
if(yych != 'c') goto yy8;
yy13: yych = *++YYCURSOR;
yy14:
-#line 84
+#line 85
{ fwrite(s->tok, 1, &cursor[-7] - s->tok, out);
s->tok = cursor;
RETURN(1); }
}
-#line 92
+#line 93
}
}
yy17: yych = *++YYCURSOR;
yy18:
-#line 107
+#line 108
{ depth = 1;
goto code;
}
yy19: yych = *++YYCURSOR;
if(yych == '*') goto yy54;
yy20:
-#line 126
+#line 127
{ RETURN(*s->tok); }
yy21: yych = *++YYCURSOR;
if(yych == '/') goto yy52;
yy22:
-#line 128
+#line 129
{ yylval.op = *s->tok;
RETURN(CLOSE); }
yy23: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy48;
yy24:
-#line 119
+#line 120
{ Scanner_fatal(s, "bad string"); }
yy25: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy42;
yy26:
-#line 124
+#line 125
{ Scanner_fatal(s, "bad character constant"); }
yy27: yych = *++YYCURSOR;
goto yy20;
yy29: yych = *++YYCURSOR;
goto yy40;
yy30:
-#line 131
+#line 132
{ SubStr substr;
s->cur = cursor;
substr = Scanner_token(s);
yy31: yych = *++YYCURSOR;
goto yy38;
yy32:
-#line 137
+#line 138
{ goto scan; }
yy33: yych = *++YYCURSOR;
yy34:
-#line 139
+#line 140
{ if(cursor == s->eof) RETURN(0);
s->pos = cursor; s->cline++;
goto scan;
}
yy35: yych = *++YYCURSOR;
yy36:
-#line 144
+#line 145
{ fprintf(stderr, "unexpected character: '%c'\n", *s->tok);
goto scan;
}
goto yy41;
yy45: yych = *++YYCURSOR;
yy46:
-#line 121
+#line 122
{ s->cur = cursor;
yylval.regexp = ranToRE(Scanner_token(s));
return RANGE; }
goto yy47;
yy50: yych = *++YYCURSOR;
yy51:
-#line 116
+#line 117
{ s->cur = cursor;
yylval.regexp = strToRE(Scanner_token(s));
return STRING; }
yy52: yych = *++YYCURSOR;
yy53:
-#line 113
+#line 114
{ s->tok = cursor;
RETURN(0); }
yy54: yych = *++YYCURSOR;
yy55:
-#line 110
+#line 111
{ depth = 1;
goto comment; }
}
-#line 147
+#line 148
code:
}
yy58: yych = *++YYCURSOR;
yy59:
-#line 151
+#line 152
{ if(--depth == 0){
s->cur = cursor;
yylval.token = Token_new(Scanner_token(s), s->tline);
goto code; }
yy60: yych = *++YYCURSOR;
yy61:
-#line 157
+#line 158
{ ++depth;
goto code; }
yy62: yych = *++YYCURSOR;
yy63:
-#line 159
+#line 160
{ if(cursor == s->eof) Scanner_fatal(s, "missing '}'");
s->pos = cursor; s->cline++;
goto code;
}
yy64: yych = *++YYCURSOR;
yy65:
-#line 163
+#line 164
{ goto code; }
yy66: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '\n') goto yy70;
goto yy72;
}
-#line 164
+#line 165
comment:
yy77: yych = *++YYCURSOR;
if(yych == '/') goto yy85;
yy78:
-#line 178
+#line 179
{ goto comment; }
yy79: yych = *++YYCURSOR;
if(yych == '*') goto yy83;
goto yy78;
yy80: yych = *++YYCURSOR;
yy81:
-#line 174
+#line 175
{ if(cursor == s->eof) RETURN(0);
s->tok = s->pos = cursor; s->cline++;
goto comment;
goto yy78;
yy83: yych = *++YYCURSOR;
yy84:
-#line 172
+#line 173
{ ++depth;
goto comment; }
yy85: yych = *++YYCURSOR;
yy86:
-#line 168
+#line 169
{ if(--depth == 0)
goto scan;
else
goto comment; }
}
-#line 179
+#line 180
}
s->pos = &buf[s->pos - s->bot];
s->lim = &buf[s->lim - s->bot];
s->top = &s->lim[BSIZE];
- free(s->bot);
+ if (s->bot)
+ free(s->bot);
s->bot = buf;
}
if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){