1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
This patch, relative to the flex-2.5.4a sources, permits really large
NFA and DFAs when flex is passed the -Ca option (since in that case it
does not affect performance in any way).
Note: The patch is ALREADY applied in the Debian GNU/Linux package
since flex-2.5.4a-6.
$Id: EnlargeFlex.patch,v 1.2 1999/12/13 15:57:18 krisrose Exp $
Copyright 1999 Kristoffer Rose; placed in the public domain.
diff -ur flex-2.5.4a/MISC/texinfo/flex.texi.orig flex-2.5.4a/MISC/texinfo/flex.texi
--- flex-2.5.4a/MISC/texinfo/flex.texi.orig Sun Jul 27 04:47:21 1997
+++ flex-2.5.4a/MISC/texinfo/flex.texi Fri Dec 3 18:59:51 1999
@@ -2152,8 +2152,10 @@
aligned for memory access and computation. On some
RISC architectures, fetching and manipulating
long-words is more efficient than with smaller-sized
-units such as shortwords. This option can double
-the size of the tables used by your scanner.
+units such as shortwords. This option can quadruple
+the size of the tables used by your scanner. It has the
+side effect of permitting much larger scanners, however,
+if you need this.
@samp{-Ce} directs @code{flex} to construct @dfn{equivalence classes},
i.e., sets of characters which have identical
diff -ur flex-2.5.4a/flexdef.h.orig flex-2.5.4a/flexdef.h
--- flex-2.5.4a/flexdef.h.orig Sun Jul 27 04:42:50 1997
+++ flex-2.5.4a/flexdef.h Fri Dec 3 18:46:36 1999
@@ -214,11 +214,12 @@
/* Maximum number of NFA states. */
#define MAXIMUM_MNS 31999
+#define MAXIMUM_MNS_LONG 3999999
/* Enough so that if it's subtracted from an NFA state number, the result
* is guaranteed to be negative.
*/
-#define MARKER_DIFFERENCE (MAXIMUM_MNS+2)
+#define MARKER_DIFFERENCE (maximum_mns+2)
/* Maximum number of nxt/chk pairs for non-templates. */
#define INITIAL_MAX_XPAIRS 2000
@@ -457,6 +458,7 @@
/* Variables for nfa machine data:
+ * maximum_mns - maximal number of NFA states supported by tables
* current_mns - current maximum on number of NFA states
* num_rules - number of the last accepting state; also is number of
* rules created so far
@@ -485,7 +487,7 @@
* rule_useful - true if we've determined that the rule can be matched
*/
-extern int current_mns, current_max_rules;
+extern int maximum_mns, current_mns, current_max_rules;
extern int num_rules, num_eof_rules, default_rule, lastnfa;
extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
extern int *accptnum, *assoc_rule, *state_type;
diff -ur flex-2.5.4a/main.c.orig flex-2.5.4a/main.c
--- flex-2.5.4a/main.c.orig Sun Jul 27 04:32:19 1997
+++ flex-2.5.4a/main.c Fri Dec 3 18:57:27 1999
@@ -70,7 +70,7 @@
int do_stdinit, use_stdout;
int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
-int current_mns, current_max_rules;
+int maximum_mns, current_mns, current_max_rules;
int num_rules, num_eof_rules, default_rule, lastnfa;
int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
int *accptnum, *assoc_rule, *state_type;
@@ -1056,6 +1056,7 @@
void set_up_initial_allocations()
{
+ maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS);
current_mns = INITIAL_MNS;
firstst = allocate_integer_array( current_mns );
lastst = allocate_integer_array( current_mns );
diff -ur flex-2.5.4a/nfa.c.orig flex-2.5.4a/nfa.c
--- flex-2.5.4a/nfa.c.orig Sun Jul 27 04:32:19 1997
+++ flex-2.5.4a/nfa.c Fri Dec 3 18:44:33 1999
@@ -595,7 +595,7 @@
{
if ( ++lastnfa >= current_mns )
{
- if ( (current_mns += MNS_INCREMENT) >= MAXIMUM_MNS )
+ if ( (current_mns += MNS_INCREMENT) >= maximum_mns )
lerrif(
_( "input rules are too complicated (>= %d NFA states)" ),
current_mns );
|