home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pccts1.zip / H / ANTLR.H next >
C/C++ Source or Header  |  1993-09-01  |  16KB  |  613 lines

  1. /*
  2.  * a n t l r . h
  3.  *
  4.  * Define all of the stack setup and manipulation of $i, #i variables.
  5.  *
  6.  *    Notes:
  7.  *        The type 'Attrib' must be defined before entry into this .h file.
  8.  *
  9.  * SOFTWARE RIGHTS
  10.  *
  11.  * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
  12.  * Set (PCCTS) -- PCCTS is in the public domain.  An individual or
  13.  * company may do whatever they wish with source code distributed with
  14.  * PCCTS or the code generated by PCCTS, including the incorporation of
  15.  * PCCTS, or its output, into commerical software.
  16.  * 
  17.  * We encourage users to develop software with PCCTS.  However, we do ask
  18.  * that credit is given to us for developing PCCTS.  By "credit",
  19.  * we mean that if you incorporate our source code into one of your
  20.  * programs (commercial product, research project, or otherwise) that you
  21.  * acknowledge this fact somewhere in the documentation, research report,
  22.  * etc...  If you like PCCTS and have developed a nice tool with the
  23.  * output, please mention that you developed it using PCCTS.  In
  24.  * addition, we ask that this header remain intact in our source code.
  25.  * As long as these guidelines are kept, we expect to continue enhancing
  26.  * this system and expect to make other tools available as they are
  27.  * completed.
  28.  *
  29.  * ANTLR 1.10
  30.  * Terence Parr
  31.  * Purdue University
  32.  * 1989-1993
  33.  */
  34. #ifdef __STDC__
  35. #include <stdlib.h>
  36. #else
  37. #include <malloc.h>
  38. #endif
  39. #include <string.h>
  40.  
  41. /* TJP 5/30/93 -- we assume always 8 bit set words for portability */
  42. typedef unsigned char SetWordType;
  43.  
  44.  
  45.                         /* G u e s s  S t u f f */
  46.  
  47. #ifdef ZZCAN_GUESS
  48. #ifndef ZZINF_LOOK
  49. #define ZZINF_LOOK
  50. #endif
  51. #endif
  52.  
  53. #ifdef ZZCAN_GUESS
  54. typedef struct _zzjmp_buf {
  55.             jmp_buf state;
  56.         } zzjmp_buf;
  57. #endif
  58.  
  59.  
  60. /* can make this a power of 2 for more efficient lookup */
  61. #ifndef ZZLEXBUFSIZE
  62. #define ZZLEXBUFSIZE    2000
  63. #endif
  64.  
  65. #define zzOvfChk                                                        \
  66.             if ( zzasp <= 0 )                                           \
  67.             {                                                           \
  68.                 fprintf(stderr, zzStackOvfMsg, __FILE__, __LINE__);        \
  69.                 exit(-1);                                               \
  70.             }
  71.  
  72. #ifndef ZZA_STACKSIZE
  73. #define ZZA_STACKSIZE    400
  74. #endif
  75. #ifndef ZZAST_STACKSIZE
  76. #define ZZAST_STACKSIZE    400
  77. #endif
  78.  
  79. #ifndef zzfailed_pred
  80. #define zzfailed_pred(_p)    \
  81.     fprintf(stderr, "semantic error; failed predicate: '%s'\n",_p)
  82. #endif
  83.  
  84. #ifdef LL_K
  85. #define LOOKAHEAD                                                \
  86.     int zztokenLA[LL_K];                                        \
  87.     char zztextLA[LL_K][ZZLEXBUFSIZE];                            \
  88.     int zzlap = 0, zzlabase=0; /* labase only used for DEMAND_LOOK */
  89. #else
  90. #define LOOKAHEAD                                                \
  91.     int zztoken;
  92. #endif
  93.  
  94. #define DEFAULT_EOF_TOKEN        1    /* This reflects what antlr thinks it is.
  95.                                      * See EofToken in generic.h in antlr directory
  96.                                      */
  97.  
  98. #ifndef zzcr_ast
  99. #define zzcr_ast(ast,attr,tok,text)
  100. #endif
  101.  
  102. #ifdef DEMAND_LOOK
  103. #define DemandLookData  int zzdirty=1;
  104. #else
  105. #define DemandLookData
  106. #endif
  107.  
  108.                         /* S t a t e  S t u f f */
  109.  
  110. #ifdef ZZCAN_GUESS
  111. #define zzGUESS_BLOCK        zzantlr_state zzst; int zzrv;
  112. #define zzGUESS                zzsave_antlr_state(&zzst); \
  113.                             zzguessing = 1; \
  114.                             zzrv = setjmp(zzguess_start.state);
  115. #define zzGUESS_FAIL        longjmp(zzguess_start.state, 1)
  116. #define zzGUESS_DONE        zzrestore_antlr_state(&zzst);
  117. #define zzNON_GUESS_MODE    if ( !zzguessing )
  118. #define zzGuessData                                     \
  119.             zzjmp_buf zzguess_start;                    \
  120.             int zzguessing;
  121. #else
  122. #define zzGUESS_BLOCK
  123. #define zzGUESS
  124. #define zzGUESS_FAIL
  125. #define zzGUESS_DONE
  126. #define zzNON_GUESS_MODE
  127. #define zzGuessData
  128. #endif
  129.  
  130. typedef struct _zzantlr_state {
  131. #ifdef ZZCAN_GUESS
  132.             zzjmp_buf guess_start;
  133.             int guessing;
  134. #endif
  135.             int asp;
  136. #ifdef ZZINF_LOOK
  137.             int inf_lap;    /* not sure we need to save this one */
  138.             int inf_labase;
  139.             int inf_last;
  140. #endif
  141. #ifdef DEMAND_LOOK
  142.             int dirty;
  143. #endif
  144.  
  145. #ifdef LL_K
  146.             int tokenLA[LL_K];
  147.             char textLA[LL_K][ZZLEXBUFSIZE];
  148.             int lap;
  149.             int labase;
  150. #else
  151.             int token;
  152. #endif
  153.         } zzantlr_state;
  154.  
  155.  
  156.                  /* I n f i n i t e  L o o k a h e a d */
  157.  
  158.  
  159. #ifdef ZZINF_LOOK
  160. #define InfLookData    \
  161.     int *zzinf_tokens;    \
  162.     char **zzinf_text;    \
  163.     char *zzinf_text_buffer;    \
  164.     int zzinf_labase;    \
  165.     int zzinf_last;
  166. #else
  167. #define InfLookData
  168. #endif
  169.  
  170. #ifdef ZZINF_LOOK
  171.  
  172. #ifndef ZZINF_DEF_TEXT_BUFFER_SIZE
  173. #define ZZINF_DEF_TEXT_BUFFER_SIZE        20000
  174. #endif
  175. #ifndef ZZINF_DEF_TOKEN_BUFFER_SIZE
  176. #define ZZINF_DEF_TOKEN_BUFFER_SIZE        2000
  177. #endif
  178. /* WARNING!!!!!!
  179.  * ZZINF_BUFFER_TEXT_CHUNK_SIZE must be > sizeof(text) largest possible token.
  180.  */
  181. #ifndef ZZINF_BUFFER_TEXT_CHUNK_SIZE
  182. #define ZZINF_BUFFER_TEXT_CHUNK_SIZE    5000
  183. #endif
  184. #ifndef ZZINF_BUFFER_TOKEN_CHUNK_SIZE
  185. #define ZZINF_BUFFER_TOKEN_CHUNK_SIZE    1000
  186. #endif
  187.  
  188. #if ZZLEXBUFSIZE > ZZINF_BUFFER_TEXT_CHUNK_SIZE
  189. #define ZZINF_BUFFER_TEXT_CHUNK_SIZE    ZZLEXBUFSIZE+5
  190. #endif
  191.  
  192. /* make inf_look user-access macros */
  193. #define ZZINF_LA_VALID(i)    ((zzinf_labase+i-1) <= zzinf_last)
  194. #define ZZINF_LA(i)            zzinf_tokens[zzinf_labase+i-1]
  195. #define ZZINF_LATEXT(i)        zzinf_text[zzinf_labase+i-1]
  196.  
  197. #ifndef ZZUSE_MACROS
  198. #define inf_zzgettok _inf_zzgettok()
  199. extern void _inf_zzgettok();
  200. #else
  201. #define inf_zzgettok                                            \
  202.             {    if ( zzinf_labase >= zzinf_last )                    \
  203.                     {NLA = DEFAULT_EOF_TOKEN; strcpy(NLATEXT, "");}    \
  204.                 else {                                            \
  205.                     NLA = zzinf_tokens[zzinf_labase];                \
  206.                     strcpy(NLATEXT, zzinf_text[zzinf_labase]);        \
  207.                     zzinf_labase++;                                 \
  208.                 }                                                \
  209.             }
  210. #endif
  211.  
  212. #endif    /* ZZINF_LOOK */
  213.  
  214.  
  215. #ifdef LL_K
  216.  
  217. #ifdef __STDC__
  218. #define ANTLR_INFO                                                \
  219.     Attrib zzempty_attr() {static Attrib a; return a;}            \
  220.     Attrib zzconstr_attr(int _tok, char *_text)\
  221.         {Attrib a; zzcr_attr((&a),_tok,_text); return a;}        \
  222.     int zzasp=ZZA_STACKSIZE;                                    \
  223.     char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
  224.     Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                \
  225.     InfLookData                                                 \
  226.     zzGuessData
  227. #else
  228. #define ANTLR_INFO                                                \
  229.     Attrib zzempty_attr() {static Attrib a; return a;}            \
  230.     Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;\
  231.         {Attrib a; zzcr_attr((&a),_tok,_text); return a;}        \
  232.     int zzasp=ZZA_STACKSIZE;                                    \
  233.     char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
  234.     Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                \
  235.     InfLookData                                                 \
  236.     zzGuessData
  237. #endif
  238.  
  239. #else
  240.  
  241. #ifdef __STDC__
  242. #define ANTLR_INFO                                                \
  243.     Attrib zzempty_attr() {static Attrib a; return a;}            \
  244.     Attrib zzconstr_attr(int _tok, char *_text)\
  245.         {Attrib a; zzcr_attr((&a),_tok,_text); return a;}        \
  246.     int zzasp=ZZA_STACKSIZE;                                    \
  247.     char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
  248.     Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                \
  249.     InfLookData                                                 \
  250.     zzGuessData
  251. #else
  252. #define ANTLR_INFO                                                \
  253.     Attrib zzempty_attr() {static Attrib a; return a;}            \
  254.     Attrib zzconstr_attr(_tok, _text) int _tok; char *_text;\
  255.         {Attrib a; zzcr_attr((&a),_tok,_text); return a;}        \
  256.     int zzasp=ZZA_STACKSIZE;                                    \
  257.     char zzStackOvfMsg[]="fatal: attrib/AST stack overflow %s(%d)!\n"; \
  258.     Attrib zzaStack[ZZA_STACKSIZE]; DemandLookData                \
  259.     InfLookData                                                 \
  260.     zzGuessData
  261. #endif
  262.     
  263. #endif /* LL_k */
  264.  
  265.  
  266. #ifdef ZZINF_LOOK
  267.  
  268. #ifdef LL_K
  269. #ifdef DEMAND_LOOK
  270. #define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}
  271. #else
  272. #define zzPrimeLookAhead  {zzlap = zzlabase = 0; zzfill_inf_look();\
  273.                           {int _i;  for(_i=1;_i<=LL_K; _i++)        \
  274.                                         {zzCONSUME;} zzlap = zzlabase = 0;}}
  275. #endif
  276.  
  277. #else /* LL_K */
  278.  
  279. #ifdef DEMAND_LOOK
  280. #define zzPrimeLookAhead  zzfill_inf_look(); zzdirty=1
  281. #else
  282. #define zzPrimeLookAhead  zzfill_inf_look(); inf_zzgettok
  283.  
  284. #endif
  285. #endif    /* LL_K */
  286.  
  287. #else    /* ZZINF_LOOK */
  288.  
  289. #ifdef LL_K
  290. #ifdef DEMAND_LOOK
  291. #define zzPrimeLookAhead  {zzdirty=LL_K; zzlap = zzlabase = 0;}
  292. #else
  293. #define zzPrimeLookAhead  {int _i; zzlap = 0; for(_i=1;_i<=LL_K; _i++)        \
  294.                                         {zzCONSUME;} zzlap = 0;}
  295. #endif
  296.  
  297. #else
  298.  
  299. #ifdef DEMAND_LOOK
  300. #define zzPrimeLookAhead  zzdirty=1
  301. #else
  302. #define zzPrimeLookAhead  zzgettok()
  303. #endif
  304. #endif    /* LL_K */
  305.  
  306. #endif    /* ZZINF_LOOK */
  307.  
  308.  
  309. #ifdef LL_K
  310. #define zzenterANTLRs(s)                            \
  311.         zzlextext = &(zztextLA[0][0]); zzrdstr( s ); zzPrimeLookAhead;
  312. #define zzenterANTLRf(f)                            \
  313.         zzlextext = &(zztextLA[0][0]); zzrdfunc( f ); zzPrimeLookAhead;
  314. #define zzenterANTLR(f)                            \
  315.         zzlextext = &(zztextLA[0][0]); zzrdstream( f ); zzPrimeLookAhead;
  316. #ifdef ZZINF_LOOK
  317. #define zzleaveANTLR(f)            free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens);
  318. #define zzleaveANTLRf(f)           free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens);
  319. #define zzleaveANTLRs(f)        free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens);
  320. #else
  321. #define zzleaveANTLR(f)
  322. #define zzleaveANTLRf(f)
  323. #define zzleaveANTLRs(f)
  324. #endif
  325.  
  326. #else
  327.  
  328. #define zzenterANTLRs(s)                            \
  329.         {static char zztoktext[ZZLEXBUFSIZE];   \
  330.         zzlextext = zztoktext; zzrdstr( s ); zzPrimeLookAhead;}
  331. #define zzenterANTLRf(f)                            \
  332.         {static char zztoktext[ZZLEXBUFSIZE];    \
  333.         zzlextext = zztoktext; zzrdfunc( f ); zzPrimeLookAhead;}
  334. #define zzenterANTLR(f)                            \
  335.         {static char zztoktext[ZZLEXBUFSIZE];    \
  336.         zzlextext = zztoktext; zzrdstream( f ); zzPrimeLookAhead;}
  337. #ifdef ZZINF_LOOK
  338. #define zzleaveANTLR(f)            free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens);
  339. #define zzleaveANTLRf(f)           free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens);
  340. #define zzleaveANTLRs(f)        free(zzinf_text_buffer); free(zzinf_text); free(zzinf_tokens);
  341. #else
  342. #define zzleaveANTLR(f)
  343. #define zzleaveANTLRf(f)
  344. #define zzleaveANTLRs(f)
  345. #endif
  346.  
  347. #endif
  348.  
  349. #define ANTLR(st, f)    zzbufsize = ZZLEXBUFSIZE;    \
  350.                         zzmode(START);                \
  351.                         zzenterANTLR(f);            \
  352.                         st; ++zzasp;                \
  353.                         zzleaveANTLR(f);
  354.                         
  355. #define ANTLRf(st, f)    zzbufsize = ZZLEXBUFSIZE;    \
  356.                         zzmode(START);                \
  357.                         zzenterANTLRf(f);            \
  358.                         st; ++zzasp;                \
  359.                         zzleaveANTLRf(f);
  360.  
  361. #define ANTLRs(st, s)   zzbufsize = ZZLEXBUFSIZE;    \
  362.                         zzmode(START);                \
  363.                         zzenterANTLRs(s);           \
  364.                         st; ++zzasp;                \
  365.                         zzleaveANTLRs(s);
  366.  
  367. #ifdef LL_K
  368. #define zztext        (&(zztextLA[zzlap][0]))
  369. #else
  370. #define zztext        zzlextext
  371. #endif
  372.  
  373.  
  374.                     /* A r g u m e n t  A c c e s s */
  375.  
  376. #define zzaCur            (zzaStack[zzasp])
  377. #define zzaRet            (*zzaRetPtr)
  378. #define zzaArg(v,n)        zzaStack[v-n]
  379. #define zzMakeAttr        {zzOvfChk; --zzasp; zzcr_attr(&(zzaStack[zzasp]),LA(1),LATEXT(1));}
  380. #ifdef zzdef0
  381. #define zzMake0            {zzOvfChk; --zzasp; zzdef0(&(zzaStack[zzasp]));}
  382. #else
  383. #define zzMake0            {zzOvfChk; --zzasp;}
  384. #endif
  385. #define zzaPush(_v)        {zzOvfChk; zzaStack[--zzasp] = _v;}
  386. #ifndef zzd_attr
  387. #define zzREL(t)        zzasp=(t);        /* Restore state of stack */
  388. #else
  389. #define zzREL(t)        for (; zzasp<(t); zzasp++)                \
  390.                         { zzd_attr(&(zzaStack[zzasp])); }
  391. #endif
  392.  
  393. #ifdef ZZUSE_MACROS
  394.  
  395. #ifdef DEMAND_LOOK
  396.  
  397. #ifdef LL_K
  398. #define zzmatch(_t)                            \
  399.             {                                \
  400.             if ( zzdirty==LL_K ) {            \
  401.                 zzCONSUME;                    \
  402.             }                                \
  403.             if ( LA(1)!=_t ) {        \
  404.                 zzBadText=zzMissText=LATEXT(1);    \
  405.                 zzMissTok=_t; zzBadTok=LA(1); \
  406.                 zzMissSet=NULL;                \
  407.                 goto fail;                    \
  408.             }                                \
  409.             zzMakeAttr                        \
  410.             zzdirty++;                        \
  411.             zzlabase++;                        \
  412.             }
  413. #else
  414. #define zzmatch(_t)                            \
  415.             {                                \
  416.             if ( zzdirty ) {zzCONSUME;}        \
  417.             if ( LA(1)!=_t ) {                \
  418.                 zzBadText=zzMissText=LATEXT(1);    \
  419.                 zzMissTok=_t; zzBadTok=LA(1); \
  420.                 zzMissSet=NULL;                \
  421.                 goto fail;                    \
  422.             }                                \
  423.             zzdirty = 1;                    \
  424.             zzMakeAttr                        \
  425.             }
  426. #endif
  427.  
  428. #else
  429.  
  430. #define zzmatch(_t)        \
  431.             {                                \
  432.             if ( LA(1)!=_t ) {                \
  433.                 zzBadText=zzMissText=LATEXT(1);    \
  434.                 zzMissTok=_t; zzBadTok=LA(1); \
  435.                 zzMissSet=NULL;                \
  436.                 goto fail;                    \
  437.             }                                \
  438.             zzMakeAttr                        \
  439.             }
  440.  
  441. #endif /* DEMAND_LOOK */
  442.  
  443. #else
  444.  
  445. #define zzmatch(_t)                            \
  446.     if ( !_zzmatch(_t, &zzBadText, &zzMissText, &zzMissTok, &zzBadTok, &zzMissSet) ) goto fail;
  447. #ifdef __STDC__
  448. extern int _zzmatch(int, char **, char **, unsigned *, unsigned *, SetWordType **);
  449. #else
  450. extern int _zzmatch();
  451. #endif
  452.  
  453. #endif
  454.  
  455. #ifdef GENAST
  456. #define zzRULE        Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);    \
  457.                     SetWordType *zzMissSet=NULL; unsigned zzMissTok=0;        \
  458.                     unsigned zzBadTok=0; char *zzBadText="";        \
  459.                     int zzErrk=1;                                \
  460.                     char *zzMissText=""; zzASTVars
  461. #else
  462. #define zzRULE        Attrib *zzaRetPtr = &(zzaStack[zzasp-1]);    \
  463.                     unsigned zzBadTok=0; char *zzBadText="";        \
  464.                     int zzErrk=1;                                \
  465.                     SetWordType *zzMissSet=NULL; unsigned zzMissTok=0; char *zzMissText=""
  466. #endif
  467.  
  468. #ifdef GENAST
  469. #define zzBLOCK(i)    int i = zzasp - 1; int zztsp = zzast_sp
  470. #define zzEXIT(i)    zzREL(i); zzastREL; zzastPush(*_root);
  471. #define zzLOOP(i)    zzREL(i); zzastREL
  472. #else
  473. #define zzBLOCK(i)    int i = zzasp - 1
  474. #define zzEXIT(i)    zzREL(i)
  475. #define zzLOOP(i)    zzREL(i)
  476. #endif
  477.  
  478. #ifdef LL_K
  479.  
  480. #ifdef DEMAND_LOOK
  481. #define LOOK(_k)    {int i,stop=_k-(LL_K-zzdirty); for (i=1; i<=stop; i++)    \
  482.                     zzCONSUME;}
  483. #define zzCONSUME    {zzgettok(); zzdirty--;                            \
  484.                     zzlap = (zzlap+1)&(LL_K-1);                        \
  485.                     zzlextext = &(zztextLA[zzlap][0]);}
  486. #else
  487. #ifdef ZZINF_LOOK
  488. #define zzCONSUME    {inf_zzgettok;                                     \
  489.                     zzlap = (zzlap+1)&(LL_K-1);                        \
  490.                     zzlextext = &(zztextLA[zzlap][0]);                \
  491.                     }
  492. #else
  493. #define zzCONSUME    {zzgettok();                                     \
  494.                     zzlap = (zzlap+1)&(LL_K-1);                        \
  495.                     zzlextext = &(zztextLA[zzlap][0]);}
  496. #endif /* ZZINF_LOOK */
  497. #endif /* DEMAND_LOOK */
  498.  
  499. #else /* LL_K */
  500.  
  501. #ifdef DEMAND_LOOK
  502. #define LOOK(_k)    if ( zzdirty) zzCONSUME;
  503. #ifdef ZZINF_LOOK
  504. #define zzCONSUME    inf_zzgettok; zzdirty=0;
  505. #else
  506. #define zzCONSUME    zzgettok(); zzdirty=0;
  507. #endif /* ZZINF_LOOK */
  508.  
  509. #else  /* DEMAND_LOOK */
  510.  
  511. #ifdef ZZINF_LOOK
  512. #define zzCONSUME    inf_zzgettok
  513. #else
  514. #define zzCONSUME    zzgettok();
  515. #endif
  516.  
  517. #endif /* DEMAND_LOOK */
  518.  
  519. #endif /* LL_K */
  520.  
  521. #ifdef LL_K
  522. #define NLA            zztokenLA[zzlap&(LL_K-1)]    /* --> next LA */
  523. #define NLATEXT        zztextLA[zzlap&(LL_K-1)]    /* --> next text of LA */
  524. #ifdef DEMAND_LOOK
  525. #define LA(i)       zztokenLA[(zzlabase+(i)-1)&(LL_K-1)]
  526. #define LATEXT(i)   (&(zztextLA[(zzlabase+(i)-1)&(LL_K-1)][0]))
  527. #else
  528. #define LA(i)       zztokenLA[(zzlap+(i)-1)&(LL_K-1)]
  529. #define LATEXT(i)   (&(zztextLA[(zzlap+(i)-1)&(LL_K-1)][0]))
  530. #endif
  531. #else
  532. #define NLA            zztoken
  533. #define NLATEXT        zztext
  534. #define LA(i)       zztoken
  535. #define LATEXT(i)   zztext
  536. #endif
  537.  
  538.            /* F u n c t i o n  T r a c i n g */
  539.  
  540. #ifndef zzTRACEIN
  541. #define zzTRACEIN(r)    fprintf(stderr, "enter rule \"%s\"\n", r);
  542. #endif
  543. #ifndef zzTRACEOUT
  544. #define zzTRACEOUT(r)    fprintf(stderr, "exit rule \"%s\"\n", r);
  545. #endif
  546.  
  547. #ifdef ZZWCHAR_T
  548. #define zzchar_t wchar_t
  549. #else
  550. #define zzchar_t char
  551. #endif
  552.  
  553.                 /* E x t e r n  D e f s */
  554.  
  555. #ifdef __STDC__
  556. extern Attrib zzempty_attr();
  557. extern Attrib zzconstr_attr(int, char *);
  558. extern void zzsyn(char *, unsigned, char *, SetWordType *, unsigned, int, char *);
  559. extern int zzset_el(unsigned, SetWordType *);
  560. extern int zzset_deg(SetWordType *);
  561. extern void zzedecode(SetWordType *);
  562. extern void zzFAIL(int k, ...);
  563. extern void zzresynch(SetWordType *, SetWordType);
  564. extern void zzsave_antlr_state(zzantlr_state *);
  565. extern void zzrestore_antlr_state(zzantlr_state *);
  566. extern void zzfill_inf_look(void);
  567. #else
  568. extern Attrib zzempty_attr();
  569. extern Attrib zzconstr_attr();
  570. extern void zzsyn();
  571. extern int zzset_el();
  572. extern int zzset_deg();
  573. extern void zzedecode();
  574. extern void zzFAIL();
  575. extern void zzresynch();
  576. extern void zzsave_antlr_state();
  577. extern void zzrestore_antlr_state();
  578. extern void zzfill_inf_look();
  579. #endif
  580.  
  581.                 /* G l o b a l  V a r i a b l e s */
  582.  
  583. /* Define a parser; user should do a "#parser myname" in their grammar file */
  584. /*extern struct pccts_parser zzparser;*/
  585.  
  586. extern char *zztokens[];
  587. #ifdef LL_K
  588. extern int zztokenLA[];
  589. extern char zztextLA[][ZZLEXBUFSIZE];
  590. extern int zzlap;
  591. extern int zzlabase;
  592. #else
  593. extern int zztoken;
  594. #endif
  595.  
  596. extern char zzStackOvfMsg[];
  597. extern int zzasp;
  598. extern Attrib zzaStack[];
  599. #ifdef ZZINF_LOOK
  600. extern int *zzinf_tokens;
  601. extern char **zzinf_text;
  602. extern char *zzinf_text_buffer;
  603. extern int zzinf_labase;
  604. extern int zzinf_last;
  605. #endif
  606. #ifdef DEMAND_LOOK
  607. extern int zzdirty;
  608. #endif
  609. #ifdef ZZCAN_GUESS
  610. extern int zzguessing;
  611. extern zzjmp_buf zzguess_start;
  612. #endif
  613.