}
*/
-static uint
+static unsigned int
AltOp_fixedLength(RegExp *r)
{
- uint l1 = RegExp_fixedLength(r->d.AltCatOp.exp1);
+ unsigned int l1 = RegExp_fixedLength(r->d.AltCatOp.exp1);
/* XXX? Should be exp2? */
- uint l2 = RegExp_fixedLength(r->d.AltCatOp.exp1);
+ unsigned int l2 = RegExp_fixedLength(r->d.AltCatOp.exp1);
if(l1 != l2 || l1 == ~0u)
return ~0;
return l1;
}
-static uint
+static unsigned int
CatOp_fixedLength(RegExp *r)
{
- uint l1, l2;
+ unsigned int l1, l2;
if((l1 = RegExp_fixedLength(r->d.AltCatOp.exp1)) != ~0u )
if((l2 = RegExp_fixedLength(r->d.AltCatOp.exp2)) != ~0u)
return l1+l2;
return ~0;
}
-uint
+unsigned int
RegExp_fixedLength(RegExp *r)
{
switch (r->type) {
RegExp_calcSize(RegExp *re, Char *rep)
{
Range *r;
- uint c;
+ unsigned int c;
switch (re->type) {
case NULLOP:
MatchOp_compile(RegExp *re, Char *rep, Ins *i)
{
Ins *j;
- uint bump;
+ unsigned int bump;
Range *r;
- uint c;
+ unsigned int c;
i->i.tag = CHAR;
i->i.link = &i[re->size];
MatchOp_split(RegExp *re, CharSet *s)
{
Range *r;
- uint c;
+ unsigned int c;
for(r = re->d.match; r; r = r->next){
for(c = r->lb; c < r->ub; ++c){
if(r1->ub > s->ub)
s->ub = r1->ub;
if(!(r1 = r1->next)){
- uint ub = 0;
+ unsigned int ub = 0;
for(; r2 && r2->lb <= s->ub; r2 = r2->next)
ub = r2->ub;
if(ub > s->ub)
if(r2->ub > s->ub)
s->ub = r2->ub;
if(!(r2 = r2->next)){
- uint ub = 0;
+ unsigned int ub = 0;
for(; r1 && r1->lb <= s->ub; r1 = r1->next)
ub = r1->ub;
if(ub > s->ub)
static Range *doDiff(Range *r1, Range *r2){
Range *r, *s, **rP = &r;
for(; r1; r1 = r1->next){
- uint lb = r1->lb;
+ unsigned int lb = r1->lb;
for(; r2 && r2->ub <= r1->lb; r2 = r2->next);
for(; r2 && r2->lb < r1->ub; r2 = r2->next){
if(lb < r2->lb){
return doAlt(merge(m1, m2), doAlt(e1, e2));
}
-static uchar unescape(SubStr *s){
- uchar c;
- uchar v;
+static unsigned char unescape(SubStr *s){
+ unsigned char c;
+ unsigned char v;
s->len--;
if((c = *s->str++) != '\\' || s->len == 0)
return xlat[c];
}
static Range *getRange(SubStr *s){
- uchar lb = unescape(s), ub;
+ unsigned char lb = unescape(s), ub;
if(s->len < 2 || *s->str != '-'){
ub = lb;
} else {
s->len--; s->str++;
ub = unescape(s);
if(ub < lb){
- uchar tmp;
+ unsigned char tmp;
tmp = lb; lb = ub; ub = tmp;
}
}
return Range_new(lb, ub+1);
}
-static RegExp *matchChar(uint c){
+static RegExp *matchChar(unsigned int c){
return RegExp_new_MatchOp(Range_new(c, c+1));
}
}
RegExp *
-RegExp_new_RuleOp(RegExp *e, RegExp *c, Token *t, uint a)
+RegExp_new_RuleOp(RegExp *e, RegExp *c, Token *t, unsigned int a)
{
RegExp *r = malloc(sizeof(RegExp));
r->type = RULEOP;
void genCode(FILE *o, RegExp *re){
CharSet cs;
- uint j;
+ unsigned int j;
Char rep[nChars];
Ins *ins, *eoi;
DFA *dfa;
cs.ptn[0].nxt = NULL;
RegExp_split(re, &cs);
/*
- for(uint k = 0; k < nChars;){
+ for(unsigned int k = 0; k < nChars;){
for(j = k; ++k < nChars && cs.rep[k] == cs.rep[j];);
printSpan(cerr, j, k);
cerr << "\t" << cs.rep[j] - &cs.ptn[0] << endl;
#define inline __inline__
#endif
-typedef unsigned int uint;
-typedef unsigned char uchar, byte;
-typedef unsigned short ushort, word;
-typedef unsigned long ulong, dword;
+typedef unsigned char byte;
+typedef unsigned short word;
+typedef unsigned long dword;
#endif
void Go_compact(Go *g){
/* arrange so that adjacent spans have different targets */
- uint i = 0, j;
+ unsigned int i = 0, j;
for(j = 1; j < g->nSpans; ++j){
if(g->span[j].to != g->span[i].to){
++i; g->span[i].to = g->span[j].to;
void Go_unmap(Go *g, Go *base, State *x){
Span *s = g->span, *b = base->span, *e = &b[base->nSpans];
- uint lb = 0;
+ unsigned int lb = 0;
s->ub = 0;
s->to = NULL;
for(; b != e; ++b){
g->nSpans = s - g->span;
}
-static void doGen(Go *g, State *s, uchar *bm, uchar m){
+static void doGen(Go *g, State *s, unsigned char *bm, unsigned char m){
Span *b = g->span, *e = &b[g->nSpans];
- uint lb = 0;
+ unsigned int lb = 0;
for(; b < e; ++b){
if(b->to == s)
for(; lb < b->ub; ++lb) bm[lb] |= m;
#if 0
static void prt(FILE *o, Go *g, State *s){
Span *b = g->span, *e = &b[g->nSpans];
- uint lb = 0;
+ unsigned int lb = 0;
for(; b < e; ++b){
if(b->to == s)
printSpan(o, lb, b->ub);
#endif
static int matches(Go *g1, State *s1, Go *g2, State *s2){
Span *b1 = g1->span, *e1 = &b1[g1->nSpans];
- uint lb1 = 0;
+ unsigned int lb1 = 0;
Span *b2 = g2->span, *e2 = &b2[g2->nSpans];
- uint lb2 = 0;
+ unsigned int lb2 = 0;
for(;;){
for(; b1 < e1 && b1->to != s1; ++b1) lb1 = b1->ub;
for(; b2 < e2 && b2->to != s2; ++b2) lb2 = b2->ub;
Go *go;
State *on;
struct BitMap *next;
- uint i;
- uchar m;
+ unsigned int i;
+ unsigned char m;
} BitMap;
static BitMap *BitMap_find_go(Go*, State*);
static BitMap *BitMap_find(State*);
-static void BitMap_gen(FILE *, uint, uint);
+static void BitMap_gen(FILE *, unsigned int, unsigned int);
/* static void BitMap_stats(void);*/
static BitMap *BitMap_new(Go*, State*);
return NULL;
}
-void BitMap_gen(FILE *o, uint lb, uint ub){
+void BitMap_gen(FILE *o, unsigned int lb, unsigned int ub){
BitMap *b = BitMap_first;
if(b){
- uint n = ub - lb;
- uint i;
- uchar *bm = malloc(sizeof(uchar)*n);
+ unsigned int n = ub - lb;
+ unsigned int i;
+ unsigned char *bm = malloc(sizeof(unsigned char)*n);
memset(bm, 0, n);
fputs("\tstatic unsigned char yybm[] = {", o);
for(i = 0; b; i += n){
- uchar m;
- uint j;
+ unsigned char m;
+ unsigned int j;
for(m = 0x80; b && m; b = b->next, m >>= 1){
b->i = i; b->m = m;
doGen(b->go, b->on, bm-lb, m);
}
for(j = 0; j < n; ++j){
if(j%8 == 0) {fputs("\n\t", o); oline++;}
- fprintf(o, "%3u, ", (uint) bm[j]);
+ fprintf(o, "%3u, ", (unsigned int) bm[j]);
}
}
fputs("\n\t};\n", o); oline+=2;
#if 0
void BitMap_stats(void){
- uint n = 0;
+ unsigned int n = 0;
BitMap *b;
for(b = BitMap_first; b; b = b->next){
prt(stderr, b->go, b->on); fputs("\n", stderr);
fprintf(o, "\tgoto yy%u;\n", to->label); oline++;
}
-static void genIf(FILE *o, const char *cmp, uint v){
+static void genIf(FILE *o, const char *cmp, unsigned int v){
fprintf(o, "\tif(yych %s '", cmp);
prtCh(o, v);
fputs("')", o);
}
-static void indent(FILE *o, uint i){
+static void indent(FILE *o, unsigned int i){
while(i-- > 0)
fputc('\t', o);
}
-static void need(FILE *o, uint n){
+static void need(FILE *o, unsigned int n){
if(n == 1) {
fputs("\tif(YYLIMIT == YYCURSOR) YYFILL(1);\n", o); oline++;
} else {
Action_emit(Action *a, FILE *o)
{
int first = 1;
- uint i;
- uint back;
+ unsigned int i;
+ unsigned int back;
switch (a->type) {
case MATCHACT:
}
Action *
-Action_new_Accept(State *x, uint n, uint *s, State **r)
+Action_new_Accept(State *x, unsigned int n, unsigned int *s, State **r)
{
Action *a = malloc(sizeof(Action));
a->type = ACCEPTACT;
return a;
}
-static void doLinear(FILE *o, uint i, Span *s, uint n, State *next){
+static void doLinear(FILE *o, unsigned int i, Span *s, unsigned int 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);
}
-static void genCases(FILE *o, uint lb, Span *s){
+static void genCases(FILE *o, unsigned int lb, Span *s){
if(lb < s->ub){
for(;;){
fputs("\tcase '", o); prtCh(o, lb); fputs("':", o);
} else {
State *def = g->span[g->nSpans-1].to;
Span **sP = malloc(sizeof(Span*)*(g->nSpans-1)), **r, **s, **t;
- uint i;
+ unsigned int i;
t = &sP[0];
for(i = 0; i < g->nSpans; ++i)
}
}
-static void doBinary(FILE *o, uint i, Span *s, uint n, State *next){
+static void doBinary(FILE *o, unsigned int i, Span *s, unsigned int n,
+ State *next){
if(n <= 4){
doLinear(o, i, s, n, next);
} else {
- uint h = n/2;
+ unsigned int h = n/2;
indent(o, i); genIf(o, "<=", s[h-1].ub - 1); fputs("{\n", o); oline++;
doBinary(o, i+1, &s[0], h, next);
indent(o, i); fputs("\t} else {\n", o); oline++;
}
if(g->nSpans > 8){
Span *bot = &g->span[0], *top = &g->span[g->nSpans-1];
- uint util;
+ unsigned int util;
if(bot[0].to == top[0].to){
util = (top[-1].ub - bot[0].ub)/(g->nSpans - 2);
} else {
void
Go_genGoto(Go *g, FILE *o, State *next){
- uint i;
+ unsigned int i;
if(bFlag){
for(i = 0; i < g->nSpans; ++i){
State *to = g->span[i].to;
Go go;
go.span = malloc(sizeof(Span)*g->nSpans);
Go_unmap(&go, g, to);
- fprintf(o, "\tif(yybm[%u+yych] & %u)", b->i, (uint) b->m);
+ fprintf(o, "\tif(yybm[%u+yych] & %u)", b->i,
+ (unsigned int) b->m);
genGoTo(o, to);
Go_genBase(&go, o, next);
free(go.span);
Action_emit(s->action, o);
}
-static uint merge(Span *x0, State *fg, State *bg){
+static unsigned int merge(Span *x0, State *fg, State *bg){
Span *x = x0, *f = fg->go.span, *b = bg->go.span;
- uint nf = fg->go.nSpans, nb = bg->go.nSpans;
+ unsigned int nf = fg->go.nSpans, nb = bg->go.nSpans;
State *prev = NULL, *to;
/* NB: we assume both spans are for same range */
for(;;){
}
}
-const uint cInfinity = ~0;
+const unsigned int cInfinity = ~0;
typedef struct SCC {
State **top, **stk;
} SCC;
-static void SCC_init(SCC*, uint);
-static SCC *SCC_new(uint);
+static void SCC_init(SCC*, unsigned int);
+static SCC *SCC_new(unsigned int);
static void SCC_destroy(SCC*);
static void SCC_delete(SCC*);
static void SCC_traverse(SCC*, State*);
static inline void
-SCC_init(SCC *s, uint size)
+SCC_init(SCC *s, unsigned int size)
{
s->top = s->stk = malloc(sizeof(State*)*size);
}
static inline SCC *
-SCC_new(uint size){
+SCC_new(unsigned int size){
SCC *s = malloc(sizeof(SCC));
s->top = s->stk = malloc(sizeof(State*)*size);
return s;
}
static void SCC_traverse(SCC *s, State *x){
- uint k, i;
+ unsigned int k, i;
*s->top = x;
k = ++s->top - s->stk;
} while(*s->top != x);
}
-static uint maxDist(State *s){
- uint mm = 0, i;
+static unsigned int maxDist(State *s){
+ unsigned int mm = 0, i;
for(i = 0; i < s->go.nSpans; ++i){
State *t = s->go.span[i].to;
if(t){
- uint m = 1;
+ unsigned int m = 1;
if(!t->link)
m += maxDist(t);
if(m > mm)
State *t, *s;
for(s = head; s; s = s->next){
if(s->link == s){
- uint i;
+ unsigned int i;
for(i = 0; i < s->go.nSpans; ++i){
t = s->go.span[i].to;
if(t && t->link == s)
}
void DFA_emit(DFA *d, FILE *o){
- static uint label = 0;
+ static unsigned int label = 0;
State *s;
- uint i;
- uint nRules = 0;
- uint nSaves = 0;
- uint *saves;
+ unsigned int i;
+ unsigned int nRules = 0;
+ unsigned int nSaves = 0;
+ unsigned int *saves;
State **rules;
State *accept = NULL;
Span *span;
if(s->rule && s->rule->d.RuleOp.accept >= nRules)
nRules = s->rule->d.RuleOp.accept + 1;
- saves = malloc(sizeof(uint)*nRules);
- memset(saves, ~0, (nRules)*sizeof(uint));
+ saves = malloc(sizeof(unsigned int)*nRules);
+ memset(saves, ~0, (nRules)*sizeof(unsigned int));
/* mark backtracking points */
for(s = d->head; s; s = s->next){
for(i = 0; i < s->go.nSpans; ++i){
State *to = s->go.span[i].to;
if(to && to->isBase){
- uint nSpans;
+ unsigned int nSpans;
to = to->go.span[0].to;
nSpans = merge(span, s, to);
if(nSpans < s->go.nSpans){
#define octCh(c) ('0' + c%8)
-void prtCh(FILE *o, uchar c){
- uchar oc = talx[c];
+void prtCh(FILE *o, unsigned char c){
+ unsigned char oc = talx[c];
switch(oc){
case '\'': fputs("\\'", o); break;
case '\n': fputs("\\n", o); break;
}
}
-void printSpan(FILE *o, uint lb, uint ub){
+void printSpan(FILE *o, unsigned int lb, unsigned int ub){
if(lb > ub)
fputc('*', o);
fputc('[', o);
fputc(']', o);
}
-uint
-Span_show(Span *s, FILE *o, uint lb)
+unsigned int
+Span_show(Span *s, FILE *o, unsigned int lb)
{
if(s->to){
printSpan(o, lb, s->ub);
void
State_out(FILE *o, const State *s){
- uint lb, i;
+ unsigned int lb, i;
fprintf(o, "state %u", s->label);
if(s->rule)
fprintf(o, " accepts %u", s->rule->d.RuleOp.accept);
} GoTo;
DFA *
-DFA_new(Ins *ins, uint ni, uint lb, uint ub, Char *rep)
+DFA_new(Ins *ins, unsigned int ni, unsigned int lb, unsigned int ub, Char *rep)
{
DFA *d = malloc(sizeof(DFA));
Ins **work = malloc(sizeof(Ins*)*(ni+1));
- uint nc = ub - lb;
+ unsigned int nc = ub - lb;
GoTo *goTo = malloc(sizeof(GoTo)*nc);
Span *span = malloc(sizeof(Span)*nc);
State *s = d->toDo;
Ins **cP, **iP, *i;
- uint nGoTos = 0;
- uint j;
+ unsigned int nGoTos = 0;
+ unsigned int j;
d->toDo = s->link;
s->rule = NULL;
d->tail = &s->next;
}
-State *DFA_findState(DFA *d, Ins **kernel, uint kCount){
+State *DFA_findState(DFA *d, Ins **kernel, unsigned int kCount){
Ins **cP, **iP, *i;
State *s;
#include <stdio.h>
#include "tools/re2c/re.h"
-extern void prtCh(FILE *, uchar);
-extern void printSpan(FILE *, uint, uint);
+extern void prtCh(FILE *, unsigned char);
+extern void printSpan(FILE *, unsigned int, unsigned int);
struct DFA;
struct State;
ActionType type;
union {
/* data for Enter */
- uint label;
+ unsigned int label;
/* data for SaveMatch */
- uint selector;
+ unsigned int selector;
/* data for Accept */
struct {
- uint nRules;
- uint *saves;
+ unsigned int nRules;
+ unsigned int *saves;
struct State **rules;
} Accept;
/* data for Rule */
void Action_emit(Action*, FILE *);
typedef struct Span {
- uint ub;
+ unsigned int ub;
struct State *to;
} Span;
-uint Span_show(Span*, FILE *, uint);
+unsigned int Span_show(Span*, FILE *, unsigned int);
typedef struct Go {
- uint nSpans;
+ unsigned int nSpans;
Span *span;
} Go;
typedef struct State {
- uint label;
+ unsigned int label;
RegExp *rule; /* RuleOp */
struct State *next;
struct State *link;
- uint depth; /* for finding SCCs */
- uint kCount;
+ unsigned int depth; /* for finding SCCs */
+ unsigned int kCount;
Ins **kernel;
- uint isBase:1;
+ unsigned int isBase:1;
Go go;
Action *action;
} State;
void State_out(FILE *, const State*);
typedef struct DFA {
- uint lbChar;
- uint ubChar;
- uint nStates;
+ unsigned int lbChar;
+ unsigned int ubChar;
+ unsigned int nStates;
State *head, **tail;
State *toDo;
} DFA;
-DFA *DFA_new(Ins*, uint, uint, uint, Char*);
+DFA *DFA_new(Ins*, unsigned int, unsigned int, unsigned int, Char*);
void DFA_delete(DFA*);
void DFA_addState(DFA*, State**, State*);
-State *DFA_findState(DFA*, Ins**, uint);
+State *DFA_findState(DFA*, Ins**, unsigned int);
void DFA_split(DFA*, State*);
void DFA_findSCCs(DFA*);
}
static inline Action *
-Action_new_Enter(State *s, uint l)
+Action_new_Enter(State *s, unsigned int l)
{
Action *a = malloc(sizeof(Action));
a->type = ENTERACT;
}
static inline Action *
-Action_new_Save(State *s, uint i)
+Action_new_Save(State *s, unsigned int i)
{
Action *a = malloc(sizeof(Action));
a->type = SAVEMATCHACT;
return a;
}
-Action *Action_new_Accept(State*, uint, uint*, State**);
+Action *Action_new_Accept(State*, unsigned int, unsigned int*, State**);
static inline Action *
Action_new_Rule(State *s, RegExp *r) /* RuleOp */
extern int bFlag;
extern unsigned int oline;
-extern uchar asc2ebc[256];
-extern uchar ebc2asc[256];
+extern unsigned char asc2ebc[256];
+extern unsigned char ebc2asc[256];
-extern uchar *xlat, *talx;
+extern unsigned char *xlat, *talx;
#endif
#include "tools/re2c/basics.h"
#define nChars 256
-typedef uchar Char;
+typedef unsigned char Char;
#define CHAR 0
#define GOTO 1
void *link;
} i;
struct {
- ushort value;
- ushort bump;
+ unsigned short value;
+ unsigned short bump;
void *link;
} c;
} Ins;
#include "tools/re2c/ins.h"
typedef struct CharPtn {
- uint card;
+ unsigned int card;
struct CharPtn *fix;
struct CharPtn *nxt;
} CharPtn;
typedef struct Range {
struct Range *next;
- uint lb, ub; /* [lb,ub) */
+ unsigned int lb, ub; /* [lb,ub) */
} Range;
static inline void
-Range_init(Range *r, uint l, uint u)
+Range_init(Range *r, unsigned int l, unsigned int u)
{
r->next = NULL;
r->lb = l;
}
static inline Range *
-Range_new(uint l, uint u)
+Range_new(unsigned int l, unsigned int u)
{
Range *r = malloc(sizeof(Range));
r->next = NULL;
typedef struct RegExp {
RegExpType type;
- uint size;
+ unsigned int size;
union {
/* for MatchOp */
Range *match;
struct RegExp *exp;
struct RegExp *ctx;
Ins *ins;
- uint accept;
+ unsigned int accept;
Token *code;
- uint line;
+ unsigned int line;
} RuleOp;
/* for AltOp and CatOp*/
struct {
void RegExp_split(RegExp*, CharSet*);
void RegExp_calcSize(RegExp*, Char*);
-uint RegExp_fixedLength(RegExp*);
+unsigned int RegExp_fixedLength(RegExp*);
void RegExp_compile(RegExp*, Char*, Ins*);
void RegExp_display(RegExp*, FILE *);
return r;
}
-RegExp *RegExp_new_RuleOp(RegExp*, RegExp*, Token*, uint);
+RegExp *RegExp_new_RuleOp(RegExp*, RegExp*, Token*, unsigned int);
static inline RegExp *
RegExp_new_AltOp(RegExp *e1, RegExp *e2)
static char *mystrdup(const char *str);
-static uint accept;
+static unsigned int accept;
static RegExp *spec;
static Scanner *in;
#define BSIZE 8192
-#define YYCTYPE uchar
+#define YYCTYPE unsigned char
#define YYCURSOR cursor
#define YYLIMIT s->lim
#define YYMARKER s->ptr
#define RETURN(i) {s->cur = cursor; return i;}
-static uchar *fill(Scanner*, uchar*);
+static unsigned char *fill(Scanner*, unsigned char*);
void
Scanner_init(Scanner *s, FILE *i)
s->cline = 1;
}
-static uchar *
-fill(Scanner *s, uchar *cursor)
+static unsigned char *
+fill(Scanner *s, unsigned char *cursor)
{
if(!s->eof){
- uint cnt = s->tok - s->bot;
+ unsigned int cnt = s->tok - s->bot;
if(cnt){
memcpy(s->bot, s->tok, s->lim - s->tok);
s->tok = s->bot;
s->lim -= cnt;
}
if((s->top - s->lim) < BSIZE){
- uchar *buf = malloc(sizeof(uchar)*((s->lim - s->bot) + BSIZE));
+ unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE));
memcpy(buf, s->tok, s->lim - s->tok);
s->tok = buf;
s->ptr = &buf[s->ptr - s->bot];
free(s->bot);
s->bot = buf;
}
- if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){
+ if((cnt = fread(s->lim, 1, BSIZE, s->in)) != BSIZE){
s->eof = &s->lim[cnt]; *s->eof++ = '\n';
}
s->lim += cnt;
int
Scanner_echo(Scanner *s, FILE *out)
{
- uchar *cursor = s->cur;
+ unsigned char *cursor = s->cur;
s->tok = cursor;
echo:
int
Scanner_scan(Scanner *s)
{
- uchar *cursor = s->cur;
- uint depth;
+ unsigned char *cursor = s->cur;
+ unsigned int depth;
scan:
s->tchar = cursor - s->pos;
typedef struct Scanner {
FILE *in;
- uchar *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
- uint tchar, tline, cline;
+ unsigned char *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
+ unsigned int tchar, tline, cline;
} Scanner;
void Scanner_init(Scanner*, FILE *);
int Scanner_scan(Scanner*);
void Scanner_fatal(Scanner*, const char*);
static inline SubStr Scanner_token(Scanner*);
-static inline uint Scanner_line(Scanner*);
+static inline unsigned int Scanner_line(Scanner*);
static inline SubStr
Scanner_token(Scanner *s)
return r;
}
-static inline uint
+static inline unsigned int
Scanner_line(Scanner *s)
{
return s->cline;
#define BSIZE 8192
-#define YYCTYPE uchar
+#define YYCTYPE unsigned char
#define YYCURSOR cursor
#define YYLIMIT s->lim
#define YYMARKER s->ptr
#define RETURN(i) {s->cur = cursor; return i;}
-static uchar *fill(Scanner*, uchar*);
+static unsigned char *fill(Scanner*, unsigned char*);
void
Scanner_init(Scanner *s, FILE *i)
s->cline = 1;
}
-static uchar *
-fill(Scanner *s, uchar *cursor)
+static unsigned char *
+fill(Scanner *s, unsigned char *cursor)
{
if(!s->eof){
- uint cnt = s->tok - s->bot;
+ unsigned int cnt = s->tok - s->bot;
if(cnt){
memcpy(s->bot, s->tok, s->lim - s->tok);
s->tok = s->bot;
s->lim -= cnt;
}
if((s->top - s->lim) < BSIZE){
- uchar *buf = malloc(sizeof(uchar)*((s->lim - s->bot) + BSIZE));
+ unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE));
memcpy(buf, s->tok, s->lim - s->tok);
s->tok = buf;
s->ptr = &buf[s->ptr - s->bot];
free(s->bot);
s->bot = buf;
}
- if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){
+ if((cnt = fread(s->lim, 1, BSIZE, s->in)) != BSIZE){
s->eof = &s->lim[cnt]; *s->eof++ = '\n';
}
s->lim += cnt;
int
Scanner_echo(Scanner *s, FILE *out)
{
- uchar *cursor = s->cur;
+ unsigned char *cursor = s->cur;
s->tok = cursor;
echo:
/*!re2c
int
Scanner_scan(Scanner *s)
{
- uchar *cursor = s->cur;
- uint depth;
+ unsigned char *cursor = s->cur;
+ unsigned int depth;
scan:
s->tchar = cursor - s->pos;
void Str_delete(Str *s) {
free(s->str);
s->str = (char*)-1;
- s->len = (uint)-1;
+ s->len = (unsigned int)-1;
free(s);
}
struct SubStr {
char *str;
- uint len;
+ unsigned int len;
};
typedef struct SubStr SubStr;
int SubStr_eq(const SubStr *, const SubStr *);
-static inline void SubStr_init_u(SubStr*, uchar*, uint);
-static inline SubStr *SubStr_new_u(uchar*, uint);
+static inline void SubStr_init_u(SubStr*, unsigned char*, unsigned int);
+static inline SubStr *SubStr_new_u(unsigned char*, unsigned int);
-static inline void SubStr_init(SubStr*, char*, uint);
-static inline SubStr *SubStr_new(char*, uint);
+static inline void SubStr_init(SubStr*, char*, unsigned int);
+static inline SubStr *SubStr_new(char*, unsigned int);
static inline void SubStr_copy(SubStr*, const SubStr*);
static inline SubStr *SubStr_new_copy(const SubStr*);
void Str_delete(Str *);
static inline void
-SubStr_init_u(SubStr *r, uchar *s, uint l)
+SubStr_init_u(SubStr *r, unsigned char *s, unsigned int l)
{
r->str = (char*)s;
r->len = l;
}
static inline SubStr *
-SubStr_new_u(uchar *s, uint l)
+SubStr_new_u(unsigned char *s, unsigned int l)
{
SubStr *r = malloc(sizeof(SubStr));
r->str = (char*)s;
}
static inline void
-SubStr_init(SubStr *r, char *s, uint l)
+SubStr_init(SubStr *r, char *s, unsigned int l)
{
r->str = s;
r->len = l;
}
static inline SubStr *
-SubStr_new(char *s, uint l)
+SubStr_new(char *s, unsigned int l)
{
SubStr *r = malloc(sizeof(SubStr));
r->str = s;
typedef struct Token {
Str text;
- uint line;
+ unsigned int line;
} Token;
-static inline void Token_init(Token *, SubStr, uint);
-static inline Token *Token_new(SubStr, uint);
+static inline void Token_init(Token *, SubStr, unsigned int);
+static inline Token *Token_new(SubStr, unsigned int);
static inline void
-Token_init(Token *r, SubStr t, uint l)
+Token_init(Token *r, SubStr t, unsigned int l)
{
Str_copy(&r->text, &t);
r->line = l;
}
static inline Token *
-Token_new(SubStr t, uint l)
+Token_new(SubStr t, unsigned int l)
{
Token *r = malloc(sizeof(Token));
Str_init(&r->text, &t);
#include "tools/re2c/globals.h"
-uchar asc2asc[256] = {
+unsigned char asc2asc[256] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
};
-uchar *xlat = asc2asc;
-uchar *talx = asc2asc;
+unsigned char *xlat = asc2asc;
+unsigned char *talx = asc2asc;
-uchar asc2ebc[256] = { /* Based on ISO 8859/1 and Code Page 37 */
+unsigned char asc2ebc[256] = { /* Based on ISO 8859/1 and Code Page 37 */
0x00,0x01,0x02,0x03,0x37,0x2d,0x2e,0x2f,0x16,0x05,0x25,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x3c,0x3d,0x32,0x26,0x18,0x19,0x3f,0x27,0x1c,0x1d,0x1e,0x1f,
0x40,0x5a,0x7f,0x7b,0x5b,0x6c,0x50,0x7d,0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x4b,0x61,
0x8c,0x49,0xcd,0xce,0xcb,0xcf,0xcc,0xe1,0x70,0xdd,0xde,0xdb,0xdc,0x8d,0xae,0xdf
};
-uchar ebc2asc[256] = { /* Based on ISO 8859/1 and Code Page 37 */
+unsigned char ebc2asc[256] = { /* Based on ISO 8859/1 and Code Page 37 */
0x00,0x01,0x02,0x03,0x9c,0x09,0x86,0x7f,0x97,0x8d,0x8e,0x0b,0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13,0x9d,0x85,0x08,0x87,0x18,0x19,0x92,0x8f,0x1c,0x1d,0x1e,0x1f,
0x80,0x81,0x82,0x83,0x84,0x0a,0x17,0x1b,0x88,0x89,0x8a,0x8b,0x8c,0x05,0x06,0x07,