#ifndef ZZDEFAUTO_H
#define ZZDEFAUTO_H
zzchar_t *zzlextext;
zzchar_t *zzbegexpr;
zzchar_t *zzendexpr;
int
zzbufsize;
int
zzbegcol = 0;
int
zzendcol = 0;
int
zzline = 1;
int
zzreal_line=1;
int
zzchar;
int
zzbufovf;
int
zzcharfull = 0;
static
zzchar_t *zznextpos;
static
int
zzclass;
#ifdef __USE_PROTOS
void
zzerrstd(
const
char
*);
void
(*zzerr)(
const
char
*)=zzerrstd;
extern
int
zzerr_in(
void
);
#else
void
zzerrstd();
void
(*zzerr)()=zzerrstd;
extern
int
zzerr_in();
#endif
static
FILE
*zzstream_in=0;
static
int
(*zzfunc_in)() = zzerr_in;
static
zzchar_t *zzstr_in=0;
#ifdef USER_ZZMODE_STACK
int
zzauto = 0;
#else
static
int
zzauto = 0;
#endif
static
int
zzadd_erase;
static
char
zzebuf[70];
#ifdef ZZCOL
#define ZZINC (++zzendcol)
#else
#define ZZINC
#endif
#define ZZGETC_STREAM {zzchar = getc(zzstream_in); zzclass = ZZSHIFT(zzchar);}
#define ZZGETC_FUNC {zzchar = (*zzfunc_in)(); zzclass = ZZSHIFT(zzchar);}
#define ZZGETC_STR { \
if
(*zzstr_in){ \
zzchar = *zzstr_in; \
++zzstr_in; \
}
else
{ \
zzchar = EOF; \
} \
zzclass = ZZSHIFT(zzchar); \
}
#define ZZNEWSTATE (newstate = dfa[state][zzclass])
#ifndef ZZCOPY
#define ZZCOPY \
\
if
(zznextpos < lastpos){ \
*(zznextpos++) = zzchar; \
}
else
{ \
zzbufovf = 1; \
}
#endif
void
#ifdef __USE_PROTOS
zzrdstream(
FILE
*f )
#else
zzrdstream( f )
FILE
*f;
#endif
{
if
(f){
#if 0
if
(zzstream_in && zzstream_in!=stdin)
fclose
( zzstream_in );
#endif
zzline = 1;
zzstream_in = f;
zzfunc_in = NULL;
zzstr_in = 0;
zzcharfull = 0;
}
}
void
#ifdef __USE_PROTOS
zzrdfunc(
int
(*f)() )
#else
zzrdfunc( f )
int
(*f)();
#endif
{
if
(f){
#if 0
if
(zzstream_in && zzstream_in!=stdin)
fclose
( zzstream_in );
#endif
zzline = 1;
zzstream_in = NULL;
zzfunc_in = f;
zzstr_in = 0;
zzcharfull = 0;
}
}
void
#ifdef __USE_PROTOS
zzrdstr( zzchar_t *s )
#else
zzrdstr( s )
zzchar_t *s;
#endif
{
if
(s){
#if 0
if
(zzstream_in && zzstream_in!=stdin)
fclose
( zzstream_in );
#endif
zzline = 1;
zzstream_in = NULL;
zzfunc_in = 0;
zzstr_in = s;
zzcharfull = 0;
}
}
void
zzclose_stream()
{
#if 0
fclose
( zzstream_in );
zzstream_in = NULL;
zzfunc_in = NULL;
#endif
}
void
#ifdef __USE_PROTOS
zzsave_dlg_state(
struct
zzdlg_state *state)
#else
zzsave_dlg_state(state)
struct
zzdlg_state *state;
#endif
{
state->stream = zzstream_in;
state->func_ptr = zzfunc_in;
state->str = zzstr_in;
state->auto_num = zzauto;
state->add_erase = zzadd_erase;
state->lookc = zzchar;
state->char_full = zzcharfull;
state->begcol = zzbegcol;
state->endcol = zzendcol;
state->line = zzline;
state->lextext = zzlextext;
state->begexpr = zzbegexpr;
state->endexpr = zzendexpr;
state->bufsize = zzbufsize;
state->bufovf = zzbufovf;
state->nextpos = zznextpos;
state->class_num = zzclass;
}
void
#ifdef __USE_PROTOS
zzrestore_dlg_state(
struct
zzdlg_state *state)
#else
zzrestore_dlg_state(state)
struct
zzdlg_state *state;
#endif
{
zzstream_in = state->stream;
zzfunc_in = state->func_ptr;
zzstr_in = state->str;
zzauto = state->auto_num;
zzadd_erase = state->add_erase;
zzchar = state->lookc;
zzcharfull = state->char_full;
zzbegcol = state->begcol;
zzendcol = state->endcol;
zzline = state->line;
zzlextext = state->lextext;
zzbegexpr = state->begexpr;
zzendexpr = state->endexpr;
zzbufsize = state->bufsize;
zzbufovf = state->bufovf;
zznextpos = state->nextpos;
zzclass = state->class_num;
}
void
#ifdef __USE_PROTOS
zzmode(
int
m )
#else
zzmode( m )
int
m;
#endif
{
if
(m<MAX_MODE){
zzauto = m;
zzclass = ZZSHIFT(zzchar);
}
else
{
snprintf(zzebuf, 69,
"Invalid automaton mode = %d "
,m);
zzerr(zzebuf);
}
}
void
zzskip()
{
zzadd_erase = 1;
}
void
zzmore()
{
zzadd_erase = 2;
}
#ifdef __USE_PROTOS
void
zzreplchar(zzchar_t c)
#else
void
zzreplchar(c)
zzchar_t c;
#endif
{
if
(zzbegexpr < &zzlextext[zzbufsize-1]){
*zzbegexpr = c;
*(zzbegexpr+1) =
'\0'
;
}
zzendexpr = zzbegexpr;
zznextpos = zzbegexpr + 1;
}
void
#ifdef __USE_PROTOS
zzreplstr(
register
zzchar_t *s)
#else
zzreplstr(s)
register
zzchar_t *s;
#endif
{
register
zzchar_t *l= &zzlextext[zzbufsize -1];
zznextpos = zzbegexpr;
if
(s){
while
((zznextpos <= l) && (*(zznextpos++) = *(s++))!=0){
}
zznextpos--;
}
if
((zznextpos <= l) && (*(--s) == 0)){
zzbufovf = 0;
}
else
{
zzbufovf = 1;
}
*(zznextpos) =
'\0'
;
zzendexpr = zznextpos - 1;
}
void
zzgettok()
{
register
int
state, newstate;
zzchar_t *lastpos;
skip:
zzreal_line = zzline;
zzbufovf = 0;
lastpos = &zzlextext[zzbufsize-1];
zznextpos = zzlextext;
zzbegcol = zzendcol+1;
more:
zzbegexpr = zznextpos;
#ifdef ZZINTERACTIVE
state = newstate = dfa_base[zzauto];
if
(zzcharfull){
ZZINC;
ZZCOPY;
ZZNEWSTATE;
}
if
(zzstr_in)
while
(zzalternatives[newstate]){
state = newstate;
ZZGETC_STR;
ZZINC;
ZZCOPY;
ZZNEWSTATE;
}
else
if
(zzstream_in)
while
(zzalternatives[newstate]){
state = newstate;
ZZGETC_STREAM;
ZZINC;
ZZCOPY;
ZZNEWSTATE;
}
else
if
(zzfunc_in)
while
(zzalternatives[newstate]){
state = newstate;
ZZGETC_FUNC;
ZZINC;
ZZCOPY;
ZZNEWSTATE;
}
if
((state != dfa_base[zzauto]) && (newstate == DfaStates)){
zzcharfull = 1;
--zznextpos;
}
else
{
zzcharfull = 0;
state = newstate;
}
*(zznextpos) =
'\0'
;
if
( state == dfa_base[zzauto] ){
zzadvance();
}
#else
if
(!zzcharfull)
zzadvance();
else
ZZINC;
state = dfa_base[zzauto];
if
(zzstr_in)
while
(ZZNEWSTATE != DfaStates){
state = newstate;
ZZCOPY;
ZZGETC_STR;
ZZINC;
}
else
if
(zzstream_in)
while
(ZZNEWSTATE != DfaStates){
state = newstate;
ZZCOPY;
ZZGETC_STREAM;
ZZINC;
}
else
if
(zzfunc_in)
while
(ZZNEWSTATE != DfaStates){
state = newstate;
ZZCOPY;
ZZGETC_FUNC;
ZZINC;
}
zzcharfull = 1;
if
( state == dfa_base[zzauto] ){
if
(zznextpos < lastpos){
*(zznextpos++) = zzchar;
}
else
{
zzbufovf = 1;
}
*zznextpos =
'\0'
;
zzadvance();
}
else
{
*zznextpos =
'\0'
;
}
#endif
#ifdef ZZCOL
zzendcol -= zzcharfull;
#endif
zzendexpr = zznextpos -1;
zzadd_erase = 0;
(*actions[accepts[state]])();
switch
(zzadd_erase) {
case
1:
goto
skip;
case
2:
goto
more;
}
}
void
zzadvance()
{
if
(zzstream_in) { ZZGETC_STREAM; zzcharfull = 1; ZZINC;}
if
(zzfunc_in) { ZZGETC_FUNC; zzcharfull = 1; ZZINC;}
if
(zzstr_in) { ZZGETC_STR; zzcharfull = 1; ZZINC;}
if
(!(zzstream_in || zzfunc_in || zzstr_in)){
zzerr_in();
}
}
void
#ifdef __USE_PROTOS
zzerrstd(
const
char
*s)
#else
zzerrstd(s)
char
*s;
#endif
{
fprintf
(stderr,
"%s near line %d (text was '%s')\n"
,
((s == NULL) ?
"Lexical error"
: s),
zzline,zzlextext);
}
int
zzerr_in()
{
fprintf
(stderr,
"No input stream, function, or string\n"
);
return
EOF;
}
#endif