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

View file

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

View file

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

View file

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