www.pudn.com > pccts133.zip > dlgauto.h
/* dlgauto.h automaton
*
* SOFTWARE RIGHTS
*
* We reserve no LEGAL rights to the Purdue Compiler Construction Tool
* Set (PCCTS) -- PCCTS is in the public domain. An individual or
* company may do whatever they wish with source code distributed with
* PCCTS or the code generated by PCCTS, including the incorporation of
* PCCTS, or its output, into commerical software.
*
* We encourage users to develop software with PCCTS. However, we do ask
* that credit is given to us for developing PCCTS. By "credit",
* we mean that if you incorporate our source code into one of your
* programs (commercial product, research project, or otherwise) that you
* acknowledge this fact somewhere in the documentation, research report,
* etc... If you like PCCTS and have developed a nice tool with the
* output, please mention that you developed it using PCCTS. In
* addition, we ask that this header remain intact in our source code.
* As long as these guidelines are kept, we expect to continue enhancing
* this system and expect to make other tools available as they are
* completed.
*
* ANTLR 1.33
* Will Cohen and Terence Parr
* Parr Research Corporation
* with Purdue University and AHPCRC, University of Minnesota
* 1989-1998
*/
#ifndef ZZDEFAUTO_H
#define ZZDEFAUTO_H
/* 10-Apr-97 133MR1 Uses __USE_PROTOS show should #include pcctscfg.h */
#include "pcctscfg.h"
zzchar_t *zzlextext; /* text of most recently matched token */
zzchar_t *zzbegexpr; /* beginning of last reg expr recogn. */
zzchar_t *zzendexpr; /* beginning of last reg expr recogn. */
int zzbufsize = 0; /* number of characters in zzlextext */ /* MR7 */
int zzbegcol = 0; /* column that first character of token is in*/
int zzendcol = 0; /* column that last character of token is in */
int zzline = 1; /* line current token is on */
int zzreal_line=1; /* line of 1st portion of token that is not skipped */
int zzchar; /* character to determine next state */
int zzbufovf; /* indicates that buffer too small for text */
int zzcharfull = 0;
static zzchar_t *zznextpos;/* points to next available position in zzlextext*/
static int zzclass;
#ifdef __USE_PROTOS
void zzerrstd(const char *);
void (*zzerr)(const char *)=zzerrstd;/* pointer to error reporting function */
extern int zzerr_in(void);
#else
void zzerrstd();
void (*zzerr)()=zzerrstd; /* pointer to error reporting function */
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 \
/* Truncate matching buffer to size (not an error) */ \
if (zznextpos < lastpos){ \
*(zznextpos++) = zzchar; \
}else{ \
zzbufovf = 1; \
}
#endif
void
#ifdef __USE_PROTOS
zzrdstream( FILE *f )
#else
zzrdstream( f )
FILE *f;
#endif
{
/* make sure that it is really set to something, otherwise just
leave it be.
*/
if (f){
/* make sure that there is always someplace to get input
before closing zzstream_in
*/
#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
{
/* make sure that it is really set to something, otherwise just
leave it be.
*/
if (f){
/* make sure that there is always someplace to get input
before closing zzstream_in
*/
#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
{
/* make sure that it is really set to something, otherwise just
leave it be.
*/
if (s){
/* make sure that there is always someplace to get input
before closing zzstream_in
*/
#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
}
/* saves dlg state, but not what feeds dlg (such as file position) */
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
{
/* points to base of dfa table */
if (m