*
* synopsis
* int cre8ecs();
- * number of classes = cre8ecs( fwd, bck, num );
+ * number of classes = cre8ecs( fwd, bck, num, start_pos );
*
* fwd is the forward linked-list of equivalence class members. bck
* is the backward linked-list, and num is the number of class members.
+ * start_pos is 0 if the class members begin in fwd[] and bck[] at
+ * position 0, and 1 if they begin at position 1.
+ *
* Returned is the number of classes.
*/
-int cre8ecs( fwd, bck, num )
-int fwd[], bck[], num;
+int cre8ecs( fwd, bck, num, start_pos )
+int fwd[], bck[], num, start_pos;
{
int i, j, numcl;
* class.
*/
- for ( i = 1; i <= num; ++i )
+ for ( i = start_pos; i < num + start_pos; ++i )
if ( bck[i] == NIL )
{
bck[i] = ++numcl;
{
int i;
- for ( i = 1; i <= csize; ++i )
+ for ( i = (uses_NUL ? 0 : 1); i < csize; ++i )
if ( xlation[i] == 0 )
ecmap[i] = num_xlations + 1;
else
#endif
#ifdef FLEX_8_BIT_CHARS
-#define CSIZE 255
+#define CSIZE 256
#define Char unsigned char
#else
#define Char char
/* size of input alphabet - should be size of ASCII set */
#ifndef CSIZE
-#define CSIZE 127
+#define CSIZE 128
#endif
#define INITIAL_MAX_CCLS 100 /* max number of unique character classes */
* backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
* listing backtracking states
* csize - size of character set for the scanner we're generating;
- * 127 for 7-bit chars and 255 for 8-bit
+ * 128 for 7-bit chars and 256 for 8-bit
* yymore_used - if true, yymore() is used in input rules
* reject - if true, generate backtracking tables for REJECT macro
* real_reject - if true, scanner really uses REJECT (as opposed to just
* num_xlations - number of different xlation values
*/
-extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
+extern int numecs, nextecm[CSIZE], ecgroup[CSIZE], nummecs;
+
+/* meta-equivalence classes are indexed starting at 1, so it's possible
+ * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
+ * slots total (since the arrays are 0-based). nextecm[] and ecgroup[]
+ * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
+ */
extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
+
extern int *xlation;
extern int num_xlations;
* hshsave - number of hash collisions saved by checking number of states
* num_backtracking - number of DFA states requiring back-tracking
* bol_needed - whether scanner needs beginning-of-line recognition
+ * uses_NUL - true if the scanner needs to be able to recognize NUL's
*/
extern char *starttime, *endtime, nmstr[MAXLINE];
extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
-extern int num_backtracking, bol_needed;
+extern int num_backtracking, bol_needed, uses_NUL;
char *allocate_array(), *reallocate_array();