Range_out(o, r->next);
}
-Range *doUnion(Range *r1, Range *r2){
+static Range *doUnion(Range *r1, Range *r2){
Range *r, **rP = &r;
for(;;){
Range *s;
return r;
}
-Range *doDiff(Range *r1, Range *r2){
+static Range *doDiff(Range *r1, Range *r2){
Range *r, *s, **rP = &r;
for(; r1; r1 = r1->next){
uint lb = r1->lb;
return r? RegExp_new_MatchOp(r) : RegExp_new_NullOp();
}
-RegExp *doAlt(RegExp *e1, RegExp *e2){
+static RegExp *doAlt(RegExp *e1, RegExp *e2){
if(!e1)
return e2;
if(!e2)
return doAlt(merge(m1, m2), doAlt(e1, e2));
}
-uchar unescape(SubStr *s){
+static uchar unescape(SubStr *s){
uchar c;
uchar v;
s->len--;
}
}
-Range *getRange(SubStr *s){
+static Range *getRange(SubStr *s){
uchar lb = unescape(s), ub;
if(s->len < 2 || *s->str != '-'){
ub = lb;
return Range_new(lb, ub+1);
}
-RegExp *matchChar(uint c){
+static RegExp *matchChar(uint c){
return RegExp_new_MatchOp(Range_new(c, c+1));
}
return r;
}
-extern void printSpan(FILE *, uint, uint);
-
-void optimize(Ins *i){
+static void optimize(Ins *i){
while(!isMarked(i)){
mark(i);
if(i->i.tag == CHAR){
g->nSpans = s - g->span;
}
-void doGen(Go *g, State *s, uchar *bm, uchar m){
+static void doGen(Go *g, State *s, uchar *bm, uchar m){
Span *b = g->span, *e = &b[g->nSpans];
uint lb = 0;
for(; b < e; ++b){
lb = b->ub;
}
}
-
-void prt(FILE *o, Go *g, State *s){
+#if 0
+static void prt(FILE *o, Go *g, State *s){
Span *b = g->span, *e = &b[g->nSpans];
uint lb = 0;
for(; b < e; ++b){
lb = b->ub;
}
}
-
-int matches(Go *g1, State *s1, Go *g2, State *s2){
+#endif
+static int matches(Go *g1, State *s1, Go *g2, State *s2){
Span *b1 = g1->span, *e1 = &b1[g1->nSpans];
uint lb1 = 0;
Span *b2 = g2->span, *e2 = &b2[g2->nSpans];
}
#endif
-void genGoTo(FILE *o, State *to){
+static void genGoTo(FILE *o, State *to){
fprintf(o, "\tgoto yy%u;\n", to->label);
}
-void genIf(FILE *o, const char *cmp, uint v){
+static void genIf(FILE *o, const char *cmp, uint v){
fprintf(o, "\tif(yych %s '", cmp);
prtCh(o, v);
fputs("')", o);
}
-void indent(FILE *o, uint i){
+static void indent(FILE *o, uint i){
while(i-- > 0)
fputc('\t', o);
}
return a;
}
-void doLinear(FILE *o, uint i, Span *s, uint n, State *next){
+static void doLinear(FILE *o, uint i, Span *s, uint n, State *next){
for(;;){
State *bg = s[0].to;
while(n >= 3 && s[2].to == bg && (s[1].ub - s[0].ub) == 1){
doLinear(o, 0, g->span, g->nSpans, next);
}
-void genCases(FILE *o, uint lb, Span *s){
+static void genCases(FILE *o, uint lb, Span *s){
if(lb < s->ub){
for(;;){
fputs("\tcase '", o); prtCh(o, lb); fputs("':", o);
}
}
-void doBinary(FILE *o, uint i, Span *s, uint n, State *next){
+static void doBinary(FILE *o, uint i, Span *s, uint n, State *next){
if(n <= 4){
doLinear(o, i, s, n, next);
} else {
} while(*s->top != x);
}
-uint maxDist(State *s){
+static uint maxDist(State *s){
uint mm = 0, i;
for(i = 0; i < s->go.nSpans; ++i){
State *t = s->go.span[i].to;
return mm;
}
-void calcDepth(State *head){
+static void calcDepth(State *head){
State *t, *s;
for(s = head; s; s = s->next){
if(s->link == s){
s->rule = NULL;
for(iP = s->kernel; (i = *iP); ++iP){
if(i->i.tag == CHAR){
- Ins *j;
- for(j = i + 1; j < (Ins*) i->i.link; ++j){
- if(!(j->c.link = goTo[j->c.value - lb].to))
- goTo[nGoTos++].ch = j->c.value;
- goTo[j->c.value - lb].to = j;
+ Ins *j2;
+ for(j2 = i + 1; j2 < (Ins*) i->i.link; ++j2){
+ if(!(j2->c.link = goTo[j2->c.value - lb].to))
+ goTo[nGoTos++].ch = j2->c.value;
+ goTo[j2->c.value - lb].to = j2;
}
} else if(i->i.tag == TERM){
if(!s->rule || ((RegExp *)i->i.link)->d.RuleOp.accept < s->rule->d.RuleOp.accept)
#include "tools/re2c/basics.h"
-extern char *fileName;
+extern const char *fileName;
extern int sFlag;
extern int bFlag;
#include <stdlib.h>
#include "tools/re2c/globals.h"
#include "tools/re2c/parse.h"
-int yyparse();
-int yylex();
-void yyerror(char*);
+int yylex(void);
+void yyerror(const char*);
+
+static char *mystrdup(const char *str);
static uint accept;
static RegExp *spec;
%%
-void yyerror(char* s){
+void yyerror(const char* s){
Scanner_fatal(in, s);
}
return Scanner_scan(in);
}
-char *
+static char *
mystrdup(const char *str)
{
size_t len;
#include "tools/re2c/parse.h"
#include "tools/re2c/dfa.h"
-char *fileName;
+const char *fileName;
int sFlag = 0;
int bFlag = 0;
-/* Generated by re2c 0.9.1-C on Fri Aug 9 17:42:28 2002
+/* Generated by re2c 0.9.1-C on Thu Aug 15 22:11:10 2002
*/
-#line 1 "scanner.re"
+#line 1 "tools/re2c/scanner.re"
#include <config.h>
#include <stdlib.h>
#include "tools/re2c/parse.h"
#include "re2c-parser.h"
-extern YYSTYPE yylval;
-
#define BSIZE 8192
#define YYCTYPE uchar
return cursor;
}
-#line 76
+#line 74
int
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '*') goto yy7;
yy3:
-#line 92
+#line 90
{ goto echo; }
yy4: yych = *++YYCURSOR;
-#line 88
+#line 86
{ 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;
yych = *++YYCURSOR;
-#line 85
+#line 83
{ fwrite(s->tok, 1, &cursor[-7] - s->tok, out);
s->tok = cursor;
RETURN(1); }
}
-#line 93
+#line 91
}
}
yy17: yych = *++YYCURSOR;
-#line 108
+#line 106
{ depth = 1;
goto code;
}
yy19: yych = *++YYCURSOR;
if(yych == '*') goto yy54;
yy20:
-#line 127
+#line 125
{ RETURN(*s->tok); }
yy21: yych = *++YYCURSOR;
if(yych == '/') goto yy52;
yy22:
-#line 129
+#line 127
{ yylval.op = *s->tok;
RETURN(CLOSE); }
yy23: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy48;
yy24:
-#line 120
+#line 118
{ Scanner_fatal(s, "bad string"); }
yy25: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy42;
yy26:
-#line 125
+#line 123
{ Scanner_fatal(s, "bad character constant"); }
yy27: yych = *++YYCURSOR;
goto yy20;
yy29: yych = *++YYCURSOR;
goto yy40;
yy30:
-#line 132
+#line 130
{ SubStr substr;
s->cur = cursor;
substr = Scanner_token(s);
yy31: yych = *++YYCURSOR;
goto yy38;
yy32:
-#line 138
+#line 136
{ goto scan; }
yy33: yych = *++YYCURSOR;
-#line 140
+#line 138
{ if(cursor == s->eof) RETURN(0);
s->pos = cursor; s->cline++;
goto scan;
}
yy35: yych = *++YYCURSOR;
-#line 145
+#line 143
{ fprintf(stderr, "unexpected character: '%c'\n", *s->tok);
goto scan;
}
goto yy41;
yy45: yych = *++YYCURSOR;
-#line 122
+#line 120
{ s->cur = cursor;
yylval.regexp = ranToRE(Scanner_token(s));
return RANGE; }
goto yy47;
yy50: yych = *++YYCURSOR;
-#line 117
+#line 115
{ s->cur = cursor;
yylval.regexp = strToRE(Scanner_token(s));
return STRING; }
yy52: yych = *++YYCURSOR;
-#line 114
+#line 112
{ s->tok = cursor;
RETURN(0); }
yy54: yych = *++YYCURSOR;
-#line 111
+#line 109
{ depth = 1;
goto comment; }
}
-#line 148
+#line 146
code:
}
yych = *++YYCURSOR;
-#line 152
+#line 150
{ if(--depth == 0){
s->cur = cursor;
yylval.token = Token_new(Scanner_token(s), s->tline);
goto code; }
yy60: yych = *++YYCURSOR;
-#line 158
+#line 156
{ ++depth;
goto code; }
yy62: yych = *++YYCURSOR;
-#line 160
+#line 158
{ if(cursor == s->eof) Scanner_fatal(s, "missing '}'");
s->pos = cursor; s->cline++;
goto code;
}
yy64: yych = *++YYCURSOR;
yy65:
-#line 164
+#line 162
{ goto code; }
yy66: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '\n') goto yy70;
goto yy72;
}
-#line 165
+#line 163
comment:
yy77: yych = *++YYCURSOR;
if(yych == '/') goto yy85;
yy78:
-#line 179
+#line 177
{ goto comment; }
yy79: yych = *++YYCURSOR;
if(yych == '*') goto yy83;
goto yy78;
yy80: yych = *++YYCURSOR;
-#line 175
+#line 173
{ if(cursor == s->eof) RETURN(0);
s->tok = s->pos = cursor; s->cline++;
goto comment;
goto yy78;
yy83: yych = *++YYCURSOR;
-#line 173
+#line 171
{ ++depth;
goto comment; }
yy85: yych = *++YYCURSOR;
-#line 169
+#line 167
{ if(--depth == 0)
goto scan;
else
goto comment; }
}
-#line 180
+#line 178
}
void
-Scanner_fatal(Scanner *s, char *msg)
+Scanner_fatal(Scanner *s, const char *msg)
{
fprintf(stderr, "line %d, column %d: %s\n", s->tline, s->tchar + 1, msg);
exit(1);
int Scanner_echo(Scanner*, FILE *);
int Scanner_scan(Scanner*);
-void Scanner_fatal(Scanner*, char*);
+void Scanner_fatal(Scanner*, const char*);
static inline SubStr Scanner_token(Scanner*);
static inline uint Scanner_line(Scanner*);
#include "tools/re2c/parse.h"
#include "re2c-parser.h"
-extern YYSTYPE yylval;
-
#define BSIZE 8192
#define YYCTYPE uchar
}
void
-Scanner_fatal(Scanner *s, char *msg)
+Scanner_fatal(Scanner *s, const char *msg)
{
fprintf(stderr, "line %d, column %d: %s\n", s->tline, s->tchar + 1, msg);
exit(1);