This is Unofficial EPICS BASE Doxygen Site
tblcmp.c File Reference
#include "flexdef.h"
+ Include dependency graph for tblcmp.c:

Go to the source code of this file.

Functions

void mkentry (int *, int, int, int, int)
 
void mkprot (int[], int, int)
 
void mktemplate (int[], int, int)
 
void mv2front (int)
 
int tbldiff (int[], int, int[])
 
void bldtbl (int *state, int statenum, int totaltrans, int comstate, int comfreq)
 
void cmptmps (void)
 
void expand_nxt_chk (void)
 
int find_table_space (int *state, int numtrans)
 
void inittbl (void)
 
void mkdeftbl (void)
 
void mk1tbl (int state, int sym, int onenxt, int onedef)
 
void mkprot (int *state, int statenum, int comstate)
 
void mktemplate (int *state, int statenum, int comstate)
 
void place_state (int *state, int statenum, int transnum)
 
void stack1 (int statenum, int sym, int nextstate, int deflink)
 
int tbldiff (int *state, int pr, int *ext)
 

Function Documentation

void bldtbl ( int *  state,
int  statenum,
int  totaltrans,
int  comstate,
int  comfreq 
)

Definition at line 84 of file tblcmp.c.

85 {
86  int extptr, extrct[2][CSIZE + 1];
87  int mindiff, minprot, i, d;
88  int checkcom;
89 
90  /* If extptr is 0 then the first array of extrct holds the result of the
91  * "best difference" to date, which is those transitions which occur in
92  * "state" but not in the proto which, to date, has the fewest differences
93  * between itself and "state". If extptr is 1 then the second array of
94  * extrct hold the best difference. The two arrays are toggled
95  * between so that the best difference to date can be kept around and
96  * also a difference just created by checking against a candidate "best"
97  * proto.
98  */
99 
100  extptr = 0;
101 
102  /* if the state has too few out-transitions, don't bother trying to
103  * compact its tables
104  */
105 
106  if ( (totaltrans * 100) < (numecs * PROTO_SIZE_PERCENTAGE) )
107  mkentry( state, numecs, statenum, JAMSTATE, totaltrans );
108 
109  else
110  {
111  /* checkcom is true if we should only check "state" against
112  * protos which have the same "comstate" value
113  */
114 
115  checkcom = comfreq * 100 > totaltrans * CHECK_COM_PERCENTAGE;
116 
117  minprot = firstprot;
118  mindiff = totaltrans;
119 
120  if ( checkcom )
121  {
122  /* find first proto which has the same "comstate" */
123  for ( i = firstprot; i != NIL; i = protnext[i] )
124  if ( protcomst[i] == comstate )
125  {
126  minprot = i;
127  mindiff = tbldiff( state, minprot, extrct[extptr] );
128  break;
129  }
130  }
131 
132  else
133  {
134  /* since we've decided that the most common destination out
135  * of "state" does not occur with a high enough frequency,
136  * we set the "comstate" to zero, assuring that if this state
137  * is entered into the proto list, it will not be considered
138  * a template.
139  */
140  comstate = 0;
141 
142  if ( firstprot != NIL )
143  {
144  minprot = firstprot;
145  mindiff = tbldiff( state, minprot, extrct[extptr] );
146  }
147  }
148 
149  /* we now have the first interesting proto in "minprot". If
150  * it matches within the tolerances set for the first proto,
151  * we don't want to bother scanning the rest of the proto list
152  * to see if we have any other reasonable matches.
153  */
154 
155  if ( mindiff * 100 > totaltrans * FIRST_MATCH_DIFF_PERCENTAGE )
156  { /* not a good enough match. Scan the rest of the protos */
157  for ( i = minprot; i != NIL; i = protnext[i] )
158  {
159  d = tbldiff( state, i, extrct[1 - extptr] );
160  if ( d < mindiff )
161  {
162  extptr = 1 - extptr;
163  mindiff = d;
164  minprot = i;
165  }
166  }
167  }
168 
169  /* check if the proto we've decided on as our best bet is close
170  * enough to the state we want to match to be usable
171  */
172 
173  if ( mindiff * 100 > totaltrans * ACCEPTABLE_DIFF_PERCENTAGE )
174  {
175  /* no good. If the state is homogeneous enough, we make a
176  * template out of it. Otherwise, we make a proto.
177  */
178 
179  if ( comfreq * 100 >= totaltrans * TEMPLATE_SAME_PERCENTAGE )
180  mktemplate( state, statenum, comstate );
181 
182  else
183  {
184  mkprot( state, statenum, comstate );
185  mkentry( state, numecs, statenum, JAMSTATE, totaltrans );
186  }
187  }
188 
189  else
190  { /* use the proto */
191  mkentry( extrct[extptr], numecs, statenum,
192  prottbl[minprot], mindiff );
193 
194  /* if this state was sufficiently different from the proto
195  * we built it from, make it, too, a proto
196  */
197 
198  if ( mindiff * 100 >= totaltrans * NEW_PROTO_DIFF_PERCENTAGE )
199  mkprot( state, statenum, comstate );
200 
201  /* since mkprot added a new proto to the proto queue, it's possible
202  * that "minprot" is no longer on the proto queue (if it happened
203  * to have been the last entry, it would have been bumped off).
204  * If it's not there, then the new proto took its physical place
205  * (though logically the new proto is at the beginning of the
206  * queue), so in that case the following call will do nothing.
207  */
208 
209  mv2front( minprot );
210  }
211  }
212  }
void mkprot(int[], int, int)
int i
Definition: scan.c:967
#define PROTO_SIZE_PERCENTAGE
Definition: flexdef.h:206
#define TEMPLATE_SAME_PERCENTAGE
Definition: flexdef.h:233
int protcomst[MSP]
Definition: flex.c:82
#define NIL
Definition: flexdef.h:153
void mv2front(int)
Definition: tblcmp.c:776
int firstprot
Definition: flex.c:82
void mktemplate(int[], int, int)
int protnext[MSP]
Definition: flex.c:81
#define CHECK_COM_PERCENTAGE
Definition: flexdef.h:214
int prottbl[MSP]
Definition: flex.c:81
#define ACCEPTABLE_DIFF_PERCENTAGE
Definition: flexdef.h:227
#define JAMSTATE
Definition: flexdef.h:176
#define FIRST_MATCH_DIFF_PERCENTAGE
Definition: flexdef.h:221
int numecs
Definition: flex.c:83
#define CSIZE
Definition: flexdef.h:58
void mkentry(int *, int, int, int, int)
Definition: tblcmp.c:517
#define NEW_PROTO_DIFF_PERCENTAGE
Definition: flexdef.h:239
int tbldiff(int[], int, int[])
void cmptmps ( void  )

Definition at line 228 of file tblcmp.c.

229 {
230  int tmpstorage[CSIZE + 1];
231  int *tmp = tmpstorage, i, j;
232  int totaltrans, trans;
233 
235 
236  if ( usemecs )
237  {
238  /* create equivalence classes base on data gathered on template
239  * transitions
240  */
241 
243  }
244 
245  else
246  nummecs = numecs;
247 
248  if ( lastdfa + numtemps + 1 >= current_max_dfas )
250 
251  /* loop through each template */
252 
253  for ( i = 1; i <= numtemps; ++i )
254  {
255  totaltrans = 0; /* number of non-jam transitions out of this template */
256 
257  for ( j = 1; j <= numecs; ++j )
258  {
259  trans = tnxt[numecs * i + j];
260 
261  if ( usemecs )
262  {
263  /* the absolute value of tecbck is the meta-equivalence class
264  * of a given equivalence class, as set up by cre8ecs
265  */
266  if ( tecbck[j] > 0 )
267  {
268  tmp[tecbck[j]] = trans;
269 
270  if ( trans > 0 )
271  ++totaltrans;
272  }
273  }
274 
275  else
276  {
277  tmp[j] = trans;
278 
279  if ( trans > 0 )
280  ++totaltrans;
281  }
282  }
283 
284  /* it is assumed (in a rather subtle way) in the skeleton that
285  * if we're using meta-equivalence classes, the def[] entry for
286  * all templates is the jam template, i.e., templates never default
287  * to other non-jam table entries (e.g., another template)
288  */
289 
290  /* leave room for the jam-state after the last real state */
291  mkentry( tmp, nummecs, lastdfa + i + 1, JAMSTATE, totaltrans );
292  }
293  }
int nummecs
Definition: flex.c:83
int tecbck[CSIZE+1]
Definition: flex.c:84
int cre8ecs(int fwd[], int bck[], int num)
Definition: ecs.c:115
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int peakpairs
Definition: flex.c:101
int lastdfa
Definition: flex.c:91
int numtemps
Definition: flex.c:81
int usemecs
Definition: flex.c:67
int * tnxt
Definition: flex.c:91
int current_max_dfas
Definition: flex.c:90
void increase_max_dfas(void)
Definition: dfa.c:370
#define JAMSTATE
Definition: flexdef.h:176
int numecs
Definition: flex.c:83
#define CSIZE
Definition: flexdef.h:58
void mkentry(int *, int, int, int, int)
Definition: tblcmp.c:517
int tecfwd[CSIZE+1]
Definition: flex.c:83
void expand_nxt_chk ( void  )

Definition at line 299 of file tblcmp.c.

300 {
301  int old_max = current_max_xpairs;
302 
304 
305  ++num_reallocs;
306 
309 
310  memset( (char *) (chk + old_max), 0,
311  MAX_XPAIRS_INCREMENT * sizeof( int ) / sizeof( char ) );
312  }
int num_reallocs
Definition: flex.c:100
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
#define MAX_XPAIRS_INCREMENT
Definition: flexdef.h:186
int * nxt
Definition: flex.c:91
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
int find_table_space ( int *  state,
int  numtrans 
)

Definition at line 334 of file tblcmp.c.

335 {
336  /* firstfree is the position of the first possible occurrence of two
337  * consecutive unused records in the chk and nxt arrays
338  */
339  int i;
340  int *state_ptr, *chk_ptr;
341  int *ptr_to_last_entry_in_state;
342 
343  /* if there are too many out-transitions, put the state at the end of
344  * nxt and chk
345  */
346  if ( numtrans > MAX_XTIONS_FULL_INTERIOR_FIT )
347  {
348  /* if table is empty, return the first available spot in chk/nxt,
349  * which should be 1
350  */
351  if ( tblend < 2 )
352  return ( 1 );
353 
354  i = tblend - numecs; /* start searching for table space near the
355  * end of chk/nxt arrays
356  */
357  }
358 
359  else
360  i = firstfree; /* start searching for table space from the
361  * beginning (skipping only the elements
362  * which will definitely not hold the new
363  * state)
364  */
365 
366  while ( 1 ) /* loops until a space is found */
367  {
368  if ( i + numecs > current_max_xpairs )
369  expand_nxt_chk();
370 
371  /* loops until space for end-of-buffer and action number are found */
372  while ( 1 )
373  {
374  if ( chk[i - 1] == 0 ) /* check for action number space */
375  {
376  if ( chk[i] == 0 ) /* check for end-of-buffer space */
377  break;
378 
379  else
380  i += 2; /* since i != 0, there is no use checking to
381  * see if (++i) - 1 == 0, because that's the
382  * same as i == 0, so we skip a space
383  */
384  }
385 
386  else
387  ++i;
388 
389  if ( i + numecs > current_max_xpairs )
390  expand_nxt_chk();
391  }
392 
393  /* if we started search from the beginning, store the new firstfree for
394  * the next call of find_table_space()
395  */
396  if ( numtrans <= MAX_XTIONS_FULL_INTERIOR_FIT )
397  firstfree = i + 1;
398 
399  /* check to see if all elements in chk (and therefore nxt) that are
400  * needed for the new state have not yet been taken
401  */
402 
403  state_ptr = &state[1];
404  ptr_to_last_entry_in_state = &chk[i + numecs + 1];
405 
406  for ( chk_ptr = &chk[i + 1]; chk_ptr != ptr_to_last_entry_in_state;
407  ++chk_ptr )
408  if ( *(state_ptr++) != 0 && *chk_ptr != 0 )
409  break;
410 
411  if ( chk_ptr == ptr_to_last_entry_in_state )
412  return ( i );
413 
414  else
415  ++i;
416  }
417  }
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int firstfree
Definition: flex.c:92
#define MAX_XTIONS_FULL_INTERIOR_FIT
Definition: flexdef.h:258
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
void expand_nxt_chk(void)
Definition: tblcmp.c:299
void inittbl ( void  )

Definition at line 430 of file tblcmp.c.

431 {
432  int i;
433 
434  memset( (char *) chk, 0,
435  current_max_xpairs * sizeof( int ) / sizeof( char ) );
436 
437  tblend = 0;
438  firstfree = tblend + 1;
439  numtemps = 0;
440 
441  if ( usemecs )
442  {
443  /* set up doubly-linked meta-equivalence classes
444  * these are sets of equivalence classes which all have identical
445  * transitions out of TEMPLATES
446  */
447 
448  tecbck[1] = NIL;
449 
450  for ( i = 2; i <= numecs; ++i )
451  {
452  tecbck[i] = i - 1;
453  tecfwd[i - 1] = i;
454  }
455 
456  tecfwd[numecs] = NIL;
457  }
458  }
int tecbck[CSIZE+1]
Definition: flex.c:84
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
#define NIL
Definition: flexdef.h:153
int firstfree
Definition: flex.c:92
int numtemps
Definition: flex.c:81
int usemecs
Definition: flex.c:67
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
int tecfwd[CSIZE+1]
Definition: flex.c:83
void mk1tbl ( int  state,
int  sym,
int  onenxt,
int  onedef 
)

Definition at line 647 of file tblcmp.c.

648 {
649  if ( firstfree < sym )
650  firstfree = sym;
651 
652  while ( chk[firstfree] != 0 )
653  if ( ++firstfree >= current_max_xpairs )
654  expand_nxt_chk();
655 
656  base[state] = firstfree - sym;
657  def[state] = onedef;
658  chk[firstfree] = state;
659  nxt[firstfree] = onenxt;
660 
661  if ( firstfree > tblend )
662  {
663  tblend = firstfree++;
664 
665  if ( firstfree >= current_max_xpairs )
666  expand_nxt_chk();
667  }
668  }
int tblend
Definition: flex.c:92
int firstfree
Definition: flex.c:92
int onedef[ONE_STACK_SIZE]
Definition: flex.c:75
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int * def
Definition: flex.c:92
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
void expand_nxt_chk(void)
Definition: tblcmp.c:299
void mkdeftbl ( void  )

Definition at line 467 of file tblcmp.c.

468 {
469  int i;
470 
471  jamstate = lastdfa + 1;
472 
473  ++tblend; /* room for transition on end-of-buffer character */
474 
475  if ( tblend + numecs > current_max_xpairs )
476  expand_nxt_chk();
477 
478  /* add in default end-of-buffer transition */
480  chk[tblend] = jamstate;
481 
482  for ( i = 1; i <= numecs; ++i )
483  {
484  nxt[tblend + i] = 0;
485  chk[tblend + i] = jamstate;
486  }
487 
488  jambase = tblend;
489 
490  base[jamstate] = jambase;
491  def[jamstate] = 0;
492 
493  tblend += numecs;
494  ++numtemps;
495  }
int jambase
Definition: flex.c:95
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int lastdfa
Definition: flex.c:91
int numtemps
Definition: flex.c:81
int end_of_buffer_state
Definition: flex.c:105
int jamstate
Definition: flex.c:95
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int * def
Definition: flex.c:92
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
void expand_nxt_chk(void)
Definition: tblcmp.c:299
void mkentry ( int *  state,
int  numchars,
int  statenum,
int  deflink,
int  totaltrans 
)

Definition at line 517 of file tblcmp.c.

518 {
519  int minec, maxec, i, baseaddr;
520  int tblbase, tbllast;
521 
522  if ( totaltrans == 0 )
523  { /* there are no out-transitions */
524  if ( deflink == JAMSTATE )
525  base[statenum] = JAMSTATE;
526  else
527  base[statenum] = 0;
528 
529  def[statenum] = deflink;
530  return;
531  }
532 
533  for ( minec = 1; minec <= numchars; ++minec )
534  {
535  if ( state[minec] != SAME_TRANS )
536  if ( state[minec] != 0 || deflink != JAMSTATE )
537  break;
538  }
539 
540  if ( totaltrans == 1 )
541  {
542  /* there's only one out-transition. Save it for later to fill
543  * in holes in the tables.
544  */
545  stack1( statenum, minec, state[minec], deflink );
546  return;
547  }
548 
549  for ( maxec = numchars; maxec > 0; --maxec )
550  {
551  if ( state[maxec] != SAME_TRANS )
552  if ( state[maxec] != 0 || deflink != JAMSTATE )
553  break;
554  }
555 
556  /* Whether we try to fit the state table in the middle of the table
557  * entries we have already generated, or if we just take the state
558  * table at the end of the nxt/chk tables, we must make sure that we
559  * have a valid base address (i.e., non-negative). Note that not only are
560  * negative base addresses dangerous at run-time (because indexing the
561  * next array with one and a low-valued character might generate an
562  * array-out-of-bounds error message), but at compile-time negative
563  * base addresses denote TEMPLATES.
564  */
565 
566  /* find the first transition of state that we need to worry about. */
567  if ( totaltrans * 100 <= numchars * INTERIOR_FIT_PERCENTAGE )
568  { /* attempt to squeeze it into the middle of the tabls */
569  baseaddr = firstfree;
570 
571  while ( baseaddr < minec )
572  {
573  /* using baseaddr would result in a negative base address below
574  * find the next free slot
575  */
576  for ( ++baseaddr; chk[baseaddr] != 0; ++baseaddr )
577  ;
578  }
579 
580  if ( baseaddr + maxec - minec >= current_max_xpairs )
581  expand_nxt_chk();
582 
583  for ( i = minec; i <= maxec; ++i )
584  if ( state[i] != SAME_TRANS )
585  if ( state[i] != 0 || deflink != JAMSTATE )
586  if ( chk[baseaddr + i - minec] != 0 )
587  { /* baseaddr unsuitable - find another */
588  for ( ++baseaddr;
589  baseaddr < current_max_xpairs &&
590  chk[baseaddr] != 0;
591  ++baseaddr )
592  ;
593 
594  if ( baseaddr + maxec - minec >= current_max_xpairs )
595  expand_nxt_chk();
596 
597  /* reset the loop counter so we'll start all
598  * over again next time it's incremented
599  */
600 
601  i = minec - 1;
602  }
603  }
604 
605  else
606  {
607  /* ensure that the base address we eventually generate is
608  * non-negative
609  */
610  baseaddr = max( tblend + 1, minec );
611  }
612 
613  tblbase = baseaddr - minec;
614  tbllast = tblbase + maxec;
615 
616  if ( tbllast >= current_max_xpairs )
617  expand_nxt_chk();
618 
619  base[statenum] = tblbase;
620  def[statenum] = deflink;
621 
622  for ( i = minec; i <= maxec; ++i )
623  if ( state[i] != SAME_TRANS )
624  if ( state[i] != 0 || deflink != JAMSTATE )
625  {
626  nxt[tblbase + i] = state[i];
627  chk[tblbase + i] = statenum;
628  }
629 
630  if ( baseaddr == firstfree )
631  /* find next free slot in tables */
632  for ( ++firstfree; chk[firstfree] != 0; ++firstfree )
633  ;
634 
635  tblend = max( tblend, tbllast );
636  }
#define max(x, y)
Definition: flexdef.h:81
int i
Definition: scan.c:967
#define INTERIOR_FIT_PERCENTAGE
Definition: flexdef.h:245
int tblend
Definition: flex.c:92
int firstfree
Definition: flex.c:92
#define SAME_TRANS
Definition: flexdef.h:198
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int * def
Definition: flex.c:92
#define JAMSTATE
Definition: flexdef.h:176
void stack1(int statenum, int sym, int nextstate, int deflink)
Definition: tblcmp.c:851
int * chk
Definition: flex.c:91
int current_max_xpairs
Definition: flex.c:89
void expand_nxt_chk(void)
Definition: tblcmp.c:299
void mkprot ( int  [],
int  ,
int   
)
void mkprot ( int *  state,
int  statenum,
int  comstate 
)

Definition at line 678 of file tblcmp.c.

679 {
680  int i, slot, tblbase;
681 
682  if ( ++numprots >= MSP || numecs * numprots >= PROT_SAVE_SIZE )
683  {
684  /* gotta make room for the new proto by dropping last entry in
685  * the queue
686  */
687  slot = lastprot;
689  protnext[lastprot] = NIL;
690  }
691 
692  else
693  slot = numprots;
694 
695  protnext[slot] = firstprot;
696 
697  if ( firstprot != NIL )
698  protprev[firstprot] = slot;
699 
700  firstprot = slot;
701  prottbl[slot] = statenum;
702  protcomst[slot] = comstate;
703 
704  /* copy state into save area so it can be compared with rapidly */
705  tblbase = numecs * (slot - 1);
706 
707  for ( i = 1; i <= numecs; ++i )
708  protsave[tblbase + i] = state[i];
709  }
int lastprot
Definition: flex.c:82
#define PROT_SAVE_SIZE
Definition: flexdef.h:250
int i
Definition: scan.c:967
int protsave[PROT_SAVE_SIZE]
Definition: flex.c:82
int protcomst[MSP]
Definition: flex.c:82
#define NIL
Definition: flexdef.h:153
int firstprot
Definition: flex.c:82
int protnext[MSP]
Definition: flex.c:81
int numprots
Definition: flex.c:81
#define MSP
Definition: flexdef.h:252
int prottbl[MSP]
Definition: flex.c:81
int numecs
Definition: flex.c:83
int protprev[MSP]
Definition: flex.c:81
void mktemplate ( int  [],
int  ,
int   
)
void mktemplate ( int *  state,
int  statenum,
int  comstate 
)

Definition at line 720 of file tblcmp.c.

721 {
722  int i, numdiff, tmpbase, tmp[CSIZE + 1];
723  Char transset[CSIZE + 1];
724  int tsptr;
725 
726  ++numtemps;
727 
728  tsptr = 0;
729 
730  /* calculate where we will temporarily store the transition table
731  * of the template in the tnxt[] array. The final transition table
732  * gets created by cmptmps()
733  */
734 
735  tmpbase = numtemps * numecs;
736 
737  if ( tmpbase + numecs >= current_max_template_xpairs )
738  {
740 
741  ++num_reallocs;
742 
744  }
745 
746  for ( i = 1; i <= numecs; ++i )
747  if ( state[i] == 0 )
748  tnxt[tmpbase + i] = 0;
749  else
750  {
751  transset[tsptr++] = i;
752  tnxt[tmpbase + i] = comstate;
753  }
754 
755  if ( usemecs )
756  mkeccl( transset, tsptr, tecfwd, tecbck, numecs, 0 );
757 
758  mkprot( tnxt + tmpbase, -numtemps, comstate );
759 
760  /* we rely on the fact that mkprot adds things to the beginning
761  * of the proto queue
762  */
763 
764  numdiff = tbldiff( state, firstprot, tmp );
765  mkentry( tmp, numecs, statenum, -numtemps, numdiff );
766  }
void mkprot(int[], int, int)
int tecbck[CSIZE+1]
Definition: flex.c:84
int i
Definition: scan.c:967
int num_reallocs
Definition: flex.c:100
int numtemps
Definition: flex.c:81
int current_max_template_xpairs
Definition: flex.c:90
int usemecs
Definition: flex.c:67
int * tnxt
Definition: flex.c:91
#define Char
Definition: flexdef.h:59
int firstprot
Definition: flex.c:82
#define reallocate_integer_array(array, size)
Definition: flexdef.h:584
int numecs
Definition: flex.c:83
#define CSIZE
Definition: flexdef.h:58
void mkeccl(unsigned char ccls[], int lenccl, int fwd[], int bck[], int llsiz, int NUL_mapping)
Definition: ecs.c:232
#define MAX_TEMPLATE_XPAIRS_INCREMENT
Definition: flexdef.h:190
void mkentry(int *, int, int, int, int)
Definition: tblcmp.c:517
int tecfwd[CSIZE+1]
Definition: flex.c:83
int tbldiff(int[], int, int[])
void mv2front ( int  qelm)

Definition at line 776 of file tblcmp.c.

777 {
778  if ( firstprot != qelm )
779  {
780  if ( qelm == lastprot )
782 
783  protnext[protprev[qelm]] = protnext[qelm];
784 
785  if ( protnext[qelm] != NIL )
786  protprev[protnext[qelm]] = protprev[qelm];
787 
788  protprev[qelm] = NIL;
789  protnext[qelm] = firstprot;
790  protprev[firstprot] = qelm;
791  firstprot = qelm;
792  }
793  }
int lastprot
Definition: flex.c:82
#define NIL
Definition: flexdef.h:153
int firstprot
Definition: flex.c:82
int protnext[MSP]
Definition: flex.c:81
int protprev[MSP]
Definition: flex.c:81
void place_state ( int *  state,
int  statenum,
int  transnum 
)

Definition at line 807 of file tblcmp.c.

808 {
809  int i;
810  int *state_ptr;
811  int position = find_table_space( state, transnum );
812 
813  /* base is the table of start positions */
814  base[statenum] = position;
815 
816  /* put in action number marker; this non-zero number makes sure that
817  * find_table_space() knows that this position in chk/nxt is taken
818  * and should not be used for another accepting number in another state
819  */
820  chk[position - 1] = 1;
821 
822  /* put in end-of-buffer marker; this is for the same purposes as above */
823  chk[position] = 1;
824 
825  /* place the state into chk and nxt */
826  state_ptr = &state[1];
827 
828  for ( i = 1; i <= numecs; ++i, ++state_ptr )
829  if ( *state_ptr != 0 )
830  {
831  chk[position + i] = i;
832  nxt[position + i] = *state_ptr;
833  }
834 
835  if ( position + numecs > tblend )
836  tblend = position + numecs;
837  }
int i
Definition: scan.c:967
int tblend
Definition: flex.c:92
int find_table_space(int *state, int numtrans)
Definition: tblcmp.c:334
int * nxt
Definition: flex.c:91
int * base
Definition: flex.c:92
int numecs
Definition: flex.c:83
int * chk
Definition: flex.c:91
void stack1 ( int  statenum,
int  sym,
int  nextstate,
int  deflink 
)

Definition at line 851 of file tblcmp.c.

852 {
853  if ( onesp >= ONE_STACK_SIZE - 1 )
854  mk1tbl( statenum, sym, nextstate, deflink );
855 
856  else
857  {
858  ++onesp;
859  onestate[onesp] = statenum;
860  onesym[onesp] = sym;
861  onenext[onesp] = nextstate;
862  onedef[onesp] = deflink;
863  }
864  }
int onestate[ONE_STACK_SIZE]
Definition: flex.c:74
#define ONE_STACK_SIZE
Definition: flexdef.h:197
int onesp
Definition: flex.c:75
void mk1tbl(int state, int sym, int onenxt, int onedef)
Definition: tblcmp.c:647
int onesym[ONE_STACK_SIZE]
Definition: flex.c:74
int onedef[ONE_STACK_SIZE]
Definition: flex.c:75
int onenext[ONE_STACK_SIZE]
Definition: flex.c:75
int tbldiff ( int  [],
int  ,
int  [] 
)
int tbldiff ( int *  state,
int  pr,
int *  ext 
)

Definition at line 885 of file tblcmp.c.

886 {
887  int i, *sp = state, *ep = ext, *protp;
888  int numdiff = 0;
889 
890  protp = &protsave[numecs * (pr - 1)];
891 
892  for ( i = numecs; i > 0; --i )
893  {
894  if ( *++protp == *++sp )
895  *++ep = SAME_TRANS;
896  else
897  {
898  *++ep = *sp;
899  ++numdiff;
900  }
901  }
902 
903  return ( numdiff );
904  }
int i
Definition: scan.c:967
int protsave[PROT_SAVE_SIZE]
Definition: flex.c:82
#define SAME_TRANS
Definition: flexdef.h:198
int numecs
Definition: flex.c:83