Source code: com/memoire/re/RETokenBackRef.java
1
2
3 package com.memoire.re;
4 import com.memoire.re.*;
5
6 /*
7 * gnu/regexp/RETokenBackRef.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 RETokenBackRef extends REToken {
28 private int num;
29 private boolean insens;
30
31 RETokenBackRef(int f_subIndex, int mynum, boolean ins) {
32 super(f_subIndex);
33 insens = ins;
34 num = mynum;
35 }
36
37 // should implement getMinimumLength() -- any ideas?
38
39 int[] match(RECharIndexed input, int index, int eflags, REMatch mymatch) {
40 int b,e;
41 b = mymatch.start[num];
42 e = mymatch.end[num];
43 if ((b==-1)||(e==-1)) return null; // this shouldn't happen, but...
44 for (int i=b; i<e; i++) {
45 if (input.charAt(index+i-b) != input.charAt(i)) return null;
46 }
47
48 return next(input,index+e-b,eflags,mymatch);
49 }
50
51 void dump(StringBuffer os) {
52 os.append('\\').append(num);
53 }
54 }
55
56