JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / com / stevesoft / pat / Regex.js
1 Clazz.declarePackage ("com.stevesoft.pat");\r
2 Clazz.load (["com.stevesoft.pat.RegRes", "$.UniValidator", "jalview.jsdev.api.RegExpInterface", "com.stevesoft.pat.NoPattern", "$.Pthings", "$.patInt", "java.util.Hashtable"], ["com.stevesoft.pat.UnicodeW", "$.UnicodeCurrency", "$.UnicodeAlpha", "$.UnicodeUpper", "$.NUnicodeCurrency", "$.NUnicodeW", "$.NUnicodeAlpha", "$.UnicodeMath", "$.UnicodeWhite", "$.UnicodeDigit", "$.NUnicodeMath", "$.Regex", "$.NUnicodeDigit", "$.NUnicodeWhite", "$.NUnicodePunct", "$.UnicodePunct", "$.UnicodeLower"], ["com.stevesoft.pat.Any", "$.BackG", "$.BackMatch", "$.Backup", "$.Boundary", "$.Bracket", "$.CaseMgr", "$.Ctrl", "$.Custom", "$.CustomEndpoint", "$.DotMulti", "$.End", "$.FastMulti", "$.Group", "$.MessageManager", "$.Multi", "$.NullPattern", "$.Or", "$.OrMark", "$.Prop", "$.Range", "$.RegOpt", "$.RegSyntax", "$.RegSyntaxError", "$.ReplaceRule", "$.Replacer", "$.Rthings", "$.Skip", "$.Skipped", "$.Start", "$.StrPos", "$.lookAhead", "$.oneChar", "$.parsePerl", "$.patInf", "com.stevesoft.pat.wrap.StringWrap", "java.lang.NullPointerException", "$.StringBuffer", "java.util.BitSet"], function () {\r
3 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodePunct", com.stevesoft.pat.UniValidator);\r
4 Clazz.overrideMethod (c$, "validate", \r
5 function (s, from, to) {\r
6 return from < s.length () && com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1;\r
7 }, "com.stevesoft.pat.StringLike,~N,~N");\r
8 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeWhite", com.stevesoft.pat.UniValidator);\r
9 Clazz.overrideMethod (c$, "validate", \r
10 function (s, from, to) {\r
11 return from < s.length () && com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1;\r
12 }, "com.stevesoft.pat.StringLike,~N,~N");\r
13 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodePunct", com.stevesoft.pat.UniValidator);\r
14 Clazz.overrideMethod (c$, "validate", \r
15 function (s, from, to) {\r
16 return from < s.length () && !com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1;\r
17 }, "com.stevesoft.pat.StringLike,~N,~N");\r
18 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeWhite", com.stevesoft.pat.UniValidator);\r
19 Clazz.overrideMethod (c$, "validate", \r
20 function (s, from, to) {\r
21 return from < s.length () && !com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1;\r
22 }, "com.stevesoft.pat.StringLike,~N,~N");\r
23 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeW", com.stevesoft.pat.UniValidator);\r
24 Clazz.overrideMethod (c$, "validate", \r
25 function (s, from, to) {\r
26 if (from >= s.length ()) {\r
27 return -1;\r
28 }var c = s.charAt (from);\r
29 return (com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1;\r
30 }, "com.stevesoft.pat.StringLike,~N,~N");\r
31 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeW", com.stevesoft.pat.UniValidator);\r
32 Clazz.overrideMethod (c$, "validate", \r
33 function (s, from, to) {\r
34 if (from >= s.length ()) {\r
35 return -1;\r
36 }var c = s.charAt (from);\r
37 return !(com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1;\r
38 }, "com.stevesoft.pat.StringLike,~N,~N");\r
39 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeDigit", com.stevesoft.pat.UniValidator);\r
40 Clazz.overrideMethod (c$, "validate", \r
41 function (s, from, to) {\r
42 return from < s.length () && com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1;\r
43 }, "com.stevesoft.pat.StringLike,~N,~N");\r
44 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeDigit", com.stevesoft.pat.UniValidator);\r
45 Clazz.overrideMethod (c$, "validate", \r
46 function (s, from, to) {\r
47 return from < s.length () && !com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1;\r
48 }, "com.stevesoft.pat.StringLike,~N,~N");\r
49 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeMath", com.stevesoft.pat.UniValidator);\r
50 Clazz.overrideMethod (c$, "validate", \r
51 function (s, from, to) {\r
52 return from < s.length () && com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1;\r
53 }, "com.stevesoft.pat.StringLike,~N,~N");\r
54 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeMath", com.stevesoft.pat.UniValidator);\r
55 Clazz.overrideMethod (c$, "validate", \r
56 function (s, from, to) {\r
57 return from < s.length () && !com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1;\r
58 }, "com.stevesoft.pat.StringLike,~N,~N");\r
59 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeCurrency", com.stevesoft.pat.UniValidator);\r
60 Clazz.overrideMethod (c$, "validate", \r
61 function (s, from, to) {\r
62 return from < s.length () && com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1;\r
63 }, "com.stevesoft.pat.StringLike,~N,~N");\r
64 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeCurrency", com.stevesoft.pat.UniValidator);\r
65 Clazz.overrideMethod (c$, "validate", \r
66 function (s, from, to) {\r
67 return from < s.length () && !com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1;\r
68 }, "com.stevesoft.pat.StringLike,~N,~N");\r
69 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeAlpha", com.stevesoft.pat.UniValidator);\r
70 Clazz.overrideMethod (c$, "validate", \r
71 function (s, from, to) {\r
72 return from < s.length () && com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1;\r
73 }, "com.stevesoft.pat.StringLike,~N,~N");\r
74 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeAlpha", com.stevesoft.pat.UniValidator);\r
75 Clazz.overrideMethod (c$, "validate", \r
76 function (s, from, to) {\r
77 return from < s.length () && !com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1;\r
78 }, "com.stevesoft.pat.StringLike,~N,~N");\r
79 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeUpper", com.stevesoft.pat.UniValidator);\r
80 Clazz.overrideMethod (c$, "validate", \r
81 function (s, from, to) {\r
82 return from < s.length () && this.isUpper (s.charAt (from)) ? to : -1;\r
83 }, "com.stevesoft.pat.StringLike,~N,~N");\r
84 Clazz.defineMethod (c$, "isUpper", \r
85 function (c) {\r
86 return c == com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c != com.stevesoft.pat.CaseMgr.toLowerCaseC (c);\r
87 }, "~S");\r
88 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeLower", com.stevesoft.pat.UniValidator);\r
89 Clazz.overrideMethod (c$, "validate", \r
90 function (s, from, to) {\r
91 return from < s.length () && this.isLower (s.charAt (from)) ? to : -1;\r
92 }, "com.stevesoft.pat.StringLike,~N,~N");\r
93 Clazz.defineMethod (c$, "isLower", \r
94 function (c) {\r
95 return c != com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c == com.stevesoft.pat.CaseMgr.toLowerCaseC (c);\r
96 }, "~S");\r
97 c$ = Clazz.decorateAsClass (function () {\r
98 this.thePattern = null;\r
99 this.minMatch = null;\r
100 this.rep = null;\r
101 this.dontMatchInQuotes = false;\r
102 this.ignoreCase = false;\r
103 this.repr = null;\r
104 this.esc = '\\';\r
105 this.pt = null;\r
106 this.gFlags = null;\r
107 this.gFlagto = 0;\r
108 this.gFlag = false;\r
109 this.sFlag = false;\r
110 this.mFlag = false;\r
111 this.p = null;\r
112 this.or = null;\r
113 this.skipper = null;\r
114 Clazz.instantialize (this, arguments);\r
115 }, com.stevesoft.pat, "Regex", com.stevesoft.pat.RegRes, [jalview.jsdev.api.RegExpInterface, Cloneable]);\r
116 Clazz.prepareFields (c$, function () {\r
117 this.thePattern = com.stevesoft.pat.Regex.none;\r
118 this.minMatch =  new com.stevesoft.pat.patInt (0);\r
119 this.pt =  new com.stevesoft.pat.Pthings ();\r
120 });\r
121 Clazz.makeConstructor (c$, \r
122 function (s, strRp) {\r
123 Clazz.superConstructor (this, com.stevesoft.pat.Regex, []);\r
124 try {\r
125 if (s != null) this.compile (s);\r
126 if (strRp.length > 0) this.rep = com.stevesoft.pat.ReplaceRule.perlCode (strRp);\r
127 } catch (rs) {\r
128 if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {\r
129 } else {\r
130 throw rs;\r
131 }\r
132 }\r
133 }, "~S,~S");\r
134 Clazz.overrideMethod (c$, "clone", \r
135 function () {\r
136 return  new com.stevesoft.pat.Regex (null, "").cloneFrom (this);\r
137 });\r
138 Clazz.defineMethod (c$, "cloneFrom", \r
139 function (r) {\r
140 this.copyOutOf (r);\r
141 this.dontMatchInQuotes = r.dontMatchInQuotes;\r
142 this.esc = r.esc;\r
143 this.ignoreCase = r.ignoreCase;\r
144 this.gFlag = r.gFlag;\r
145 if (r.rep == null) {\r
146 this.rep = null;\r
147 } else {\r
148 this.rep = r.rep.clone ();\r
149 }this.thePattern = r.thePattern.clone ( new java.util.Hashtable ());\r
150 this.minMatch = r.minMatch;\r
151 this.skipper = r.skipper;\r
152 return this;\r
153 }, "com.stevesoft.pat.Regex");\r
154 Clazz.defineMethod (c$, "setDontMatchInQuotes", \r
155 function (b) {\r
156 this.dontMatchInQuotes = b;\r
157 }, "~B");\r
158 Clazz.defineMethod (c$, "getDontMatchInQuotes", \r
159 function () {\r
160 return this.dontMatchInQuotes;\r
161 });\r
162 Clazz.overrideMethod (c$, "setIgnoreCase", \r
163 function (b) {\r
164 this.ignoreCase = b;\r
165 }, "~B");\r
166 Clazz.defineMethod (c$, "getIgnoreCase", \r
167 function () {\r
168 return this.ignoreCase;\r
169 });\r
170 c$.setDefaultMFlag = Clazz.defineMethod (c$, "setDefaultMFlag", \r
171 function (mFlag) {\r
172 com.stevesoft.pat.Regex.defaultMFlag = mFlag;\r
173 }, "~B");\r
174 c$.getDefaultMFlag = Clazz.defineMethod (c$, "getDefaultMFlag", \r
175 function () {\r
176 return com.stevesoft.pat.Regex.defaultMFlag;\r
177 });\r
178 Clazz.defineMethod (c$, "setReplaceRuleStr", \r
179 function (rp) {\r
180 this.rep = com.stevesoft.pat.ReplaceRule.perlCode (rp);\r
181 this.repr = null;\r
182 }, "~S");\r
183 Clazz.defineMethod (c$, "setReplaceRule", \r
184 function (rp) {\r
185 this.rep = rp;\r
186 }, "com.stevesoft.pat.ReplaceRule");\r
187 c$.isDefined = Clazz.defineMethod (c$, "isDefined", \r
188 function (nm) {\r
189 return com.stevesoft.pat.Regex.validators.get (nm) != null;\r
190 }, "~S");\r
191 c$.undefine = Clazz.defineMethod (c$, "undefine", \r
192 function (nm) {\r
193 com.stevesoft.pat.Regex.validators.remove (nm);\r
194 }, "~S");\r
195 c$.defineV = Clazz.defineMethod (c$, "defineV", \r
196 function (nm, pat, v) {\r
197 v.pattern = pat;\r
198 com.stevesoft.pat.Regex.validators.put (nm, v);\r
199 }, "~S,~S,com.stevesoft.pat.Validator");\r
200 c$.define = Clazz.defineMethod (c$, "define", \r
201 function (nm, pat) {\r
202 com.stevesoft.pat.Regex.validators.put (nm, pat);\r
203 }, "~S,~S");\r
204 Clazz.defineMethod (c$, "getReplaceRule", \r
205 function () {\r
206 return this.rep;\r
207 });\r
208 Clazz.defineMethod (c$, "_getReplacer", \r
209 function () {\r
210 return this.repr == null ? this.repr =  new com.stevesoft.pat.Replacer () : this.repr;\r
211 });\r
212 Clazz.defineMethod (c$, "getReplacer", \r
213 function () {\r
214 if (this.repr == null) {\r
215 this.repr =  new com.stevesoft.pat.Replacer ();\r
216 }this.repr.rh.me = this;\r
217 this.repr.rh.prev = null;\r
218 return this.repr;\r
219 });\r
220 Clazz.defineMethod (c$, "replaceFirst", \r
221 function (s) {\r
222 return this._getReplacer ().replaceFirstRegion (s, this, 0, s.length).toString ();\r
223 }, "~S");\r
224 Clazz.defineMethod (c$, "replaceFirstFrom", \r
225 function (s, pos) {\r
226 return this._getReplacer ().replaceFirstRegion (s, this, pos, s.length).toString ();\r
227 }, "~S,~N");\r
228 Clazz.defineMethod (c$, "replaceFirstRegion", \r
229 function (s, start, end) {\r
230 return this._getReplacer ().replaceFirstRegion (s, this, start, end).toString ();\r
231 }, "~S,~N,~N");\r
232 Clazz.overrideMethod (c$, "replaceAll", \r
233 function (s) {\r
234 return this._getReplacer ().replaceAllRegion (s, this, 0, s.length).toString ();\r
235 }, "~S");\r
236 Clazz.defineMethod (c$, "replaceAllLike", \r
237 function (s) {\r
238 return this._getReplacer ().replaceAllRegion (s, this, 0, s.length ());\r
239 }, "com.stevesoft.pat.StringLike");\r
240 Clazz.defineMethod (c$, "replaceAllFrom", \r
241 function (s, pos) {\r
242 return this._getReplacer ().replaceAllRegion (s, this, pos, s.length).toString ();\r
243 }, "~S,~N");\r
244 Clazz.defineMethod (c$, "replaceAllRegion", \r
245 function (s, start, end) {\r
246 return this._getReplacer ().replaceAllRegion (s, this, start, end).toString ();\r
247 }, "~S,~N,~N");\r
248 Clazz.defineMethod (c$, "compile", \r
249 function (prepat) {\r
250 var postpat = com.stevesoft.pat.parsePerl.codify (prepat, true);\r
251 var pat = postpat == null ? prepat : postpat;\r
252 this.minMatch = null;\r
253 this.ignoreCase = false;\r
254 this.dontMatchInQuotes = false;\r
255 var mk =  new com.stevesoft.pat.Rthings (this);\r
256 var offset = mk.val;\r
257 var newpat = pat;\r
258 this.thePattern = com.stevesoft.pat.Regex.none;\r
259 this.p = null;\r
260 this.or = null;\r
261 this.minMatch =  new com.stevesoft.pat.patInt (0);\r
262 var sp =  new com.stevesoft.pat.StrPos (pat, 0);\r
263 if (sp.incMatch ("(?e=")) {\r
264 var newEsc = sp.c;\r
265 sp.inc ();\r
266 if (sp.match (')')) {\r
267 newpat = com.stevesoft.pat.Regex.reEscape (pat.substring (6), newEsc, '\\');\r
268 }} else if (this.esc != '\\') {\r
269 newpat = com.stevesoft.pat.Regex.reEscape (pat, this.esc, '\\');\r
270 }this.thePattern = this._compile (newpat, mk);\r
271 this.numSubs_ = mk.val - offset;\r
272 mk.set (this);\r
273 }, "~S");\r
274 Clazz.defineMethod (c$, "equals", \r
275 function (o) {\r
276 if (Clazz.instanceOf (o, com.stevesoft.pat.Regex)) {\r
277 if (this.toString ().equals (o.toString ())) {\r
278 return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]);\r
279 } else {\r
280 return false;\r
281 }} else {\r
282 return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]);\r
283 }}, "~O");\r
284 Clazz.defineMethod (c$, "prep", \r
285 function (s) {\r
286 this.pt.lastPos = this.matchedTo ();\r
287 if (this.pt.lastPos < 0) {\r
288 this.pt.lastPos = 0;\r
289 }if ((s == null ? null : s.unwrap ()) !== (this.src == null ? null : s.unwrap ())) {\r
290 this.pt.lastPos = 0;\r
291 }this.src = s;\r
292 this.pt.dotDoesntMatchCR = com.stevesoft.pat.Regex.dotDoesntMatchCR && (!this.sFlag);\r
293 this.pt.mFlag = ( new Boolean (this.mFlag | com.stevesoft.pat.Regex.defaultMFlag).valueOf ());\r
294 this.pt.ignoreCase = this.ignoreCase;\r
295 this.pt.no_check = false;\r
296 if (this.pt.marks != null) {\r
297 for (var i = 0; i < this.pt.marks.length; i++) {\r
298 this.pt.marks[i] = -1;\r
299 }\r
300 }this.pt.marks = null;\r
301 this.pt.nMarks = this.numSubs_;\r
302 this.pt.src = s;\r
303 if (this.dontMatchInQuotes) {\r
304 com.stevesoft.pat.Regex.setCbits (s, this.pt);\r
305 } else {\r
306 this.pt.cbits = null;\r
307 }return this.pt;\r
308 }, "com.stevesoft.pat.StringLike");\r
309 Clazz.defineMethod (c$, "matchAt", \r
310 function (s, start_pos) {\r
311 return this._search (s, start_pos, start_pos);\r
312 }, "~S,~N");\r
313 Clazz.defineMethod (c$, "matchAtLike", \r
314 function (s, start_pos) {\r
315 return this._searchLike (s, start_pos, start_pos);\r
316 }, "com.stevesoft.pat.StringLike,~N");\r
317 Clazz.overrideMethod (c$, "search", \r
318 function (s) {\r
319 if (s == null) {\r
320 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_search"));\r
321 }return this._search (s, 0, s.length);\r
322 }, "~S");\r
323 Clazz.defineMethod (c$, "searchLike", \r
324 function (sl) {\r
325 if (sl == null) {\r
326 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search"));\r
327 }return this._searchLike (sl, 0, sl.length ());\r
328 }, "com.stevesoft.pat.StringLike");\r
329 Clazz.defineMethod (c$, "reverseSearch", \r
330 function (s) {\r
331 if (s == null) {\r
332 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_reverse_search"));\r
333 }return this._reverseSearch (s, 0, s.length);\r
334 }, "~S");\r
335 Clazz.defineMethod (c$, "reverseSearchLike", \r
336 function (sl) {\r
337 if (sl == null) {\r
338 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_reverse_search"));\r
339 }return this._reverseSearchLike (sl, 0, sl.length ());\r
340 }, "com.stevesoft.pat.StringLike");\r
341 Clazz.overrideMethod (c$, "searchFrom", \r
342 function (s, start) {\r
343 if (s == null) {\r
344 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from"));\r
345 }return this._search (s, start, s.length);\r
346 }, "~S,~N");\r
347 Clazz.defineMethod (c$, "searchFromLike", \r
348 function (s, start) {\r
349 if (s == null) {\r
350 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from"));\r
351 }return this._searchLike (s, start, s.length ());\r
352 }, "com.stevesoft.pat.StringLike,~N");\r
353 Clazz.defineMethod (c$, "searchRegion", \r
354 function (s, start, end) {\r
355 if (s == null) {\r
356 throw  new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_region"));\r
357 }return this._search (s, start, end);\r
358 }, "~S,~N,~N");\r
359 Clazz.defineMethod (c$, "setGFlag", \r
360 function (b) {\r
361 this.gFlag = b;\r
362 }, "~B");\r
363 Clazz.defineMethod (c$, "getGFlag", \r
364 function () {\r
365 return this.gFlag;\r
366 });\r
367 Clazz.defineMethod (c$, "getSFlag", \r
368 function () {\r
369 return this.sFlag;\r
370 });\r
371 Clazz.defineMethod (c$, "getMFlag", \r
372 function () {\r
373 return this.mFlag;\r
374 });\r
375 Clazz.defineMethod (c$, "_search", \r
376 function (s, start, end) {\r
377 return this._searchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end);\r
378 }, "~S,~N,~N");\r
379 Clazz.defineMethod (c$, "_searchLike", \r
380 function (s, start, end) {\r
381 if (this.gFlag && this.gFlagto > 0 && this.gFlags != null && s.unwrap () === this.gFlags.unwrap ()) {\r
382 start = this.gFlagto;\r
383 }this.gFlags = null;\r
384 var pt = this.prep (s);\r
385 var up = (this.minMatch == null ? end : end - this.minMatch.i);\r
386 if (up < start && end >= start) {\r
387 up = start;\r
388 }if (this.skipper == null) {\r
389 for (var i = start; i <= up; i++) {\r
390 this.charsMatched_ = this.thePattern.matchAt (s, i, pt);\r
391 if (this.charsMatched_ >= 0) {\r
392 this.matchFrom_ = this.thePattern.mfrom;\r
393 this.marks = pt.marks;\r
394 this.gFlagto = this.matchFrom_ + this.charsMatched_;\r
395 this.gFlags = s;\r
396 return this.didMatch_ = true;\r
397 }}\r
398 } else {\r
399 pt.no_check = true;\r
400 for (var i = start; i <= up; i++) {\r
401 i = this.skipper.find (this.src, i, up);\r
402 if (i < 0) {\r
403 this.charsMatched_ = this.matchFrom_ = -1;\r
404 return this.didMatch_ = false;\r
405 }this.charsMatched_ = this.thePattern.matchAt (s, i, pt);\r
406 if (this.charsMatched_ >= 0) {\r
407 this.matchFrom_ = this.thePattern.mfrom;\r
408 this.marks = pt.marks;\r
409 this.gFlagto = this.matchFrom_ + this.charsMatched_;\r
410 this.gFlags = s;\r
411 return this.didMatch_ = true;\r
412 }}\r
413 }return this.didMatch_ = false;\r
414 }, "com.stevesoft.pat.StringLike,~N,~N");\r
415 Clazz.defineMethod (c$, "_reverseSearch", \r
416 function (s, start, end) {\r
417 return this._reverseSearchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end);\r
418 }, "~S,~N,~N");\r
419 Clazz.defineMethod (c$, "_reverseSearchLike", \r
420 function (s, start, end) {\r
421 if (this.gFlag && this.gFlagto > 0 && s.unwrap () === this.gFlags.unwrap ()) {\r
422 end = this.gFlagto;\r
423 }this.gFlags = null;\r
424 var pt = this.prep (s);\r
425 for (var i = end; i >= start; i--) {\r
426 this.charsMatched_ = this.thePattern.matchAt (s, i, pt);\r
427 if (this.charsMatched_ >= 0) {\r
428 this.matchFrom_ = this.thePattern.mfrom;\r
429 this.marks = pt.marks;\r
430 this.gFlagto = this.matchFrom_ - 1;\r
431 this.gFlags = s;\r
432 return this.didMatch_ = true;\r
433 }}\r
434 return this.didMatch_ = false;\r
435 }, "com.stevesoft.pat.StringLike,~N,~N");\r
436 c$.setCbits = Clazz.defineMethod (c$, "setCbits", \r
437 function (s, pt) {\r
438 if (s === com.stevesoft.pat.Regex.lasts) {\r
439 pt.cbits = com.stevesoft.pat.Regex.lastbs;\r
440 return;\r
441 }var bs =  new java.util.BitSet (s.length ());\r
442 var qc = ' ';\r
443 var setBit = false;\r
444 for (var i = 0; i < s.length (); i++) {\r
445 if (setBit) {\r
446 bs.set (i);\r
447 }var c = s.charAt (i);\r
448 if (!setBit && c == '"') {\r
449 qc = c;\r
450 setBit = true;\r
451 bs.set (i);\r
452 } else if (!setBit && c == '\'') {\r
453 qc = c;\r
454 setBit = true;\r
455 bs.set (i);\r
456 } else if (setBit && c == qc) {\r
457 setBit = false;\r
458 } else if (setBit && c == '\\' && i + 1 < s.length ()) {\r
459 i++;\r
460 if (setBit) {\r
461 bs.set (i);\r
462 }}}\r
463 pt.cbits = com.stevesoft.pat.Regex.lastbs = bs;\r
464 com.stevesoft.pat.Regex.lasts = s;\r
465 }, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings");\r
466 Clazz.defineMethod (c$, "add", \r
467 function (p2) {\r
468 if (this.p == null) {\r
469 this.p = p2;\r
470 } else {\r
471 this.p.add (p2);\r
472 p2 = this.p;\r
473 }}, "com.stevesoft.pat.Pattern");\r
474 Clazz.defineMethod (c$, "compileSP", \r
475 function (sp, mk) {\r
476 if (sp.match ('[')) {\r
477 sp.inc ();\r
478 this.add (this.matchBracket (sp));\r
479 } else if (sp.match ('|')) {\r
480 if (this.or == null) {\r
481 this.or =  new com.stevesoft.pat.Or ();\r
482 }if (this.p == null) {\r
483 this.p =  new com.stevesoft.pat.NullPattern ();\r
484 }this.or.addOr (this.p);\r
485 this.p = null;\r
486 } else if (sp.incMatch ("(?<")) {\r
487 var i = sp.getPatInt ();\r
488 if (i == null) {\r
489 com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?<");\r
490 }this.add ( new com.stevesoft.pat.Backup (i.intValue ()));\r
491 if (!sp.match (')')) {\r
492 com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<");\r
493 }} else if (sp.incMatch ("(?>")) {\r
494 var i = sp.getPatInt ();\r
495 if (i == null) {\r
496 com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?>");\r
497 }this.add ( new com.stevesoft.pat.Backup (-i.intValue ()));\r
498 if (!sp.match (')')) {\r
499 com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<");\r
500 }} else if (sp.incMatch ("(?@")) {\r
501 var op = sp.c;\r
502 sp.inc ();\r
503 var cl = sp.c;\r
504 sp.inc ();\r
505 if (!sp.match (')')) {\r
506 com.stevesoft.pat.RegSyntaxError.endItAll ("(?@ does not have closing paren");\r
507 }this.add ( new com.stevesoft.pat.Group (op, cl));\r
508 } else if (sp.incMatch ("(?#")) {\r
509 while (!sp.match (')')) {\r
510 sp.inc ();\r
511 }\r
512 } else if (sp.dontMatch && sp.c == 'w') {\r
513 var b =  new com.stevesoft.pat.Bracket (false);\r
514 b.addOr ( new com.stevesoft.pat.Range ('a', 'z'));\r
515 b.addOr ( new com.stevesoft.pat.Range ('A', 'Z'));\r
516 b.addOr ( new com.stevesoft.pat.Range ('0', '9'));\r
517 b.addOr ( new com.stevesoft.pat.oneChar ('_'));\r
518 this.add (b);\r
519 } else if (sp.dontMatch && sp.c == 'G') {\r
520 this.add ( new com.stevesoft.pat.BackG ());\r
521 } else if (sp.dontMatch && sp.c == 's') {\r
522 var b =  new com.stevesoft.pat.Bracket (false);\r
523 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32)));\r
524 b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10)));\r
525 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13)));\r
526 this.add (b);\r
527 } else if (sp.dontMatch && sp.c == 'd') {\r
528 var digit =  new com.stevesoft.pat.Range ('0', '9');\r
529 digit.printBrackets = true;\r
530 this.add (digit);\r
531 } else if (sp.dontMatch && sp.c == 'W') {\r
532 var b =  new com.stevesoft.pat.Bracket (true);\r
533 b.addOr ( new com.stevesoft.pat.Range ('a', 'z'));\r
534 b.addOr ( new com.stevesoft.pat.Range ('A', 'Z'));\r
535 b.addOr ( new com.stevesoft.pat.Range ('0', '9'));\r
536 b.addOr ( new com.stevesoft.pat.oneChar ('_'));\r
537 this.add (b);\r
538 } else if (sp.dontMatch && sp.c == 'S') {\r
539 var b =  new com.stevesoft.pat.Bracket (true);\r
540 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32)));\r
541 b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10)));\r
542 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13)));\r
543 this.add (b);\r
544 } else if (sp.dontMatch && sp.c == 'D') {\r
545 var b =  new com.stevesoft.pat.Bracket (true);\r
546 b.addOr ( new com.stevesoft.pat.Range ('0', '9'));\r
547 this.add (b);\r
548 } else if (sp.dontMatch && sp.c == 'B') {\r
549 var r =  new com.stevesoft.pat.Regex (null, "");\r
550 r._compile ("(?!\\b)", mk);\r
551 this.add (r.thePattern);\r
552 } else if (this.isOctalString (sp)) {\r
553 var d = sp.c.charCodeAt (0) - 48;\r
554 sp.inc ();\r
555 d = 8 * d + sp.c.charCodeAt (0) - 48;\r
556 var sp2 =  new com.stevesoft.pat.StrPos (sp);\r
557 sp2.inc ();\r
558 if (this.isOctalDigit (sp2, false)) {\r
559 sp.inc ();\r
560 d = 8 * d + sp.c.charCodeAt (0) - 48;\r
561 }this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));\r
562 } else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') {\r
563 var iv = sp.c.charCodeAt (0) - 48;\r
564 var s2 =  new com.stevesoft.pat.StrPos (sp);\r
565 s2.inc ();\r
566 if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') {\r
567 iv = 10 * iv + (s2.c.charCodeAt (0) - 48);\r
568 sp.inc ();\r
569 }this.add ( new com.stevesoft.pat.BackMatch (iv));\r
570 } else if (sp.dontMatch && sp.c == 'b') {\r
571 this.add ( new com.stevesoft.pat.Boundary ());\r
572 } else if (sp.match ('\b')) {\r
573 this.add ( new com.stevesoft.pat.Boundary ());\r
574 } else if (sp.match ('$')) {\r
575 this.add ( new com.stevesoft.pat.End (true));\r
576 } else if (sp.dontMatch && sp.c == 'Z') {\r
577 this.add ( new com.stevesoft.pat.End (false));\r
578 } else if (sp.match ('.')) {\r
579 this.add ( new com.stevesoft.pat.Any ());\r
580 } else if (sp.incMatch ("(??")) {\r
581 var sb =  new StringBuffer ();\r
582 var sb2 =  new StringBuffer ();\r
583 while (!sp.match (')') && !sp.match (':')) {\r
584 sb.append (sp.c);\r
585 sp.inc ();\r
586 }\r
587 if (sp.incMatch (":")) {\r
588 while (!sp.match (')')) {\r
589 sb2.append (sp.c);\r
590 sp.inc ();\r
591 }\r
592 }var sbs = sb.toString ();\r
593 if (Clazz.instanceOf (com.stevesoft.pat.Regex.validators.get (sbs), String)) {\r
594 var pat = com.stevesoft.pat.Regex.validators.get (sbs);\r
595 var r =  new com.stevesoft.pat.Regex (null, "");\r
596 var rth =  new com.stevesoft.pat.Rthings (this);\r
597 rth.noBackRefs = true;\r
598 r._compile (pat, rth);\r
599 this.add (r.thePattern);\r
600 } else {\r
601 var cm =  new com.stevesoft.pat.Custom (sb.toString ());\r
602 if (cm.v != null) {\r
603 var v2 = cm.v.arg (sb2.toString ());\r
604 if (v2 != null) {\r
605 v2.argsave = sb2.toString ();\r
606 var p = cm.v.pattern;\r
607 cm.v = v2;\r
608 v2.pattern = p;\r
609 }var r =  new com.stevesoft.pat.Regex (null, "");\r
610 var rth =  new com.stevesoft.pat.Rthings (this);\r
611 rth.noBackRefs = true;\r
612 r._compile (cm.v.pattern, rth);\r
613 cm.sub = r.thePattern;\r
614 cm.sub.add ( new com.stevesoft.pat.CustomEndpoint (cm));\r
615 cm.sub.setParent (cm);\r
616 this.add (cm);\r
617 }}} else if (sp.match ('(')) {\r
618 mk.parenLevel++;\r
619 var r =  new com.stevesoft.pat.Regex (null, "");\r
620 sp.inc ();\r
621 if (sp.incMatch ("?:")) {\r
622 r.or =  new com.stevesoft.pat.Or ();\r
623 } else if (sp.incMatch ("?=")) {\r
624 r.or =  new com.stevesoft.pat.lookAhead (false);\r
625 } else if (sp.incMatch ("?!")) {\r
626 r.or =  new com.stevesoft.pat.lookAhead (true);\r
627 } else if (sp.match ('?')) {\r
628 sp.inc ();\r
629 do {\r
630 if (sp.c == 'i') {\r
631 mk.ignoreCase = true;\r
632 }if (sp.c == 'Q') {\r
633 mk.dontMatchInQuotes = true;\r
634 }if (sp.c == 'o') {\r
635 mk.optimizeMe = true;\r
636 }if (sp.c == 'g') {\r
637 mk.gFlag = true;\r
638 }if (sp.c == 's') {\r
639 mk.sFlag = true;\r
640 }if (sp.c == 'm') {\r
641 mk.mFlag = true;\r
642 }sp.inc ();\r
643 } while (!sp.match (')') && !sp.$eos);\r
644 r = null;\r
645 mk.parenLevel--;\r
646 if (sp.$eos) {\r
647 com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed ()");\r
648 }} else {\r
649 r.or = mk.noBackRefs ?  new com.stevesoft.pat.Or () :  new com.stevesoft.pat.OrMark (mk.val++);\r
650 }if (r != null) {\r
651 this.add (r._compileSP (sp, mk));\r
652 }} else if (sp.match ('^')) {\r
653 this.add ( new com.stevesoft.pat.Start (true));\r
654 } else if (sp.dontMatch && sp.c == 'A') {\r
655 this.add ( new com.stevesoft.pat.Start (false));\r
656 } else if (sp.match ('*')) {\r
657 this.addMulti ( new com.stevesoft.pat.patInt (0),  new com.stevesoft.pat.patInf ());\r
658 } else if (sp.match ('+')) {\r
659 this.addMulti ( new com.stevesoft.pat.patInt (1),  new com.stevesoft.pat.patInf ());\r
660 } else if (sp.match ('?')) {\r
661 this.addMulti ( new com.stevesoft.pat.patInt (0),  new com.stevesoft.pat.patInt (1));\r
662 } else if (sp.match ('{')) {\r
663 var bad = false;\r
664 var sp2 =  new com.stevesoft.pat.StrPos (sp);\r
665 sp.inc ();\r
666 var i1 = sp.getPatInt ();\r
667 var i2 = null;\r
668 if (sp.match ('}')) {\r
669 i2 = i1;\r
670 } else {\r
671 if (!sp.match (',')) {\r
672 bad = true;\r
673 }sp.inc ();\r
674 if (sp.match ('}')) {\r
675 i2 =  new com.stevesoft.pat.patInf ();\r
676 } else {\r
677 i2 = sp.getPatInt ();\r
678 }}if (i1 == null || i2 == null) {\r
679 bad = true;\r
680 }if (bad) {\r
681 sp.dup (sp2);\r
682 this.add ( new com.stevesoft.pat.oneChar (sp.c));\r
683 } else {\r
684 this.addMulti (i1, i2);\r
685 }} else if (sp.escMatch ('x') && this.next2Hex (sp)) {\r
686 sp.inc ();\r
687 var d = this.getHexDigit (sp);\r
688 sp.inc ();\r
689 d = 16 * d + this.getHexDigit (sp);\r
690 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));\r
691 } else if (sp.escMatch ('c')) {\r
692 sp.inc ();\r
693 if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) {\r
694 this.add ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)]));\r
695 } else {\r
696 this.add ( new com.stevesoft.pat.oneChar (sp.c));\r
697 }} else if (sp.escMatch ('f')) {\r
698 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (12)));\r
699 } else if (sp.escMatch ('a')) {\r
700 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (7)));\r
701 } else if (sp.escMatch ('t')) {\r
702 this.add ( new com.stevesoft.pat.oneChar ('\t'));\r
703 } else if (sp.escMatch ('n')) {\r
704 this.add ( new com.stevesoft.pat.oneChar ('\n'));\r
705 } else if (sp.escMatch ('r')) {\r
706 this.add ( new com.stevesoft.pat.oneChar ('\r'));\r
707 } else if (sp.escMatch ('b')) {\r
708 this.add ( new com.stevesoft.pat.oneChar ('\b'));\r
709 } else if (sp.escMatch ('e')) {\r
710 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (27)));\r
711 } else {\r
712 this.add ( new com.stevesoft.pat.oneChar (sp.c));\r
713 if (sp.match (')')) {\r
714 com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched right paren in pattern");\r
715 }}}, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings");\r
716 Clazz.defineMethod (c$, "_compile", \r
717  function (pat, mk) {\r
718 this.minMatch = null;\r
719 this.sFlag = this.mFlag = this.ignoreCase = this.gFlag = false;\r
720 var sp =  new com.stevesoft.pat.StrPos (pat, 0);\r
721 this.thePattern = this._compileSP (sp, mk);\r
722 this.pt.marks = null;\r
723 return this.thePattern;\r
724 }, "~S,com.stevesoft.pat.Rthings");\r
725 Clazz.defineMethod (c$, "_compileSP", \r
726 function (sp, mk) {\r
727 while (!(sp.$eos || (this.or != null && sp.match (')')))) {\r
728 this.compileSP (sp, mk);\r
729 sp.inc ();\r
730 }\r
731 if (sp.match (')')) {\r
732 mk.parenLevel--;\r
733 } else if (sp.$eos && mk.parenLevel != 0) {\r
734 com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed Parenthesis! lvl=" + mk.parenLevel);\r
735 }if (this.or != null) {\r
736 if (this.p == null) {\r
737 this.p =  new com.stevesoft.pat.NullPattern ();\r
738 }this.or.addOr (this.p);\r
739 return this.or;\r
740 }return this.p == null ?  new com.stevesoft.pat.NullPattern () : this.p;\r
741 }, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings");\r
742 Clazz.defineMethod (c$, "addMulti", \r
743 function (i1, i2) {\r
744 var last;\r
745 var last2;\r
746 for (last = this.p; last != null && last.next != null; last = last.next) {\r
747 ;}\r
748 if (last == null || last === this.p) {\r
749 last2 = null;\r
750 } else {\r
751 for (last2 = this.p; last2.next !== last; last2 = last2.next) {\r
752 ;}\r
753 }if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) && i1.intValue () == 0 && i2.intValue () == 1) {\r
754 (last).matchFewest = true;\r
755 } else if (Clazz.instanceOf (last, com.stevesoft.pat.FastMulti) && i1.intValue () == 0 && i2.intValue () == 1) {\r
756 (last).matchFewest = true;\r
757 } else if (Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) && i1.intValue () == 0 && i2.intValue () == 1) {\r
758 (last).matchFewest = true;\r
759 } else if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) || Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) || Clazz.instanceOf (last, com.stevesoft.pat.FastMulti)) {\r
760 throw  new com.stevesoft.pat.RegSyntax ("Syntax error.");\r
761 } else if (last2 == null) {\r
762 this.p = com.stevesoft.pat.Regex.mkMulti (i1, i2, this.p);\r
763 } else {\r
764 last2.next = com.stevesoft.pat.Regex.mkMulti (i1, i2, last);\r
765 }}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt");\r
766 c$.mkMulti = Clazz.defineMethod (c$, "mkMulti", \r
767 function (lo, hi, p) {\r
768 if (Clazz.instanceOf (p, com.stevesoft.pat.Any) && p.next == null) {\r
769 return  new com.stevesoft.pat.DotMulti (lo, hi);\r
770 }return com.stevesoft.pat.RegOpt.safe4fm (p) ?  new com.stevesoft.pat.FastMulti (lo, hi, p) :  new com.stevesoft.pat.Multi (lo, hi, p);\r
771 }, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern");\r
772 Clazz.defineMethod (c$, "matchBracket", \r
773 function (sp) {\r
774 var ret;\r
775 if (sp.match ('^')) {\r
776 ret =  new com.stevesoft.pat.Bracket (true);\r
777 sp.inc ();\r
778 } else {\r
779 ret =  new com.stevesoft.pat.Bracket (false);\r
780 }if (sp.match (']')) {\r
781 com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched []");\r
782 }while (!sp.$eos && !sp.match (']')) {\r
783 var s1 =  new com.stevesoft.pat.StrPos (sp);\r
784 s1.inc ();\r
785 var s1_ =  new com.stevesoft.pat.StrPos (s1);\r
786 s1_.inc ();\r
787 if (s1.match ('-') && !s1_.match (']')) {\r
788 var s2 =  new com.stevesoft.pat.StrPos (s1);\r
789 s2.inc ();\r
790 if (!s2.$eos) {\r
791 ret.addOr ( new com.stevesoft.pat.Range (sp.c, s2.c));\r
792 }sp.inc ();\r
793 sp.inc ();\r
794 } else if (sp.escMatch ('Q')) {\r
795 sp.inc ();\r
796 while (!sp.escMatch ('E')) {\r
797 ret.addOr ( new com.stevesoft.pat.oneChar (sp.c));\r
798 sp.inc ();\r
799 }\r
800 } else if (sp.escMatch ('d')) {\r
801 ret.addOr ( new com.stevesoft.pat.Range ('0', '9'));\r
802 } else if (sp.escMatch ('s')) {\r
803 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32)));\r
804 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10)));\r
805 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13)));\r
806 } else if (sp.escMatch ('w')) {\r
807 ret.addOr ( new com.stevesoft.pat.Range ('a', 'z'));\r
808 ret.addOr ( new com.stevesoft.pat.Range ('A', 'Z'));\r
809 ret.addOr ( new com.stevesoft.pat.Range ('0', '9'));\r
810 ret.addOr ( new com.stevesoft.pat.oneChar ('_'));\r
811 } else if (sp.escMatch ('D')) {\r
812 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (47)));\r
813 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (58), String.fromCharCode (65535)));\r
814 } else if (sp.escMatch ('S')) {\r
815 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (7)));\r
816 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (11), String.fromCharCode (12)));\r
817 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (14), String.fromCharCode (31)));\r
818 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (33), String.fromCharCode (65535)));\r
819 } else if (sp.escMatch ('W')) {\r
820 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (64)));\r
821 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (91), String.fromCharCode (94)));\r
822 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (96)));\r
823 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (123), String.fromCharCode (65535)));\r
824 } else if (sp.escMatch ('x') && this.next2Hex (sp)) {\r
825 sp.inc ();\r
826 var d = this.getHexDigit (sp);\r
827 sp.inc ();\r
828 d = 16 * d + this.getHexDigit (sp);\r
829 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));\r
830 } else if (sp.escMatch ('a')) {\r
831 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (7)));\r
832 } else if (sp.escMatch ('f')) {\r
833 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (12)));\r
834 } else if (sp.escMatch ('e')) {\r
835 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (27)));\r
836 } else if (sp.escMatch ('n')) {\r
837 ret.addOr ( new com.stevesoft.pat.oneChar ('\n'));\r
838 } else if (sp.escMatch ('t')) {\r
839 ret.addOr ( new com.stevesoft.pat.oneChar ('\t'));\r
840 } else if (sp.escMatch ('r')) {\r
841 ret.addOr ( new com.stevesoft.pat.oneChar ('\r'));\r
842 } else if (sp.escMatch ('c')) {\r
843 sp.inc ();\r
844 if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) {\r
845 ret.addOr ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)]));\r
846 } else {\r
847 ret.addOr ( new com.stevesoft.pat.oneChar (sp.c));\r
848 }} else if (this.isOctalString (sp)) {\r
849 var d = sp.c.charCodeAt (0) - 48;\r
850 sp.inc ();\r
851 d = 8 * d + sp.c.charCodeAt (0) - 48;\r
852 var sp2 =  new com.stevesoft.pat.StrPos (sp);\r
853 sp2.inc ();\r
854 if (this.isOctalDigit (sp2, false)) {\r
855 sp.inc ();\r
856 d = 8 * d + sp.c.charCodeAt (0) - 48;\r
857 }ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));\r
858 } else {\r
859 ret.addOr ( new com.stevesoft.pat.oneChar (sp.c));\r
860 }sp.inc ();\r
861 }\r
862 return ret;\r
863 }, "com.stevesoft.pat.StrPos");\r
864 Clazz.overrideMethod (c$, "toString", \r
865 function () {\r
866 {\r
867 var sb =  new StringBuffer ();\r
868 if (this.esc != '\\') {\r
869 sb.append ("(?e=");\r
870 sb.append (this.esc);\r
871 sb.append (")");\r
872 }if (this.gFlag || this.mFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR || this.sFlag || this.ignoreCase || this.dontMatchInQuotes || this.optimized ()) {\r
873 sb.append ("(?");\r
874 if (this.ignoreCase) {\r
875 sb.append ("i");\r
876 }if (this.mFlag) {\r
877 sb.append ("m");\r
878 }if (this.sFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR) {\r
879 sb.append ("s");\r
880 }if (this.dontMatchInQuotes) {\r
881 sb.append ("Q");\r
882 }if (this.optimized ()) {\r
883 sb.append ("o");\r
884 }if (this.gFlag) {\r
885 sb.append ("g");\r
886 }sb.append (")");\r
887 }var patstr = this.thePattern.toString ();\r
888 if (this.esc != '\\') {\r
889 patstr = com.stevesoft.pat.Regex.reEscape (patstr, '\\', this.esc);\r
890 }sb.append (patstr);\r
891 return sb.toString ();\r
892 }});\r
893 c$.reEscape = Clazz.defineMethod (c$, "reEscape", \r
894 function (s, oldEsc, newEsc) {\r
895 if (oldEsc == newEsc) {\r
896 return s;\r
897 }var i;\r
898 var sb =  new StringBuffer ();\r
899 for (i = 0; i < s.length; i++) {\r
900 if (s.charAt (i) == oldEsc && i + 1 < s.length) {\r
901 if (s.charAt (i + 1) == oldEsc) {\r
902 sb.append (oldEsc);\r
903 } else {\r
904 sb.append (newEsc);\r
905 sb.append (s.charAt (i + 1));\r
906 }i++;\r
907 } else if (s.charAt (i) == newEsc) {\r
908 sb.append (newEsc);\r
909 sb.append (newEsc);\r
910 } else {\r
911 sb.append (s.charAt (i));\r
912 }}\r
913 return sb.toString ();\r
914 }, "~S,~S,~S");\r
915 Clazz.defineMethod (c$, "accept", \r
916 function (dir, s) {\r
917 return this.search (s);\r
918 }, "java.io.File,~S");\r
919 c$.version = Clazz.defineMethod (c$, "version", \r
920 function () {\r
921 return "lgpl release 1.5.3";\r
922 });\r
923 Clazz.defineMethod (c$, "optimize", \r
924 function () {\r
925 if (this.optimized () || this.thePattern == null) {\r
926 return;\r
927 }this.minMatch =  new com.stevesoft.pat.patInt (0);\r
928 this.thePattern = com.stevesoft.pat.RegOpt.opt (this.thePattern, this.ignoreCase, this.dontMatchInQuotes);\r
929 this.skipper = com.stevesoft.pat.Skip.findSkipRegex (this);\r
930 return;\r
931 });\r
932 Clazz.defineMethod (c$, "optimized", \r
933 function () {\r
934 return this.minMatch != null;\r
935 });\r
936 c$.perlCode = Clazz.defineMethod (c$, "perlCode", \r
937 function (s) {\r
938 return com.stevesoft.pat.parsePerl.parse (s);\r
939 }, "~S");\r
940 Clazz.defineMethod (c$, "isLiteral", \r
941 function () {\r
942 var x = this.thePattern;\r
943 while (x != null) {\r
944 if (Clazz.instanceOf (x, com.stevesoft.pat.oneChar)) {\r
945 ;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Skipped)) {\r
946 ;} else {\r
947 return false;\r
948 }x = x.next;\r
949 }\r
950 return true;\r
951 });\r
952 Clazz.defineMethod (c$, "countMinChars", \r
953 function () {\r
954 return this.thePattern.countMinChars ();\r
955 });\r
956 Clazz.defineMethod (c$, "countMaxChars", \r
957 function () {\r
958 return this.thePattern.countMaxChars ();\r
959 });\r
960 Clazz.defineMethod (c$, "isHexDigit", \r
961 function (sp) {\r
962 var r = !sp.$eos && !sp.dontMatch && ((sp.c >= '0' && sp.c <= '9') || (sp.c >= 'a' && sp.c <= 'f') || (sp.c >= 'A' && sp.c <= 'F'));\r
963 return r;\r
964 }, "com.stevesoft.pat.StrPos");\r
965 Clazz.defineMethod (c$, "isOctalDigit", \r
966 function (sp, first) {\r
967 var r = !sp.$eos && !( new Boolean (first ^ sp.dontMatch).valueOf ()) && sp.c >= '0' && sp.c <= '7';\r
968 return r;\r
969 }, "com.stevesoft.pat.StrPos,~B");\r
970 Clazz.defineMethod (c$, "getHexDigit", \r
971 function (sp) {\r
972 if (sp.c >= '0' && sp.c <= '9') {\r
973 return sp.c.charCodeAt (0) - 48;\r
974 }if (sp.c >= 'a' && sp.c <= 'f') {\r
975 return sp.c.charCodeAt (0) - 97 + 10;\r
976 }return sp.c.charCodeAt (0) - 65 + 10;\r
977 }, "com.stevesoft.pat.StrPos");\r
978 Clazz.defineMethod (c$, "next2Hex", \r
979 function (sp) {\r
980 var sp2 =  new com.stevesoft.pat.StrPos (sp);\r
981 sp2.inc ();\r
982 if (!this.isHexDigit (sp2)) {\r
983 return false;\r
984 }sp2.inc ();\r
985 if (!this.isHexDigit (sp2)) {\r
986 return false;\r
987 }return true;\r
988 }, "com.stevesoft.pat.StrPos");\r
989 Clazz.defineMethod (c$, "isOctalString", \r
990 function (sp) {\r
991 if (!this.isOctalDigit (sp, true)) {\r
992 return false;\r
993 }var sp2 =  new com.stevesoft.pat.StrPos (sp);\r
994 sp2.inc ();\r
995 if (!this.isOctalDigit (sp2, false)) {\r
996 return false;\r
997 }return true;\r
998 }, "com.stevesoft.pat.StrPos");\r
999 Clazz.defineStatics (c$,\r
1000 "BackRefOffset", 1);\r
1001 c$.none = c$.prototype.none =  new com.stevesoft.pat.NoPattern ();\r
1002 c$.validators = c$.prototype.validators =  new java.util.Hashtable ();\r
1003 {\r
1004 com.stevesoft.pat.Regex.defineV ("p", "(?>1)",  new com.stevesoft.pat.UnicodePunct ());\r
1005 com.stevesoft.pat.Regex.defineV ("P", "(?>1)",  new com.stevesoft.pat.NUnicodePunct ());\r
1006 com.stevesoft.pat.Regex.defineV ("s", "(?>1)",  new com.stevesoft.pat.UnicodeWhite ());\r
1007 com.stevesoft.pat.Regex.defineV ("S", "(?>1)",  new com.stevesoft.pat.NUnicodeWhite ());\r
1008 com.stevesoft.pat.Regex.defineV ("w", "(?>1)",  new com.stevesoft.pat.UnicodeW ());\r
1009 com.stevesoft.pat.Regex.defineV ("W", "(?>1)",  new com.stevesoft.pat.NUnicodeW ());\r
1010 com.stevesoft.pat.Regex.defineV ("d", "(?>1)",  new com.stevesoft.pat.UnicodeDigit ());\r
1011 com.stevesoft.pat.Regex.defineV ("D", "(?>1)",  new com.stevesoft.pat.NUnicodeDigit ());\r
1012 com.stevesoft.pat.Regex.defineV ("m", "(?>1)",  new com.stevesoft.pat.UnicodeMath ());\r
1013 com.stevesoft.pat.Regex.defineV ("M", "(?>1)",  new com.stevesoft.pat.NUnicodeMath ());\r
1014 com.stevesoft.pat.Regex.defineV ("c", "(?>1)",  new com.stevesoft.pat.UnicodeCurrency ());\r
1015 com.stevesoft.pat.Regex.defineV ("C", "(?>1)",  new com.stevesoft.pat.NUnicodeCurrency ());\r
1016 com.stevesoft.pat.Regex.defineV ("a", "(?>1)",  new com.stevesoft.pat.UnicodeAlpha ());\r
1017 com.stevesoft.pat.Regex.defineV ("A", "(?>1)",  new com.stevesoft.pat.NUnicodeAlpha ());\r
1018 com.stevesoft.pat.Regex.defineV ("uc", "(?>1)",  new com.stevesoft.pat.UnicodeUpper ());\r
1019 com.stevesoft.pat.Regex.defineV ("lc", "(?>1)",  new com.stevesoft.pat.UnicodeLower ());\r
1020 }Clazz.defineStatics (c$,\r
1021 "defaultMFlag", false,\r
1022 "dotDoesntMatchCR", true,\r
1023 "lasts", null,\r
1024 "lastbs", null,\r
1025 "back_slash", '\\');\r
1026 });\r