Warning cleanups.

svn path=/trunk/yasm/; revision=699
0.3
Peter Johnson 23 years ago
parent 5f02a6f596
commit 582c5ea3d7
  1. 16
      tools/re2c/actions.c
  2. 26
      tools/re2c/code.c
  3. 10
      tools/re2c/dfa.c
  4. 2
      tools/re2c/globals.h
  5. 11
      tools/re2c/re2c-parser.y
  6. 2
      tools/re2c/re2c.c
  7. 66
      tools/re2c/scanner.c
  8. 2
      tools/re2c/scanner.h
  9. 4
      tools/re2c/scanner.re

@ -310,7 +310,7 @@ Range_out(FILE *o, const Range *r)
Range_out(o, r->next); Range_out(o, r->next);
} }
Range *doUnion(Range *r1, Range *r2){ static Range *doUnion(Range *r1, Range *r2){
Range *r, **rP = &r; Range *r, **rP = &r;
for(;;){ for(;;){
Range *s; Range *s;
@ -357,7 +357,7 @@ Range *doUnion(Range *r1, Range *r2){
return r; return r;
} }
Range *doDiff(Range *r1, Range *r2){ static Range *doDiff(Range *r1, Range *r2){
Range *r, *s, **rP = &r; Range *r, *s, **rP = &r;
for(; r1; r1 = r1->next){ for(; r1; r1 = r1->next){
uint lb = r1->lb; uint lb = r1->lb;
@ -397,7 +397,7 @@ RegExp *mkDiff(RegExp *e1, RegExp *e2){
return r? RegExp_new_MatchOp(r) : RegExp_new_NullOp(); return r? RegExp_new_MatchOp(r) : RegExp_new_NullOp();
} }
RegExp *doAlt(RegExp *e1, RegExp *e2){ static RegExp *doAlt(RegExp *e1, RegExp *e2){
if(!e1) if(!e1)
return e2; return e2;
if(!e2) if(!e2)
@ -423,7 +423,7 @@ RegExp *mkAlt(RegExp *e1, RegExp *e2){
return doAlt(merge(m1, m2), doAlt(e1, e2)); return doAlt(merge(m1, m2), doAlt(e1, e2));
} }
uchar unescape(SubStr *s){ static uchar unescape(SubStr *s){
uchar c; uchar c;
uchar v; uchar v;
s->len--; s->len--;
@ -456,7 +456,7 @@ uchar unescape(SubStr *s){
} }
} }
Range *getRange(SubStr *s){ static Range *getRange(SubStr *s){
uchar lb = unescape(s), ub; uchar lb = unescape(s), ub;
if(s->len < 2 || *s->str != '-'){ if(s->len < 2 || *s->str != '-'){
ub = lb; ub = lb;
@ -471,7 +471,7 @@ Range *getRange(SubStr *s){
return Range_new(lb, ub+1); 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 RegExp_new_MatchOp(Range_new(c, c+1));
} }
@ -510,9 +510,7 @@ RegExp_new_RuleOp(RegExp *e, RegExp *c, Token *t, uint a)
return r; return r;
} }
extern void printSpan(FILE *, uint, uint); static void optimize(Ins *i){
void optimize(Ins *i){
while(!isMarked(i)){ while(!isMarked(i)){
mark(i); mark(i);
if(i->i.tag == CHAR){ if(i->i.tag == CHAR){

@ -46,7 +46,7 @@ void Go_unmap(Go *g, Go *base, State *x){
g->nSpans = s - g->span; 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]; Span *b = g->span, *e = &b[g->nSpans];
uint lb = 0; uint lb = 0;
for(; b < e; ++b){ for(; b < e; ++b){
@ -55,8 +55,8 @@ void doGen(Go *g, State *s, uchar *bm, uchar m){
lb = b->ub; lb = b->ub;
} }
} }
#if 0
void prt(FILE *o, Go *g, State *s){ static void prt(FILE *o, Go *g, State *s){
Span *b = g->span, *e = &b[g->nSpans]; Span *b = g->span, *e = &b[g->nSpans];
uint lb = 0; uint lb = 0;
for(; b < e; ++b){ for(; b < e; ++b){
@ -65,8 +65,8 @@ void prt(FILE *o, Go *g, State *s){
lb = b->ub; lb = b->ub;
} }
} }
#endif
int matches(Go *g1, State *s1, Go *g2, State *s2){ static int matches(Go *g1, State *s1, Go *g2, State *s2){
Span *b1 = g1->span, *e1 = &b1[g1->nSpans]; Span *b1 = g1->span, *e1 = &b1[g1->nSpans];
uint lb1 = 0; uint lb1 = 0;
Span *b2 = g2->span, *e2 = &b2[g2->nSpans]; Span *b2 = g2->span, *e2 = &b2[g2->nSpans];
@ -165,17 +165,17 @@ void BitMap_stats(void){
} }
#endif #endif
void genGoTo(FILE *o, State *to){ static void genGoTo(FILE *o, State *to){
fprintf(o, "\tgoto yy%u;\n", to->label); 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); fprintf(o, "\tif(yych %s '", cmp);
prtCh(o, v); prtCh(o, v);
fputs("')", o); fputs("')", o);
} }
void indent(FILE *o, uint i){ static void indent(FILE *o, uint i){
while(i-- > 0) while(i-- > 0)
fputc('\t', o); fputc('\t', o);
} }
@ -263,7 +263,7 @@ Action_new_Accept(State *x, uint n, uint *s, State **r)
return a; 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(;;){ for(;;){
State *bg = s[0].to; State *bg = s[0].to;
while(n >= 3 && s[2].to == bg && (s[1].ub - s[0].ub) == 1){ while(n >= 3 && s[2].to == bg && (s[1].ub - s[0].ub) == 1){
@ -295,7 +295,7 @@ Go_genLinear(Go *g, FILE *o, State *next){
doLinear(o, 0, g->span, g->nSpans, next); 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){ if(lb < s->ub){
for(;;){ for(;;){
fputs("\tcase '", o); prtCh(o, lb); fputs("':", o); fputs("\tcase '", o); prtCh(o, lb); fputs("':", o);
@ -346,7 +346,7 @@ Go_genSwitch(Go *g, FILE *o, State *next){
} }
} }
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){ if(n <= 4){
doLinear(o, i, s, n, next); doLinear(o, i, s, n, next);
} else { } else {
@ -524,7 +524,7 @@ static void SCC_traverse(SCC *s, State *x){
} while(*s->top != x); } while(*s->top != x);
} }
uint maxDist(State *s){ static uint maxDist(State *s){
uint mm = 0, i; uint mm = 0, i;
for(i = 0; i < s->go.nSpans; ++i){ for(i = 0; i < s->go.nSpans; ++i){
State *t = s->go.span[i].to; State *t = s->go.span[i].to;
@ -539,7 +539,7 @@ uint maxDist(State *s){
return mm; return mm;
} }
void calcDepth(State *head){ static void calcDepth(State *head){
State *t, *s; State *t, *s;
for(s = head; s; s = s->next){ for(s = head; s; s = s->next){
if(s->link == s){ if(s->link == s){

@ -146,11 +146,11 @@ DFA_new(Ins *ins, uint ni, uint lb, uint ub, Char *rep)
s->rule = NULL; s->rule = NULL;
for(iP = s->kernel; (i = *iP); ++iP){ for(iP = s->kernel; (i = *iP); ++iP){
if(i->i.tag == CHAR){ if(i->i.tag == CHAR){
Ins *j; Ins *j2;
for(j = i + 1; j < (Ins*) i->i.link; ++j){ for(j2 = i + 1; j2 < (Ins*) i->i.link; ++j2){
if(!(j->c.link = goTo[j->c.value - lb].to)) if(!(j2->c.link = goTo[j2->c.value - lb].to))
goTo[nGoTos++].ch = j->c.value; goTo[nGoTos++].ch = j2->c.value;
goTo[j->c.value - lb].to = j; goTo[j2->c.value - lb].to = j2;
} }
} else if(i->i.tag == TERM){ } else if(i->i.tag == TERM){
if(!s->rule || ((RegExp *)i->i.link)->d.RuleOp.accept < s->rule->d.RuleOp.accept) if(!s->rule || ((RegExp *)i->i.link)->d.RuleOp.accept < s->rule->d.RuleOp.accept)

@ -3,7 +3,7 @@
#include "tools/re2c/basics.h" #include "tools/re2c/basics.h"
extern char *fileName; extern const char *fileName;
extern int sFlag; extern int sFlag;
extern int bFlag; extern int bFlag;

@ -7,9 +7,10 @@
#include <stdlib.h> #include <stdlib.h>
#include "tools/re2c/globals.h" #include "tools/re2c/globals.h"
#include "tools/re2c/parse.h" #include "tools/re2c/parse.h"
int yyparse(); int yylex(void);
int yylex(); void yyerror(const char*);
void yyerror(char*);
static char *mystrdup(const char *str);
static uint accept; static uint accept;
static RegExp *spec; static RegExp *spec;
@ -120,7 +121,7 @@ primary : ID
%% %%
void yyerror(char* s){ void yyerror(const char* s){
Scanner_fatal(in, s); Scanner_fatal(in, s);
} }
@ -128,7 +129,7 @@ int yylex(){
return Scanner_scan(in); return Scanner_scan(in);
} }
char * static char *
mystrdup(const char *str) mystrdup(const char *str)
{ {
size_t len; size_t len;

@ -7,7 +7,7 @@
#include "tools/re2c/parse.h" #include "tools/re2c/parse.h"
#include "tools/re2c/dfa.h" #include "tools/re2c/dfa.h"
char *fileName; const char *fileName;
int sFlag = 0; int sFlag = 0;
int bFlag = 0; int bFlag = 0;

@ -1,6 +1,6 @@
/* 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 <config.h>
#include <stdlib.h> #include <stdlib.h>
@ -9,8 +9,6 @@
#include "tools/re2c/parse.h" #include "tools/re2c/parse.h"
#include "re2c-parser.h" #include "re2c-parser.h"
extern YYSTYPE yylval;
#define BSIZE 8192 #define BSIZE 8192
#define YYCTYPE uchar #define YYCTYPE uchar
@ -67,7 +65,7 @@ fill(Scanner *s, uchar *cursor)
return cursor; return cursor;
} }
#line 76 #line 74
int int
@ -90,11 +88,11 @@ yy0:
yych = *(YYMARKER = ++YYCURSOR); yych = *(YYMARKER = ++YYCURSOR);
if(yych == '*') goto yy7; if(yych == '*') goto yy7;
yy3: yy3:
#line 92 #line 90
{ goto echo; } { goto echo; }
yy4: yych = *++YYCURSOR; yy4: yych = *++YYCURSOR;
#line 88 #line 86
{ if(cursor == s->eof) RETURN(0); { if(cursor == s->eof) RETURN(0);
fwrite(s->tok, 1, cursor - s->tok, out); fwrite(s->tok, 1, cursor - s->tok, out);
s->tok = s->pos = cursor; s->cline++; s->tok = s->pos = cursor; s->cline++;
@ -117,12 +115,12 @@ yy9: yych = *++YYCURSOR;
if(yych != 'c') goto yy8; if(yych != 'c') goto yy8;
yych = *++YYCURSOR; yych = *++YYCURSOR;
#line 85 #line 83
{ fwrite(s->tok, 1, &cursor[-7] - s->tok, out); { fwrite(s->tok, 1, &cursor[-7] - s->tok, out);
s->tok = cursor; s->tok = cursor;
RETURN(1); } RETURN(1); }
} }
#line 93 #line 91
} }
@ -192,32 +190,32 @@ yy15:
} }
yy17: yych = *++YYCURSOR; yy17: yych = *++YYCURSOR;
#line 108 #line 106
{ depth = 1; { depth = 1;
goto code; goto code;
} }
yy19: yych = *++YYCURSOR; yy19: yych = *++YYCURSOR;
if(yych == '*') goto yy54; if(yych == '*') goto yy54;
yy20: yy20:
#line 127 #line 125
{ RETURN(*s->tok); } { RETURN(*s->tok); }
yy21: yych = *++YYCURSOR; yy21: yych = *++YYCURSOR;
if(yych == '/') goto yy52; if(yych == '/') goto yy52;
yy22: yy22:
#line 129 #line 127
{ yylval.op = *s->tok; { yylval.op = *s->tok;
RETURN(CLOSE); } RETURN(CLOSE); }
yy23: yyaccept = 0; yy23: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR); yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy48; if(yych != '\n') goto yy48;
yy24: yy24:
#line 120 #line 118
{ Scanner_fatal(s, "bad string"); } { Scanner_fatal(s, "bad string"); }
yy25: yyaccept = 1; yy25: yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR); yych = *(YYMARKER = ++YYCURSOR);
if(yych != '\n') goto yy42; if(yych != '\n') goto yy42;
yy26: yy26:
#line 125 #line 123
{ Scanner_fatal(s, "bad character constant"); } { Scanner_fatal(s, "bad character constant"); }
yy27: yych = *++YYCURSOR; yy27: yych = *++YYCURSOR;
goto yy20; goto yy20;
@ -226,7 +224,7 @@ yy28: yych = *++YYCURSOR;
yy29: yych = *++YYCURSOR; yy29: yych = *++YYCURSOR;
goto yy40; goto yy40;
yy30: yy30:
#line 132 #line 130
{ SubStr substr; { SubStr substr;
s->cur = cursor; s->cur = cursor;
substr = Scanner_token(s); substr = Scanner_token(s);
@ -235,18 +233,18 @@ yy30:
yy31: yych = *++YYCURSOR; yy31: yych = *++YYCURSOR;
goto yy38; goto yy38;
yy32: yy32:
#line 138 #line 136
{ goto scan; } { goto scan; }
yy33: yych = *++YYCURSOR; yy33: yych = *++YYCURSOR;
#line 140 #line 138
{ if(cursor == s->eof) RETURN(0); { if(cursor == s->eof) RETURN(0);
s->pos = cursor; s->cline++; s->pos = cursor; s->cline++;
goto scan; goto scan;
} }
yy35: yych = *++YYCURSOR; yy35: yych = *++YYCURSOR;
#line 145 #line 143
{ fprintf(stderr, "unexpected character: '%c'\n", *s->tok); { fprintf(stderr, "unexpected character: '%c'\n", *s->tok);
goto scan; goto scan;
} }
@ -291,7 +289,7 @@ yy44: ++YYCURSOR;
goto yy41; goto yy41;
yy45: yych = *++YYCURSOR; yy45: yych = *++YYCURSOR;
#line 122 #line 120
{ s->cur = cursor; { s->cur = cursor;
yylval.regexp = ranToRE(Scanner_token(s)); yylval.regexp = ranToRE(Scanner_token(s));
return RANGE; } return RANGE; }
@ -312,22 +310,22 @@ yy48: if(yych <= '!'){
goto yy47; goto yy47;
yy50: yych = *++YYCURSOR; yy50: yych = *++YYCURSOR;
#line 117 #line 115
{ s->cur = cursor; { s->cur = cursor;
yylval.regexp = strToRE(Scanner_token(s)); yylval.regexp = strToRE(Scanner_token(s));
return STRING; } return STRING; }
yy52: yych = *++YYCURSOR; yy52: yych = *++YYCURSOR;
#line 114 #line 112
{ s->tok = cursor; { s->tok = cursor;
RETURN(0); } RETURN(0); }
yy54: yych = *++YYCURSOR; yy54: yych = *++YYCURSOR;
#line 111 #line 109
{ depth = 1; { depth = 1;
goto comment; } goto comment; }
} }
#line 148 #line 146
code: code:
@ -358,7 +356,7 @@ yy56:
} }
yych = *++YYCURSOR; yych = *++YYCURSOR;
#line 152 #line 150
{ if(--depth == 0){ { if(--depth == 0){
s->cur = cursor; s->cur = cursor;
yylval.token = Token_new(Scanner_token(s), s->tline); yylval.token = Token_new(Scanner_token(s), s->tline);
@ -367,19 +365,19 @@ yy56:
goto code; } goto code; }
yy60: yych = *++YYCURSOR; yy60: yych = *++YYCURSOR;
#line 158 #line 156
{ ++depth; { ++depth;
goto code; } goto code; }
yy62: yych = *++YYCURSOR; yy62: yych = *++YYCURSOR;
#line 160 #line 158
{ if(cursor == s->eof) Scanner_fatal(s, "missing '}'"); { if(cursor == s->eof) Scanner_fatal(s, "missing '}'");
s->pos = cursor; s->cline++; s->pos = cursor; s->cline++;
goto code; goto code;
} }
yy64: yych = *++YYCURSOR; yy64: yych = *++YYCURSOR;
yy65: yy65:
#line 164 #line 162
{ goto code; } { goto code; }
yy66: yyaccept = 0; yy66: yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR); yych = *(YYMARKER = ++YYCURSOR);
@ -424,7 +422,7 @@ yy73: if(yych <= '!'){
if(yych == '\n') goto yy70; if(yych == '\n') goto yy70;
goto yy72; goto yy72;
} }
#line 165 #line 163
comment: comment:
@ -447,14 +445,14 @@ yy75:
yy77: yych = *++YYCURSOR; yy77: yych = *++YYCURSOR;
if(yych == '/') goto yy85; if(yych == '/') goto yy85;
yy78: yy78:
#line 179 #line 177
{ goto comment; } { goto comment; }
yy79: yych = *++YYCURSOR; yy79: yych = *++YYCURSOR;
if(yych == '*') goto yy83; if(yych == '*') goto yy83;
goto yy78; goto yy78;
yy80: yych = *++YYCURSOR; yy80: yych = *++YYCURSOR;
#line 175 #line 173
{ if(cursor == s->eof) RETURN(0); { if(cursor == s->eof) RETURN(0);
s->tok = s->pos = cursor; s->cline++; s->tok = s->pos = cursor; s->cline++;
goto comment; goto comment;
@ -463,23 +461,23 @@ yy82: yych = *++YYCURSOR;
goto yy78; goto yy78;
yy83: yych = *++YYCURSOR; yy83: yych = *++YYCURSOR;
#line 173 #line 171
{ ++depth; { ++depth;
goto comment; } goto comment; }
yy85: yych = *++YYCURSOR; yy85: yych = *++YYCURSOR;
#line 169 #line 167
{ if(--depth == 0) { if(--depth == 0)
goto scan; goto scan;
else else
goto comment; } goto comment; }
} }
#line 180 #line 178
} }
void 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); fprintf(stderr, "line %d, column %d: %s\n", s->tline, s->tchar + 1, msg);
exit(1); exit(1);

@ -15,7 +15,7 @@ static inline Scanner *Scanner_new(FILE *);
int Scanner_echo(Scanner*, FILE *); int Scanner_echo(Scanner*, FILE *);
int Scanner_scan(Scanner*); int Scanner_scan(Scanner*);
void Scanner_fatal(Scanner*, char*); void Scanner_fatal(Scanner*, const char*);
static inline SubStr Scanner_token(Scanner*); static inline SubStr Scanner_token(Scanner*);
static inline uint Scanner_line(Scanner*); static inline uint Scanner_line(Scanner*);

@ -6,8 +6,6 @@
#include "tools/re2c/parse.h" #include "tools/re2c/parse.h"
#include "re2c-parser.h" #include "re2c-parser.h"
extern YYSTYPE yylval;
#define BSIZE 8192 #define BSIZE 8192
#define YYCTYPE uchar #define YYCTYPE uchar
@ -181,7 +179,7 @@ comment:
} }
void 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); fprintf(stderr, "line %d, column %d: %s\n", s->tline, s->tchar + 1, msg);
exit(1); exit(1);

Loading…
Cancel
Save