1 /* |
|
2 * Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
3 * this software and associated documentation files (the "Software"), to deal in |
|
4 * the Software without restriction, including without limitation the rights to |
|
5 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
|
6 * of the Software, and to permit persons to whom the Software is furnished to do |
|
7 * so, subject to the following conditions: |
|
8 * |
|
9 * The above copyright notice and this permission notice shall be included in all |
|
10 * copies or substantial portions of the Software. |
|
11 * |
|
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
18 * SOFTWARE. |
|
19 */ |
|
20 package jdk.nashorn.internal.runtime.regexp.joni.constants; |
|
21 |
|
22 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.A; |
|
23 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.AQ; |
|
24 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.ASIS; |
|
25 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.DEL; |
|
26 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.PQ_Q; |
|
27 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.P_QQ; |
|
28 import static jdk.nashorn.internal.runtime.regexp.joni.constants.Reduce.ReduceType.QQ; |
|
29 |
|
30 public interface Reduce { |
|
31 |
|
32 enum ReduceType { |
|
33 ASIS, /* as is */ |
|
34 DEL, /* delete parent */ |
|
35 A, /* to '*' */ |
|
36 AQ, /* to '*?' */ |
|
37 QQ, /* to '??' */ |
|
38 P_QQ, /* to '+)??' */ |
|
39 PQ_Q, /* to '+?)?' */ |
|
40 } |
|
41 |
|
42 final ReduceType[][]REDUCE_TABLE = { |
|
43 {DEL, A, A, QQ, AQ, ASIS}, /* '?' */ |
|
44 {DEL, DEL, DEL, P_QQ, P_QQ, DEL}, /* '*' */ |
|
45 {A, A, DEL, ASIS, P_QQ, DEL}, /* '+' */ |
|
46 {DEL, AQ, AQ, DEL, AQ, AQ}, /* '??' */ |
|
47 {DEL, DEL, DEL, DEL, DEL, DEL}, /* '*?' */ |
|
48 {ASIS, PQ_Q, DEL, AQ, AQ, DEL} /* '+?' */ |
|
49 }; |
|
50 |
|
51 |
|
52 final String PopularQStr[] = new String[] { |
|
53 "?", "*", "+", "??", "*?", "+?" |
|
54 }; |
|
55 |
|
56 String ReduceQStr[]= new String[] { |
|
57 "", "", "*", "*?", "??", "+ and ??", "+? and ?" |
|
58 }; |
|
59 |
|
60 } |
|
61 |
|