2 // This software is now distributed according to
\r
3 // the Lesser Gnu Public License. Please see
\r
4 // http://www.gnu.org/copyleft/lesser.txt for
\r
6 // -- Happy Computing!
\r
8 package com.stevesoft.pat;
\r
9 import java.util.Hashtable;
\r
11 /** Implements the (?<number) Pattern, where number is
\r
12 an integer telling us how far to back up in the Pattern.
\r
13 Not in perl 5. It also allows (?>number). */
\r
14 class Backup extends Pattern {
\r
16 Backup(int ii) { bk = ii; }
\r
17 public String toString() {
\r
18 return "(?" + (bk < 0 ? ">" + (-bk) : "<" + bk) + ")" + nextString();
\r
20 public int matchInternal(int pos,Pthings pt) {
\r
21 if(pos < bk) return -1;
\r
22 return nextMatch(pos-bk,pt);
\r
24 public patInt minChars() { return new patInt(-bk); }
\r
25 public patInt maxChars() { return new patInt(-bk); }
\r
26 public Pattern clone1(Hashtable h) { return new Backup(bk); }
\r