2 * gnu/regexp/RETokenStart.java
3 * Copyright (C) 1998-2001 Wes Biggs
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation; either version 2.1 of the License, or
8 * (at your option) any later version.
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 Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser 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.
22 class RETokenStart extends REToken {
23 private String newline; // matches after a newline
25 RETokenStart(int subIndex, String newline) {
27 this.newline = newline;
30 boolean match(CharIndexed input, REMatch mymatch) {
31 // charAt(index-n) may be unknown on a Reader/InputStream. FIXME
32 // Match after a newline if in multiline mode
34 if (newline != null) {
35 int len = newline.length();
36 if (mymatch.offset >= len) {
39 int i = 0; // position in REToken.newline
40 char ch = input.charAt(mymatch.index - len);
42 z = newline.charAt(i);
48 ch = input.charAt(mymatch.index - len + i);
51 if (found) return next(input, mymatch);
55 // Don't match at all if REG_NOTBOL is set.
56 if ((mymatch.eflags & RE.REG_NOTBOL) > 0) return false;
58 if ((mymatch.eflags & RE.REG_ANCHORINDEX) > 0)
59 return (mymatch.anchor == mymatch.offset) ?
60 next(input, mymatch) : false;
62 return ((mymatch.index == 0) && (mymatch.offset == 0)) ?
63 next(input, mymatch) : false;
66 void dump(StringBuffer os) {