01: /*
02: * gnu/regexp/RETokenEnd.java
03: * Copyright (C) 1998 Wes Biggs
04: *
05: * This library is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU Library General Public License as published
07: * by the Free Software Foundation; either version 2 of the License, or
08: * (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU Library General Public License for more details.
14: *
15: * You should have received a copy of the GNU Library General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18: */
19:
20: package gnu.regexp;
21:
22: class RETokenEnd extends REToken {
23: private boolean newline;
24:
25: RETokenEnd(int f_subIndex, boolean f_newline) {
26: super (f_subIndex);
27: newline = f_newline;
28: }
29:
30: int[] match(CharIndexed input, int index, int eflags,
31: REMatch mymatch) {
32: // this may not work on systems that use \r\n as line separator. FIXME
33: // use System.getProperty("line.separator");
34: char ch = input.charAt(index);
35: if (ch == CharIndexed.OUT_OF_BOUNDS)
36: return ((eflags & RE.REG_NOTEOL) > 0) ? null : next(input,
37: index, eflags, mymatch);
38: return (newline && (ch == '\n')) ? next(input, index, eflags,
39: mymatch) : null;
40: }
41:
42: void dump(StringBuffer os) {
43: os.append('$');
44: }
45: }
|