/* antlr.h
*
* 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
* Terence Parr
* Parr Research Corporation
* with Purdue University and AHPCRC, University of Minnesota
* 1989-2000
*/
#ifndef ANTLR_H
#define ANTLR_H
#include "pcctscfg.h"
#include "pccts_stdio.h"
/* turn off warnings for unreferenced labels */
#ifdef _MSC_VER
#endif
/*
* Define all of the stack setup and manipulation of $i, #i variables.
*
* Notes:
* The type 'Attrib' must be defined before entry into this .h file.
*/
#ifdef __USE_PROTOS
#include "pccts_stdlib.h"
#else
#ifdef VAXC
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#endif
#include "pccts_string.h"
#if 0
#include "set.h"
#endif
typedef int ANTLRTokenType;
typedef unsigned char SetWordType;
typedef char ANTLRChar;
/* G u e s s S t u f f */
#ifdef ZZCAN_GUESS
#ifndef ZZINF_LOOK
#define ZZINF_LOOK
#endif
#endif
#ifdef ZZCAN_GUESS
typedef struct _zzjmp_buf {
} zzjmp_buf;
#endif
/* can make this a power of 2 for more efficient lookup */
#ifndef ZZLEXBUFSIZE
#endif
#define zzOvfChk \
if ( zzasp <= 0 ) \
{ \
}
#ifndef ZZA_STACKSIZE
#endif
#ifndef ZZAST_STACKSIZE
#endif
#ifndef zzfailed_pred
#ifdef ZZCAN_GUESS
if (zzguessing) { \
zzGUESS_FAIL; \
} else { \
}
#else
#endif
#endif
/* MR23 Provide more control over failed predicate action
without any need for user to worry about guessing internals.
_hasuseraction == 0 => no user specified error action
_hasuseraction == 1 => user specified error action
*/
#ifndef zzfailed_pred_action
if (_hasuseraction) { _useraction } \
#endif
/* MR19 zzchar_t additions */
#ifdef LL_K
#define LOOKAHEAD \
#else
#define LOOKAHEAD \
int zztoken;
#endif
#ifndef zzcr_ast
#endif
#ifdef DEMAND_LOOK
#else
#define DemandLookData
#endif
#ifndef zzUSER_GUESS_HOOK
#endif
#ifndef zzUSER_GUESS_DONE_HOOK
#endif
/* S t a t e S t u f f */
#ifdef ZZCAN_GUESS
/* MR10 change zzGUESS: do zzGUESS_DONE when zzrv==1 after longjmp as in C++ mode */
zzguessing = 1; \
if (zzrv) zzGUESS_DONE;
#ifdef zzTRACE_RULES
#else
#endif
/* MR10 change zzGUESS_DONE: zzrv=1 to simulate longjmp() return value as in C++ mode */
#define zzGUESS_DONE { zzrestore_antlr_state(&zzst); zzrv=1; zzUSER_GUESS_DONE_HOOK(zzGuessSeqFrozen) }
#define zzGuessData \
int zzguessing;
#else
#define zzGUESS_BLOCK
#define zzGUESS
#define zzGUESS_FAIL
#define zzGUESS_DONE
#define zzNON_GUESS_MODE
#define zzGuessData
#endif
typedef struct _zzantlr_state {
#ifdef ZZCAN_GUESS
int guessing;
#endif
int asp;
int ast_sp;
#ifdef ZZINF_LOOK
int inf_labase;
int inf_last;
/* MR6 Gunnar Rxnning (gunnar@candleweb.no) */
/* MR6 Matching changes in err.h */
#endif
#ifdef DEMAND_LOOK
int dirty;
#endif
#ifdef LL_K
int lap;
int labase;
#else
int token;
#endif
#ifdef zzTRACE_RULES
#endif
#ifdef zzTRACE_RULES
extern int zzTraceOptionValueDefault;
extern int zzTraceOptionValue;
extern int zzTraceGuessOptionValue;
extern char *zzTraceCurrentRuleName;
extern int zzTraceDepth;
#endif
extern int zzGuessSeq; /* MR10 */
extern int zzSyntaxErrCount; /* MR11 */
extern int zzLexErrCount; /* MR11 */
/* I n f i n i t e L o o k a h e a d */
#ifdef ZZINF_LOOK
#define InfLookData \
int *zzinf_tokens; \
char **zzinf_text; \
char *zzinf_text_buffer; \
int *zzinf_line; \
int zzinf_labase; \
int zzinf_last;
#else
#define InfLookData
#endif
#ifdef ZZINF_LOOK
#ifndef ZZINF_DEF_TEXT_BUFFER_SIZE
#endif
#ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE
#endif
/* WARNING!!!!!!
* ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.
*/
#ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE
#endif
#ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE
#endif
#endif
/* make inf_look user-access macros */
#ifdef LL_K
/* MR6 In 1.33 vanilla the #define ZZINF_LINE(i) is was commented out */
#else
#endif
extern void _inf_zzgettok();
#endif /* ZZINF_LOOK */
#ifdef LL_K
#ifdef __USE_PROTOS
#define ANTLR_INFO \
int zzasp=ZZA_STACKSIZE; \
char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
#else
#define ANTLR_INFO \
int zzasp=ZZA_STACKSIZE; \
char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
#endif
#else
#ifdef __USE_PROTOS
#define ANTLR_INFO \
int zzasp=ZZA_STACKSIZE; \
char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
#else
#define ANTLR_INFO \
int zzasp=ZZA_STACKSIZE; \
char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
#endif
#endif /* LL_k */
#ifdef ZZINF_LOOK
#ifdef LL_K
#ifdef DEMAND_LOOK
#else
#endif
#else /* LL_K */
#ifdef DEMAND_LOOK
#else
#endif
#endif /* LL_K */
#else /* ZZINF_LOOK */
#ifdef LL_K
#ifdef DEMAND_LOOK
#else
#endif
#else
#ifdef DEMAND_LOOK
#else
#endif
#endif /* LL_K */
#endif /* ZZINF_LOOK */
#ifdef LL_K
#define zzenterANTLRs(s) \
#define zzenterANTLRf(f) \
#define zzenterANTLR(f) \
#ifdef ZZINF_LOOK
#define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
#define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
#define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
#else
#define zzleaveANTLR(f)
#define zzleaveANTLRf(f)
#define zzleaveANTLRs(f)
#endif
#else
#define zzenterANTLRs(s) \
{static char zztoktext[ZZLEXBUFSIZE]; \
#define zzenterANTLRf(f) \
{static char zztoktext[ZZLEXBUFSIZE]; \
#define zzenterANTLR(f) \
{static char zztoktext[ZZLEXBUFSIZE]; \
#ifdef ZZINF_LOOK
#define zzleaveANTLR(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
#define zzleaveANTLRf(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
#define zzleaveANTLRs(f) free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens); free(zzinf_line);
#else
#define zzleaveANTLR(f)
#define zzleaveANTLRf(f)
#define zzleaveANTLRs(f)
#endif
#endif
/* MR19 Paul D. Smith (psmith@baynetworks.com)
Need to adjust AST stack pointer at exit.
Referenced in ANTLRx macros.
*/
#ifdef GENAST
#else
#define ZZAST_ADJUST
#endif
zzenterANTLR(f); \
{ \
st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
/* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
/* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
} \
zzleaveANTLR(f);
zzenterANTLR(f); \
{ \
st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
/* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
/* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
} \
zzleaveANTLR(f);
zzenterANTLRf(f); \
{ \
st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
/* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
/* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
} \
zzleaveANTLRf(f);
zzenterANTLRs(s); \
{ \
st; /* ++zzasp; Removed MR20 G. Hobbelt */ \
/* ZZAST_ADJUST Removed MR20 G. Hobbelt */ \
/* MR20 G. Hobbelt. Kill the top' attribute (+AST stack corr.) */ \
} \
zzleaveANTLRs(s);
#ifdef LL_K
#else
#endif
/* A r g u m e n t A c c e s s */
#define zzMakeAttr { zzNON_GUESS_MODE {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}}
#ifdef zzdef0
#else
#endif
#ifndef zzd_attr
#else
#endif
if ( !_zzsetmatch(_es, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet, _tokclassErrset) ) goto fail; /* MR23 */
#ifdef ZZCAN_GUESS
if ( !_zzsetmatch_wsig(_es) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}
#else
#endif
#ifdef __USE_PROTOS
extern int _zzsetmatch(SetWordType *, char **, char **, int *, int *, SetWordType **, SetWordType * /* MR23 */);
extern int _zzsetmatch_wsig(SetWordType *);
#else
extern int _zzsetmatch();
extern int _zzsetmatch_wsig();
#endif
#ifdef ZZCAN_GUESS
if ( !_zzmatch_wsig(_t) ) if (zzguessing) { zzGUESS_FAIL; } else {_signal=MismatchedToken; goto handler;}
#else
#endif
#ifdef __USE_PROTOS
extern int _zzmatch(int, char **, char **, int *, int *, SetWordType **);
extern int _zzmatch_wsig(int);
#else
extern int _zzmatch();
extern int _zzmatch_wsig();
#endif
#ifdef __USE_PROTOS
extern int _zzmatch_wdfltsig(int, SetWordType *);
int tokenTypeOfSet,
#else
extern int _zzmatch_wdfltsig();
extern int _zzsetmatch_wdfltsig();
#endif
#ifdef GENAST
#else
#endif
#ifdef GENAST
#define zzEXIT_ANTLR(i) zzREL(i); zzastREL /* [i_a] added as we want this for the ANTLRx() macros */
#else
#endif
#ifdef LL_K
#ifdef DEMAND_LOOK
#else
#ifdef ZZINF_LOOK
}
#else
#endif /* ZZINF_LOOK */
#endif /* DEMAND_LOOK */
#else /* LL_K */
#ifdef DEMAND_LOOK
#ifdef ZZINF_LOOK
#else
#endif /* ZZINF_LOOK */
#else /* DEMAND_LOOK */
#ifdef ZZINF_LOOK
#else
#endif
#endif /* DEMAND_LOOK */
#endif /* LL_K */
#ifdef LL_K
#ifdef DEMAND_LOOK
#else
#endif
#else
#endif
/* S t a n d a r d S i g n a l s */
#define NoSignal 0
/* MR7 Allow more control over signalling */
/* by adding "Unwind" and "zzsetSignal" */
/* F u n c t i o n T r a c i n g */
#ifndef zzTRACE_RULES
#define zzTRACEdata
#else
#ifndef zzTRACEdata
#endif
#endif
#ifndef zzTRACEIN
#endif
#ifndef zzTRACEOUT
#endif
/* MR19 zzchar_t additions */
#ifndef zzchar_t
#ifdef ZZWCHAR_T
#else
#define zzchar_t char
#endif
#endif
/* MR26 */
#ifdef PCCTS_USE_STDARG
extern void zzFAIL(int k, ...);
#else
extern void zzFAIL();
#endif
/* E x t e r n D e f s */
#ifdef __USE_PROTOS
extern Attrib zzempty_attr(void);
extern Attrib zzconstr_attr(int, char *);
extern void zzsyn(char *, int, char *, SetWordType *, int, int, char *);
extern int zzset_el(unsigned, SetWordType *);
extern int zzset_deg(SetWordType *);
extern void zzedecode(SetWordType *);
extern void zzsave_antlr_state(zzantlr_state *);
extern void zzrestore_antlr_state(zzantlr_state *);
extern void zzfill_inf_look(void);
extern void zzconsumeUntilToken(int t); /* MR7 */
extern void zzTraceReset(void); /* MR10 */
extern void zzTraceGuessFail(void); /* MR10 */
#ifdef EXCEPTION_HANDLING
extern void zzdflthandlers(int, int *);
#endif
#else
extern Attrib zzempty_attr();
extern Attrib zzconstr_attr();
extern void zzsyn();
extern int zzset_el();
extern int zzset_deg();
extern void zzedecode();
extern void zzresynch();
extern void zzsave_antlr_state();
extern void zzrestore_antlr_state();
extern void zzfill_inf_look();
extern void zzconsumeUntil(); /* MR7 */
extern void zzconsumeUntilToken(); /* MR7 */
extern void zzTraceIn(); /* MR10 */
extern void zzTraceOut(); /* MR10 */
extern int zzTraceOption(); /* MR10 */
extern int zzTraceGuessOption(); /* MR10 */
extern void zzTraceReset(); /* MR10 */
extern void zzTraceGuessFail(); /* MR10 */
#ifdef EXCEPTION_HANDLING
extern void zzdflthandlers();
#endif
#endif
/* G l o b a l V a r i a b l e s */
/* Define a parser; user should do a "#parser myname" in their grammar file */
/*extern struct pccts_parser zzparser;*/
extern char *zztokens[];
#ifdef LL_K
extern int zztokenLA[];
extern int zzlap;
extern int zzlabase;
#else
extern int zztoken;
#endif
extern char zzStackOvfMsg[];
extern int zzasp;
#ifdef ZZINF_LOOK
extern int *zzinf_tokens;
extern char **zzinf_text;
extern char *zzinf_text_buffer;
extern int *zzinf_line;
extern int zzinf_labase;
extern int zzinf_last;
#endif
#ifdef DEMAND_LOOK
extern int zzdirty;
#endif
#ifdef ZZCAN_GUESS
extern int zzguessing;
extern zzjmp_buf zzguess_start;
#endif
/* Define global veriables that refer to values exported by the scanner.
* These declarations duplicate those in dlgdef.h, but are needed
* if ANTLR is not to generate a .dlg file (-gx); PS, this is a hack.
*/
extern int zzbufsize; /* how long zzlextext is */
#endif