wipe out config lookup in ATNConfigSet when it goes readonly.

This commit is contained in:
Terence Parr 2012-07-27 22:20:23 -07:00
parent 54fd28c29d
commit 7ff5544573
3 changed files with 88 additions and 5 deletions

View File

@ -63,7 +63,7 @@ import java.util.Set;
1 12
1 119 <- max size
322 set size for SLL parser java.*
322 set size for SLL parser java.* in DFA states:
888 1
411 54
@ -142,6 +142,91 @@ import java.util.Set;
1 9
1 2
javalr, java.* all atnconfigsets; max size = 322, num sets = 269088
114186 1 <-- optimize
35712 6
28081 78
15252 54
14171 56
13159 12
11810 88
6873 86
6158 80
5169 4
3773 118
2350 16
1002 112
915 28
898 44
734 2
632 62
575 8
566 59
474 20
388 84
343 48
333 55
328 47
311 41
306 38
277 81
263 79
255 66
245 90
245 87
234 50
224 10
220 60
194 64
186 32
184 82
150 18
125 7
121 132
116 30
103 51
95 114
84 36
82 40
78 22
77 89
55 9
53 174
48 152
44 67
44 5
42 115
41 58
38 122
37 134
34 13
34 116
29 45
29 3
29 24
27 144
26 146
25 91
24 113
20 27
...
number with 1-9 elements:
114186 1
35712 6
5169 4
734 2
575 8
125 7
55 9
44 5
29 3
Can cover 60% of sizes with size up to 6
Can cover 44% of sizes with size up to 4
Can cover 42% of sizes with size up to 1
*/
public class ATNConfigSet implements Set<ATNConfig> {
/*
@ -366,6 +451,7 @@ public class ATNConfigSet implements Set<ATNConfig> {
public void setReadonly(boolean readonly) {
this.readonly = readonly;
configLookup.clear();
}
@Override

View File

@ -651,9 +651,6 @@ public class ParserATNSimulator<Symbol extends Token> extends ATNSimulator {
}
if ( reach.size()==0 ) return null;
// reach.setConflictingAlts(getConflictingAlts(reach, false));
//
return reach;
}

View File

@ -270,7 +270,7 @@ public class Array2DHashSet<T> implements Set<T> {
@Override
public void clear() {
buckets = (T[][])new Object[buckets.length][];
buckets = (T[][])new Object[INITAL_CAPACITY][];
n = 0;
}