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 //class AddToEnd extends RegSyntax {};
\r
13 /** Compiles the '$' or the '\Z' Pattern. It is
\r
14 an error to have further Pattern elements after
\r
15 '\Z'. It is the end of the String. */
\r
16 class End extends Pattern {
\r
18 End(boolean b) { retIsEnd = b; }
\r
19 public int matchInternal(int pos,Pthings pt) {
\r
20 if(retIsEnd && pt.mFlag && pos < pt.src.length()) {
\r
21 if(pt.src.charAt(pos)=='\n') {
\r
22 return nextMatch(pos,pt);
\r
25 if(pt.src.length() == pos)
\r
26 return nextMatch(pos,pt);
\r
27 else if(pos<pt.src.length())
\r
28 // Access the next character...
\r
29 // this is crucial to making
\r
30 // RegexReader work.
\r
34 public String toString() {
\r
40 public patInt maxChars() { return new patInt(1); }
\r
41 public Pattern clone1(Hashtable h) { return new End(retIsEnd); }
\r