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