home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Programming / GDBbundle-1.0-MIS / src / TextEdit / GdbBundle.bproj / pccts / err.h < prev   
Encoding:
C/C++ Source or Header  |  1997-04-01  |  18.1 KB  |  864 lines

  1. /*
  2.  * err.h
  3.  *
  4.  * Standard error handling mechanism
  5.  *
  6.  * SOFTWARE RIGHTS
  7.  *
  8.  * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
  9.  * Set (PCCTS) -- PCCTS is in the public domain.  An individual or
  10.  * company may do whatever they wish with source code distributed with
  11.  * PCCTS or the code generated by PCCTS, including the incorporation of
  12.  * PCCTS, or its output, into commerical software.
  13.  * 
  14.  * We encourage users to develop software with PCCTS.  However, we do ask
  15.  * that credit is given to us for developing PCCTS.  By "credit",
  16.  * we mean that if you incorporate our source code into one of your
  17.  * programs (commercial product, research project, or otherwise) that you
  18.  * acknowledge this fact somewhere in the documentation, research report,
  19.  * etc...  If you like PCCTS and have developed a nice tool with the
  20.  * output, please mention that you developed it using PCCTS.  In
  21.  * addition, we ask that this header remain intact in our source code.
  22.  * As long as these guidelines are kept, we expect to continue enhancing
  23.  * this system and expect to make other tools available as they are
  24.  * completed.
  25.  *
  26.  * Has grown to hold all kinds of stuff (err.h is increasingly misnamed)
  27.  *
  28.  * ANTLR 1.33
  29.  * Terence Parr
  30.  * Parr Research Corporation
  31.  * with Purdue University and AHPCRC, University of Minnesota
  32.  * 1989-1995
  33.  */
  34.  
  35. #ifndef ERR_H
  36. #define ERR_H
  37.  
  38. #include "config.h"
  39.  
  40. #import <Foundation/NSString.h>
  41.  
  42. #include <string.h>
  43. #ifdef __STDC__
  44. #include <stdarg.h>
  45. #else
  46. #include <varargs.h>
  47. #endif
  48.  
  49. #ifdef DUM
  50. /* Define usable bits per unsigned int word (used for set stuff) */
  51. #ifdef PC
  52. #define BSETWORDSIZE 16
  53. #define BSETLOGWORDSIZE    4
  54. #else
  55. #define    BSETWORDSIZE 32
  56. #define BSETLOGWORDSIZE 5
  57. #endif
  58. #endif
  59.  
  60. #define    BSETWORDSIZE 8
  61. #define BSETLOGWORDSIZE 3        /* SetWordType is 8bits */
  62.  
  63. #define    BSETMODWORD(x) ((x) & (BSETWORDSIZE-1))        /* x % BSETWORDSIZE */
  64. #define    BSETDIVWORD(x) ((x) >> BSETLOGWORDSIZE)        /* x / BSETWORDSIZE */
  65.  
  66. /* This is not put into the global pccts_parser structure because it is
  67.  * hidden and does not need to be saved during a "save state" operation
  68.  */
  69. /* maximum of 32 bits/unsigned int and must be 8 bits/byte */
  70. static SetWordType bitmask[] = {
  71.     0x00000001, 0x00000002, 0x00000004, 0x00000008,
  72.     0x00000010, 0x00000020, 0x00000040, 0x00000080
  73. };
  74.  
  75. void
  76. #ifdef __USE_PROTOS
  77. zzresynch(SetWordType *wd,SetWordType mask)
  78. #else
  79. zzresynch(wd,mask)
  80. SetWordType *wd, mask;
  81. #endif
  82. {
  83.     static int consumed = 1;
  84.  
  85.     /* if you enter here without having consumed a token from last resynch
  86.      * force a token consumption.
  87.      */
  88.     if ( !consumed ) {zzCONSUME; return;}
  89.  
  90.     /* if current token is in resynch set, we've got what we wanted */
  91.     if ( wd[LA(1)]&mask || LA(1) == zzEOF_TOKEN ) {consumed=0; return;}
  92.     
  93.     /* scan until we find something in the resynch set */
  94.     while ( !(wd[LA(1)]&mask) && LA(1) != zzEOF_TOKEN ) {zzCONSUME;}
  95.     consumed=1;
  96. }
  97.  
  98. void
  99. #ifdef __USE_PROTOS
  100. zzconsumeUntil(SetWordType *st)
  101. #else
  102. zzconsumeUntil(st)
  103. SetWordType *st;
  104. #endif
  105. {
  106.     while ( !zzset_el(LA(1), st) ) { zzCONSUME; }
  107. }
  108.  
  109. void
  110. #ifdef __USE_PROTOS
  111. zzconsumeUntilToken(int t)
  112. #else
  113. zzconsumeUntilToken(t)
  114. int t;
  115. #endif
  116. {
  117.     while ( LA(1)!=t ) { zzCONSUME; }
  118. }
  119.  
  120. /* input looks like:
  121.  *        zzFAIL(k, e1, e2, ...,&zzMissSet,&zzMissText,&zzBadTok,&zzBadText)
  122.  * where the zzMiss stuff is set here to the token that did not match
  123.  * (and which set wasn't it a member of).
  124.  */
  125. void
  126. #ifdef __USE_PROTOS
  127. zzFAIL(int k, ...)
  128. #else
  129. zzFAIL(va_alist)
  130. va_dcl
  131. #endif
  132. {
  133. #ifdef LL_K
  134.     static char text[LL_K*ZZLEXBUFSIZE+1];
  135.     SetWordType *f[LL_K];
  136. #else
  137.     static char text[ZZLEXBUFSIZE+1];
  138.     SetWordType *f[1];
  139. #endif
  140.     SetWordType **miss_set;
  141.     char **miss_text;
  142.     int *bad_tok;
  143.     char **bad_text;
  144.     int *err_k;
  145.     int i;
  146.     va_list ap;
  147. #ifndef __USE_PROTOS
  148.     int k;
  149. #endif
  150. #ifdef __USE_PROTOS
  151.     va_start(ap, k);
  152. #else
  153.     va_start(ap);
  154.     k = va_arg(ap, int);    /* how many lookahead sets? */
  155. #endif
  156.     text[0] = '\0';
  157.     for (i=1; i<=k; i++)    /* collect all lookahead sets */
  158.     {
  159.         f[i-1] = va_arg(ap, SetWordType *);
  160.     }
  161.     for (i=1; i<=k; i++)    /* look for offending token */
  162.     {
  163.         if ( i>1 ) strcat(text, " ");
  164.         strcat(text, LATEXT(i));
  165.         if ( !zzset_el((unsigned)LA(i), f[i-1]) ) break;
  166.     }
  167.     miss_set = va_arg(ap, SetWordType **);
  168.     miss_text = va_arg(ap, char **);
  169.     bad_tok = va_arg(ap, int *);
  170.     bad_text = va_arg(ap, char **);
  171.     err_k = va_arg(ap, int *);
  172.     if ( i>k )
  173.     {
  174.         /* bad; lookahead is permutation that cannot be matched,
  175.          * but, the ith token of lookahead is valid at the ith position
  176.          * (The old LL sub 1 (k) versus LL(k) parsing technique)
  177.          */
  178.         *miss_set = NULL;
  179.         *miss_text = zzlextext;
  180.         *bad_tok = LA(1);
  181.         *bad_text = LATEXT(1);
  182.         *err_k = k;
  183.         return;
  184.     }
  185. /*    fprintf(stderr, "%s not in %dth set\n", zztokens[LA(i)], i);*/
  186.     *miss_set = f[i-1];
  187.     *miss_text = text;
  188.     *bad_tok = LA(i);
  189.     *bad_text = LATEXT(i);
  190.     if ( i==1 ) *err_k = 1;
  191.     else *err_k = k;
  192. }
  193.  
  194. void
  195. #ifdef __USE_PROTOS
  196. zzsave_antlr_state(zzantlr_state *buf)
  197. #else
  198. zzsave_antlr_state(buf)
  199. zzantlr_state *buf;
  200. #endif
  201. {
  202. #ifdef LL_K
  203.     int i;
  204. #endif
  205.  
  206. #ifdef ZZCAN_GUESS
  207.     buf->guess_start = zzguess_start;
  208.     buf->guessing = zzguessing;
  209. #endif
  210.     buf->asp = zzasp;
  211. #ifdef GENAST
  212.     buf->ast_sp = zzast_sp;
  213. #endif
  214. #ifdef ZZINF_LOOK
  215.     buf->inf_labase = zzinf_labase;
  216.     buf->inf_last = zzinf_last;
  217. #endif
  218. #ifdef DEMAND_LOOK
  219.     buf->dirty = zzdirty;
  220. #endif
  221. #ifdef LL_K
  222.     for (i=0; i<LL_K; i++) buf->tokenLA[i] = zztokenLA[i];
  223.     for (i=0; i<LL_K; i++) strcpy(buf->textLA[i], zztextLA[i]);
  224.     buf->lap = zzlap;
  225.     buf->labase = zzlabase;
  226. #else
  227.     buf->token = zztoken;
  228.     strcpy(buf->text, zzlextext);
  229. #endif
  230. }
  231.  
  232. void
  233. #ifdef __USE_PROTOS
  234. zzrestore_antlr_state(zzantlr_state *buf)
  235. #else
  236. zzrestore_antlr_state(buf)
  237. zzantlr_state *buf;
  238. #endif
  239. {
  240. #ifdef LL_K
  241.     int i;
  242. #endif
  243.  
  244. #ifdef ZZCAN_GUESS
  245.     zzguess_start = buf->guess_start;
  246.     zzguessing = buf->guessing;
  247. #endif
  248.     zzasp = buf->asp;
  249. #ifdef GENAST
  250.     zzast_sp = buf->ast_sp;
  251. #endif
  252. #ifdef ZZINF_LOOK
  253.     zzinf_labase = buf->inf_labase;
  254.     zzinf_last = buf->inf_last;
  255. #endif
  256. #ifdef DEMAND_LOOK
  257.     zzdirty = buf->dirty;
  258. #endif
  259. #ifdef LL_K
  260.     for (i=0; i<LL_K; i++) zztokenLA[i] = buf->tokenLA[i];
  261.     for (i=0; i<LL_K; i++) strcpy(zztextLA[i], buf->textLA[i]);
  262.     zzlap = buf->lap;
  263.     zzlabase = buf->labase;
  264. #else
  265.     zztoken = buf->token;
  266.     strcpy(zzlextext, buf->text);
  267. #endif
  268. }
  269.  
  270. NSString* zzedecode(SetWordType *a)
  271. {
  272.     register SetWordType *p = a;
  273.     register SetWordType *endp = &(p[zzSET_SIZE]);
  274.     register unsigned e = 0;
  275.     NSMutableString* string = [[NSMutableString new] autorelease];
  276.  
  277.     if (zzset_deg (a) > 1)
  278.     [string appendString:@" {"];
  279.     do {
  280.     register SetWordType t = *p;
  281.     register SetWordType *b = &(bitmask[0]);
  282.     do {
  283.         if (t & *b)
  284.         [string appendFormat:@" %s", zztokens[e]];
  285.         e++;
  286.     } while (++b < &(bitmask[sizeof(SetWordType)*8]));
  287.     } while (++p < endp);
  288.     if (zzset_deg(a) > 1)
  289.     [string appendString:@" }"];
  290.  
  291.     return string;
  292. }
  293.  
  294. #ifndef USER_ZZSYN
  295. /* standard error reporting function */
  296. void
  297. #ifdef __USE_PROTOS
  298. zzsyn(char *text, int tok, char *egroup, SetWordType *eset, int etok, int k, char *bad_text)
  299. #else
  300. zzsyn(text, tok, egroup, eset, etok, k, bad_text)
  301. char *text, *egroup, *bad_text;
  302. int tok;
  303. int etok;
  304. int k;
  305. SetWordType *eset;
  306. #endif
  307. {
  308.     
  309.     fprintf(stderr, "line %d: syntax error at \"%s\"", zzline, (tok==zzEOF_TOKEN)?"EOF":bad_text);
  310.     if ( !etok && !eset ) {fprintf(stderr, "\n"); return;}
  311.     if ( k==1 ) fprintf(stderr, " missing");
  312.     else
  313.     {
  314.         fprintf(stderr, "; \"%s\" not", bad_text);
  315.         if ( zzset_deg(eset)>1 ) fprintf(stderr, " in");
  316.     }
  317.     if ( zzset_deg(eset)>0 ) zzedecode(eset);
  318.     else fprintf(stderr, " %s", zztokens[etok]);
  319.     if ( strlen(egroup) > 0 ) fprintf(stderr, " in %s", egroup);
  320.     fprintf(stderr, "\n");
  321. }
  322. #endif
  323.  
  324. /* is b an element of set p? */
  325. int
  326. #ifdef __USE_PROTOS
  327. zzset_el(unsigned b, SetWordType *p)
  328. #else
  329. zzset_el(b,p)
  330. unsigned b;
  331. SetWordType *p;
  332. #endif
  333. {
  334.     return( p[BSETDIVWORD(b)] & bitmask[BSETMODWORD(b)] );
  335. }
  336.  
  337. int
  338. #ifdef __USE_PROTOS
  339. zzset_deg(SetWordType *a)
  340. #else
  341. zzset_deg(a)
  342. SetWordType *a;
  343. #endif
  344. {
  345.     /* Fast compute degree of a set... the number
  346.        of elements present in the set.  Assumes
  347.        that all word bits are used in the set
  348.     */
  349.     register SetWordType *p = a;
  350.     register SetWordType *endp = &(a[zzSET_SIZE]);
  351.     register int degree = 0;
  352.  
  353.     if ( a == NULL ) return 0;
  354.     while ( p < endp )
  355.     {
  356.         register SetWordType t = *p;
  357.         register SetWordType *b = &(bitmask[0]);
  358.         do {
  359.             if (t & *b) ++degree;
  360.         } while (++b < &(bitmask[sizeof(SetWordType)*8]));
  361.         p++;
  362.     }
  363.  
  364.     return(degree);
  365. }
  366.  
  367. #ifdef DEMAND_LOOK
  368.  
  369. #ifdef LL_K
  370. int
  371. #ifdef __USE_PROTOS
  372. _zzmatch(int _t, char **zzBadText, char **zzMissText,
  373.         int *zzMissTok, int *zzBadTok,
  374.         SetWordType **zzMissSet)
  375. #else
  376. _zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
  377. int _t;
  378. char **zzBadText;
  379. char **zzMissText;
  380. int *zzMissTok, *zzBadTok;
  381. SetWordType **zzMissSet;
  382. #endif
  383. {
  384.     if ( zzdirty==LL_K ) {
  385.         zzCONSUME;
  386.     }
  387.     if ( LA(1)!=_t ) {
  388.         *zzBadText = *zzMissText=LATEXT(1);    
  389.         *zzMissTok= _t; *zzBadTok=LA(1); 
  390.         *zzMissSet=NULL;                
  391.         return 0;
  392.     }
  393.     zzMakeAttr                        
  394.     zzdirty++;                        
  395.     zzlabase++;                        
  396.     return 1;
  397. }
  398.  
  399. int
  400. #ifdef __USE_PROTOS
  401. _zzmatch_wsig(int _t)
  402. #else
  403. _zzmatch_wsig(_t)
  404. int _t;
  405. #endif
  406. {
  407.     if ( zzdirty==LL_K ) {
  408.         zzCONSUME;
  409.     }
  410.     if ( LA(1)!=_t ) {
  411.         return 0;
  412.     }
  413.     zzMakeAttr                        
  414.     zzdirty++;                        
  415.     zzlabase++;                        
  416.     return 1;
  417. }
  418.  
  419. #else
  420.  
  421. int
  422. #ifdef __USE_PROTOS
  423. _zzmatch(int _t, char **zzBadText, char **zzMissText,
  424.          int *zzMissTok, int *zzBadTok, SetWordType **zzMissSet)
  425. #else
  426. _zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
  427. int _t;
  428. char **zzBadText;
  429. char **zzMissText;
  430. int *zzMissTok, *zzBadTok;
  431. SetWordType **zzMissSet;
  432. #endif
  433. {                                
  434.     if ( zzdirty ) {zzCONSUME;}        
  435.     if ( LA(1)!=_t ) {
  436.         *zzBadText = *zzMissText=LATEXT(1);    
  437.         *zzMissTok= _t; *zzBadTok=LA(1); 
  438.         *zzMissSet=NULL;                
  439.         return 0;
  440.     }                                
  441.     zzdirty = 1;                    
  442.     zzMakeAttr                        
  443.     return 1;
  444. }
  445.  
  446. int
  447. #ifdef __USE_PROTOS
  448. _zzmatch_wsig(int _t)
  449. #else
  450. _zzmatch_wsig(_t)
  451. int _t;
  452. #endif
  453. {
  454.     if ( zzdirty ) {zzCONSUME;}        
  455.     if ( LA(1)!=_t ) {
  456.         return 0;
  457.     }
  458.     zzdirty = 1;                    
  459.     zzMakeAttr                        
  460.     return 1;
  461. }
  462.  
  463. #endif /*LL_K*/
  464.  
  465. #else
  466.  
  467. int
  468. #ifdef __USE_PROTOS
  469. _zzmatch(int _t, char **zzBadText, char **zzMissText,
  470.         int *zzMissTok, int *zzBadTok,
  471.         SetWordType **zzMissSet)
  472. #else
  473. _zzmatch(_t, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
  474. int _t;
  475. char **zzBadText;
  476. char **zzMissText;
  477. int *zzMissTok, *zzBadTok;
  478. SetWordType **zzMissSet;
  479. #endif
  480. {
  481.     if ( LA(1)!=_t ) {                
  482.         *zzBadText = *zzMissText=LATEXT(1);    
  483.         *zzMissTok= _t; *zzBadTok=LA(1); 
  484.         *zzMissSet=NULL;                
  485.         return 0;
  486.     }
  487.     zzMakeAttr
  488.     return 1;
  489. }
  490.  
  491. int
  492. #ifdef __USE_PROTOS
  493. _zzmatch_wsig(int _t)
  494. #else
  495. _zzmatch_wsig(_t)
  496. int _t;
  497. #endif
  498. {
  499.     if ( LA(1)!=_t ) return 0;
  500.     zzMakeAttr                        
  501.     return 1;
  502. }
  503.  
  504. #endif /*DEMAND_LOOK*/
  505.  
  506. #ifdef ZZINF_LOOK
  507. void
  508. #ifdef __USE_PROTOS
  509. _inf_zzgettok(void)
  510. #else
  511. _inf_zzgettok()
  512. #endif
  513. {
  514.     if ( zzinf_labase >= zzinf_last )                    
  515.         {NLA = zzEOF_TOKEN; strcpy(NLATEXT, "");}    
  516.     else {                                            
  517.         NLA = zzinf_tokens[zzinf_labase];
  518.         zzline = zzinf_line[zzinf_labase];    /* wrong in 1.21 */
  519.         strcpy(NLATEXT, zzinf_text[zzinf_labase]);        
  520.         zzinf_labase++;                                 
  521.     }                                                
  522. }
  523. #endif
  524.  
  525. #ifdef ZZINF_LOOK
  526. /* allocate default size text,token and line arrays;
  527.  * then, read all of the input reallocing the arrays as needed.
  528.  * Once the number of total tokens is known, the LATEXT(i) array (zzinf_text)
  529.  * is allocated and it's pointers are set to the tokens in zzinf_text_buffer.
  530.  */
  531. void
  532. #ifdef __USE_PROTOS
  533. zzfill_inf_look(void)
  534. #else
  535. zzfill_inf_look()
  536. #endif
  537. {
  538.     int tok, line;
  539.     int zzinf_token_buffer_size = ZZINF_DEF_TOKEN_BUFFER_SIZE;
  540.     int zzinf_text_buffer_size = ZZINF_DEF_TEXT_BUFFER_SIZE;
  541.     int zzinf_text_buffer_index = 0;
  542.     int zzinf_lap = 0;
  543.  
  544.     /* allocate text/token buffers */
  545.     zzinf_text_buffer = (char *) malloc(zzinf_text_buffer_size);
  546.     if ( zzinf_text_buffer == NULL )
  547.     {
  548.         fprintf(stderr, "cannot allocate lookahead text buffer (%d bytes)\n", 
  549.         zzinf_text_buffer_size);
  550.         exit(PCCTS_EXIT_FAILURE);                                        
  551.     }
  552.     zzinf_tokens = (int *) calloc(zzinf_token_buffer_size,sizeof(int)); 
  553.     if ( zzinf_tokens == NULL )
  554.     {
  555.         fprintf(stderr,    "cannot allocate token buffer (%d tokens)\n", 
  556.                 zzinf_token_buffer_size);
  557.         exit(PCCTS_EXIT_FAILURE);                                        
  558.     }
  559.     zzinf_line = (int *) calloc(zzinf_token_buffer_size,sizeof(int));
  560.     if ( zzinf_line == NULL )
  561.     {
  562.         fprintf(stderr, "cannot allocate line buffer (%d ints)\n",
  563.                 zzinf_token_buffer_size);
  564.         exit(PCCTS_EXIT_FAILURE);
  565.     }
  566.  
  567.     /* get tokens, copying text to text buffer */
  568.     zzinf_text_buffer_index = 0;
  569.     do {
  570.         zzgettok();
  571.         line = zzreal_line;
  572.         while ( zzinf_lap>=zzinf_token_buffer_size )
  573.         {
  574.             zzinf_token_buffer_size += ZZINF_BUFFER_TOKEN_CHUNK_SIZE; 
  575.             zzinf_tokens = (int *) realloc(zzinf_tokens,
  576.                                                  zzinf_token_buffer_size*sizeof(int));
  577.             if ( zzinf_tokens == NULL )
  578.             {
  579.                 fprintf(stderr, "cannot allocate lookahead token buffer (%d tokens)\n", 
  580.                         zzinf_token_buffer_size);
  581.                 exit(PCCTS_EXIT_FAILURE);
  582.             }
  583.             zzinf_line = (int *) realloc(zzinf_line,
  584.                                          zzinf_token_buffer_size*sizeof(int));
  585.             if ( zzinf_line == NULL )
  586.             {
  587.                 fprintf(stderr, "cannot allocate lookahead line buffer (%d ints)\n",
  588.                         zzinf_token_buffer_size);
  589.                 exit(PCCTS_EXIT_FAILURE);
  590.             }
  591.  
  592.         }
  593.         while ( (zzinf_text_buffer_index+strlen(NLATEXT)+1) >= zzinf_text_buffer_size )
  594.         {
  595.             zzinf_text_buffer_size += ZZINF_BUFFER_TEXT_CHUNK_SIZE; 
  596.             zzinf_text_buffer = (char *) realloc(zzinf_text_buffer,
  597.                                                  zzinf_text_buffer_size);
  598.             if ( zzinf_text_buffer == NULL )
  599.             {
  600.                 fprintf(stderr,    "cannot allocate lookahead text buffer (%d bytes)\n", 
  601.                         zzinf_text_buffer_size);
  602.                 exit(PCCTS_EXIT_FAILURE);
  603.             }
  604.         }
  605.         /* record token and text and line of input symbol */
  606.         tok = zzinf_tokens[zzinf_lap] = NLA;
  607.         strcpy(&zzinf_text_buffer[zzinf_text_buffer_index], NLATEXT);
  608.         zzinf_text_buffer_index += strlen(NLATEXT)+1;
  609.         zzinf_line[zzinf_lap] = line;
  610.         zzinf_lap++;
  611.     } while (tok!=zzEOF_TOKEN);
  612.     zzinf_labase = 0;
  613.     zzinf_last = zzinf_lap-1;
  614.  
  615.     /* allocate ptrs to text of ith token */
  616.     zzinf_text = (char **) calloc(zzinf_last+1,sizeof(char *));
  617.     if ( zzinf_text == NULL )
  618.     {
  619.         fprintf(stderr,    "cannot allocate lookahead text buffer (%d)\n", 
  620.                 zzinf_text_buffer_size); 
  621.         exit(PCCTS_EXIT_FAILURE);                                            
  622.     }                                                        
  623.     zzinf_text_buffer_index = 0;
  624.     zzinf_lap = 0;
  625.     /* set ptrs so that zzinf_text[i] is the text of the ith token found on input */
  626.     while (zzinf_lap<=zzinf_last)
  627.     {
  628.         zzinf_text[zzinf_lap++] = &zzinf_text_buffer[zzinf_text_buffer_index]; 
  629.         zzinf_text_buffer_index += strlen(&zzinf_text_buffer[zzinf_text_buffer_index])+1; 
  630.     }
  631. }
  632. #endif
  633.  
  634. int
  635. #ifdef __USE_PROTOS
  636. _zzsetmatch(SetWordType *e, char **zzBadText, char **zzMissText,
  637.             int *zzMissTok, int *zzBadTok,
  638.             SetWordType **zzMissSet)
  639. #else
  640. _zzsetmatch(e, zzBadText, zzMissText, zzMissTok, zzBadTok, zzMissSet)
  641. SetWordType *e;
  642. char **zzBadText;
  643. char **zzMissText;
  644. int *zzMissTok, *zzBadTok;
  645. SetWordType **zzMissSet;
  646. #endif
  647. {
  648. #ifdef DEMAND_LOOK
  649. #ifdef LL_K
  650.     if ( zzdirty==LL_K ) {zzCONSUME;}
  651. #else
  652.     if ( zzdirty ) {zzCONSUME;}
  653. #endif
  654. #endif
  655.     if ( !zzset_el((unsigned)LA(1), e) ) {
  656.         *zzBadText = LATEXT(1); *zzMissText=NULL;
  657.         *zzMissTok= 0; *zzBadTok=LA(1);
  658.         *zzMissSet=e;
  659.         return 0;
  660.     }
  661. #ifdef DEMAND_LOOK
  662. #ifdef LL_K
  663.     zzdirty++;
  664. #else
  665.     zzdirty = 1;
  666. #endif
  667. #endif
  668.     zzMakeAttr
  669.     return 1;
  670. }
  671.  
  672. int
  673. #ifdef __USE_PROTOS
  674. _zzmatch_wdfltsig(int tokenWanted, SetWordType *whatFollows)
  675. #else
  676. _zzmatch_wdfltsig(tokenWanted, whatFollows)
  677. int tokenWanted;
  678. SetWordType *whatFollows;
  679. #endif
  680. {
  681. #ifdef DEMAND_LOOK
  682. #ifdef LL_K
  683.     if ( zzdirty==LL_K ) {
  684.             zzCONSUME;
  685.     }
  686. #else
  687.     if ( zzdirty ) {zzCONSUME;}
  688. #endif
  689. #endif
  690.  
  691.     if ( LA(1)!=tokenWanted )
  692.     {
  693.         fprintf(stderr,
  694.                 "line %d: syntax error at \"%s\" missing %s\n",
  695.                 zzline,
  696.                 (LA(1)==zzEOF_TOKEN)?"<eof>":LATEXT(1),
  697.                 zztokens[tokenWanted]);
  698.         zzconsumeUntil( whatFollows );
  699.         return 0;
  700.     }
  701.     else {
  702.         zzMakeAttr                        
  703. #ifdef DEMAND_LOOK
  704. #ifdef LL_K
  705.         zzdirty++;
  706.         zzlabase++;
  707. #else
  708.         zzdirty = 1;
  709. #endif
  710. #else
  711. /*        zzCONSUME;         consume if not demand lookahead */
  712. #endif
  713.         return 1;
  714.     }
  715. }
  716.  
  717. int
  718. #ifdef __USE_PROTOS
  719. _zzsetmatch_wdfltsig(SetWordType *tokensWanted,
  720.                      int tokenTypeOfSet,
  721.                      SetWordType *whatFollows)
  722. #else
  723. _zzsetmatch_wdfltsig(tokensWanted, tokenTypeOfSet, whatFollows)
  724. SetWordType *tokensWanted;
  725. int tokenTypeOfSet;
  726. SetWordType *whatFollows;
  727. #endif
  728. {
  729. #ifdef DEMAND_LOOK
  730. #ifdef LL_K
  731.     if ( zzdirty==LL_K ) {zzCONSUME;}
  732. #else
  733.     if ( zzdirty ) {zzCONSUME;}
  734. #endif
  735. #endif
  736.     if ( !zzset_el((unsigned)LA(1), tokensWanted) )
  737.     {
  738.         fprintf(stderr,
  739.                 "line %d: syntax error at \"%s\" missing %s\n",
  740.                 zzline,
  741.                 (LA(1)==zzEOF_TOKEN)?"<eof>":LATEXT(1),
  742.                 zztokens[tokenTypeOfSet]);
  743.         zzconsumeUntil( whatFollows );
  744.         return 0;
  745.     }
  746.     else {
  747.         zzMakeAttr
  748. #ifdef DEMAND_LOOK
  749. #ifdef LL_K
  750.         zzdirty++;
  751.         zzlabase++;
  752. #else
  753.         zzdirty = 1;
  754. #endif
  755. #else
  756. /*        zzCONSUME;        consume if not demand lookahead */
  757. #endif
  758.         return 1;
  759.     }
  760. }
  761.  
  762. int
  763. #ifdef __USE_PROTOS
  764. _zzsetmatch_wsig(SetWordType *e)
  765. #else
  766. _zzsetmatch_wsig(e)
  767. SetWordType *e;
  768. #endif
  769. {
  770. #ifdef DEMAND_LOOK
  771. #ifdef LL_K
  772.     if ( zzdirty==LL_K ) {zzCONSUME;}
  773. #else
  774.     if ( zzdirty ) {zzCONSUME;}
  775. #endif
  776. #endif
  777.     if ( !zzset_el((unsigned)LA(1), e) ) return 0;
  778. #ifdef DEMAND_LOOK
  779. #ifdef LL_K
  780.     zzdirty++;
  781. #else
  782.     zzdirty = 1;
  783. #endif
  784. #endif
  785.     zzMakeAttr
  786.     return 1;
  787. }
  788.  
  789. #ifdef USER_ZZMODE_STACK
  790. static int  zzmstk[ZZMAXSTK] = { -1 };
  791. static int  zzmdep = 0;
  792. static char zzmbuf[70];
  793.  
  794. void
  795. #ifdef __USE_PROTOS
  796. zzmpush( int m )
  797. #else
  798. zzmpush( m )
  799. int m;
  800. #endif
  801. {
  802.    if(zzmdep == ZZMAXSTK - 1) {
  803.      sprintf(zzmbuf, "Mode stack overflow ");
  804.      zzerr(zzmbuf);
  805.    } else {
  806.      zzmstk[zzmdep++] = zzauto;
  807.      zzmode(m);
  808.    }
  809. }
  810.  
  811. void
  812. #ifdef __USE_PROTOS
  813. zzmpop( void )
  814. #else
  815. zzmpop( )
  816. #endif
  817. {
  818.    if(zzmdep == 0)
  819.    {  sprintf(zzmbuf, "Mode stack underflow ");
  820.       zzerr(zzmbuf);
  821.    }
  822.    else
  823.    {  zzmdep--;
  824.       zzmode(zzmstk[zzmdep]);
  825.    }
  826. }
  827.  
  828. void
  829. #ifdef __USE_PROTOS
  830. zzsave_mode_stack( int modeStack[], int *modeLevel )
  831. #else
  832. zzsave_mode_stack( modeStack, modeLevel )
  833. int modeStack[];
  834. int *modeLevel;
  835. #endif
  836. {
  837.   int i;
  838.   memcpy(modeStack, zzmstk, sizeof(zzmstk));
  839.   *modeLevel = zzmdep;
  840.   zzmdep = 0;
  841.     
  842.   return;
  843. }
  844.  
  845. void
  846. #ifdef __USE_PROTOS
  847. zzrestore_mode_stack( int modeStack[], int *modeLevel )
  848. #else
  849. zzrestore_mode_stack( modeStack, modeLevel )
  850. int modeStack[];
  851. int *modeLevel;
  852. #endif
  853. {
  854.   int i;
  855.  
  856.   memcpy(zzmstk, modeStack, sizeof(zzmstk));
  857.   zzmdep = *modeLevel;
  858.     
  859.   return;
  860. }
  861. #endif /* USER_ZZMODE_STACK */
  862.  
  863. #endif /* ERR_H */
  864.