2 // This software is now distributed according to
3 // the Lesser Gnu Public License. Please see
4 // http://www.gnu.org/copyleft/lesser.txt for
8 package com.stevesoft.pat;
10 import java.util.Hashtable;
12 /** Thrown when one encounters things like [z-a] */
13 class BadRangeArgs extends RegSyntax
18 * Implments a subelement (ranges) of the [] pattern element. For example,
19 * [a-z023] is implemented using a range and tree oneChar classes.
24 class Range extends Pattern
26 char lo, hi, altlo, althi;
28 boolean printBrackets = false;
30 public String toString()
32 String s = protect("" + lo, PROTECT_THESE, ESC) + "-"
33 + protect("" + hi, PROTECT_THESE, ESC);
41 Range(char loi, char hii) throws RegSyntax
48 // throw new BadRangeArgs();
49 RegSyntaxError.endItAll("Badly formed []'s : " + lo + " >= " + hi);
57 public int matchInternal(int pos, Pthings pt)
59 if (pos >= pt.src.length())
67 char c = pt.src.charAt(pos);
68 if (lo <= c && c <= hi || (pt.ignoreCase && (altlo <= c && c <= althi)))
70 return nextMatch(pos + 1, pt);
75 public patInt minChars()
80 public patInt maxChars()
85 public Pattern clone1(Hashtable h)
89 Range r = new Range(lo, hi);
90 r.printBrackets = printBrackets;
92 } catch (RegSyntax rs)