1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
package com.stevesoft.pat; |
9 |
|
|
10 |
|
import java.util.Hashtable; |
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
|
|
| 52.2% |
Uncovered Elements: 43 (90) |
Complexity: 25 |
Complexity Density: 0.44 |
|
16 |
|
class Multi_stage2 extends PatternSub |
17 |
|
{ |
18 |
|
Pattern nextRet; |
19 |
|
|
20 |
|
patInt count; |
21 |
|
|
22 |
|
patInt matchMin, matchMax; |
23 |
|
|
24 |
|
public boolean matchFewest = false; |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
26 |
0 |
public String toString()... |
27 |
|
{ |
28 |
0 |
String ret = ""; |
29 |
0 |
ret += sub.toString(); |
30 |
0 |
ret += "{" + matchMin + "," + matchMax + "}"; |
31 |
0 |
if (matchFewest) |
32 |
|
{ |
33 |
0 |
ret += "?"; |
34 |
|
} |
35 |
0 |
ret += parent.nextString(); |
36 |
0 |
return ret; |
37 |
|
} |
38 |
|
|
|
|
| 68.4% |
Uncovered Elements: 6 (19) |
Complexity: 4 |
Complexity Density: 0.31 |
|
39 |
16 |
Multi_stage2(patInt a, patInt b, Pattern p) throws RegSyntax... |
40 |
|
{ |
41 |
16 |
if (p == null) |
42 |
|
{ |
43 |
0 |
RegSyntaxError.endItAll("Multiple match of Null pattern requested."); |
44 |
|
} |
45 |
16 |
sub = p; |
46 |
16 |
nextRet = this; |
47 |
16 |
sub.setParent(this); |
48 |
16 |
matchMin = a; |
49 |
16 |
matchMax = b; |
50 |
16 |
count = new patInt(0); |
51 |
|
|
52 |
|
|
53 |
16 |
if (!a.lessEq(b)) |
54 |
|
{ |
55 |
|
|
56 |
0 |
RegSyntaxError.endItAll("Bad Multi Args: " + a + ">" + b); |
57 |
|
} |
58 |
16 |
patInt i = new patInt(-1); |
59 |
16 |
if (a.lessEq(i)) |
60 |
|
{ |
61 |
|
|
62 |
0 |
RegSyntaxError.endItAll("Bad Multi Args: " + a + "< 0"); |
63 |
|
} |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
350 |
public Pattern getNext()... |
67 |
|
{ |
68 |
350 |
return nextRet; |
69 |
|
} |
70 |
|
|
71 |
|
int pos_old = -1; |
72 |
|
|
|
|
| 58.8% |
Uncovered Elements: 21 (51) |
Complexity: 16 |
Complexity Density: 0.52 |
|
73 |
350 |
public int matchInternal(int pos, Pthings pt)... |
74 |
|
{ |
75 |
350 |
sub.setParent(this); |
76 |
|
|
77 |
350 |
int canUse = -1; |
78 |
|
|
79 |
|
|
80 |
350 |
if (pos_old >= 0 && pos == pos_old) |
81 |
|
{ |
82 |
0 |
return -1; |
83 |
|
} |
84 |
350 |
pos_old = pos; |
85 |
|
|
86 |
350 |
if (matchMin.lessEq(count)) |
87 |
|
{ |
88 |
342 |
canUse = pos; |
89 |
|
} |
90 |
350 |
if (!count.lessEq(matchMax) || pos > pt.src.length()) |
91 |
|
{ |
92 |
0 |
return -1; |
93 |
|
} |
94 |
|
|
95 |
350 |
if ((matchFewest || count.equals(matchMax)) && canUse >= 0) |
96 |
|
{ |
97 |
0 |
Pattern n = super.getNext(); |
98 |
0 |
if (n == null) |
99 |
|
{ |
100 |
0 |
return canUse; |
101 |
|
} |
102 |
0 |
int ret = testMatch(n, pos, pt); |
103 |
0 |
if (ret >= 0) |
104 |
|
{ |
105 |
0 |
return ret; |
106 |
|
} |
107 |
|
else |
108 |
|
{ |
109 |
0 |
canUse = -1; |
110 |
|
} |
111 |
|
} |
112 |
|
|
113 |
350 |
count.inc(); |
114 |
350 |
try |
115 |
|
{ |
116 |
350 |
if (count.lessEq(matchMax)) |
117 |
|
{ |
118 |
350 |
int r = testMatch(sub, pos, pt); |
119 |
350 |
if (r >= 0) |
120 |
|
{ |
121 |
342 |
return r; |
122 |
|
} |
123 |
|
} |
124 |
|
} finally |
125 |
|
{ |
126 |
350 |
count.dec(); |
127 |
|
} |
128 |
|
|
129 |
8 |
if (!matchFewest && canUse >= 0) |
130 |
|
{ |
131 |
8 |
Pattern n = super.getNext(); |
132 |
8 |
if (n == null) |
133 |
|
{ |
134 |
0 |
return canUse; |
135 |
|
} |
136 |
8 |
int ret = testMatch(n, pos, pt); |
137 |
8 |
return ret; |
138 |
|
} |
139 |
|
else |
140 |
|
{ |
141 |
0 |
return canUse; |
142 |
|
} |
143 |
|
} |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
145 |
0 |
public Pattern clone1(Hashtable h)... |
146 |
|
{ |
147 |
0 |
try |
148 |
|
{ |
149 |
0 |
Multi_stage2 m = new Multi_stage2(matchMin, matchMax, sub.clone(h)); |
150 |
0 |
m.matchFewest = matchFewest; |
151 |
0 |
return m; |
152 |
|
} catch (RegSyntax rs) |
153 |
|
{ |
154 |
0 |
return null; |
155 |
|
} |
156 |
|
} |
157 |
|
}; |