generate #defines for MAXREPLLEN, MAXEMREPLLEN

This commit is contained in:
ceriel 1989-11-08 17:14:52 +00:00
parent 339f9dd942
commit 3e80ca51fc
4 changed files with 22 additions and 7 deletions

View file

@ -30,7 +30,6 @@ int emhere=0; /* lexical analyzer flag */
int optexact=0; /* Inside "with exact" rule */ int optexact=0; /* Inside "with exact" rule */
int optstack=0; /* Inside with <blah> STACK rule */ int optstack=0; /* Inside with <blah> STACK rule */
int saferulefound=0; int saferulefound=0;
int maxempatlen=0;
int maxrule=0; int maxrule=0;
int in_em_repl=0; /* set when in EM replacement part */ int in_em_repl=0; /* set when in EM replacement part */
struct varinfo *defcost; struct varinfo *defcost;
@ -727,6 +726,7 @@ stackpattern
: WITH optexact : WITH optexact
{ startline = lineno; } { startline = lineno; }
setlist optstack setlist optstack
{ if (tokpatlen > maxtokpatlen) maxtokpatlen = tokpatlen; }
; ;
optexact optexact
: /* empty */ : /* empty */
@ -866,8 +866,8 @@ gen_oplist
yields yields
: /* empty */ : /* empty */
{ $$ = 0; } { $$ = 0; }
| YIELDS yieldlist | YIELDS { tokrepllen = 0; } yieldlist
{ $$ = $2; } { $$ = $3; if (tokrepllen > maxtokrepllen) maxtokrepllen = tokrepllen; }
; ;
yieldlist yieldlist
: /* empty */ : /* empty */
@ -877,14 +877,17 @@ yieldlist
NEW($$,struct varinfo); NEW($$,struct varinfo);
$$->vi_next = $2; $$->vi_next = $2;
$$->vi_int[0] = $1.in_index; $$->vi_int[0] = $1.in_index;
tokrepllen++;
} }
; ;
leaving leaving
: /* empty */ : /* empty */
{ $$ = 0; } { $$ = 0; }
| LEAVING {emhere=1; in_em_repl=1; } leavelist | LEAVING {emhere=1; in_em_repl=1; emrepllen = 0; } leavelist
{ emhere=0; in_em_repl=0; $$ = $3; } { emhere=0; in_em_repl=0; $$ = $3;
if (emrepllen > maxemrepllen) maxemrepllen = emrepllen;
}
; ;
leavelist leavelist
: leavelist_el : leavelist_el
@ -897,6 +900,7 @@ leavelist_el
$$->vi_next=0; $$->vi_next=0;
$$->vi_int[0] = $1; $$->vi_int[0] = $1;
$$->vi_int[1] = $2; $$->vi_int[1] = $2;
emrepllen++;
} }
; ;

View file

@ -12,10 +12,16 @@ extern int ntokens;
extern int nsets; extern int nsets;
extern int ninstr; extern int ninstr;
extern int empatlen; extern int empatlen;
extern int emrepllen;
extern int tokrepllen;
extern int emmnem[]; extern int emmnem[];
extern int empatexpr; extern int empatexpr;
extern int codeindex; extern int codeindex;
extern int tokpatlen; extern int tokpatlen;
extern int maxtokpatlen;
extern int maxempatlen;
extern int maxemrepllen;
extern int maxtokrepllen;
extern int tokpatro[]; extern int tokpatro[];
extern int tokpatset[]; extern int tokpatset[];
extern int nallreg; extern int nallreg;

View file

@ -582,6 +582,9 @@ outdefs() {
cdef("TOKENSIZE",maxtokensize); cdef("TOKENSIZE",maxtokensize);
cdef("MAXMEMBERS",maxmembers); cdef("MAXMEMBERS",maxmembers);
cdef("LONGESTPATTERN",maxempatlen); cdef("LONGESTPATTERN",maxempatlen);
cdef("MAXPATLEN",maxtokpatlen);
cdef("MAXREPLLEN",maxtokrepllen);
cdef("MAXEMREPLLEN",maxemrepllen);
cdef("MAXRULE",maxrule<16 ? 16 : maxrule); cdef("MAXRULE",maxrule<16 ? 16 : maxrule);
if (nsplit>0) { if (nsplit>0) {
cdef("MAXSPLIT",maxsplit); cdef("MAXSPLIT",maxsplit);

View file

@ -23,9 +23,11 @@ int ntokens=1;
int nsets; int nsets;
int ninstr; int ninstr;
int codeindex; int codeindex;
int empatlen,emmnem[EMPATMAX]; int empatlen,emrepllen,emmnem[EMPATMAX];
int maxempatlen, maxemrepllen;
int empatexpr; int empatexpr;
int tokpatlen,tokpatset[TOKPATMAX],tokpatro[TOKPATMAX]; int tokpatlen,tokrepllen,tokpatset[TOKPATMAX],tokpatro[TOKPATMAX];
int maxtokpatlen, maxtokrepllen;
int nallreg,allreg[MAXALLREG]; int nallreg,allreg[MAXALLREG];
int cursetno = -1; int cursetno = -1;
int allsetno; int allsetno;