1 Clazz.declarePackage ("com.stevesoft.pat");
\r
2 Clazz.load (["com.stevesoft.pat.Bracket"], "com.stevesoft.pat.FastBracket", ["com.stevesoft.pat.Range", "$.oneChar", "java.util.BitSet", "$.Vector"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
7 Clazz.instantialize (this, arguments);
\r
8 }, com.stevesoft.pat, "FastBracket", com.stevesoft.pat.Bracket);
\r
9 c$.process = Clazz.defineMethod (c$, "process",
\r
10 function (b, ignc) {
\r
16 nv = new java.util.Vector ();
\r
17 for (var i = 0; i < v.size (); i++) {
\r
18 var p = v.elementAt (i);
\r
20 if (Clazz.instanceOf (p, com.stevesoft.pat.oneChar)) {
\r
22 nv.addElement ( new com.stevesoft.pat.oneChar (oc.altc));
\r
23 } else if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
\r
25 nv.addElement ( new com.stevesoft.pat.Range (ra.altlo, ra.althi));
\r
28 for (var i = 0; i < v.size () - 1; i++) {
\r
29 for (var j = 0; j < v.size () - 1; j++) {
\r
30 var c1 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j));
\r
31 var c2 = com.stevesoft.pat.FastBracket.getl (v.elementAt (j + 1));
\r
33 var o = v.elementAt (j);
\r
34 v.setElementAt (v.elementAt (j + 1), j);
\r
35 v.setElementAt (o, j + 1);
\r
38 nv = new java.util.Vector ();
\r
39 var p = v.elementAt (0);
\r
41 for (var i = 1; i < v.size (); i++) {
\r
42 if ((com.stevesoft.pat.FastBracket.geth (p)).charCodeAt (0) + 1 >= (com.stevesoft.pat.FastBracket.getl (v.elementAt (i))).charCodeAt (0)) {
\r
43 var p2 = v.elementAt (i);
\r
44 var lo = com.stevesoft.pat.FastBracket.min (com.stevesoft.pat.FastBracket.getl (p), com.stevesoft.pat.FastBracket.getl (p2));
\r
45 var hi = com.stevesoft.pat.FastBracket.max (com.stevesoft.pat.FastBracket.geth (p), com.stevesoft.pat.FastBracket.geth (p2));
\r
46 nv.setElementAt (p = com.stevesoft.pat.FastBracket.mkelem (lo, hi), nv.size () - 1);
\r
48 p = v.elementAt (i);
\r
53 if (Clazz.exceptionOf (e, com.stevesoft.pat.RegSyntax)) {
\r
54 e.printStackTrace ();
\r
59 var negv = com.stevesoft.pat.FastBracket.neg (v);
\r
60 if (v.size () == 1) {
\r
62 }if (negv.size () == 1) {
\r
66 }var fb = com.stevesoft.pat.FastBracket.newbrack (v, b.neg);
\r
68 fb = com.stevesoft.pat.FastBracket.newbrack (negv, !b.neg);
\r
70 fb.parent = b.parent;
\r
74 }, "com.stevesoft.pat.Bracket,~B");
\r
75 c$.newbrack = Clazz.defineMethod (c$, "newbrack",
\r
77 var fb = new com.stevesoft.pat.FastBracket (neg);
\r
79 if (v.size () == 0) {
\r
81 }fb.$min = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);
\r
82 fb.$max = (com.stevesoft.pat.FastBracket.geth (v.elementAt (v.size () - 1))).charCodeAt (0);
\r
83 if (fb.$max - fb.$min <= 256) {
\r
84 fb.bs = new java.util.BitSet (fb.$max - fb.$min + 1);
\r
85 for (var i = 0; i < v.size (); i++) {
\r
86 var o = v.elementAt (i);
\r
87 var min0 = (com.stevesoft.pat.FastBracket.getl (o)).charCodeAt (0) - fb.$min;
\r
88 var max0 = (com.stevesoft.pat.FastBracket.geth (o)).charCodeAt (0) - fb.$min;
\r
89 for (var j = min0; j <= max0; j++) {
\r
95 }, "java.util.Vector,~B");
\r
96 c$.neg = Clazz.defineMethod (c$, "neg",
\r
99 var nv = new java.util.Vector ();
\r
100 if (v.size () == 0) {
\r
101 nv.addElement ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (65535)));
\r
103 }var p0 = (com.stevesoft.pat.FastBracket.getl (v.elementAt (0))).charCodeAt (0);
\r
105 nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (0), String.fromCharCode (p0 - 1)));
\r
106 }for (var i = 0; i < v.size () - 1; i++) {
\r
107 var hi = (com.stevesoft.pat.FastBracket.getl (v.elementAt (i + 1))).charCodeAt (0) - 1;
\r
108 var lo = (com.stevesoft.pat.FastBracket.geth (v.elementAt (i))).charCodeAt (0) + 1;
\r
109 nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (lo), String.fromCharCode (hi)));
\r
111 var pN = (com.stevesoft.pat.FastBracket.geth (v.lastElement ())).charCodeAt (0);
\r
113 nv.addElement (com.stevesoft.pat.FastBracket.mkelem (String.fromCharCode (pN + 1), String.fromCharCode (65535)));
\r
116 if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {
\r
122 }, "java.util.Vector");
\r
123 c$.mkelem = Clazz.defineMethod (c$, "mkelem",
\r
124 function (lo, hi) {
\r
125 return lo == hi ? ( new com.stevesoft.pat.oneChar (lo)) : ( new com.stevesoft.pat.Range (lo, hi));
\r
127 c$.min = Clazz.defineMethod (c$, "min",
\r
129 return a < b ? a : b;
\r
131 c$.max = Clazz.defineMethod (c$, "max",
\r
133 return a > b ? a : b;
\r
135 c$.getl = Clazz.defineMethod (c$, "getl",
\r
138 if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
\r
142 c$.geth = Clazz.defineMethod (c$, "geth",
\r
145 if (Clazz.instanceOf (p, com.stevesoft.pat.Range)) {
\r
149 Clazz.overrideMethod (c$, "matchInternal",
\r
150 function (pos, pt) {
\r
151 if (pos >= pt.src.length () || this.Masked (pos, pt)) {
\r
153 }var c = pt.src.charAt (pos);
\r
154 return ( new Boolean (this.neg ^ (c.charCodeAt (0) >= this.$min && c.charCodeAt (0) <= this.$max && this.bs.get (c.charCodeAt (0) - this.$min))).valueOf ()) ? this.nextMatch (pos + 1, pt) : -1;
\r
155 }, "~N,com.stevesoft.pat.Pthings");
\r