diff options
author | Shashank Bapat <shashankbapat@yahoo.com> | 2004-09-25 19:04:34 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2004-09-25 19:04:34 +0000 |
commit | 27a92d683b4fcfa5b2446580b1aadaa50fe5840b (patch) | |
tree | ffc01befdc137abc39092adb9c561cb9a1c78bd9 /libjava/gnu/regexp/RE.java | |
parent | 75d17889dff3b4cd5e31430c6c9769c18a210efe (diff) | |
download | gcc-27a92d683b4fcfa5b2446580b1aadaa50fe5840b.zip gcc-27a92d683b4fcfa5b2446580b1aadaa50fe5840b.tar.gz gcc-27a92d683b4fcfa5b2446580b1aadaa50fe5840b.tar.bz2 |
RE.java (initialize): Add RETokenLookAhead support.
2004-09-25 Shashank Bapat <shashankbapat@yahoo.com>
Mark Wielaard <mark@klomp.org>
* gnu/regexp/RE.java (initialize): Add RETokenLookAhead support.
* gnu/regexp/RETokenLookAhead.java: New file.
* Makefile.am (ordinary_java_source_files): Add RETokenLookAhead.java.
* Makefile.in: Regenerated.
Co-Authored-By: Mark Wielaard <mark@klomp.org>
From-SVN: r88106
Diffstat (limited to 'libjava/gnu/regexp/RE.java')
-rw-r--r-- | libjava/gnu/regexp/RE.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/libjava/gnu/regexp/RE.java b/libjava/gnu/regexp/RE.java index fdc00fe..d782975 100644 --- a/libjava/gnu/regexp/RE.java +++ b/libjava/gnu/regexp/RE.java @@ -492,8 +492,25 @@ public class RE extends REToken { else if ((unit.ch == '(') && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ unit.bk)) { boolean pure = false; boolean comment = false; + boolean lookAhead = false; + boolean negativelh = false; if ((index+1 < pLength) && (pattern[index] == '?')) { switch (pattern[index+1]) { + case '!': + if (syntax.get(RESyntax.RE_LOOKAHEAD)) { + pure = true; + negativelh = true; + lookAhead = true; + index += 2; + } + break; + case '=': + if (syntax.get(RESyntax.RE_LOOKAHEAD)) { + pure = true; + lookAhead = true; + index += 2; + } + break; case ':': if (syntax.get(RESyntax.RE_PURE_GROUPING)) { pure = true; @@ -539,10 +556,14 @@ public class RE extends REToken { numSubs++; } - int useIndex = (pure) ? 0 : nextSub + numSubs; + int useIndex = (pure || lookAhead) ? 0 : nextSub + numSubs; currentToken = new RE(String.valueOf(pattern,index,endIndex-index).toCharArray(),cflags,syntax,useIndex,nextSub + numSubs); numSubs += ((RE) currentToken).getNumSubs(); + if (lookAhead) { + currentToken = new RETokenLookAhead(currentToken,negativelh); + } + index = nextIndex; } // not a comment } // subexpression |