1 Clazz.declarePackage ("com.stevesoft.pat");
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 () {
3 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodePunct", com.stevesoft.pat.UniValidator);
4 Clazz.overrideMethod (c$, "validate",
5 function (s, from, to) {
6 return from < s.length () && com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1;
7 }, "com.stevesoft.pat.StringLike,~N,~N");
8 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeWhite", com.stevesoft.pat.UniValidator);
9 Clazz.overrideMethod (c$, "validate",
10 function (s, from, to) {
11 return from < s.length () && com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1;
12 }, "com.stevesoft.pat.StringLike,~N,~N");
13 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodePunct", com.stevesoft.pat.UniValidator);
14 Clazz.overrideMethod (c$, "validate",
15 function (s, from, to) {
16 return from < s.length () && !com.stevesoft.pat.Prop.isPunct (s.charAt (from)) ? to : -1;
17 }, "com.stevesoft.pat.StringLike,~N,~N");
18 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeWhite", com.stevesoft.pat.UniValidator);
19 Clazz.overrideMethod (c$, "validate",
20 function (s, from, to) {
21 return from < s.length () && !com.stevesoft.pat.Prop.isWhite (s.charAt (from)) ? to : -1;
22 }, "com.stevesoft.pat.StringLike,~N,~N");
23 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeW", com.stevesoft.pat.UniValidator);
24 Clazz.overrideMethod (c$, "validate",
25 function (s, from, to) {
26 if (from >= s.length ()) {
28 }var c = s.charAt (from);
29 return (com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1;
30 }, "com.stevesoft.pat.StringLike,~N,~N");
31 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeW", com.stevesoft.pat.UniValidator);
32 Clazz.overrideMethod (c$, "validate",
33 function (s, from, to) {
34 if (from >= s.length ()) {
36 }var c = s.charAt (from);
37 return !(com.stevesoft.pat.Prop.isAlphabetic (c) || com.stevesoft.pat.Prop.isDecimalDigit (c) || c == '_') ? to : -1;
38 }, "com.stevesoft.pat.StringLike,~N,~N");
39 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeDigit", com.stevesoft.pat.UniValidator);
40 Clazz.overrideMethod (c$, "validate",
41 function (s, from, to) {
42 return from < s.length () && com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1;
43 }, "com.stevesoft.pat.StringLike,~N,~N");
44 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeDigit", com.stevesoft.pat.UniValidator);
45 Clazz.overrideMethod (c$, "validate",
46 function (s, from, to) {
47 return from < s.length () && !com.stevesoft.pat.Prop.isDecimalDigit (s.charAt (from)) ? to : -1;
48 }, "com.stevesoft.pat.StringLike,~N,~N");
49 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeMath", com.stevesoft.pat.UniValidator);
50 Clazz.overrideMethod (c$, "validate",
51 function (s, from, to) {
52 return from < s.length () && com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1;
53 }, "com.stevesoft.pat.StringLike,~N,~N");
54 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeMath", com.stevesoft.pat.UniValidator);
55 Clazz.overrideMethod (c$, "validate",
56 function (s, from, to) {
57 return from < s.length () && !com.stevesoft.pat.Prop.isMath (s.charAt (from)) ? to : -1;
58 }, "com.stevesoft.pat.StringLike,~N,~N");
59 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeCurrency", com.stevesoft.pat.UniValidator);
60 Clazz.overrideMethod (c$, "validate",
61 function (s, from, to) {
62 return from < s.length () && com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1;
63 }, "com.stevesoft.pat.StringLike,~N,~N");
64 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeCurrency", com.stevesoft.pat.UniValidator);
65 Clazz.overrideMethod (c$, "validate",
66 function (s, from, to) {
67 return from < s.length () && !com.stevesoft.pat.Prop.isCurrency (s.charAt (from)) ? to : -1;
68 }, "com.stevesoft.pat.StringLike,~N,~N");
69 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeAlpha", com.stevesoft.pat.UniValidator);
70 Clazz.overrideMethod (c$, "validate",
71 function (s, from, to) {
72 return from < s.length () && com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1;
73 }, "com.stevesoft.pat.StringLike,~N,~N");
74 c$ = Clazz.declareType (com.stevesoft.pat, "NUnicodeAlpha", com.stevesoft.pat.UniValidator);
75 Clazz.overrideMethod (c$, "validate",
76 function (s, from, to) {
77 return from < s.length () && !com.stevesoft.pat.Prop.isAlphabetic (s.charAt (from)) ? to : -1;
78 }, "com.stevesoft.pat.StringLike,~N,~N");
79 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeUpper", com.stevesoft.pat.UniValidator);
80 Clazz.overrideMethod (c$, "validate",
81 function (s, from, to) {
82 return from < s.length () && this.isUpper (s.charAt (from)) ? to : -1;
83 }, "com.stevesoft.pat.StringLike,~N,~N");
84 Clazz.defineMethod (c$, "isUpper",
86 return c == com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c != com.stevesoft.pat.CaseMgr.toLowerCaseC (c);
88 c$ = Clazz.declareType (com.stevesoft.pat, "UnicodeLower", com.stevesoft.pat.UniValidator);
89 Clazz.overrideMethod (c$, "validate",
90 function (s, from, to) {
91 return from < s.length () && this.isLower (s.charAt (from)) ? to : -1;
92 }, "com.stevesoft.pat.StringLike,~N,~N");
93 Clazz.defineMethod (c$, "isLower",
95 return c != com.stevesoft.pat.CaseMgr.toUpperCaseC (c) && c == com.stevesoft.pat.CaseMgr.toLowerCaseC (c);
97 c$ = Clazz.decorateAsClass (function () {
98 this.thePattern = null;
101 this.dontMatchInQuotes = false;
102 this.ignoreCase = false;
114 Clazz.instantialize (this, arguments);
115 }, com.stevesoft.pat, "Regex", com.stevesoft.pat.RegRes, [jalview.jsdev.api.RegExpInterface, Cloneable]);
116 Clazz.prepareFields (c$, function () {
117 this.thePattern = com.stevesoft.pat.Regex.none;
118 this.minMatch = new com.stevesoft.pat.patInt (0);
119 this.pt = new com.stevesoft.pat.Pthings ();
121 Clazz.makeConstructor (c$,
122 function (s, strRp) {
123 Clazz.superConstructor (this, com.stevesoft.pat.Regex, []);
125 if (s != null) this.compile (s);
126 if (strRp.length > 0) this.rep = com.stevesoft.pat.ReplaceRule.perlCode (strRp);
128 if (Clazz.exceptionOf (rs, com.stevesoft.pat.RegSyntax)) {
134 Clazz.overrideMethod (c$, "clone",
136 return new com.stevesoft.pat.Regex (null, "").cloneFrom (this);
138 Clazz.defineMethod (c$, "cloneFrom",
141 this.dontMatchInQuotes = r.dontMatchInQuotes;
143 this.ignoreCase = r.ignoreCase;
144 this.gFlag = r.gFlag;
148 this.rep = r.rep.clone ();
149 }this.thePattern = r.thePattern.clone ( new java.util.Hashtable ());
150 this.minMatch = r.minMatch;
151 this.skipper = r.skipper;
153 }, "com.stevesoft.pat.Regex");
154 Clazz.defineMethod (c$, "setDontMatchInQuotes",
156 this.dontMatchInQuotes = b;
158 Clazz.defineMethod (c$, "getDontMatchInQuotes",
160 return this.dontMatchInQuotes;
162 Clazz.overrideMethod (c$, "setIgnoreCase",
166 Clazz.defineMethod (c$, "getIgnoreCase",
168 return this.ignoreCase;
170 c$.setDefaultMFlag = Clazz.defineMethod (c$, "setDefaultMFlag",
172 com.stevesoft.pat.Regex.defaultMFlag = mFlag;
174 c$.getDefaultMFlag = Clazz.defineMethod (c$, "getDefaultMFlag",
176 return com.stevesoft.pat.Regex.defaultMFlag;
178 Clazz.defineMethod (c$, "setReplaceRuleStr",
180 this.rep = com.stevesoft.pat.ReplaceRule.perlCode (rp);
183 Clazz.defineMethod (c$, "setReplaceRule",
186 }, "com.stevesoft.pat.ReplaceRule");
187 c$.isDefined = Clazz.defineMethod (c$, "isDefined",
189 return com.stevesoft.pat.Regex.validators.get (nm) != null;
191 c$.undefine = Clazz.defineMethod (c$, "undefine",
193 com.stevesoft.pat.Regex.validators.remove (nm);
195 c$.defineV = Clazz.defineMethod (c$, "defineV",
196 function (nm, pat, v) {
198 com.stevesoft.pat.Regex.validators.put (nm, v);
199 }, "~S,~S,com.stevesoft.pat.Validator");
200 c$.define = Clazz.defineMethod (c$, "define",
202 com.stevesoft.pat.Regex.validators.put (nm, pat);
204 Clazz.defineMethod (c$, "getReplaceRule",
208 Clazz.defineMethod (c$, "_getReplacer",
210 return this.repr == null ? this.repr = new com.stevesoft.pat.Replacer () : this.repr;
212 Clazz.defineMethod (c$, "getReplacer",
214 if (this.repr == null) {
215 this.repr = new com.stevesoft.pat.Replacer ();
216 }this.repr.rh.me = this;
217 this.repr.rh.prev = null;
220 Clazz.defineMethod (c$, "replaceFirst",
222 return this._getReplacer ().replaceFirstRegion (s, this, 0, s.length).toString ();
224 Clazz.defineMethod (c$, "replaceFirstFrom",
226 return this._getReplacer ().replaceFirstRegion (s, this, pos, s.length).toString ();
228 Clazz.defineMethod (c$, "replaceFirstRegion",
229 function (s, start, end) {
230 return this._getReplacer ().replaceFirstRegion (s, this, start, end).toString ();
232 Clazz.overrideMethod (c$, "replaceAll",
234 return this._getReplacer ().replaceAllRegion (s, this, 0, s.length).toString ();
236 Clazz.defineMethod (c$, "replaceAllLike",
238 return this._getReplacer ().replaceAllRegion (s, this, 0, s.length ());
239 }, "com.stevesoft.pat.StringLike");
240 Clazz.defineMethod (c$, "replaceAllFrom",
242 return this._getReplacer ().replaceAllRegion (s, this, pos, s.length).toString ();
244 Clazz.defineMethod (c$, "replaceAllRegion",
245 function (s, start, end) {
246 return this._getReplacer ().replaceAllRegion (s, this, start, end).toString ();
248 Clazz.defineMethod (c$, "compile",
250 var postpat = com.stevesoft.pat.parsePerl.codify (prepat, true);
251 var pat = postpat == null ? prepat : postpat;
252 this.minMatch = null;
253 this.ignoreCase = false;
254 this.dontMatchInQuotes = false;
255 var mk = new com.stevesoft.pat.Rthings (this);
258 this.thePattern = com.stevesoft.pat.Regex.none;
261 this.minMatch = new com.stevesoft.pat.patInt (0);
262 var sp = new com.stevesoft.pat.StrPos (pat, 0);
263 if (sp.incMatch ("(?e=")) {
266 if (sp.match (')')) {
267 newpat = com.stevesoft.pat.Regex.reEscape (pat.substring (6), newEsc, '\\');
268 }} else if (this.esc != '\\') {
269 newpat = com.stevesoft.pat.Regex.reEscape (pat, this.esc, '\\');
270 }this.thePattern = this._compile (newpat, mk);
271 this.numSubs_ = mk.val - offset;
274 Clazz.defineMethod (c$, "equals",
276 if (Clazz.instanceOf (o, com.stevesoft.pat.Regex)) {
277 if (this.toString ().equals (o.toString ())) {
278 return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]);
282 return Clazz.superCall (this, com.stevesoft.pat.Regex, "equals", [o]);
284 Clazz.defineMethod (c$, "prep",
286 this.pt.lastPos = this.matchedTo ();
287 if (this.pt.lastPos < 0) {
289 }if ((s == null ? null : s.unwrap ()) !== (this.src == null ? null : s.unwrap ())) {
292 this.pt.dotDoesntMatchCR = com.stevesoft.pat.Regex.dotDoesntMatchCR && (!this.sFlag);
293 this.pt.mFlag = ( new Boolean (this.mFlag | com.stevesoft.pat.Regex.defaultMFlag).valueOf ());
294 this.pt.ignoreCase = this.ignoreCase;
295 this.pt.no_check = false;
296 if (this.pt.marks != null) {
297 for (var i = 0; i < this.pt.marks.length; i++) {
298 this.pt.marks[i] = -1;
300 }this.pt.marks = null;
301 this.pt.nMarks = this.numSubs_;
303 if (this.dontMatchInQuotes) {
304 com.stevesoft.pat.Regex.setCbits (s, this.pt);
306 this.pt.cbits = null;
308 }, "com.stevesoft.pat.StringLike");
309 Clazz.defineMethod (c$, "matchAt",
310 function (s, start_pos) {
311 return this._search (s, start_pos, start_pos);
313 Clazz.defineMethod (c$, "matchAtLike",
314 function (s, start_pos) {
315 return this._searchLike (s, start_pos, start_pos);
316 }, "com.stevesoft.pat.StringLike,~N");
317 Clazz.overrideMethod (c$, "search",
320 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_search"));
321 }return this._search (s, 0, s.length);
323 Clazz.defineMethod (c$, "searchLike",
326 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search"));
327 }return this._searchLike (sl, 0, sl.length ());
328 }, "com.stevesoft.pat.StringLike");
329 Clazz.defineMethod (c$, "reverseSearch",
332 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_given_to_regex_reverse_search"));
333 }return this._reverseSearch (s, 0, s.length);
335 Clazz.defineMethod (c$, "reverseSearchLike",
338 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_reverse_search"));
339 }return this._reverseSearchLike (sl, 0, sl.length ());
340 }, "com.stevesoft.pat.StringLike");
341 Clazz.overrideMethod (c$, "searchFrom",
342 function (s, start) {
344 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from"));
345 }return this._search (s, start, s.length);
347 Clazz.defineMethod (c$, "searchFromLike",
348 function (s, start) {
350 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_from"));
351 }return this._searchLike (s, start, s.length ());
352 }, "com.stevesoft.pat.StringLike,~N");
353 Clazz.defineMethod (c$, "searchRegion",
354 function (s, start, end) {
356 throw new NullPointerException (com.stevesoft.pat.MessageManager.getString ("exception.null_string_like_given_to_regex_search_region"));
357 }return this._search (s, start, end);
359 Clazz.defineMethod (c$, "setGFlag",
363 Clazz.defineMethod (c$, "getGFlag",
367 Clazz.defineMethod (c$, "getSFlag",
371 Clazz.defineMethod (c$, "getMFlag",
375 Clazz.defineMethod (c$, "_search",
376 function (s, start, end) {
377 return this._searchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end);
379 Clazz.defineMethod (c$, "_searchLike",
380 function (s, start, end) {
381 if (this.gFlag && this.gFlagto > 0 && this.gFlags != null && s.unwrap () === this.gFlags.unwrap ()) {
382 start = this.gFlagto;
384 var pt = this.prep (s);
385 var up = (this.minMatch == null ? end : end - this.minMatch.i);
386 if (up < start && end >= start) {
388 }if (this.skipper == null) {
389 for (var i = start; i <= up; i++) {
390 this.charsMatched_ = this.thePattern.matchAt (s, i, pt);
391 if (this.charsMatched_ >= 0) {
392 this.matchFrom_ = this.thePattern.mfrom;
393 this.marks = pt.marks;
394 this.gFlagto = this.matchFrom_ + this.charsMatched_;
396 return this.didMatch_ = true;
400 for (var i = start; i <= up; i++) {
401 i = this.skipper.find (this.src, i, up);
403 this.charsMatched_ = this.matchFrom_ = -1;
404 return this.didMatch_ = false;
405 }this.charsMatched_ = this.thePattern.matchAt (s, i, pt);
406 if (this.charsMatched_ >= 0) {
407 this.matchFrom_ = this.thePattern.mfrom;
408 this.marks = pt.marks;
409 this.gFlagto = this.matchFrom_ + this.charsMatched_;
411 return this.didMatch_ = true;
413 }return this.didMatch_ = false;
414 }, "com.stevesoft.pat.StringLike,~N,~N");
415 Clazz.defineMethod (c$, "_reverseSearch",
416 function (s, start, end) {
417 return this._reverseSearchLike ( new com.stevesoft.pat.wrap.StringWrap (s), start, end);
419 Clazz.defineMethod (c$, "_reverseSearchLike",
420 function (s, start, end) {
421 if (this.gFlag && this.gFlagto > 0 && s.unwrap () === this.gFlags.unwrap ()) {
424 var pt = this.prep (s);
425 for (var i = end; i >= start; i--) {
426 this.charsMatched_ = this.thePattern.matchAt (s, i, pt);
427 if (this.charsMatched_ >= 0) {
428 this.matchFrom_ = this.thePattern.mfrom;
429 this.marks = pt.marks;
430 this.gFlagto = this.matchFrom_ - 1;
432 return this.didMatch_ = true;
434 return this.didMatch_ = false;
435 }, "com.stevesoft.pat.StringLike,~N,~N");
436 c$.setCbits = Clazz.defineMethod (c$, "setCbits",
438 if (s === com.stevesoft.pat.Regex.lasts) {
439 pt.cbits = com.stevesoft.pat.Regex.lastbs;
441 }var bs = new java.util.BitSet (s.length ());
444 for (var i = 0; i < s.length (); i++) {
447 }var c = s.charAt (i);
448 if (!setBit && c == '"') {
452 } else if (!setBit && c == '\'') {
456 } else if (setBit && c == qc) {
458 } else if (setBit && c == '\\' && i + 1 < s.length ()) {
463 pt.cbits = com.stevesoft.pat.Regex.lastbs = bs;
464 com.stevesoft.pat.Regex.lasts = s;
465 }, "com.stevesoft.pat.StringLike,com.stevesoft.pat.Pthings");
466 Clazz.defineMethod (c$, "add",
468 if (this.p == null) {
473 }}, "com.stevesoft.pat.Pattern");
474 Clazz.defineMethod (c$, "compileSP",
476 if (sp.match ('[')) {
478 this.add (this.matchBracket (sp));
479 } else if (sp.match ('|')) {
480 if (this.or == null) {
481 this.or = new com.stevesoft.pat.Or ();
482 }if (this.p == null) {
483 this.p = new com.stevesoft.pat.NullPattern ();
484 }this.or.addOr (this.p);
486 } else if (sp.incMatch ("(?<")) {
487 var i = sp.getPatInt ();
489 com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?<");
490 }this.add ( new com.stevesoft.pat.Backup (i.intValue ()));
491 if (!sp.match (')')) {
492 com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<");
493 }} else if (sp.incMatch ("(?>")) {
494 var i = sp.getPatInt ();
496 com.stevesoft.pat.RegSyntaxError.endItAll ("No int after (?>");
497 }this.add ( new com.stevesoft.pat.Backup (-i.intValue ()));
498 if (!sp.match (')')) {
499 com.stevesoft.pat.RegSyntaxError.endItAll ("No ) after (?<");
500 }} else if (sp.incMatch ("(?@")) {
505 if (!sp.match (')')) {
506 com.stevesoft.pat.RegSyntaxError.endItAll ("(?@ does not have closing paren");
507 }this.add ( new com.stevesoft.pat.Group (op, cl));
508 } else if (sp.incMatch ("(?#")) {
509 while (!sp.match (')')) {
512 } else if (sp.dontMatch && sp.c == 'w') {
513 var b = new com.stevesoft.pat.Bracket (false);
514 b.addOr ( new com.stevesoft.pat.Range ('a', 'z'));
515 b.addOr ( new com.stevesoft.pat.Range ('A', 'Z'));
516 b.addOr ( new com.stevesoft.pat.Range ('0', '9'));
517 b.addOr ( new com.stevesoft.pat.oneChar ('_'));
519 } else if (sp.dontMatch && sp.c == 'G') {
520 this.add ( new com.stevesoft.pat.BackG ());
521 } else if (sp.dontMatch && sp.c == 's') {
522 var b = new com.stevesoft.pat.Bracket (false);
523 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32)));
524 b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10)));
525 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13)));
527 } else if (sp.dontMatch && sp.c == 'd') {
528 var digit = new com.stevesoft.pat.Range ('0', '9');
529 digit.printBrackets = true;
531 } else if (sp.dontMatch && sp.c == 'W') {
532 var b = new com.stevesoft.pat.Bracket (true);
533 b.addOr ( new com.stevesoft.pat.Range ('a', 'z'));
534 b.addOr ( new com.stevesoft.pat.Range ('A', 'Z'));
535 b.addOr ( new com.stevesoft.pat.Range ('0', '9'));
536 b.addOr ( new com.stevesoft.pat.oneChar ('_'));
538 } else if (sp.dontMatch && sp.c == 'S') {
539 var b = new com.stevesoft.pat.Bracket (true);
540 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32)));
541 b.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10)));
542 b.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13)));
544 } else if (sp.dontMatch && sp.c == 'D') {
545 var b = new com.stevesoft.pat.Bracket (true);
546 b.addOr ( new com.stevesoft.pat.Range ('0', '9'));
548 } else if (sp.dontMatch && sp.c == 'B') {
549 var r = new com.stevesoft.pat.Regex (null, "");
550 r._compile ("(?!\\b)", mk);
551 this.add (r.thePattern);
552 } else if (this.isOctalString (sp)) {
553 var d = sp.c.charCodeAt (0) - 48;
555 d = 8 * d + sp.c.charCodeAt (0) - 48;
556 var sp2 = new com.stevesoft.pat.StrPos (sp);
558 if (this.isOctalDigit (sp2, false)) {
560 d = 8 * d + sp.c.charCodeAt (0) - 48;
561 }this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));
562 } else if (sp.dontMatch && sp.c >= '1' && sp.c <= '9') {
563 var iv = sp.c.charCodeAt (0) - 48;
564 var s2 = new com.stevesoft.pat.StrPos (sp);
566 if (!s2.dontMatch && s2.c >= '0' && s2.c <= '9') {
567 iv = 10 * iv + (s2.c.charCodeAt (0) - 48);
569 }this.add ( new com.stevesoft.pat.BackMatch (iv));
570 } else if (sp.dontMatch && sp.c == 'b') {
571 this.add ( new com.stevesoft.pat.Boundary ());
572 } else if (sp.match ('\b')) {
573 this.add ( new com.stevesoft.pat.Boundary ());
574 } else if (sp.match ('$')) {
575 this.add ( new com.stevesoft.pat.End (true));
576 } else if (sp.dontMatch && sp.c == 'Z') {
577 this.add ( new com.stevesoft.pat.End (false));
578 } else if (sp.match ('.')) {
579 this.add ( new com.stevesoft.pat.Any ());
580 } else if (sp.incMatch ("(??")) {
581 var sb = new StringBuffer ();
582 var sb2 = new StringBuffer ();
583 while (!sp.match (')') && !sp.match (':')) {
587 if (sp.incMatch (":")) {
588 while (!sp.match (')')) {
592 }var sbs = sb.toString ();
593 if (Clazz.instanceOf (com.stevesoft.pat.Regex.validators.get (sbs), String)) {
594 var pat = com.stevesoft.pat.Regex.validators.get (sbs);
595 var r = new com.stevesoft.pat.Regex (null, "");
596 var rth = new com.stevesoft.pat.Rthings (this);
597 rth.noBackRefs = true;
598 r._compile (pat, rth);
599 this.add (r.thePattern);
601 var cm = new com.stevesoft.pat.Custom (sb.toString ());
603 var v2 = cm.v.arg (sb2.toString ());
605 v2.argsave = sb2.toString ();
606 var p = cm.v.pattern;
609 }var r = new com.stevesoft.pat.Regex (null, "");
610 var rth = new com.stevesoft.pat.Rthings (this);
611 rth.noBackRefs = true;
612 r._compile (cm.v.pattern, rth);
613 cm.sub = r.thePattern;
614 cm.sub.add ( new com.stevesoft.pat.CustomEndpoint (cm));
615 cm.sub.setParent (cm);
617 }}} else if (sp.match ('(')) {
619 var r = new com.stevesoft.pat.Regex (null, "");
621 if (sp.incMatch ("?:")) {
622 r.or = new com.stevesoft.pat.Or ();
623 } else if (sp.incMatch ("?=")) {
624 r.or = new com.stevesoft.pat.lookAhead (false);
625 } else if (sp.incMatch ("?!")) {
626 r.or = new com.stevesoft.pat.lookAhead (true);
627 } else if (sp.match ('?')) {
631 mk.ignoreCase = true;
633 mk.dontMatchInQuotes = true;
635 mk.optimizeMe = true;
643 } while (!sp.match (')') && !sp.$eos);
647 com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed ()");
649 r.or = mk.noBackRefs ? new com.stevesoft.pat.Or () : new com.stevesoft.pat.OrMark (mk.val++);
651 this.add (r._compileSP (sp, mk));
652 }} else if (sp.match ('^')) {
653 this.add ( new com.stevesoft.pat.Start (true));
654 } else if (sp.dontMatch && sp.c == 'A') {
655 this.add ( new com.stevesoft.pat.Start (false));
656 } else if (sp.match ('*')) {
657 this.addMulti ( new com.stevesoft.pat.patInt (0), new com.stevesoft.pat.patInf ());
658 } else if (sp.match ('+')) {
659 this.addMulti ( new com.stevesoft.pat.patInt (1), new com.stevesoft.pat.patInf ());
660 } else if (sp.match ('?')) {
661 this.addMulti ( new com.stevesoft.pat.patInt (0), new com.stevesoft.pat.patInt (1));
662 } else if (sp.match ('{')) {
664 var sp2 = new com.stevesoft.pat.StrPos (sp);
666 var i1 = sp.getPatInt ();
668 if (sp.match ('}')) {
671 if (!sp.match (',')) {
674 if (sp.match ('}')) {
675 i2 = new com.stevesoft.pat.patInf ();
677 i2 = sp.getPatInt ();
678 }}if (i1 == null || i2 == null) {
682 this.add ( new com.stevesoft.pat.oneChar (sp.c));
684 this.addMulti (i1, i2);
685 }} else if (sp.escMatch ('x') && this.next2Hex (sp)) {
687 var d = this.getHexDigit (sp);
689 d = 16 * d + this.getHexDigit (sp);
690 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));
691 } else if (sp.escMatch ('c')) {
693 if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) {
694 this.add ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)]));
696 this.add ( new com.stevesoft.pat.oneChar (sp.c));
697 }} else if (sp.escMatch ('f')) {
698 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (12)));
699 } else if (sp.escMatch ('a')) {
700 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (7)));
701 } else if (sp.escMatch ('t')) {
702 this.add ( new com.stevesoft.pat.oneChar ('\t'));
703 } else if (sp.escMatch ('n')) {
704 this.add ( new com.stevesoft.pat.oneChar ('\n'));
705 } else if (sp.escMatch ('r')) {
706 this.add ( new com.stevesoft.pat.oneChar ('\r'));
707 } else if (sp.escMatch ('b')) {
708 this.add ( new com.stevesoft.pat.oneChar ('\b'));
709 } else if (sp.escMatch ('e')) {
710 this.add ( new com.stevesoft.pat.oneChar (String.fromCharCode (27)));
712 this.add ( new com.stevesoft.pat.oneChar (sp.c));
713 if (sp.match (')')) {
714 com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched right paren in pattern");
715 }}}, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings");
716 Clazz.defineMethod (c$, "_compile",
718 this.minMatch = null;
719 this.sFlag = this.mFlag = this.ignoreCase = this.gFlag = false;
720 var sp = new com.stevesoft.pat.StrPos (pat, 0);
721 this.thePattern = this._compileSP (sp, mk);
722 this.pt.marks = null;
723 return this.thePattern;
724 }, "~S,com.stevesoft.pat.Rthings");
725 Clazz.defineMethod (c$, "_compileSP",
727 while (!(sp.$eos || (this.or != null && sp.match (')')))) {
728 this.compileSP (sp, mk);
731 if (sp.match (')')) {
733 } else if (sp.$eos && mk.parenLevel != 0) {
734 com.stevesoft.pat.RegSyntaxError.endItAll ("Unclosed Parenthesis! lvl=" + mk.parenLevel);
735 }if (this.or != null) {
736 if (this.p == null) {
737 this.p = new com.stevesoft.pat.NullPattern ();
738 }this.or.addOr (this.p);
740 }return this.p == null ? new com.stevesoft.pat.NullPattern () : this.p;
741 }, "com.stevesoft.pat.StrPos,com.stevesoft.pat.Rthings");
742 Clazz.defineMethod (c$, "addMulti",
746 for (last = this.p; last != null && last.next != null; last = last.next) {
748 if (last == null || last === this.p) {
751 for (last2 = this.p; last2.next !== last; last2 = last2.next) {
753 }if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) && i1.intValue () == 0 && i2.intValue () == 1) {
754 (last).matchFewest = true;
755 } else if (Clazz.instanceOf (last, com.stevesoft.pat.FastMulti) && i1.intValue () == 0 && i2.intValue () == 1) {
756 (last).matchFewest = true;
757 } else if (Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) && i1.intValue () == 0 && i2.intValue () == 1) {
758 (last).matchFewest = true;
759 } else if (Clazz.instanceOf (last, com.stevesoft.pat.Multi) || Clazz.instanceOf (last, com.stevesoft.pat.DotMulti) || Clazz.instanceOf (last, com.stevesoft.pat.FastMulti)) {
760 throw new com.stevesoft.pat.RegSyntax ("Syntax error.");
761 } else if (last2 == null) {
762 this.p = com.stevesoft.pat.Regex.mkMulti (i1, i2, this.p);
764 last2.next = com.stevesoft.pat.Regex.mkMulti (i1, i2, last);
765 }}, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt");
766 c$.mkMulti = Clazz.defineMethod (c$, "mkMulti",
767 function (lo, hi, p) {
768 if (Clazz.instanceOf (p, com.stevesoft.pat.Any) && p.next == null) {
769 return new com.stevesoft.pat.DotMulti (lo, hi);
770 }return com.stevesoft.pat.RegOpt.safe4fm (p) ? new com.stevesoft.pat.FastMulti (lo, hi, p) : new com.stevesoft.pat.Multi (lo, hi, p);
771 }, "com.stevesoft.pat.patInt,com.stevesoft.pat.patInt,com.stevesoft.pat.Pattern");
772 Clazz.defineMethod (c$, "matchBracket",
775 if (sp.match ('^')) {
776 ret = new com.stevesoft.pat.Bracket (true);
779 ret = new com.stevesoft.pat.Bracket (false);
780 }if (sp.match (']')) {
781 com.stevesoft.pat.RegSyntaxError.endItAll ("Unmatched []");
782 }while (!sp.$eos && !sp.match (']')) {
783 var s1 = new com.stevesoft.pat.StrPos (sp);
785 var s1_ = new com.stevesoft.pat.StrPos (s1);
787 if (s1.match ('-') && !s1_.match (']')) {
788 var s2 = new com.stevesoft.pat.StrPos (s1);
791 ret.addOr ( new com.stevesoft.pat.Range (sp.c, s2.c));
794 } else if (sp.escMatch ('Q')) {
796 while (!sp.escMatch ('E')) {
797 ret.addOr ( new com.stevesoft.pat.oneChar (sp.c));
800 } else if (sp.escMatch ('d')) {
801 ret.addOr ( new com.stevesoft.pat.Range ('0', '9'));
802 } else if (sp.escMatch ('s')) {
803 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (32)));
804 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (8), String.fromCharCode (10)));
805 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (13)));
806 } else if (sp.escMatch ('w')) {
807 ret.addOr ( new com.stevesoft.pat.Range ('a', 'z'));
808 ret.addOr ( new com.stevesoft.pat.Range ('A', 'Z'));
809 ret.addOr ( new com.stevesoft.pat.Range ('0', '9'));
810 ret.addOr ( new com.stevesoft.pat.oneChar ('_'));
811 } else if (sp.escMatch ('D')) {
812 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (47)));
813 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (58), String.fromCharCode (65535)));
814 } else if (sp.escMatch ('S')) {
815 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (7)));
816 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (11), String.fromCharCode (12)));
817 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (14), String.fromCharCode (31)));
818 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (33), String.fromCharCode (65535)));
819 } else if (sp.escMatch ('W')) {
820 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (0), String.fromCharCode (64)));
821 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (91), String.fromCharCode (94)));
822 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (96)));
823 ret.addOr ( new com.stevesoft.pat.Range (String.fromCharCode (123), String.fromCharCode (65535)));
824 } else if (sp.escMatch ('x') && this.next2Hex (sp)) {
826 var d = this.getHexDigit (sp);
828 d = 16 * d + this.getHexDigit (sp);
829 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));
830 } else if (sp.escMatch ('a')) {
831 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (7)));
832 } else if (sp.escMatch ('f')) {
833 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (12)));
834 } else if (sp.escMatch ('e')) {
835 ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (27)));
836 } else if (sp.escMatch ('n')) {
837 ret.addOr ( new com.stevesoft.pat.oneChar ('\n'));
838 } else if (sp.escMatch ('t')) {
839 ret.addOr ( new com.stevesoft.pat.oneChar ('\t'));
840 } else if (sp.escMatch ('r')) {
841 ret.addOr ( new com.stevesoft.pat.oneChar ('\r'));
842 } else if (sp.escMatch ('c')) {
844 if (sp.c.charCodeAt (0) < com.stevesoft.pat.Ctrl.cmap.length) {
845 ret.addOr ( new com.stevesoft.pat.oneChar (com.stevesoft.pat.Ctrl.cmap[sp.c.charCodeAt (0)]));
847 ret.addOr ( new com.stevesoft.pat.oneChar (sp.c));
848 }} else if (this.isOctalString (sp)) {
849 var d = sp.c.charCodeAt (0) - 48;
851 d = 8 * d + sp.c.charCodeAt (0) - 48;
852 var sp2 = new com.stevesoft.pat.StrPos (sp);
854 if (this.isOctalDigit (sp2, false)) {
856 d = 8 * d + sp.c.charCodeAt (0) - 48;
857 }ret.addOr ( new com.stevesoft.pat.oneChar (String.fromCharCode (d)));
859 ret.addOr ( new com.stevesoft.pat.oneChar (sp.c));
863 }, "com.stevesoft.pat.StrPos");
864 Clazz.overrideMethod (c$, "toString",
867 var sb = new StringBuffer ();
868 if (this.esc != '\\') {
870 sb.append (this.esc);
872 }if (this.gFlag || this.mFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR || this.sFlag || this.ignoreCase || this.dontMatchInQuotes || this.optimized ()) {
874 if (this.ignoreCase) {
878 }if (this.sFlag || !com.stevesoft.pat.Regex.dotDoesntMatchCR) {
880 }if (this.dontMatchInQuotes) {
882 }if (this.optimized ()) {
887 }var patstr = this.thePattern.toString ();
888 if (this.esc != '\\') {
889 patstr = com.stevesoft.pat.Regex.reEscape (patstr, '\\', this.esc);
891 return sb.toString ();
893 c$.reEscape = Clazz.defineMethod (c$, "reEscape",
894 function (s, oldEsc, newEsc) {
895 if (oldEsc == newEsc) {
898 var sb = new StringBuffer ();
899 for (i = 0; i < s.length; i++) {
900 if (s.charAt (i) == oldEsc && i + 1 < s.length) {
901 if (s.charAt (i + 1) == oldEsc) {
905 sb.append (s.charAt (i + 1));
907 } else if (s.charAt (i) == newEsc) {
911 sb.append (s.charAt (i));
913 return sb.toString ();
915 Clazz.defineMethod (c$, "accept",
917 return this.search (s);
918 }, "java.io.File,~S");
919 c$.version = Clazz.defineMethod (c$, "version",
921 return "lgpl release 1.5.3";
923 Clazz.defineMethod (c$, "optimize",
925 if (this.optimized () || this.thePattern == null) {
927 }this.minMatch = new com.stevesoft.pat.patInt (0);
928 this.thePattern = com.stevesoft.pat.RegOpt.opt (this.thePattern, this.ignoreCase, this.dontMatchInQuotes);
929 this.skipper = com.stevesoft.pat.Skip.findSkipRegex (this);
932 Clazz.defineMethod (c$, "optimized",
934 return this.minMatch != null;
936 c$.perlCode = Clazz.defineMethod (c$, "perlCode",
938 return com.stevesoft.pat.parsePerl.parse (s);
940 Clazz.defineMethod (c$, "isLiteral",
942 var x = this.thePattern;
944 if (Clazz.instanceOf (x, com.stevesoft.pat.oneChar)) {
945 ;} else if (Clazz.instanceOf (x, com.stevesoft.pat.Skipped)) {
952 Clazz.defineMethod (c$, "countMinChars",
954 return this.thePattern.countMinChars ();
956 Clazz.defineMethod (c$, "countMaxChars",
958 return this.thePattern.countMaxChars ();
960 Clazz.defineMethod (c$, "isHexDigit",
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'));
964 }, "com.stevesoft.pat.StrPos");
965 Clazz.defineMethod (c$, "isOctalDigit",
966 function (sp, first) {
967 var r = !sp.$eos && !( new Boolean (first ^ sp.dontMatch).valueOf ()) && sp.c >= '0' && sp.c <= '7';
969 }, "com.stevesoft.pat.StrPos,~B");
970 Clazz.defineMethod (c$, "getHexDigit",
972 if (sp.c >= '0' && sp.c <= '9') {
973 return sp.c.charCodeAt (0) - 48;
974 }if (sp.c >= 'a' && sp.c <= 'f') {
975 return sp.c.charCodeAt (0) - 97 + 10;
976 }return sp.c.charCodeAt (0) - 65 + 10;
977 }, "com.stevesoft.pat.StrPos");
978 Clazz.defineMethod (c$, "next2Hex",
980 var sp2 = new com.stevesoft.pat.StrPos (sp);
982 if (!this.isHexDigit (sp2)) {
985 if (!this.isHexDigit (sp2)) {
988 }, "com.stevesoft.pat.StrPos");
989 Clazz.defineMethod (c$, "isOctalString",
991 if (!this.isOctalDigit (sp, true)) {
993 }var sp2 = new com.stevesoft.pat.StrPos (sp);
995 if (!this.isOctalDigit (sp2, false)) {
998 }, "com.stevesoft.pat.StrPos");
999 Clazz.defineStatics (c$,
1000 "BackRefOffset", 1);
1001 c$.none = c$.prototype.none = new com.stevesoft.pat.NoPattern ();
1002 c$.validators = c$.prototype.validators = new java.util.Hashtable ();
1004 com.stevesoft.pat.Regex.defineV ("p", "(?>1)", new com.stevesoft.pat.UnicodePunct ());
1005 com.stevesoft.pat.Regex.defineV ("P", "(?>1)", new com.stevesoft.pat.NUnicodePunct ());
1006 com.stevesoft.pat.Regex.defineV ("s", "(?>1)", new com.stevesoft.pat.UnicodeWhite ());
1007 com.stevesoft.pat.Regex.defineV ("S", "(?>1)", new com.stevesoft.pat.NUnicodeWhite ());
1008 com.stevesoft.pat.Regex.defineV ("w", "(?>1)", new com.stevesoft.pat.UnicodeW ());
1009 com.stevesoft.pat.Regex.defineV ("W", "(?>1)", new com.stevesoft.pat.NUnicodeW ());
1010 com.stevesoft.pat.Regex.defineV ("d", "(?>1)", new com.stevesoft.pat.UnicodeDigit ());
1011 com.stevesoft.pat.Regex.defineV ("D", "(?>1)", new com.stevesoft.pat.NUnicodeDigit ());
1012 com.stevesoft.pat.Regex.defineV ("m", "(?>1)", new com.stevesoft.pat.UnicodeMath ());
1013 com.stevesoft.pat.Regex.defineV ("M", "(?>1)", new com.stevesoft.pat.NUnicodeMath ());
1014 com.stevesoft.pat.Regex.defineV ("c", "(?>1)", new com.stevesoft.pat.UnicodeCurrency ());
1015 com.stevesoft.pat.Regex.defineV ("C", "(?>1)", new com.stevesoft.pat.NUnicodeCurrency ());
1016 com.stevesoft.pat.Regex.defineV ("a", "(?>1)", new com.stevesoft.pat.UnicodeAlpha ());
1017 com.stevesoft.pat.Regex.defineV ("A", "(?>1)", new com.stevesoft.pat.NUnicodeAlpha ());
1018 com.stevesoft.pat.Regex.defineV ("uc", "(?>1)", new com.stevesoft.pat.UnicodeUpper ());
1019 com.stevesoft.pat.Regex.defineV ("lc", "(?>1)", new com.stevesoft.pat.UnicodeLower ());
1020 }Clazz.defineStatics (c$,
1021 "defaultMFlag", false,
1022 "dotDoesntMatchCR", true,
1025 "back_slash", '\\');