mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Add 'T' prefix to regex implementation classes
This commit is contained in:
parent
78f4f7a1ff
commit
bc74f817fe
|
@ -773,7 +773,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
|
|||
}
|
||||
|
||||
public TString substring(int from, int to) {
|
||||
if (from > to || from < 0 || to >= length) {
|
||||
if (from > to || from < 0 || to > length) {
|
||||
throw new TIndexOutOfBoundsException();
|
||||
}
|
||||
return new TString(buffer, from, to - from);
|
||||
|
|
|
@ -636,8 +636,12 @@ public class TCharacter extends TObject implements TComparable<TCharacter> {
|
|||
case 0x1E:
|
||||
case 0x1F:
|
||||
return true;
|
||||
case 0xA0:
|
||||
case 0x2007:
|
||||
case 0x202F:
|
||||
return false;
|
||||
default:
|
||||
return isWhitespace(codePoint);
|
||||
return isSpaceChar(codePoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
|
||||
package org.teavm.classlib.java.util.regex;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* Internationalization stub. All the messages in java.util.regexp
|
||||
* package done though this class. This class should be lately replaced with
|
||||
* real internationalization utility.
|
||||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*
|
||||
*/
|
||||
class I18n {
|
||||
public static String getMessage(String message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String getFormattedMessage(String message, Object arg1) {
|
||||
return MessageFormat.format(message, new Object[] {arg1});
|
||||
}
|
||||
|
||||
public static String getFormattedMessage(String message, Object arg1, Object arg2) {
|
||||
return MessageFormat.format(message, new Object[] {arg1, arg2});
|
||||
}
|
||||
|
||||
}
|
|
@ -45,7 +45,7 @@ import java.util.BitSet;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class AbstractCharClass extends SpecialToken {
|
||||
abstract class TAbstractCharClass extends TSpecialToken {
|
||||
protected boolean alt;
|
||||
|
||||
protected boolean altSurrogates;
|
||||
|
@ -55,9 +55,9 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
BitSet lowHighSurrogates = new BitSet(SURROGATE_CARDINALITY);
|
||||
|
||||
AbstractCharClass charClassWithoutSurrogates = null;
|
||||
TAbstractCharClass charClassWithoutSurrogates = null;
|
||||
|
||||
AbstractCharClass charClassWithSurrogates = null;
|
||||
TAbstractCharClass charClassWithSurrogates = null;
|
||||
|
||||
static PredefinedCharacterClasses charClasses = new PredefinedCharacterClasses();
|
||||
|
||||
|
@ -101,24 +101,24 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SpecialToken.TOK_CHARCLASS;
|
||||
return TSpecialToken.TOK_CHARCLASS;
|
||||
}
|
||||
|
||||
public AbstractCharClass getInstance() {
|
||||
public TAbstractCharClass getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AbstractCharClass getSurrogates() {
|
||||
public TAbstractCharClass getSurrogates() {
|
||||
|
||||
if (charClassWithSurrogates == null) {
|
||||
final BitSet lHS = getLowHighSurrogates();
|
||||
|
||||
charClassWithSurrogates = new AbstractCharClass() {
|
||||
charClassWithSurrogates = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
int index = ch - Character.MIN_SURROGATE;
|
||||
|
||||
return ((index >= 0) && (index < AbstractCharClass.SURROGATE_CARDINALITY)) ? this.altSurrogates ^
|
||||
return ((index >= 0) && (index < TAbstractCharClass.SURROGATE_CARDINALITY)) ? this.altSurrogates ^
|
||||
lHS.get(index) : false;
|
||||
}
|
||||
};
|
||||
|
@ -128,17 +128,17 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
return charClassWithSurrogates;
|
||||
}
|
||||
|
||||
public AbstractCharClass getWithoutSurrogates() {
|
||||
public TAbstractCharClass getWithoutSurrogates() {
|
||||
if (charClassWithoutSurrogates == null) {
|
||||
final BitSet lHS = getLowHighSurrogates();
|
||||
final AbstractCharClass thisClass = this;
|
||||
final TAbstractCharClass thisClass = this;
|
||||
|
||||
charClassWithoutSurrogates = new AbstractCharClass() {
|
||||
charClassWithoutSurrogates = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
int index = ch - Character.MIN_SURROGATE;
|
||||
|
||||
boolean containslHS = ((index >= 0) && (index < AbstractCharClass.SURROGATE_CARDINALITY)) ? this.altSurrogates ^
|
||||
boolean containslHS = ((index >= 0) && (index < TAbstractCharClass.SURROGATE_CARDINALITY)) ? this.altSurrogates ^
|
||||
lHS.get(index)
|
||||
: false;
|
||||
|
||||
|
@ -165,10 +165,10 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
* just overall meaning of the class.
|
||||
*
|
||||
* @see #contains(int)
|
||||
* @see #intersect(CharClass)
|
||||
* @see #union(CharClass)
|
||||
* @see #intersect(TCharClass)
|
||||
* @see #union(TCharClass)
|
||||
*/
|
||||
public AbstractCharClass setNegative(boolean value) {
|
||||
public TAbstractCharClass setNegative(boolean value) {
|
||||
if (alt ^ value) {
|
||||
alt = !alt;
|
||||
altSurrogates = !altSurrogates;
|
||||
|
@ -191,26 +191,26 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
return ch1 == ch2;
|
||||
}
|
||||
|
||||
public static boolean intersects(AbstractCharClass cc, int ch) {
|
||||
public static boolean intersects(TAbstractCharClass cc, int ch) {
|
||||
return cc.contains(ch);
|
||||
}
|
||||
|
||||
public static boolean intersects(AbstractCharClass cc1, AbstractCharClass cc2) {
|
||||
public static boolean intersects(TAbstractCharClass cc1, TAbstractCharClass cc2) {
|
||||
if (cc1.getBits() == null || cc2.getBits() == null)
|
||||
return true;
|
||||
return cc1.getBits().intersects(cc2.getBits());
|
||||
}
|
||||
|
||||
public static AbstractCharClass getPredefinedClass(String name, boolean negative) {
|
||||
public static TAbstractCharClass getPredefinedClass(String name, boolean negative) {
|
||||
return ((LazyCharClass)charClasses.getObject(name)).getValue(negative);
|
||||
}
|
||||
|
||||
abstract static class LazyCharClass {
|
||||
AbstractCharClass posValue = null;
|
||||
TAbstractCharClass posValue = null;
|
||||
|
||||
AbstractCharClass negValue = null;
|
||||
TAbstractCharClass negValue = null;
|
||||
|
||||
public AbstractCharClass getValue(boolean negative) {
|
||||
public TAbstractCharClass getValue(boolean negative) {
|
||||
if (!negative && posValue == null) {
|
||||
posValue = computeValue();
|
||||
} else if (negative && negValue == null) {
|
||||
|
@ -221,20 +221,20 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
return negValue;
|
||||
}
|
||||
|
||||
protected abstract AbstractCharClass computeValue();
|
||||
protected abstract TAbstractCharClass computeValue();
|
||||
}
|
||||
|
||||
static class LazyDigit extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add('0', '9');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add('0', '9');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyNonDigit extends LazyDigit {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = super.computeValue().setNegative(true);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = super.computeValue().setNegative(true);
|
||||
|
||||
chCl.mayContainSupplCodepoints = true;
|
||||
return chCl;
|
||||
|
@ -243,16 +243,16 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazySpace extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
/* 9-13 - \t\n\x0B\f\r; 32 - ' ' */
|
||||
return new CharClass().add(9, 13).add(32);
|
||||
return new TCharClass().add(9, 13).add(32);
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyNonSpace extends LazySpace {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = super.computeValue().setNegative(true);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = super.computeValue().setNegative(true);
|
||||
|
||||
chCl.mayContainSupplCodepoints = true;
|
||||
return chCl;
|
||||
|
@ -261,15 +261,15 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyWord extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add('a', 'z').add('A', 'Z').add('0', '9').add('_');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add('a', 'z').add('A', 'Z').add('0', '9').add('_');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyNonWord extends LazyWord {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = super.computeValue().setNegative(true);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = super.computeValue().setNegative(true);
|
||||
|
||||
chCl.mayContainSupplCodepoints = true;
|
||||
return chCl;
|
||||
|
@ -278,80 +278,80 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyLower extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add('a', 'z');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add('a', 'z');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyUpper extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add('A', 'Z');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add('A', 'Z');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyASCII extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add(0x00, 0x7F);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add(0x00, 0x7F);
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyAlpha extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add('a', 'z').add('A', 'Z');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add('a', 'z').add('A', 'Z');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyAlnum extends LazyAlpha {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return ((CharClass)super.computeValue()).add('0', '9');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return ((TCharClass)super.computeValue()).add('0', '9');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyPunct extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
/* Punctuation !"#$%&'()*+,-./:;<=>?@ [\]^_` {|}~ */
|
||||
return new CharClass().add(0x21, 0x40).add(0x5B, 0x60).add(0x7B, 0x7E);
|
||||
return new TCharClass().add(0x21, 0x40).add(0x5B, 0x60).add(0x7B, 0x7E);
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyGraph extends LazyAlnum {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
/* plus punctuation */
|
||||
return ((CharClass)super.computeValue()).add(0x21, 0x40).add(0x5B, 0x60).add(0x7B, 0x7E);
|
||||
return ((TCharClass)super.computeValue()).add(0x21, 0x40).add(0x5B, 0x60).add(0x7B, 0x7E);
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyPrint extends LazyGraph {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return ((CharClass)super.computeValue()).add(0x20);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return ((TCharClass)super.computeValue()).add(0x20);
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyBlank extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add(' ').add('\t');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add(' ').add('\t');
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyCntrl extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add(0x00, 0x1F).add(0x7F);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add(0x00, 0x1F).add(0x7F);
|
||||
}
|
||||
}
|
||||
|
||||
static class LazyXDigit extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new CharClass().add('0', '9').add('a', 'f').add('A', 'F');
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add('0', '9').add('a', 'f').add('A', 'F');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,16 +364,16 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new CharClass().add(start, end);
|
||||
public TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TCharClass().add(start, end);
|
||||
return chCl;
|
||||
}
|
||||
}
|
||||
|
||||
static class LazySpecialsBlock extends LazyCharClass {
|
||||
@Override
|
||||
public AbstractCharClass computeValue() {
|
||||
return new CharClass().add(0xFEFF, 0xFEFF).add(0xFFF0, 0xFFFD);
|
||||
public TAbstractCharClass computeValue() {
|
||||
return new TCharClass().add(0xFEFF, 0xFEFF).add(0xFFF0, 0xFFFD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,8 +396,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new UnicodeCategoryScope(category);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TUnicodeCategoryScope(category);
|
||||
if (containsAllSurrogates) {
|
||||
chCl.lowHighSurrogates.set(0, SURROGATE_CARDINALITY);
|
||||
}
|
||||
|
@ -426,8 +426,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new UnicodeCategory(category);
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TUnicodeCategory(category);
|
||||
if (containsAllSurrogates) {
|
||||
chCl.lowHighSurrogates.set(0, SURROGATE_CARDINALITY);
|
||||
}
|
||||
|
@ -439,8 +439,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaLowerCase extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isLowerCase(ch);
|
||||
|
@ -454,8 +454,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaUpperCase extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isUpperCase(ch);
|
||||
|
@ -469,8 +469,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaWhitespace extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isWhitespace(ch);
|
||||
|
@ -481,8 +481,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaMirrored extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
// TODO implement this method and uncomment
|
||||
|
@ -495,8 +495,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaDefined extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isDefined(ch);
|
||||
|
@ -511,8 +511,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaDigit extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isDigit(ch);
|
||||
|
@ -526,8 +526,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaIdentifierIgnorable extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isIdentifierIgnorable(ch);
|
||||
|
@ -541,8 +541,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaISOControl extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isISOControl(ch);
|
||||
|
@ -553,8 +553,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaJavaIdentifierPart extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isJavaIdentifierPart(ch);
|
||||
|
@ -568,8 +568,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaJavaIdentifierStart extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isJavaIdentifierStart(ch);
|
||||
|
@ -583,8 +583,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaLetter extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isLetter(ch);
|
||||
|
@ -598,8 +598,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaLetterOrDigit extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isLetterOrDigit(ch);
|
||||
|
@ -613,8 +613,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaSpaceChar extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isSpaceChar(ch);
|
||||
|
@ -625,8 +625,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaTitleCase extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
return new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
return new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isTitleCase(ch);
|
||||
|
@ -637,8 +637,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaUnicodeIdentifierPart extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isUnicodeIdentifierPart(ch);
|
||||
|
@ -652,8 +652,8 @@ abstract class AbstractCharClass extends SpecialToken {
|
|||
|
||||
static class LazyJavaUnicodeIdentifierStart extends LazyCharClass {
|
||||
@Override
|
||||
protected AbstractCharClass computeValue() {
|
||||
AbstractCharClass chCl = new AbstractCharClass() {
|
||||
protected TAbstractCharClass computeValue() {
|
||||
TAbstractCharClass chCl = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return Character.isUnicodeIdentifierStart(ch);
|
|
@ -40,20 +40,20 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class AbstractLineTerminator {
|
||||
static AbstractLineTerminator unixLT = null;
|
||||
abstract class TAbstractLineTerminator {
|
||||
static TAbstractLineTerminator unixLT = null;
|
||||
|
||||
static AbstractLineTerminator unicodeLT = null;
|
||||
static TAbstractLineTerminator unicodeLT = null;
|
||||
|
||||
public abstract boolean isLineTerminator(int ch);
|
||||
|
||||
public abstract boolean isAfterLineTerminator(int ch1, int ch2);
|
||||
|
||||
public static AbstractLineTerminator getInstance(int flag) {
|
||||
public static TAbstractLineTerminator getInstance(int flag) {
|
||||
if ((flag & TPattern.UNIX_LINES) != 0) {
|
||||
if (unixLT != null)
|
||||
return unixLT;
|
||||
unixLT = new AbstractLineTerminator() {
|
||||
unixLT = new TAbstractLineTerminator() {
|
||||
@Override
|
||||
public boolean isLineTerminator(int ch) {
|
||||
return ch == '\n';
|
||||
|
@ -68,7 +68,7 @@ abstract class AbstractLineTerminator {
|
|||
} else {
|
||||
if (unicodeLT != null)
|
||||
return unicodeLT;
|
||||
unicodeLT = new AbstractLineTerminator() {
|
||||
unicodeLT = new TAbstractLineTerminator() {
|
||||
@Override
|
||||
public boolean isLineTerminator(int ch) {
|
||||
return (ch == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029');
|
|
@ -41,7 +41,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class AbstractSet {
|
||||
abstract class TAbstractSet {
|
||||
|
||||
public static final int TYPE_LEAF = 1 << 0;
|
||||
|
||||
|
@ -54,7 +54,7 @@ abstract class AbstractSet {
|
|||
/**
|
||||
* Next node to visit
|
||||
*/
|
||||
protected AbstractSet next;
|
||||
protected TAbstractSet next;
|
||||
|
||||
/**
|
||||
* Counter for debugging purposes, represent unique node index;
|
||||
|
@ -63,14 +63,14 @@ abstract class AbstractSet {
|
|||
|
||||
protected boolean isSecondPassVisited = false;
|
||||
|
||||
protected String index = new Integer(AbstractSet.counter++).toString();
|
||||
protected String index = new Integer(TAbstractSet.counter++).toString();
|
||||
|
||||
private int type = 0;
|
||||
|
||||
public AbstractSet() {
|
||||
public TAbstractSet() {
|
||||
}
|
||||
|
||||
public AbstractSet(AbstractSet n) {
|
||||
public TAbstractSet(TAbstractSet n) {
|
||||
next = n;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ abstract class AbstractSet {
|
|||
* - MatchResult to sore result into
|
||||
* @return -1 if match fails or n > 0;
|
||||
*/
|
||||
public abstract int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult);
|
||||
public abstract int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult);
|
||||
|
||||
/**
|
||||
* Attempts to apply pattern starting from this set/stringIndex; returns
|
||||
|
@ -108,7 +108,7 @@ abstract class AbstractSet {
|
|||
* result of the match
|
||||
* @return last searched index
|
||||
*/
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int length = matchResult.getRightBound();
|
||||
while (stringIndex <= length) {
|
||||
if (matches(stringIndex, testString, matchResult) >= 0) {
|
||||
|
@ -132,7 +132,7 @@ abstract class AbstractSet {
|
|||
* @return an index to start back search next time if this search fails(new
|
||||
* left bound); if this search fails the value is negative;
|
||||
*/
|
||||
public int findBack(int stringIndex, int startSearch, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int stringIndex, int startSearch, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
while (startSearch >= stringIndex) {
|
||||
if (matches(startSearch, testString, matchResult) >= 0) {
|
||||
return startSearch;
|
||||
|
@ -152,7 +152,7 @@ abstract class AbstractSet {
|
|||
* @param matchResult
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean hasConsumed(MatchResultImpl matchResult);
|
||||
public abstract boolean hasConsumed(TMatchResultImpl matchResult);
|
||||
|
||||
/**
|
||||
* Returns name for the particular node type. Used for debugging purposes.
|
||||
|
@ -179,7 +179,7 @@ abstract class AbstractSet {
|
|||
/**
|
||||
* Returns the next.
|
||||
*/
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return next;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ abstract class AbstractSet {
|
|||
* @param next
|
||||
* The next to set.
|
||||
*/
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ abstract class AbstractSet {
|
|||
*
|
||||
* @return true if the given node intersects with this one
|
||||
*/
|
||||
public boolean first(AbstractSet set) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ abstract class AbstractSet {
|
|||
* @return null if current node need not to be replaced JointSet which is
|
||||
* replacement of current node otherwise
|
||||
*/
|
||||
public JointSet processBackRefReplacement() {
|
||||
public TJointSet processBackRefReplacement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ abstract class AbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
JointSet set = next.processBackRefReplacement();
|
||||
TJointSet set = next.processBackRefReplacement();
|
||||
|
||||
if (set != null) {
|
||||
next.isSecondPassVisited = true;
|
||||
|
@ -259,7 +259,7 @@ abstract class AbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
if (next instanceof SingleSet && ((FSet)((JointSet)next).fSet).isBackReferenced) {
|
||||
if (next instanceof TSingleSet && ((TFSet)((TJointSet)next).fSet).isBackReferenced) {
|
||||
next = next.next;
|
||||
}
|
||||
|
|
@ -40,13 +40,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class AheadFSet extends FSet {
|
||||
public AheadFSet() {
|
||||
class TAheadFSet extends TFSet {
|
||||
public TAheadFSet() {
|
||||
super(-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
return stringIndex;
|
||||
}
|
||||
|
|
@ -40,13 +40,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class AltGroupQuantifierSet extends GroupQuantifierSet {
|
||||
public AltGroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
class TAltGroupQuantifierSet extends TGroupQuantifierSet {
|
||||
public TAltGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
|
||||
|
@ -60,7 +60,7 @@ class AltGroupQuantifierSet extends GroupQuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
super.setNext(next);
|
||||
innerSet.setNext(next);
|
||||
}
|
|
@ -40,14 +40,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class AltQuantifierSet extends LeafQuantifierSet {
|
||||
class TAltQuantifierSet extends TLeafQuantifierSet {
|
||||
|
||||
public AltQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
public TAltQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
|
||||
if ((shift = innerSet.matches(stringIndex, testString, matchResult)) >= 0) {
|
||||
|
@ -58,7 +58,7 @@ class AltQuantifierSet extends LeafQuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
super.setNext(next);
|
||||
innerSet.setNext(next);
|
||||
}
|
|
@ -38,16 +38,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class AtomicFSet extends FSet {
|
||||
class TAtomicFSet extends TFSet {
|
||||
|
||||
int index;
|
||||
|
||||
public AtomicFSet(int groupIndex) {
|
||||
public TAtomicFSet(int groupIndex) {
|
||||
super(groupIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
int gr = getGroupIndex();
|
||||
matchResult.setConsumed(gr, stringIndex - matchResult.getConsumed(gr));
|
||||
|
@ -66,7 +66,7 @@ class AtomicFSet extends FSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -43,8 +43,8 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class AtomicJointSet extends NonCapJointSet {
|
||||
public AtomicJointSet(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
class TAtomicJointSet extends TNonCapJointSet {
|
||||
public TAtomicJointSet(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
super(children, fSet);
|
||||
}
|
||||
|
||||
|
@ -52,18 +52,18 @@ class AtomicJointSet extends NonCapJointSet {
|
|||
* Returns stringIndex+shift, the next position to match
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int start = matchResult.getConsumed(groupIndex);
|
||||
matchResult.setConsumed(groupIndex, stringIndex);
|
||||
|
||||
int size = children.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
int shift = e.matches(stringIndex, testString, matchResult);
|
||||
if (shift >= 0) {
|
||||
// AtomicFset always returns true, but saves the index to run
|
||||
// this next.match() from;
|
||||
return next.matches(((AtomicFSet)fSet).getIndex(), testString, matchResult);
|
||||
return next.matches(((TAtomicFSet)fSet).getIndex(), testString, matchResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,12 @@ class AtomicJointSet extends NonCapJointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return next;
|
||||
}
|
||||
|
|
@ -40,14 +40,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class BackReferenceSet extends CIBackReferenceSet {
|
||||
class TBackReferenceSet extends TCIBackReferenceSet {
|
||||
|
||||
public BackReferenceSet(int groupIndex, int consCounter) {
|
||||
public TBackReferenceSet(int groupIndex, int consCounter) {
|
||||
super(groupIndex, consCounter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound())
|
||||
return -1;
|
||||
|
@ -61,7 +61,7 @@ class BackReferenceSet extends CIBackReferenceSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
int strLength = matchResult.getLeftBound();
|
||||
|
||||
|
@ -86,7 +86,7 @@ class BackReferenceSet extends CIBackReferenceSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
|
||||
if (group == null)
|
||||
|
@ -109,12 +109,12 @@ class BackReferenceSet extends CIBackReferenceSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "back reference: " + this.groupIndex; //$NON-NLS-1$
|
||||
return "back reference: " + this.groupIndex;
|
||||
}
|
||||
}
|
|
@ -41,7 +41,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
* group is referenced via backreference.
|
||||
*/
|
||||
|
||||
class BackReferencedSingleSet extends SingleSet {
|
||||
class TBackReferencedSingleSet extends TSingleSet {
|
||||
|
||||
/*
|
||||
* This class is needed only for overwriting find() and findBack() methods
|
||||
|
@ -57,16 +57,16 @@ class BackReferencedSingleSet extends SingleSet {
|
|||
* performance, but ensure correctness of the match.
|
||||
*/
|
||||
|
||||
public BackReferencedSingleSet(AbstractSet child, FSet fSet) {
|
||||
public TBackReferencedSingleSet(TAbstractSet child, TFSet fSet) {
|
||||
super(child, fSet);
|
||||
}
|
||||
|
||||
public BackReferencedSingleSet(SingleSet node) {
|
||||
super(node.kid, ((FSet)node.fSet));
|
||||
public TBackReferencedSingleSet(TSingleSet node) {
|
||||
super(node.kid, ((TFSet)node.fSet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int res = 0;
|
||||
int lastIndex = matchResult.getRightBound();
|
||||
int startSearch = stringIndex;
|
||||
|
@ -88,7 +88,7 @@ class BackReferencedSingleSet extends SingleSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int stringIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int stringIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int res = 0;
|
||||
int startSearch = lastIndex;
|
||||
|
||||
|
@ -115,7 +115,7 @@ class BackReferencedSingleSet extends SingleSet {
|
|||
* - node who references to this node
|
||||
*/
|
||||
@Override
|
||||
public JointSet processBackRefReplacement() {
|
||||
public TJointSet processBackRefReplacement() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -42,13 +42,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class BehindFSet extends FSet {
|
||||
public BehindFSet(int groupIndex) {
|
||||
class TBehindFSet extends TFSet {
|
||||
public TBehindFSet(int groupIndex) {
|
||||
super(groupIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
int gr = getGroupIndex();
|
||||
int rightBound = matchResult.getConsumed(gr);
|
||||
|
@ -57,6 +57,6 @@ class BehindFSet extends FSet {
|
|||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "BehindFSet"; //$NON-NLS-1$
|
||||
return "BehindFSet";
|
||||
}
|
||||
}
|
|
@ -40,11 +40,11 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CIBackReferenceSet extends JointSet {
|
||||
class TCIBackReferenceSet extends TJointSet {
|
||||
protected int referencedGroup;
|
||||
protected int consCounter;
|
||||
|
||||
public CIBackReferenceSet(int groupIndex, int consCounter) {
|
||||
public TCIBackReferenceSet(int groupIndex, int consCounter) {
|
||||
this.referencedGroup = groupIndex;
|
||||
this.consCounter = consCounter;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class CIBackReferenceSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound())
|
||||
|
@ -71,16 +71,16 @@ class CIBackReferenceSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
protected String getString(MatchResultImpl matchResult) {
|
||||
protected String getString(TMatchResultImpl matchResult) {
|
||||
String res = matchResult.getGroupNoCheck(referencedGroup);
|
||||
return res;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class CIBackReferenceSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
matchResult.setConsumed(consCounter, -1);
|
|
@ -40,13 +40,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CICharSet extends LeafSet {
|
||||
class TCICharSet extends TLeafSet {
|
||||
|
||||
private char ch;
|
||||
|
||||
private char supplement;
|
||||
|
||||
public CICharSet(char ch) {
|
||||
public TCICharSet(char ch) {
|
||||
this.ch = ch;
|
||||
this.supplement = TPattern.getSupplement(ch);
|
||||
}
|
|
@ -39,12 +39,12 @@ package org.teavm.classlib.java.util.regex;
|
|||
* CANON_EQ flag of Pattern class
|
||||
* is specified.
|
||||
*/
|
||||
class CIDecomposedCharSet extends DecomposedCharSet{
|
||||
class TCIDecomposedCharSet extends TDecomposedCharSet {
|
||||
|
||||
/*
|
||||
* Just only a stub
|
||||
*/
|
||||
public CIDecomposedCharSet(int [] decomp, int decomposedCharLength) {
|
||||
public TCIDecomposedCharSet(int [] decomp, int decomposedCharLength) {
|
||||
super(decomp, decomposedCharLength);
|
||||
}
|
||||
}
|
|
@ -40,10 +40,10 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CISequenceSet extends LeafSet {
|
||||
class TCISequenceSet extends TLeafSet {
|
||||
private String string = null;
|
||||
|
||||
CISequenceSet(StringBuffer substring) {
|
||||
TCISequenceSet(StringBuffer substring) {
|
||||
this.string = substring.toString();
|
||||
this.charCount = substring.length();
|
||||
}
|
|
@ -43,7 +43,7 @@ import java.util.BitSet;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CharClass extends AbstractCharClass {
|
||||
class TCharClass extends TAbstractCharClass {
|
||||
// Flag indicates if we add supplement upper/lower case
|
||||
boolean ci = false;
|
||||
|
||||
|
@ -60,17 +60,17 @@ class CharClass extends AbstractCharClass {
|
|||
|
||||
BitSet bits = new BitSet();
|
||||
|
||||
AbstractCharClass nonBitSet = null;
|
||||
TAbstractCharClass nonBitSet = null;
|
||||
|
||||
public CharClass() {
|
||||
public TCharClass() {
|
||||
}
|
||||
|
||||
public CharClass(boolean ci, boolean uci) {
|
||||
public TCharClass(boolean ci, boolean uci) {
|
||||
this.ci = ci;
|
||||
this.uci = uci;
|
||||
}
|
||||
|
||||
public CharClass(boolean negative, boolean ci, boolean uci) {
|
||||
public TCharClass(boolean negative, boolean ci, boolean uci) {
|
||||
this(ci, uci);
|
||||
setNegative(negative);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class CharClass extends AbstractCharClass {
|
|||
* We can use this method safely even if nonBitSet != null due to specific
|
||||
* of range constructions in regular expressions.
|
||||
*/
|
||||
public CharClass add(int ch) {
|
||||
public TCharClass add(int ch) {
|
||||
if (ci) {
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
|
||||
if (!inverted) {
|
||||
|
@ -94,7 +94,7 @@ class CharClass extends AbstractCharClass {
|
|||
}
|
||||
}
|
||||
|
||||
if (Lexer.isHighSurrogate(ch) || Lexer.isLowSurrogate(ch)) {
|
||||
if (TLexer.isHighSurrogate(ch) || TLexer.isLowSurrogate(ch)) {
|
||||
if (!invertedSurrogates) {
|
||||
lowHighSurrogates.set(ch - Character.MIN_SURROGATE);
|
||||
} else {
|
||||
|
@ -120,7 +120,7 @@ class CharClass extends AbstractCharClass {
|
|||
* "[^abc\\d]" (this pattern doesn't match "1") while union is used for
|
||||
* constructions like "[^abc[\\d]]" (this pattern matches "1").
|
||||
*/
|
||||
public CharClass add(final AbstractCharClass cc) {
|
||||
public TCharClass add(final TAbstractCharClass cc) {
|
||||
|
||||
if (!mayContainSupplCodepoints && cc.mayContainSupplCodepoints) {
|
||||
mayContainSupplCodepoints = true;
|
||||
|
@ -182,7 +182,7 @@ class CharClass extends AbstractCharClass {
|
|||
if (nonBitSet == null) {
|
||||
|
||||
if (curAlt && !inverted && bits.isEmpty()) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return cc.contains(ch);
|
||||
|
@ -196,7 +196,7 @@ class CharClass extends AbstractCharClass {
|
|||
* [^[abc]fgb] by using the formula a ^ b == !a ^ !b.
|
||||
*/
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !((curAlt ^ bits.get(ch)) || ((curAlt ^ inverted) ^ cc.contains(ch)));
|
||||
|
@ -204,7 +204,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return (curAlt ^ bits.get(ch)) || ((curAlt ^ inverted) ^ cc.contains(ch));
|
||||
|
@ -216,10 +216,10 @@ class CharClass extends AbstractCharClass {
|
|||
|
||||
hideBits = true;
|
||||
} else {
|
||||
final AbstractCharClass nb = nonBitSet;
|
||||
final TAbstractCharClass nb = nonBitSet;
|
||||
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !(curAlt ^ (nb.contains(ch) || cc.contains(ch)));
|
||||
|
@ -227,7 +227,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return curAlt ^ (nb.contains(ch) || cc.contains(ch));
|
||||
|
@ -241,7 +241,7 @@ class CharClass extends AbstractCharClass {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CharClass add(int st, int end) {
|
||||
public TCharClass add(int st, int end) {
|
||||
if (st > end)
|
||||
throw new IllegalArgumentException();
|
||||
if (!ci
|
||||
|
@ -263,7 +263,7 @@ class CharClass extends AbstractCharClass {
|
|||
}
|
||||
|
||||
// OR operation
|
||||
public void union(final AbstractCharClass clazz) {
|
||||
public void union(final TAbstractCharClass clazz) {
|
||||
if (!mayContainSupplCodepoints && clazz.mayContainSupplCodepoints) {
|
||||
mayContainSupplCodepoints = true;
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ class CharClass extends AbstractCharClass {
|
|||
|
||||
if (!inverted && bits.isEmpty()) {
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !clazz.contains(ch);
|
||||
|
@ -336,7 +336,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return clazz.contains(ch);
|
||||
|
@ -347,7 +347,7 @@ class CharClass extends AbstractCharClass {
|
|||
} else {
|
||||
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !(clazz.contains(ch) || (curAlt ^ bits.get(ch)));
|
||||
|
@ -355,7 +355,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return clazz.contains(ch) || (curAlt ^ bits.get(ch));
|
||||
|
@ -366,10 +366,10 @@ class CharClass extends AbstractCharClass {
|
|||
}
|
||||
hideBits = true;
|
||||
} else {
|
||||
final AbstractCharClass nb = nonBitSet;
|
||||
final TAbstractCharClass nb = nonBitSet;
|
||||
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !((curAlt ^ nb.contains(ch)) || clazz.contains(ch));
|
||||
|
@ -377,7 +377,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return (curAlt ^ nb.contains(ch)) || clazz.contains(ch);
|
||||
|
@ -390,7 +390,7 @@ class CharClass extends AbstractCharClass {
|
|||
}
|
||||
|
||||
// AND operation
|
||||
public void intersection(final AbstractCharClass clazz) {
|
||||
public void intersection(final TAbstractCharClass clazz) {
|
||||
if (!mayContainSupplCodepoints && clazz.mayContainSupplCodepoints) {
|
||||
mayContainSupplCodepoints = true;
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ class CharClass extends AbstractCharClass {
|
|||
|
||||
if (!inverted && bits.isEmpty()) {
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !clazz.contains(ch);
|
||||
|
@ -462,7 +462,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return clazz.contains(ch);
|
||||
|
@ -473,7 +473,7 @@ class CharClass extends AbstractCharClass {
|
|||
} else {
|
||||
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !(clazz.contains(ch) && (curAlt ^ bits.get(ch)));
|
||||
|
@ -481,7 +481,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return clazz.contains(ch) && (curAlt ^ bits.get(ch));
|
||||
|
@ -492,10 +492,10 @@ class CharClass extends AbstractCharClass {
|
|||
}
|
||||
hideBits = true;
|
||||
} else {
|
||||
final AbstractCharClass nb = nonBitSet;
|
||||
final TAbstractCharClass nb = nonBitSet;
|
||||
|
||||
if (curAlt) {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return !((curAlt ^ nb.contains(ch)) && clazz.contains(ch));
|
||||
|
@ -503,7 +503,7 @@ class CharClass extends AbstractCharClass {
|
|||
};
|
||||
// alt = true
|
||||
} else {
|
||||
nonBitSet = new AbstractCharClass() {
|
||||
nonBitSet = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return (curAlt ^ nb.contains(ch)) && clazz.contains(ch);
|
||||
|
@ -550,12 +550,12 @@ class CharClass extends AbstractCharClass {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractCharClass getInstance() {
|
||||
public TAbstractCharClass getInstance() {
|
||||
|
||||
if (nonBitSet == null) {
|
||||
final BitSet bs = getBits();
|
||||
|
||||
AbstractCharClass res = new AbstractCharClass() {
|
||||
TAbstractCharClass res = new TAbstractCharClass() {
|
||||
@Override
|
||||
public boolean contains(int ch) {
|
||||
return this.alt ^ bs.get(ch);
|
|
@ -40,11 +40,11 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CharSet extends LeafSet {
|
||||
class TCharSet extends TLeafSet {
|
||||
|
||||
private char ch = 0;
|
||||
|
||||
public CharSet(char ch) {
|
||||
public TCharSet(char ch) {
|
||||
this.ch = ch;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class CharSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
@ -81,7 +81,7 @@ class CharSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
|
||||
|
@ -114,14 +114,14 @@ class CharSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof CharSet) {
|
||||
return ((CharSet)set).getChar() == ch;
|
||||
} else if (set instanceof RangeSet) {
|
||||
return ((RangeSet)set).accepts(0, Character.toString(ch)) > 0;
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
return ((SupplRangeSet)set).contains(ch);
|
||||
} else if (set instanceof SupplCharSet) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return ((TCharSet)set).getChar() == ch;
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return ((TRangeSet)set).accepts(0, Character.toString(ch)) > 0;
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return ((TSupplRangeSet)set).contains(ch);
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -40,9 +40,9 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CompositeGroupQuantifierSet extends GroupQuantifierSet {
|
||||
class TCompositeGroupQuantifierSet extends TGroupQuantifierSet {
|
||||
|
||||
protected Quantifier quantifier = null;
|
||||
protected TQuantifier quantifier = null;
|
||||
|
||||
int setCounter;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class CompositeGroupQuantifierSet extends GroupQuantifierSet {
|
|||
* @param next
|
||||
* - next set after the quantifier
|
||||
*/
|
||||
public CompositeGroupQuantifierSet(Quantifier quant, AbstractSet innerSet, AbstractSet next, int type,
|
||||
public TCompositeGroupQuantifierSet(TQuantifier quant, TAbstractSet innerSet, TAbstractSet next, int type,
|
||||
int setCounter) {
|
||||
super(innerSet, next, type);
|
||||
this.quantifier = quant;
|
||||
|
@ -64,7 +64,7 @@ class CompositeGroupQuantifierSet extends GroupQuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int enterCounter = matchResult.getEnterCounter(setCounter);
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
|
@ -102,7 +102,7 @@ class CompositeGroupQuantifierSet extends GroupQuantifierSet {
|
|||
return quantifier.toString();
|
||||
}
|
||||
|
||||
void setQuantifier(Quantifier quant) {
|
||||
void setQuantifier(TQuantifier quant) {
|
||||
this.quantifier = quant;
|
||||
}
|
||||
}
|
|
@ -40,17 +40,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class CompositeQuantifierSet extends LeafQuantifierSet {
|
||||
class TCompositeQuantifierSet extends TLeafQuantifierSet {
|
||||
|
||||
protected Quantifier quantifier = null;
|
||||
protected TQuantifier quantifier = null;
|
||||
|
||||
public CompositeQuantifierSet(Quantifier quant, LeafSet innerSet, AbstractSet next, int type) {
|
||||
public TCompositeQuantifierSet(TQuantifier quant, TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
this.quantifier = quant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int min = quantifier.min();
|
||||
int max = quantifier.max();
|
||||
int i = 0;
|
||||
|
@ -98,7 +98,7 @@ class CompositeQuantifierSet extends LeafQuantifierSet {
|
|||
return quantifier.toString();
|
||||
}
|
||||
|
||||
void setQuantifier(Quantifier quant) {
|
||||
void setQuantifier(TQuantifier quant) {
|
||||
this.quantifier = quant;
|
||||
}
|
||||
}
|
|
@ -103,21 +103,21 @@ package org.teavm.classlib.java.util.regex;
|
|||
* consisting of all others characters from the parent range. This class
|
||||
* represents the parent range split in such a manner.
|
||||
*/
|
||||
class CompositeRangeSet extends JointSet {
|
||||
class TCompositeRangeSet extends TJointSet {
|
||||
|
||||
// range without surrogates
|
||||
AbstractSet withoutSurrogates;
|
||||
TAbstractSet withoutSurrogates;
|
||||
|
||||
// range containing surrogates only
|
||||
AbstractSet withSurrogates;
|
||||
TAbstractSet withSurrogates;
|
||||
|
||||
public CompositeRangeSet(AbstractSet withoutSurrogates, AbstractSet withSurrogates, AbstractSet next) {
|
||||
public TCompositeRangeSet(TAbstractSet withoutSurrogates, TAbstractSet withSurrogates, TAbstractSet next) {
|
||||
this.withoutSurrogates = withoutSurrogates;
|
||||
this.withSurrogates = withSurrogates;
|
||||
setNext(next);
|
||||
}
|
||||
|
||||
public CompositeRangeSet(AbstractSet withoutSurrogates, AbstractSet withSurrogates) {
|
||||
public TCompositeRangeSet(TAbstractSet withoutSurrogates, TAbstractSet withSurrogates) {
|
||||
this.withoutSurrogates = withoutSurrogates;
|
||||
this.withSurrogates = withSurrogates;
|
||||
}
|
||||
|
@ -126,12 +126,12 @@ class CompositeRangeSet extends JointSet {
|
|||
* Returns the next.
|
||||
*/
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = withoutSurrogates.matches(stringIndex, testString, matchResult);
|
||||
|
||||
if (shift < 0) {
|
||||
|
@ -151,17 +151,17 @@ class CompositeRangeSet extends JointSet {
|
|||
* The next to set.
|
||||
*/
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
withSurrogates.setNext(next);
|
||||
withoutSurrogates.setNext(next);
|
||||
}
|
||||
|
||||
public AbstractSet getSurrogates() {
|
||||
public TAbstractSet getSurrogates() {
|
||||
return withSurrogates;
|
||||
}
|
||||
|
||||
public AbstractSet getWithoutSurrogates() {
|
||||
public TAbstractSet getWithoutSurrogates() {
|
||||
return withoutSurrogates;
|
||||
}
|
||||
|
||||
|
@ -171,12 +171,12 @@ class CompositeRangeSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
* Represents canonical decomposition of Unicode character. Is used when
|
||||
* CANON_EQ flag of Pattern class is specified.
|
||||
*/
|
||||
class DecomposedCharSet extends JointSet {
|
||||
class TDecomposedCharSet extends TJointSet {
|
||||
|
||||
/**
|
||||
* Contains information about number of chars that were read for a codepoint
|
||||
|
@ -45,7 +45,7 @@ class DecomposedCharSet extends JointSet {
|
|||
*/
|
||||
private int decomposedCharLength;
|
||||
|
||||
public DecomposedCharSet(int[] decomposedChar, int decomposedCharLength) {
|
||||
public TDecomposedCharSet(int[] decomposedChar, int decomposedCharLength) {
|
||||
this.decomposedChar = decomposedChar;
|
||||
this.decomposedCharLength = decomposedCharLength;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class DecomposedCharSet extends JointSet {
|
|||
* Returns the next.
|
||||
*/
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
|
@ -65,19 +65,19 @@ class DecomposedCharSet extends JointSet {
|
|||
* The next to set.
|
||||
*/
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
/*
|
||||
* All decompositions have length that is less or equal
|
||||
* Lexer.MAX_DECOMPOSITION_LENGTH
|
||||
*/
|
||||
int[] decCurCodePoint;
|
||||
int[] decCodePoint = new int[Lexer.MAX_DECOMPOSITION_LENGTH];
|
||||
int[] decCodePoint = new int[TLexer.MAX_DECOMPOSITION_LENGTH];
|
||||
int readCodePoints = 0;
|
||||
int rightBound = matchResult.getRightBound();
|
||||
int curChar;
|
||||
|
@ -93,7 +93,7 @@ class DecomposedCharSet extends JointSet {
|
|||
*/
|
||||
curChar = codePointAt(strIndex, testString, rightBound);
|
||||
strIndex += readCharsForCodePoint;
|
||||
decCurCodePoint = Lexer.getDecomposition(curChar);
|
||||
decCurCodePoint = TLexer.getDecomposition(curChar);
|
||||
if (decCurCodePoint == null) {
|
||||
decCodePoint[readCodePoints++] = curChar;
|
||||
} else {
|
||||
|
@ -109,9 +109,9 @@ class DecomposedCharSet extends JointSet {
|
|||
* Read testString until we met a decomposed char boundary and
|
||||
* decompose obtained portion of testString
|
||||
*/
|
||||
while ((readCodePoints < Lexer.MAX_DECOMPOSITION_LENGTH) && !Lexer.isDecomposedCharBoundary(curChar)) {
|
||||
while ((readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH) && !TLexer.isDecomposedCharBoundary(curChar)) {
|
||||
|
||||
if (Lexer.hasDecompositionNonNullCanClass(curChar)) {
|
||||
if (TLexer.hasDecompositionNonNullCanClass(curChar)) {
|
||||
|
||||
/*
|
||||
* A few codepoints have decompositions and non null
|
||||
|
@ -119,7 +119,7 @@ class DecomposedCharSet extends JointSet {
|
|||
* consideration, but general rule is: if canonical class !=
|
||||
* 0 then no decomposition
|
||||
*/
|
||||
decCurCodePoint = Lexer.getDecomposition(curChar);
|
||||
decCurCodePoint = TLexer.getDecomposition(curChar);
|
||||
|
||||
/*
|
||||
* Length of such decomposition is 1 or 2. See UnicodeData
|
||||
|
@ -156,8 +156,8 @@ class DecomposedCharSet extends JointSet {
|
|||
break;
|
||||
|
||||
case 3:
|
||||
int i1 = Lexer.getCanonicalClass(decCodePoint[1]);
|
||||
int i2 = Lexer.getCanonicalClass(decCodePoint[2]);
|
||||
int i1 = TLexer.getCanonicalClass(decCodePoint[1]);
|
||||
int i2 = TLexer.getCanonicalClass(decCodePoint[2]);
|
||||
|
||||
if ((i2 != 0) && (i1 > i2)) {
|
||||
i1 = decCodePoint[1];
|
||||
|
@ -167,7 +167,7 @@ class DecomposedCharSet extends JointSet {
|
|||
break;
|
||||
|
||||
default:
|
||||
decCodePoint = Lexer.getCanonicalOrder(decCodePoint, readCodePoints);
|
||||
decCodePoint = TLexer.getCanonicalOrder(decCodePoint, readCodePoints);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -248,13 +248,13 @@ class DecomposedCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
return (set instanceof DecomposedCharSet) ? ((DecomposedCharSet)set).getDecomposedChar().equals(
|
||||
public boolean first(TAbstractSet set) {
|
||||
return (set instanceof TDecomposedCharSet) ? ((TDecomposedCharSet)set).getDecomposedChar().equals(
|
||||
getDecomposedChar()) : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -26,14 +26,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class DotAllQuantifierSet extends QuantifierSet {
|
||||
class TDotAllQuantifierSet extends TQuantifierSet {
|
||||
|
||||
public DotAllQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
public TDotAllQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
|
@ -44,7 +44,7 @@ class DotAllQuantifierSet extends QuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
if (next.findBack(stringIndex, strLength, testString, matchResult) >= 0) {
|
||||
return stringIndex;
|
|
@ -25,10 +25,10 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class DotAllSet extends JointSet {
|
||||
class TDotAllSet extends TJointSet {
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
if (stringIndex + 1 > strLength) {
|
||||
|
@ -54,22 +54,22 @@ class DotAllSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return AbstractSet.TYPE_DOTSET;
|
||||
return TAbstractSet.TYPE_DOTSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -26,17 +26,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class DotQuantifierSet extends QuantifierSet {
|
||||
class TDotQuantifierSet extends TQuantifierSet {
|
||||
|
||||
AbstractLineTerminator lt;
|
||||
TAbstractLineTerminator lt;
|
||||
|
||||
public DotQuantifierSet(AbstractSet innerSet, AbstractSet next, int type, AbstractLineTerminator lt) {
|
||||
public TDotQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type, TAbstractLineTerminator lt) {
|
||||
super(innerSet, next, type);
|
||||
this.lt = lt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
|
@ -54,7 +54,7 @@ class DotQuantifierSet extends QuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
// String testStr = testString.toString();
|
||||
int strLength = matchResult.getRightBound();
|
||||
// 1. skip line terminators ???
|
|
@ -25,17 +25,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
final class DotSet extends JointSet {
|
||||
final class TDotSet extends TJointSet {
|
||||
|
||||
AbstractLineTerminator lt;
|
||||
TAbstractLineTerminator lt;
|
||||
|
||||
public DotSet(AbstractLineTerminator lt) {
|
||||
public TDotSet(TAbstractLineTerminator lt) {
|
||||
super();
|
||||
this.lt = lt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
if (stringIndex + 1 > strLength) {
|
||||
|
@ -62,22 +62,22 @@ final class DotSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return AbstractSet.TYPE_DOTSET;
|
||||
return TAbstractSet.TYPE_DOTSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -25,10 +25,10 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class EOISet extends AbstractSet {
|
||||
class TEOISet extends TAbstractSet {
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int rightBound = matchResult.hasTransparentBounds() ? testString.length() : matchResult.getRightBound();
|
||||
if (stringIndex < rightBound)
|
||||
return -1;
|
||||
|
@ -43,7 +43,7 @@ class EOISet extends AbstractSet {
|
|||
* Returns false, enough for quantifiers
|
||||
*/
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -25,15 +25,15 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
final class EOLSet extends AbstractSet {
|
||||
final class TEOLSet extends TAbstractSet {
|
||||
private int consCounter;
|
||||
|
||||
public EOLSet(int counter) {
|
||||
public TEOLSet(int counter) {
|
||||
this.consCounter = counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int rightBound = matchResult.hasAnchoringBounds() ? matchResult.getRightBound() : testString.length();
|
||||
|
||||
if (strIndex >= rightBound) {
|
||||
|
@ -59,7 +59,7 @@ final class EOLSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
matchResult.setConsumed(consCounter, -1);
|
|
@ -25,8 +25,8 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class EmptySet extends LeafSet {
|
||||
public EmptySet(AbstractSet next) {
|
||||
class TEmptySet extends TLeafSet {
|
||||
public TEmptySet(TAbstractSet next) {
|
||||
super(next);
|
||||
charCount = 0;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class EmptySet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
int startStr = matchResult.getLeftBound();
|
||||
|
||||
|
@ -69,7 +69,7 @@ class EmptySet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int stringIndex, int startSearch, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int stringIndex, int startSearch, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
int startStr = matchResult.getLeftBound();
|
||||
|
||||
|
@ -106,7 +106,7 @@ class EmptySet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class FSet extends AbstractSet {
|
||||
class TFSet extends TAbstractSet {
|
||||
|
||||
static PossessiveFSet posFSet = new PossessiveFSet();
|
||||
|
||||
|
@ -33,12 +33,12 @@ class FSet extends AbstractSet {
|
|||
|
||||
private int groupIndex;
|
||||
|
||||
public FSet(int groupIndex) {
|
||||
public TFSet(int groupIndex) {
|
||||
this.groupIndex = groupIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int end = matchResult.getEnd(groupIndex);
|
||||
matchResult.setEnd(groupIndex, stringIndex);
|
||||
int shift = next.matches(stringIndex, testString, matchResult);
|
||||
|
@ -61,7 +61,7 @@ class FSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,10 @@ class FSet extends AbstractSet {
|
|||
* kickbacks(required for atomic groups, for instance)
|
||||
*
|
||||
*/
|
||||
static class PossessiveFSet extends AbstractSet {
|
||||
static class PossessiveFSet extends TAbstractSet {
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
return stringIndex;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class FSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -25,14 +25,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class FinalSet extends FSet {
|
||||
class TFinalSet extends TFSet {
|
||||
|
||||
public FinalSet() {
|
||||
public TFinalSet() {
|
||||
super(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (matchResult.mode() == TMatcher.MODE_FIND || stringIndex == matchResult.getRightBound()) {
|
||||
matchResult.setValid();
|
||||
matchResult.setEnd(0, stringIndex);
|
|
@ -26,19 +26,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class GroupQuantifierSet extends QuantifierSet {
|
||||
class TGroupQuantifierSet extends TQuantifierSet {
|
||||
|
||||
public GroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
public TGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
return next.matches(stringIndex, testString, matchResult);// return
|
||||
// -1;
|
||||
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
int nextIndex = innerSet.matches(stringIndex, testString, matchResult);
|
||||
|
||||
if (nextIndex < 0) {
|
||||
|
@ -50,6 +48,6 @@ class GroupQuantifierSet extends QuantifierSet {
|
|||
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "<GroupQuant>"; //$NON-NLS-1$
|
||||
return "<GroupQuant>";
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
* Represents canonical decomposition of Hangul syllable. Is used when CANON_EQ
|
||||
* flag of Pattern class is specified.
|
||||
*/
|
||||
class HangulDecomposedCharSet extends JointSet {
|
||||
class THangulDecomposedCharSet extends TJointSet {
|
||||
|
||||
/**
|
||||
* Decomposed Hangul syllable.
|
||||
|
@ -39,7 +39,7 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
*/
|
||||
private int decomposedCharLength;
|
||||
|
||||
public HangulDecomposedCharSet(char[] decomposedChar, int decomposedCharLength) {
|
||||
public THangulDecomposedCharSet(char[] decomposedChar, int decomposedCharLength) {
|
||||
this.decomposedChar = decomposedChar;
|
||||
this.decomposedCharLength = decomposedCharLength;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
* Returns the next.
|
||||
*/
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
* The next to set.
|
||||
*/
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
/*
|
||||
* All decompositions for Hangul syllables have length that is less or
|
||||
|
@ -86,7 +86,7 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
*/
|
||||
int rightBound = matchResult.getRightBound();
|
||||
int SyllIndex = 0;
|
||||
int[] decompSyllable = new int[Lexer.MAX_HANGUL_DECOMPOSITION_LENGTH];
|
||||
int[] decompSyllable = new int[TLexer.MAX_HANGUL_DECOMPOSITION_LENGTH];
|
||||
int[] decompCurSymb;
|
||||
char curSymb;
|
||||
|
||||
|
@ -103,7 +103,7 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
return -1;
|
||||
}
|
||||
curSymb = testString.charAt(strIndex++);
|
||||
decompCurSymb = Lexer.getHangulDecomposition(curSymb);
|
||||
decompCurSymb = TLexer.getHangulDecomposition(curSymb);
|
||||
|
||||
if (decompCurSymb == null) {
|
||||
|
||||
|
@ -112,9 +112,9 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
* testString.
|
||||
*/
|
||||
decompSyllable[SyllIndex++] = curSymb;
|
||||
LIndex = curSymb - Lexer.LBase;
|
||||
LIndex = curSymb - TLexer.LBase;
|
||||
|
||||
if ((LIndex < 0) || (LIndex >= Lexer.LCount)) {
|
||||
if ((LIndex < 0) || (LIndex >= TLexer.LCount)) {
|
||||
|
||||
/*
|
||||
* Ordinary letter, that doesn't match this
|
||||
|
@ -124,10 +124,10 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
|
||||
if (strIndex < rightBound) {
|
||||
curSymb = testString.charAt(strIndex);
|
||||
VIndex = curSymb - Lexer.VBase;
|
||||
VIndex = curSymb - TLexer.VBase;
|
||||
}
|
||||
|
||||
if ((VIndex < 0) || (VIndex >= Lexer.VCount)) {
|
||||
if ((VIndex < 0) || (VIndex >= TLexer.VCount)) {
|
||||
|
||||
/*
|
||||
* Single L jamo doesn't compose Hangul syllable, so doesn't
|
||||
|
@ -140,10 +140,10 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
|
||||
if (strIndex < rightBound) {
|
||||
curSymb = testString.charAt(strIndex);
|
||||
TIndex = curSymb - Lexer.TBase;
|
||||
TIndex = curSymb - TLexer.TBase;
|
||||
}
|
||||
|
||||
if ((TIndex < 0) || (TIndex >= Lexer.TCount)) {
|
||||
if ((TIndex < 0) || (TIndex >= TLexer.TCount)) {
|
||||
|
||||
/*
|
||||
* We deal with LV syllable at testString, so compare it to this
|
||||
|
@ -182,13 +182,13 @@ class HangulDecomposedCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
return (set instanceof HangulDecomposedCharSet) ? ((HangulDecomposedCharSet)set).getDecomposedChar().equals(
|
||||
public boolean first(TAbstractSet set) {
|
||||
return (set instanceof THangulDecomposedCharSet) ? ((THangulDecomposedCharSet)set).getDecomposedChar().equals(
|
||||
getDecomposedChar()) : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* This class represents high surrogate character.
|
||||
*/
|
||||
class HighSurrogateCharSet extends JointSet {
|
||||
class THighSurrogateCharSet extends TJointSet {
|
||||
|
||||
/*
|
||||
* Note that we can use high and low surrogate characters that don't combine
|
||||
|
@ -95,7 +95,7 @@ class HighSurrogateCharSet extends JointSet {
|
|||
|
||||
private char high;
|
||||
|
||||
public HighSurrogateCharSet(char high) {
|
||||
public THighSurrogateCharSet(char high) {
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class HighSurrogateCharSet extends JointSet {
|
|||
* Returns the next.
|
||||
*/
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
|
@ -114,12 +114,12 @@ class HighSurrogateCharSet extends JointSet {
|
|||
* The next to set.
|
||||
*/
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
if (stringIndex + 1 > strLength) {
|
||||
|
@ -149,7 +149,7 @@ class HighSurrogateCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
@ -185,7 +185,7 @@ class HighSurrogateCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
@ -231,26 +231,26 @@ class HighSurrogateCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof CharSet) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof RangeSet) {
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return false;
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return false;
|
||||
} else if (set instanceof SupplCharSet) {
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof LowSurrogateCharSet) {
|
||||
} else if (set instanceof TLowSurrogateCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof HighSurrogateCharSet) {
|
||||
return ((HighSurrogateCharSet)set).high == this.high;
|
||||
} else if (set instanceof THighSurrogateCharSet) {
|
||||
return ((THighSurrogateCharSet)set).high == this.high;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -20,14 +20,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* Hashtable implementation for int arrays.
|
||||
*/
|
||||
class IntArrHash {
|
||||
class TIntArrHash {
|
||||
final int[] table;
|
||||
|
||||
final Object[] values;
|
||||
|
||||
final int mask;
|
||||
|
||||
public IntArrHash(int size) {
|
||||
public TIntArrHash(int size) {
|
||||
int tmpMask = 0;
|
||||
while (size >= tmpMask) {
|
||||
tmpMask = (tmpMask << 1) | 1;
|
|
@ -20,7 +20,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* Hashtable implementation for int values.
|
||||
*/
|
||||
class IntHash {
|
||||
class TIntHash {
|
||||
int[] table;
|
||||
|
||||
int[] values;
|
||||
|
@ -29,7 +29,7 @@ class IntHash {
|
|||
|
||||
int size; // maximum shift
|
||||
|
||||
public IntHash(int size) {
|
||||
public TIntHash(int size) {
|
||||
while (size >= mask) {
|
||||
mask = (mask << 1) | 1;
|
||||
}
|
|
@ -28,18 +28,18 @@ import java.util.Iterator;
|
|||
* think about "group" in this model as JointSet opening group and corresponding
|
||||
* FSet closing group.
|
||||
*/
|
||||
class JointSet extends AbstractSet {
|
||||
class TJointSet extends TAbstractSet {
|
||||
|
||||
protected ArrayList<AbstractSet> children;
|
||||
protected ArrayList<TAbstractSet> children;
|
||||
|
||||
protected AbstractSet fSet;
|
||||
protected TAbstractSet fSet;
|
||||
|
||||
protected int groupIndex;
|
||||
|
||||
protected JointSet() {
|
||||
protected TJointSet() {
|
||||
}
|
||||
|
||||
public JointSet(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
public TJointSet(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
this.children = children;
|
||||
this.fSet = fSet;
|
||||
this.groupIndex = fSet.getGroupIndex();
|
||||
|
@ -49,7 +49,7 @@ class JointSet extends AbstractSet {
|
|||
* Returns stringIndex+shift, the next position to match
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (children == null) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class JointSet extends AbstractSet {
|
|||
matchResult.setStart(groupIndex, stringIndex);
|
||||
int size = children.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
int shift = e.matches(stringIndex, testString, matchResult);
|
||||
if (shift >= 0) {
|
||||
return shift;
|
||||
|
@ -68,12 +68,12 @@ class JointSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
fSet.setNext(next);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return fSet.getNext();
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,9 @@ class JointSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (children != null) {
|
||||
for (Iterator<AbstractSet> i = children.iterator(); i.hasNext();) {
|
||||
for (Iterator<TAbstractSet> i = children.iterator(); i.hasNext();) {
|
||||
if ((i.next()).first(set)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class JointSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return !(matchResult.getEnd(groupIndex) >= 0 && matchResult.getStart(groupIndex) == matchResult
|
||||
.getEnd(groupIndex));
|
||||
}
|
||||
|
@ -121,8 +121,8 @@ class JointSet extends AbstractSet {
|
|||
int childrenSize = children.size();
|
||||
|
||||
for (int i = 0; i < childrenSize; i++) {
|
||||
AbstractSet child = children.get(i);
|
||||
JointSet set = child.processBackRefReplacement();
|
||||
TAbstractSet child = children.get(i);
|
||||
TJointSet set = child.processBackRefReplacement();
|
||||
|
||||
if (set != null) {
|
||||
child.isSecondPassVisited = true;
|
|
@ -23,17 +23,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class LeafQuantifierSet extends QuantifierSet {
|
||||
class TLeafQuantifierSet extends TQuantifierSet {
|
||||
|
||||
protected LeafSet leaf;
|
||||
protected TLeafSet leaf;
|
||||
|
||||
public LeafQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
public TLeafQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
this.leaf = innerSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int i = 0;
|
||||
int shift = 0;
|
||||
|
||||
|
@ -66,10 +66,10 @@ class LeafQuantifierSet extends QuantifierSet {
|
|||
* The innerSet to set.
|
||||
*/
|
||||
@Override
|
||||
public void setInnerSet(AbstractSet innerSet) {
|
||||
if (!(innerSet instanceof LeafSet))
|
||||
public void setInnerSet(TAbstractSet innerSet) {
|
||||
if (!(innerSet instanceof TLeafSet))
|
||||
throw new RuntimeException("");
|
||||
super.setInnerSet(innerSet);
|
||||
this.leaf = (LeafSet)innerSet;
|
||||
this.leaf = (TLeafSet)innerSet;
|
||||
}
|
||||
}
|
|
@ -26,16 +26,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class LeafSet extends AbstractSet {
|
||||
abstract class TLeafSet extends TAbstractSet {
|
||||
|
||||
protected int charCount = 1;
|
||||
|
||||
public LeafSet(AbstractSet next) {
|
||||
public TLeafSet(TAbstractSet next) {
|
||||
super(next);
|
||||
setType(AbstractSet.TYPE_LEAF);
|
||||
setType(TAbstractSet.TYPE_LEAF);
|
||||
}
|
||||
|
||||
public LeafSet() {
|
||||
public TLeafSet() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ abstract class LeafSet extends AbstractSet {
|
|||
* Return positive value if match succeeds, negative otherwise.
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (stringIndex + charCount() > matchResult.getRightBound()) {
|
||||
matchResult.hitEnd = true;
|
||||
|
@ -74,7 +74,7 @@ abstract class LeafSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ import java.util.MissingResourceException;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class Lexer {
|
||||
class TLexer {
|
||||
|
||||
public static final int CHAR_DOLLAR = 0xe0000000 | '$';
|
||||
|
||||
|
@ -145,10 +145,10 @@ class Lexer {
|
|||
static final int NCount = 588;
|
||||
|
||||
// table that contains canonical decomposition mappings
|
||||
private static IntArrHash decompTable = null;
|
||||
private static TIntArrHash decompTable = null;
|
||||
|
||||
// table that contains canonical combining classes
|
||||
private static IntHash canonClassesTable = null;
|
||||
private static TIntHash canonClassesTable = null;
|
||||
|
||||
private static int canonClassesTableSize;
|
||||
|
||||
|
@ -156,7 +156,7 @@ class Lexer {
|
|||
* Table that contains information about Unicode codepoints with single
|
||||
* codepoint decomposition
|
||||
*/
|
||||
private static IntHash singleDecompTable = null;
|
||||
private static TIntHash singleDecompTable = null;
|
||||
|
||||
private static int singleDecompTableSize;
|
||||
|
||||
|
@ -182,10 +182,10 @@ class Lexer {
|
|||
private int patternFullLength = 0;
|
||||
|
||||
// cur special token
|
||||
private SpecialToken curST = null;
|
||||
private TSpecialToken curST = null;
|
||||
|
||||
// next special token
|
||||
private SpecialToken lookAheadST = null;
|
||||
private TSpecialToken lookAheadST = null;
|
||||
|
||||
// cur char being processed
|
||||
private int index = 0;
|
||||
|
@ -202,12 +202,12 @@ class Lexer {
|
|||
// original string representing pattern
|
||||
private String orig = null;
|
||||
|
||||
public Lexer(String pattern, int flags) {
|
||||
public TLexer(String pattern, int flags) {
|
||||
orig = pattern;
|
||||
if ((flags & TPattern.LITERAL) > 0) {
|
||||
pattern = TPattern.quote(pattern);
|
||||
} else if ((flags & TPattern.CANON_EQ) > 0) {
|
||||
pattern = Lexer.normalize(pattern);
|
||||
pattern = TLexer.normalize(pattern);
|
||||
}
|
||||
|
||||
this.pattern = new char[pattern.length() + 2];
|
||||
|
@ -244,7 +244,7 @@ class Lexer {
|
|||
this.mode = mode;
|
||||
}
|
||||
|
||||
if (mode == Lexer.MODE_PATTERN) {
|
||||
if (mode == TLexer.MODE_PATTERN) {
|
||||
reread();
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ class Lexer {
|
|||
movePointer();
|
||||
}
|
||||
|
||||
public SpecialToken peekSpecial() {
|
||||
public TSpecialToken peekSpecial() {
|
||||
return curST;
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ class Lexer {
|
|||
}
|
||||
|
||||
public boolean isQuantifier() {
|
||||
return isSpecial() && curST.getType() == SpecialToken.TOK_QUANTIFIER;
|
||||
return isSpecial() && curST.getType() == TSpecialToken.TOK_QUANTIFIER;
|
||||
}
|
||||
|
||||
public boolean isNextSpecial() {
|
||||
|
@ -299,8 +299,8 @@ class Lexer {
|
|||
/**
|
||||
* Returns current special token and moves string index to the next one;
|
||||
*/
|
||||
public SpecialToken nextSpecial() {
|
||||
SpecialToken res = curST;
|
||||
public TSpecialToken nextSpecial() {
|
||||
TSpecialToken res = curST;
|
||||
movePointer();
|
||||
return res;
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ class Lexer {
|
|||
lookAhead = (index < pattern.length) ? nextCodePoint() : 0;
|
||||
lookAheadST = null;
|
||||
|
||||
if (mode == Lexer.MODE_ESCAPE) {
|
||||
if (mode == TLexer.MODE_ESCAPE) {
|
||||
if (lookAhead == '\\') {
|
||||
|
||||
// need not care about supplementary codepoints here
|
||||
|
@ -448,7 +448,7 @@ class Lexer {
|
|||
if (lookAhead == 'P')
|
||||
negative = true;
|
||||
try {
|
||||
lookAheadST = AbstractCharClass.getPredefinedClass(cs, negative);
|
||||
lookAheadST = TAbstractCharClass.getPredefinedClass(cs, negative);
|
||||
} catch (MissingResourceException mre) {
|
||||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
}
|
||||
|
@ -462,14 +462,14 @@ class Lexer {
|
|||
case 'W':
|
||||
case 'S':
|
||||
case 'D': {
|
||||
lookAheadST = CharClass.getPredefinedClass(new String(pattern, prevNW, 1), false);
|
||||
lookAheadST = TCharClass.getPredefinedClass(new String(pattern, prevNW, 1), false);
|
||||
lookAhead = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Q': {
|
||||
saved_mode = mode;
|
||||
mode = Lexer.MODE_ESCAPE;
|
||||
mode = TLexer.MODE_ESCAPE;
|
||||
reread = true;
|
||||
break;
|
||||
}
|
||||
|
@ -502,7 +502,7 @@ class Lexer {
|
|||
case '7':
|
||||
case '8':
|
||||
case '9': {
|
||||
if (mode == Lexer.MODE_PATTERN) {
|
||||
if (mode == TLexer.MODE_PATTERN) {
|
||||
lookAhead = 0x80000000 | lookAhead;
|
||||
}
|
||||
break;
|
||||
|
@ -578,7 +578,7 @@ class Lexer {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} else if (mode == Lexer.MODE_PATTERN) {
|
||||
} else if (mode == TLexer.MODE_PATTERN) {
|
||||
switch (lookAhead) {
|
||||
case '+':
|
||||
case '*':
|
||||
|
@ -586,17 +586,17 @@ class Lexer {
|
|||
char mod = (index < pattern.length) ? pattern[index] : '*';
|
||||
switch (mod) {
|
||||
case '+': {
|
||||
lookAhead = lookAhead | Lexer.QMOD_POSSESSIVE;
|
||||
lookAhead = lookAhead | TLexer.QMOD_POSSESSIVE;
|
||||
nextIndex();
|
||||
break;
|
||||
}
|
||||
case '?': {
|
||||
lookAhead = lookAhead | Lexer.QMOD_RELUCTANT;
|
||||
lookAhead = lookAhead | TLexer.QMOD_RELUCTANT;
|
||||
nextIndex();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
lookAhead = lookAhead | Lexer.QMOD_GREEDY;
|
||||
lookAhead = lookAhead | TLexer.QMOD_GREEDY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -688,11 +688,11 @@ class Lexer {
|
|||
break;
|
||||
case '[': {
|
||||
lookAhead = CHAR_LEFT_SQUARE_BRACKET;
|
||||
setMode(Lexer.MODE_RANGE);
|
||||
setMode(TLexer.MODE_RANGE);
|
||||
break;
|
||||
}
|
||||
case ']': {
|
||||
if (mode == Lexer.MODE_RANGE) {
|
||||
if (mode == TLexer.MODE_RANGE) {
|
||||
lookAhead = CHAR_RIGHT_SQUARE_BRACKET;
|
||||
}
|
||||
break;
|
||||
|
@ -709,7 +709,7 @@ class Lexer {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} else if (mode == Lexer.MODE_RANGE) {
|
||||
} else if (mode == TLexer.MODE_RANGE) {
|
||||
switch (lookAhead) {
|
||||
case '[':
|
||||
lookAhead = CHAR_LEFT_SQUARE_BRACKET;
|
||||
|
@ -765,7 +765,7 @@ class Lexer {
|
|||
/**
|
||||
* Process given character in assumption that it's quantifier.
|
||||
*/
|
||||
private Quantifier processQuantifier(int ch) {
|
||||
private TQuantifier processQuantifier(int ch) {
|
||||
StringBuilder sb = new StringBuilder(4);
|
||||
int min = -1;
|
||||
int max = Integer.MAX_VALUE;
|
||||
|
@ -803,18 +803,18 @@ class Lexer {
|
|||
|
||||
switch (mod) {
|
||||
case '+':
|
||||
lookAhead = Lexer.QUANT_COMP_P;
|
||||
lookAhead = TLexer.QUANT_COMP_P;
|
||||
nextIndex();
|
||||
break;
|
||||
case '?':
|
||||
lookAhead = Lexer.QUANT_COMP_R;
|
||||
lookAhead = TLexer.QUANT_COMP_R;
|
||||
nextIndex();
|
||||
break;
|
||||
default:
|
||||
lookAhead = Lexer.QUANT_COMP;
|
||||
lookAhead = TLexer.QUANT_COMP;
|
||||
break;
|
||||
}
|
||||
return new Quantifier(min, max);
|
||||
return new TQuantifier(min, max);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -85,19 +85,19 @@ package org.teavm.classlib.java.util.regex;
|
|||
/*
|
||||
* This class is a range that contains only surrogate characters.
|
||||
*/
|
||||
class LowHighSurrogateRangeSet extends JointSet {
|
||||
class TLowHighSurrogateRangeSet extends TJointSet {
|
||||
|
||||
protected AbstractCharClass surrChars;
|
||||
protected TAbstractCharClass surrChars;
|
||||
|
||||
protected boolean alt = false;
|
||||
|
||||
public LowHighSurrogateRangeSet(AbstractCharClass surrChars, AbstractSet next) {
|
||||
public TLowHighSurrogateRangeSet(TAbstractCharClass surrChars, TAbstractSet next) {
|
||||
this.surrChars = surrChars.getInstance();
|
||||
this.alt = surrChars.alt;
|
||||
setNext(next);
|
||||
}
|
||||
|
||||
public LowHighSurrogateRangeSet(AbstractCharClass surrChars) {
|
||||
public TLowHighSurrogateRangeSet(TAbstractCharClass surrChars) {
|
||||
this.surrChars = surrChars.getInstance();
|
||||
this.alt = surrChars.alt;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class LowHighSurrogateRangeSet extends JointSet {
|
|||
* Returns the next.
|
||||
*/
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ class LowHighSurrogateRangeSet extends JointSet {
|
|||
* The next to set.
|
||||
*/
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ class LowHighSurrogateRangeSet extends JointSet {
|
|||
* Returns stringIndex+shift, the next position to match
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int startStr = matchResult.getLeftBound();
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
|
@ -169,26 +169,26 @@ class LowHighSurrogateRangeSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof CharSet) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof RangeSet) {
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return false;
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return false;
|
||||
} else if (set instanceof SupplCharSet) {
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected AbstractCharClass getChars() {
|
||||
protected TAbstractCharClass getChars() {
|
||||
return surrChars;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -85,7 +85,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* This class represents low surrogate character.
|
||||
*/
|
||||
class LowSurrogateCharSet extends JointSet {
|
||||
class TLowSurrogateCharSet extends TJointSet {
|
||||
|
||||
/*
|
||||
* Note that we can use high and low surrogate characters that don't combine
|
||||
|
@ -94,7 +94,7 @@ class LowSurrogateCharSet extends JointSet {
|
|||
*/
|
||||
private char low;
|
||||
|
||||
public LowSurrogateCharSet(char low) {
|
||||
public TLowSurrogateCharSet(char low) {
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class LowSurrogateCharSet extends JointSet {
|
|||
* Returns the next.
|
||||
*/
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return this.next;
|
||||
}
|
||||
|
||||
|
@ -113,12 +113,12 @@ class LowSurrogateCharSet extends JointSet {
|
|||
* The next to set.
|
||||
*/
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (stringIndex + 1 > matchResult.getRightBound()) {
|
||||
matchResult.hitEnd = true;
|
||||
|
@ -147,7 +147,7 @@ class LowSurrogateCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
int startStr = matchResult.getLeftBound();
|
||||
|
@ -184,7 +184,7 @@ class LowSurrogateCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
int startStr = matchResult.getLeftBound();
|
||||
String testStr = (String)testString;
|
||||
|
@ -230,26 +230,26 @@ class LowSurrogateCharSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof CharSet) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof RangeSet) {
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return false;
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return false;
|
||||
} else if (set instanceof SupplCharSet) {
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof HighSurrogateCharSet) {
|
||||
} else if (set instanceof THighSurrogateCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof LowSurrogateCharSet) {
|
||||
return ((LowSurrogateCharSet)set).low == this.low;
|
||||
} else if (set instanceof TLowSurrogateCharSet) {
|
||||
return ((TLowSurrogateCharSet)set).low == this.low;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ import java.util.Arrays;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class MatchResultImpl implements TMatchResult {
|
||||
class TMatchResultImpl implements TMatchResult {
|
||||
|
||||
private int[] groupBounds = null;
|
||||
|
||||
|
@ -60,7 +60,7 @@ class MatchResultImpl implements TMatchResult {
|
|||
|
||||
private int mode;
|
||||
|
||||
MatchResultImpl(CharSequence string, int leftBound, int rightBound, int groupCount, int compQuantCount,
|
||||
TMatchResultImpl(CharSequence string, int leftBound, int rightBound, int groupCount, int compQuantCount,
|
||||
int consumersCount) {
|
||||
this.groupCount = ++groupCount;
|
||||
this.groupBounds = new int[groupCount * 2];
|
||||
|
@ -75,7 +75,7 @@ class MatchResultImpl implements TMatchResult {
|
|||
}
|
||||
|
||||
TMatchResult cloneImpl() {
|
||||
MatchResultImpl res = new MatchResultImpl(this.string, this.leftBound, this.rightBound, this.groupCount - 1, 0,
|
||||
TMatchResultImpl res = new TMatchResultImpl(this.string, this.leftBound, this.rightBound, this.groupCount - 1, 0,
|
||||
0);
|
||||
|
||||
res.valid = valid;
|
|
@ -54,11 +54,11 @@ public final class TMatcher implements TMatchResult {
|
|||
|
||||
private TPattern pat = null;
|
||||
|
||||
private AbstractSet start = null;
|
||||
private TAbstractSet start = null;
|
||||
|
||||
private CharSequence string = null;
|
||||
|
||||
private MatchResultImpl matchResult = null;
|
||||
private TMatchResultImpl matchResult = null;
|
||||
|
||||
// bounds
|
||||
private int leftBound = -1;
|
||||
|
@ -480,7 +480,7 @@ public final class TMatcher implements TMatchResult {
|
|||
* sequence starting at <code>index</code> specified; Result of the match
|
||||
* will be stored into matchResult instance;
|
||||
*/
|
||||
private boolean runMatch(AbstractSet set, int index, MatchResultImpl matchResult) {
|
||||
private boolean runMatch(TAbstractSet set, int index, TMatchResultImpl matchResult) {
|
||||
|
||||
if (set.matches(index, string, matchResult) >= 0) {
|
||||
matchResult.finalizeMatch();
|
||||
|
@ -670,7 +670,7 @@ public final class TMatcher implements TMatchResult {
|
|||
int mode = matchResult.mode();
|
||||
this.pat = pattern;
|
||||
this.start = pattern.start;
|
||||
matchResult = new MatchResultImpl(this.string, leftBound, rightBound, pattern.groupCount(),
|
||||
matchResult = new TMatchResultImpl(this.string, leftBound, rightBound, pattern.groupCount(),
|
||||
pattern.compCount(), pattern.consCount());
|
||||
matchResult.setStartIndex(startIndex);
|
||||
matchResult.setMode(mode);
|
||||
|
@ -683,7 +683,7 @@ public final class TMatcher implements TMatchResult {
|
|||
this.string = cs;
|
||||
this.leftBound = 0;
|
||||
this.rightBound = string.length();
|
||||
matchResult = new MatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(), pat.consCount());
|
||||
matchResult = new TMatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(), pat.consCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,16 +25,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class MultiLineEOLSet extends AbstractSet {
|
||||
class TMultiLineEOLSet extends TAbstractSet {
|
||||
|
||||
private int consCounter;
|
||||
|
||||
public MultiLineEOLSet(int counter) {
|
||||
public TMultiLineEOLSet(int counter) {
|
||||
this.consCounter = counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strDif = matchResult.hasAnchoringBounds() ? matchResult.getLeftBound() - strIndex : testString.length() -
|
||||
strIndex;
|
||||
char ch1;
|
||||
|
@ -74,7 +74,7 @@ class MultiLineEOLSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
matchResult.setConsumed(consCounter, -1);
|
|
@ -25,16 +25,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class MultiLineSOLSet extends AbstractSet {
|
||||
class TMultiLineSOLSet extends TAbstractSet {
|
||||
|
||||
private AbstractLineTerminator lt;
|
||||
private TAbstractLineTerminator lt;
|
||||
|
||||
public MultiLineSOLSet(AbstractLineTerminator lt) {
|
||||
public TMultiLineSOLSet(TAbstractLineTerminator lt) {
|
||||
this.lt = lt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (strIndex != matchResult.getRightBound() &&
|
||||
((strIndex == 0 || (matchResult.hasAnchoringBounds() && strIndex == matchResult.getLeftBound())) || lt
|
||||
.isAfterLineTerminator(testString.charAt(strIndex - 1), testString.charAt(strIndex)))) {
|
||||
|
@ -44,7 +44,7 @@ class MultiLineSOLSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -27,9 +27,9 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class NegativeLookAhead extends AtomicJointSet {
|
||||
class TNegativeLookAhead extends TAtomicJointSet {
|
||||
|
||||
public NegativeLookAhead(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
public TNegativeLookAhead(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
super(children, fSet);
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,11 @@ class NegativeLookAhead extends AtomicJointSet {
|
|||
* Returns stringIndex+shift, the next position to match
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int size = children.size();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
if (e.matches(stringIndex, testString, matchResult) >= 0)
|
||||
return -1;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class NegativeLookAhead extends AtomicJointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -27,9 +27,9 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class NegativeLookBehind extends AtomicJointSet {
|
||||
class TNegativeLookBehind extends TAtomicJointSet {
|
||||
|
||||
public NegativeLookBehind(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
public TNegativeLookBehind(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
super(children, fSet);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class NegativeLookBehind extends AtomicJointSet {
|
|||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString,
|
||||
MatchResultImpl matchResult) {
|
||||
TMatchResultImpl matchResult) {
|
||||
|
||||
int size = children.size();
|
||||
int shift;
|
||||
|
@ -48,7 +48,7 @@ class NegativeLookBehind extends AtomicJointSet {
|
|||
matchResult.setConsumed(groupIndex, stringIndex);
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
// find limits could be calculated though e.getCharCount()
|
||||
// fSet will return true only if string index at fSet equal
|
||||
// to stringIndex
|
||||
|
@ -62,7 +62,7 @@ class NegativeLookBehind extends AtomicJointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -25,13 +25,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class NonCapFSet extends FSet {
|
||||
public NonCapFSet(int groupIndex) {
|
||||
class TNonCapFSet extends TFSet {
|
||||
public TNonCapFSet(int groupIndex) {
|
||||
super(groupIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int gr = getGroupIndex();
|
||||
matchResult.setConsumed(gr, stringIndex - matchResult.getConsumed(gr));
|
||||
|
||||
|
@ -44,7 +44,7 @@ class NonCapFSet extends FSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -26,12 +26,12 @@ import java.util.ArrayList;
|
|||
* Node representing non-capturing group
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class NonCapJointSet extends JointSet {
|
||||
class TNonCapJointSet extends TJointSet {
|
||||
|
||||
protected NonCapJointSet() {
|
||||
protected TNonCapJointSet() {
|
||||
}
|
||||
|
||||
public NonCapJointSet(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
public TNonCapJointSet(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
super(children, fSet);
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,13 @@ class NonCapJointSet extends JointSet {
|
|||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString,
|
||||
MatchResultImpl matchResult) {
|
||||
TMatchResultImpl matchResult) {
|
||||
int start = matchResult.getConsumed(groupIndex);
|
||||
matchResult.setConsumed(groupIndex, stringIndex);
|
||||
|
||||
int size = children.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
int shift = e.matches(stringIndex, testString, matchResult);
|
||||
if (shift >= 0) {
|
||||
return shift;
|
||||
|
@ -62,7 +62,7 @@ class NonCapJointSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons = matchResult.getConsumed(groupIndex);
|
||||
return cons != 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -26,15 +26,15 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PosAltGroupQuantifierSet extends AltGroupQuantifierSet {
|
||||
class TPosAltGroupQuantifierSet extends TAltGroupQuantifierSet {
|
||||
|
||||
public PosAltGroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
public TPosAltGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
((JointSet)innerSet).setNext(FSet.posFSet);
|
||||
((TJointSet)innerSet).setNext(TFSet.posFSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int nextIndex = innerSet.matches(stringIndex, testString, matchResult);
|
||||
if (nextIndex > 0) {
|
||||
stringIndex = nextIndex;
|
||||
|
@ -43,7 +43,7 @@ class PosAltGroupQuantifierSet extends AltGroupQuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
}
|
|
@ -25,16 +25,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PosCompositeGroupQuantifierSet extends CompositeGroupQuantifierSet {
|
||||
class TPosCompositeGroupQuantifierSet extends TCompositeGroupQuantifierSet {
|
||||
|
||||
public PosCompositeGroupQuantifierSet(Quantifier quant, AbstractSet innerSet, AbstractSet next, int type,
|
||||
public TPosCompositeGroupQuantifierSet(TQuantifier quant, TAbstractSet innerSet, TAbstractSet next, int type,
|
||||
int setCounter) {
|
||||
super(quant, innerSet, next, type, setCounter);
|
||||
innerSet.setNext(FSet.posFSet);
|
||||
innerSet.setNext(TFSet.posFSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int nextIndex;
|
||||
int counter = 0;
|
||||
int max = quantifier.max();
|
|
@ -25,15 +25,15 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PosPlusGroupQuantifierSet extends GroupQuantifierSet {
|
||||
class TPosPlusGroupQuantifierSet extends TGroupQuantifierSet {
|
||||
|
||||
public PosPlusGroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
public TPosPlusGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
((JointSet)innerSet).setNext(FSet.posFSet);
|
||||
((TJointSet)innerSet).setNext(TFSet.posFSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int nextIndex;
|
||||
if ((nextIndex = innerSet.matches(stringIndex, testString, matchResult)) < 0) {
|
||||
return -1;
|
|
@ -27,8 +27,8 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PositiveLookAhead extends AtomicJointSet {
|
||||
public PositiveLookAhead(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
class TPositiveLookAhead extends TAtomicJointSet {
|
||||
public TPositiveLookAhead(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
super(children, fSet);
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,10 @@ class PositiveLookAhead extends AtomicJointSet {
|
|||
* Returns stringIndex+shift, the next position to match
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int size = children.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
int shift = e.matches(stringIndex, testString, matchResult);
|
||||
if (shift >= 0) {
|
||||
// PosLookaheadFset always returns true, position remains the
|
||||
|
@ -53,7 +53,7 @@ class PositiveLookAhead extends AtomicJointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -27,9 +27,9 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PositiveLookBehind extends AtomicJointSet {
|
||||
class TPositiveLookBehind extends TAtomicJointSet {
|
||||
|
||||
public PositiveLookBehind(ArrayList<AbstractSet> children, FSet fSet) {
|
||||
public TPositiveLookBehind(ArrayList<TAbstractSet> children, TFSet fSet) {
|
||||
super(children, fSet);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class PositiveLookBehind extends AtomicJointSet {
|
|||
* Returns stringIndex+shift, the next position to match
|
||||
*/
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
int size = children.size();
|
||||
int leftBound = matchResult.hasTransparentBounds() ? 0 : matchResult.getLeftBound();
|
||||
|
@ -48,7 +48,7 @@ class PositiveLookBehind extends AtomicJointSet {
|
|||
// and return true if the current index equal to this one
|
||||
matchResult.setConsumed(groupIndex, stringIndex);
|
||||
for (int i = 0; i < size; i++) {
|
||||
AbstractSet e = children.get(i);
|
||||
TAbstractSet e = children.get(i);
|
||||
// find limits could be calculated though e.getCharCount()
|
||||
// fSet will return true only if string index at fSet equal
|
||||
// to stringIndex
|
||||
|
@ -63,7 +63,7 @@ class PositiveLookBehind extends AtomicJointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -25,13 +25,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PossessiveAltQuantifierSet extends AltQuantifierSet {
|
||||
public PossessiveAltQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
class TPossessiveAltQuantifierSet extends TAltQuantifierSet {
|
||||
public TPossessiveAltQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
|
||||
if (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
|
@ -25,13 +25,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PossessiveCompositeQuantifierSet extends CompositeQuantifierSet {
|
||||
public PossessiveCompositeQuantifierSet(Quantifier quant, LeafSet innerSet, AbstractSet next, int type) {
|
||||
class TPossessiveCompositeQuantifierSet extends TCompositeQuantifierSet {
|
||||
public TPossessiveCompositeQuantifierSet(TQuantifier quant, TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(quant, innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int min = quantifier.min();
|
||||
int max = quantifier.max();
|
||||
int i = 0;
|
|
@ -25,15 +25,15 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PossessiveGroupQuantifierSet extends GroupQuantifierSet {
|
||||
public PossessiveGroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
class TPossessiveGroupQuantifierSet extends TGroupQuantifierSet {
|
||||
public TPossessiveGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
innerSet.setNext(FSet.posFSet);
|
||||
innerSet.setNext(TFSet.posFSet);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int nextIndex;
|
||||
while ((nextIndex = innerSet.matches(stringIndex, testString, matchResult)) > 0) {
|
||||
stringIndex = nextIndex;
|
|
@ -25,14 +25,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PossessiveQuantifierSet extends LeafQuantifierSet {
|
||||
class TPossessiveQuantifierSet extends TLeafQuantifierSet {
|
||||
|
||||
public PossessiveQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
public TPossessiveQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
||||
(shift = leaf.accepts(stringIndex, testString)) >= 1) {
|
|
@ -25,10 +25,10 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class PreviousMatch extends AbstractSet {
|
||||
class TPreviousMatch extends TAbstractSet {
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString,
|
||||
MatchResultImpl matchResult) {
|
||||
TMatchResultImpl matchResult) {
|
||||
if (stringIndex == matchResult.getPreviousMatchEnd()) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class PreviousMatch extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class Quantifier extends SpecialToken implements Cloneable {
|
||||
class TQuantifier extends TSpecialToken implements Cloneable {
|
||||
|
||||
private int min;
|
||||
|
||||
|
@ -35,11 +35,11 @@ class Quantifier extends SpecialToken implements Cloneable {
|
|||
|
||||
private int counter = 0;
|
||||
|
||||
public Quantifier(int min) {
|
||||
public TQuantifier(int min) {
|
||||
this.min = this.max = min;
|
||||
}
|
||||
|
||||
public Quantifier(int min, int max) {
|
||||
public TQuantifier(int min, int max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ class Quantifier extends SpecialToken implements Cloneable {
|
|||
|
||||
@Override
|
||||
public int getType() {
|
||||
return SpecialToken.TOK_QUANTIFIER;
|
||||
return TSpecialToken.TOK_QUANTIFIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return new Quantifier(min, max);
|
||||
return new TQuantifier(min, max);
|
||||
}
|
||||
}
|
|
@ -25,11 +25,11 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class QuantifierSet extends AbstractSet {
|
||||
abstract class TQuantifierSet extends TAbstractSet {
|
||||
|
||||
protected AbstractSet innerSet;
|
||||
protected TAbstractSet innerSet;
|
||||
|
||||
public QuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
public TQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(next);
|
||||
this.innerSet = innerSet;
|
||||
setType(type);
|
||||
|
@ -38,7 +38,7 @@ abstract class QuantifierSet extends AbstractSet {
|
|||
/**
|
||||
* Returns the innerSet.
|
||||
*/
|
||||
public AbstractSet getInnerSet() {
|
||||
public TAbstractSet getInnerSet() {
|
||||
return innerSet;
|
||||
}
|
||||
|
||||
|
@ -48,17 +48,17 @@ abstract class QuantifierSet extends AbstractSet {
|
|||
* @param innerSet
|
||||
* The innerSet to set.
|
||||
*/
|
||||
public void setInnerSet(AbstractSet innerSet) {
|
||||
public void setInnerSet(TAbstractSet innerSet) {
|
||||
this.innerSet = innerSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
return innerSet.first(set) || next.first(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ abstract class QuantifierSet extends AbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
JointSet set = next.processBackRefReplacement();
|
||||
TJointSet set = next.processBackRefReplacement();
|
||||
|
||||
if (set != null) {
|
||||
next.isSecondPassVisited = true;
|
||||
|
@ -98,7 +98,7 @@ abstract class QuantifierSet extends AbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
JointSet set = innerSet.processBackRefReplacement();
|
||||
TJointSet set = innerSet.processBackRefReplacement();
|
||||
|
||||
if (set != null) {
|
||||
innerSet.isSecondPassVisited = true;
|
||||
|
@ -121,7 +121,7 @@ abstract class QuantifierSet extends AbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
if (innerSet instanceof SingleSet && ((FSet)((JointSet)innerSet).fSet).isBackReferenced) {
|
||||
if (innerSet instanceof TSingleSet && ((TFSet)((TJointSet)innerSet).fSet).isBackReferenced) {
|
||||
innerSet = innerSet.next;
|
||||
}
|
||||
|
|
@ -26,19 +26,19 @@ package org.teavm.classlib.java.util.regex;
|
|||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
|
||||
class RangeSet extends LeafSet {
|
||||
class TRangeSet extends TLeafSet {
|
||||
|
||||
private AbstractCharClass chars;
|
||||
private TAbstractCharClass chars;
|
||||
|
||||
private boolean alt = false;
|
||||
|
||||
public RangeSet(AbstractCharClass cs, AbstractSet next) {
|
||||
public TRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
super(next);
|
||||
this.chars = cs.getInstance();
|
||||
this.alt = cs.alt;
|
||||
}
|
||||
|
||||
public RangeSet(AbstractCharClass cc) {
|
||||
public TRangeSet(TAbstractCharClass cc) {
|
||||
this.chars = cc.getInstance();
|
||||
this.alt = cc.alt;
|
||||
}
|
||||
|
@ -54,20 +54,20 @@ class RangeSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof CharSet) {
|
||||
return AbstractCharClass.intersects(chars, ((CharSet)set).getChar());
|
||||
} else if (set instanceof RangeSet) {
|
||||
return AbstractCharClass.intersects(chars, ((RangeSet)set).chars);
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
return AbstractCharClass.intersects(chars, ((SupplRangeSet)set).getChars());
|
||||
} else if (set instanceof SupplCharSet) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TCharSet)set).getChar());
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TRangeSet)set).chars);
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplRangeSet)set).getChars());
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected AbstractCharClass getChars() {
|
||||
protected TAbstractCharClass getChars() {
|
||||
return chars;
|
||||
}
|
||||
}
|
|
@ -25,14 +25,14 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class RelAltGroupQuantifierSet extends AltGroupQuantifierSet {
|
||||
class TRelAltGroupQuantifierSet extends TAltGroupQuantifierSet {
|
||||
|
||||
public RelAltGroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
public TRelAltGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
return next.matches(stringIndex, testString, matchResult);
|
|
@ -25,15 +25,15 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class RelCompositeGroupQuantifierSet extends CompositeGroupQuantifierSet {
|
||||
class TRelCompositeGroupQuantifierSet extends TCompositeGroupQuantifierSet {
|
||||
|
||||
public RelCompositeGroupQuantifierSet(Quantifier quant, AbstractSet innerSet, AbstractSet next, int type,
|
||||
public TRelCompositeGroupQuantifierSet(TQuantifier quant, TAbstractSet innerSet, TAbstractSet next, int type,
|
||||
int setCounter) {
|
||||
super(quant, innerSet, next, type, setCounter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int enterCounter = matchResult.getEnterCounter(setCounter);
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
|
@ -25,13 +25,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class ReluctantAltQuantifierSet extends AltQuantifierSet {
|
||||
public ReluctantAltQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
class TReluctantAltQuantifierSet extends TAltQuantifierSet {
|
||||
public TReluctantAltQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift;
|
||||
|
||||
if ((shift = next.matches(stringIndex, testString, matchResult)) >= 0) {
|
|
@ -25,13 +25,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class ReluctantCompositeQuantifierSet extends CompositeQuantifierSet {
|
||||
public ReluctantCompositeQuantifierSet(Quantifier quant, LeafSet innerSet, AbstractSet next, int type) {
|
||||
class TReluctantCompositeQuantifierSet extends TCompositeQuantifierSet {
|
||||
public TReluctantCompositeQuantifierSet(TQuantifier quant, TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(quant, innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int min = quantifier.min();
|
||||
int max = quantifier.max();
|
||||
int i = 0;
|
|
@ -25,13 +25,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class ReluctantGroupQuantifierSet extends GroupQuantifierSet {
|
||||
public ReluctantGroupQuantifierSet(AbstractSet innerSet, AbstractSet next, int type) {
|
||||
class TReluctantGroupQuantifierSet extends TGroupQuantifierSet {
|
||||
public TReluctantGroupQuantifierSet(TAbstractSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
|
|
@ -23,17 +23,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* This class represents [+*]? constructs over LeafSets.
|
||||
*
|
||||
* @see java.util.regex.LeafSet
|
||||
* @see java.util.regex.TLeafSet
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class ReluctantQuantifierSet extends LeafQuantifierSet {
|
||||
class TReluctantQuantifierSet extends TLeafQuantifierSet {
|
||||
|
||||
public ReluctantQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
public TReluctantQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
|
||||
do {
|
|
@ -25,11 +25,11 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
final class SOLSet extends AbstractSet {
|
||||
final class TSOLSet extends TAbstractSet {
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString,
|
||||
MatchResultImpl matchResult) {
|
||||
TMatchResultImpl matchResult) {
|
||||
if (strIndex == 0
|
||||
|| (matchResult.hasAnchoringBounds() && strIndex == matchResult
|
||||
.getLeftBound())) {
|
||||
|
@ -39,7 +39,7 @@ final class SOLSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class SequenceSet extends LeafSet {
|
||||
class TSequenceSet extends TLeafSet {
|
||||
|
||||
private String string = null;
|
||||
|
||||
|
@ -42,7 +42,7 @@ class SequenceSet extends LeafSet {
|
|||
|
||||
private IntHash rightToLeft;
|
||||
|
||||
SequenceSet(StringBuffer substring) {
|
||||
TSequenceSet(StringBuffer substring) {
|
||||
this.string = substring.toString();
|
||||
charCount = substring.length();
|
||||
|
||||
|
@ -50,8 +50,7 @@ class SequenceSet extends LeafSet {
|
|||
rightToLeft = new IntHash(charCount);
|
||||
for (int j = 0; j < charCount - 1; j++) {
|
||||
leftToRight.put(string.charAt(j), charCount - j - 1);
|
||||
rightToLeft
|
||||
.put(string.charAt(charCount - j - 1), charCount - j - 1);
|
||||
rightToLeft.put(string.charAt(charCount - j - 1), charCount - j - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +61,7 @@ class SequenceSet extends LeafSet {
|
|||
|
||||
@Override
|
||||
public int find(int strIndex, CharSequence testString,
|
||||
MatchResultImpl matchResult) {
|
||||
TMatchResultImpl matchResult) {
|
||||
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
|
@ -82,7 +81,7 @@ class SequenceSet extends LeafSet {
|
|||
|
||||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString,
|
||||
MatchResultImpl matchResult) {
|
||||
TMatchResultImpl matchResult) {
|
||||
|
||||
while (lastIndex >= strIndex) {
|
||||
lastIndex = lastIndexOf(testString, strIndex, lastIndex);
|
||||
|
@ -104,18 +103,18 @@ class SequenceSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof CharSet) {
|
||||
return ((CharSet) set).getChar() == string.charAt(0);
|
||||
} else if (set instanceof RangeSet) {
|
||||
return ((RangeSet) set).accepts(0, string.substring(0, 1)) > 0;
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
return ((SupplRangeSet) set).contains(string.charAt(0))
|
||||
|| ((string.length() > 1) && ((SupplRangeSet) set).contains(Character
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return ((TCharSet) set).getChar() == string.charAt(0);
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return ((TRangeSet) set).accepts(0, string.substring(0, 1)) > 0;
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return ((TSupplRangeSet) set).contains(string.charAt(0))
|
||||
|| ((string.length() > 1) && ((TSupplRangeSet) set).contains(Character
|
||||
.toCodePoint(string.charAt(0), string.charAt(1))));
|
||||
} else if ((set instanceof SupplCharSet)) {
|
||||
} else if ((set instanceof TSupplCharSet)) {
|
||||
return (string.length() > 1)
|
||||
? ((SupplCharSet) set).getCodePoint()
|
||||
? ((TSupplCharSet) set).getCodePoint()
|
||||
== Character.toCodePoint(string.charAt(0),
|
||||
string.charAt(1))
|
||||
: false;
|
|
@ -25,18 +25,18 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class SingleSet extends JointSet {
|
||||
class TSingleSet extends TJointSet {
|
||||
|
||||
protected AbstractSet kid;
|
||||
protected TAbstractSet kid;
|
||||
|
||||
public SingleSet(AbstractSet child, FSet fSet) {
|
||||
public TSingleSet(TAbstractSet child, TFSet fSet) {
|
||||
this.kid = child;
|
||||
this.fSet = fSet;
|
||||
this.groupIndex = fSet.getGroupIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int start = matchResult.getStart(groupIndex);
|
||||
matchResult.setStart(groupIndex, stringIndex);
|
||||
int shift = kid.matches(stringIndex, testString, matchResult);
|
||||
|
@ -48,7 +48,7 @@ class SingleSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int res = kid.find(stringIndex, testString, matchResult);
|
||||
if (res >= 0)
|
||||
matchResult.setStart(groupIndex, res);
|
||||
|
@ -56,7 +56,7 @@ class SingleSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int stringIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int stringIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int res = kid.findBack(stringIndex, lastIndex, testString, matchResult);
|
||||
if (res >= 0)
|
||||
matchResult.setStart(groupIndex, res);
|
||||
|
@ -64,7 +64,7 @@ class SingleSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
return kid.first(set);
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ class SingleSet extends JointSet {
|
|||
* This method is used for replacement backreferenced sets.
|
||||
*/
|
||||
@Override
|
||||
public JointSet processBackRefReplacement() {
|
||||
BackReferencedSingleSet set = new BackReferencedSingleSet(this);
|
||||
public TJointSet processBackRefReplacement() {
|
||||
TBackReferencedSingleSet set = new TBackReferencedSingleSet(this);
|
||||
|
||||
/*
|
||||
* We will store a reference to created BackReferencedSingleSet in next
|
||||
|
@ -111,7 +111,7 @@ class SingleSet extends JointSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
JointSet set = kid.processBackRefReplacement();
|
||||
TJointSet set = kid.processBackRefReplacement();
|
||||
|
||||
if (set != null) {
|
||||
kid.isSecondPassVisited = true;
|
|
@ -26,7 +26,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class SpecialToken {
|
||||
abstract class TSpecialToken {
|
||||
|
||||
public static final int TOK_CHARCLASS = 1 << 0;
|
||||
|
|
@ -85,7 +85,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
/**
|
||||
* Represents node accepting single supplementary codepoint.
|
||||
*/
|
||||
class SupplCharSet extends LeafSet {
|
||||
class TSupplCharSet extends TLeafSet {
|
||||
|
||||
/*
|
||||
* UTF-16 encoding of this supplementary codepoint
|
||||
|
@ -97,7 +97,7 @@ class SupplCharSet extends LeafSet {
|
|||
// int value of this supplementary codepoint
|
||||
private int ch;
|
||||
|
||||
public SupplCharSet(int ch) {
|
||||
public TSupplCharSet(int ch) {
|
||||
charCount = 2;
|
||||
this.ch = ch;
|
||||
char[] chUTF16 = Character.toChars(ch);
|
||||
|
@ -118,7 +118,7 @@ class SupplCharSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
|
@ -146,7 +146,7 @@ class SupplCharSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
|
@ -180,14 +180,14 @@ class SupplCharSet extends LeafSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof SupplCharSet) {
|
||||
return ((SupplCharSet)set).getCodePoint() == ch;
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
return ((SupplRangeSet)set).contains(ch);
|
||||
} else if (set instanceof CharSet) {
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TSupplCharSet) {
|
||||
return ((TSupplCharSet)set).getCodePoint() == ch;
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return ((TSupplRangeSet)set).contains(ch);
|
||||
} else if (set instanceof TCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof RangeSet) {
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -87,25 +87,25 @@ package org.teavm.classlib.java.util.regex;
|
|||
* character can be supplementary (2 chars needed to represent) or from basic
|
||||
* multilingual pane (1 needed char to represent it).
|
||||
*/
|
||||
class SupplRangeSet extends JointSet {
|
||||
class TSupplRangeSet extends TJointSet {
|
||||
|
||||
protected AbstractCharClass chars;
|
||||
protected TAbstractCharClass chars;
|
||||
|
||||
protected boolean alt = false;
|
||||
|
||||
public SupplRangeSet(AbstractCharClass cs, AbstractSet next) {
|
||||
public TSupplRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
this.chars = cs.getInstance();
|
||||
this.alt = cs.alt;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
public SupplRangeSet(AbstractCharClass cc) {
|
||||
public TSupplRangeSet(TAbstractCharClass cc) {
|
||||
this.chars = cc.getInstance();
|
||||
this.alt = cc.alt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strLength = matchResult.getRightBound();
|
||||
int offset = -1;
|
||||
|
||||
|
@ -138,36 +138,36 @@ class SupplRangeSet extends JointSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean first(AbstractSet set) {
|
||||
if (set instanceof SupplCharSet) {
|
||||
return AbstractCharClass.intersects(chars, ((SupplCharSet)set).getCodePoint());
|
||||
} else if (set instanceof CharSet) {
|
||||
return AbstractCharClass.intersects(chars, ((CharSet)set).getChar());
|
||||
} else if (set instanceof SupplRangeSet) {
|
||||
return AbstractCharClass.intersects(chars, ((SupplRangeSet)set).chars);
|
||||
} else if (set instanceof RangeSet) {
|
||||
return AbstractCharClass.intersects(chars, ((RangeSet)set).getChars());
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TSupplCharSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplCharSet)set).getCodePoint());
|
||||
} else if (set instanceof TCharSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TCharSet)set).getChar());
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplRangeSet)set).chars);
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TRangeSet)set).getChars());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected AbstractCharClass getChars() {
|
||||
protected TAbstractCharClass getChars() {
|
||||
return chars;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSet getNext() {
|
||||
public TAbstractSet getNext() {
|
||||
return next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNext(AbstractSet next) {
|
||||
public void setNext(TAbstractSet next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl mr) {
|
||||
public boolean hasConsumed(TMatchResultImpl mr) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -25,16 +25,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UCIBackReferenceSet extends CIBackReferenceSet {
|
||||
class TUCIBackReferenceSet extends TCIBackReferenceSet {
|
||||
|
||||
int groupIndex;
|
||||
|
||||
public UCIBackReferenceSet(int groupIndex, int consCounter) {
|
||||
public TUCIBackReferenceSet(int groupIndex, int consCounter) {
|
||||
super(groupIndex, consCounter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound())
|
|
@ -26,18 +26,17 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UCICharSet extends LeafSet {
|
||||
class TUCICharSet extends TLeafSet {
|
||||
|
||||
private char ch;
|
||||
|
||||
public UCICharSet(char ch) {
|
||||
public TUCICharSet(char ch) {
|
||||
this.ch = Character.toLowerCase(Character.toUpperCase(ch));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int accepts(int strIndex, CharSequence testString) {
|
||||
return (this.ch == Character.toLowerCase(Character
|
||||
.toUpperCase(testString.charAt(strIndex)))) ? 1 : -1;
|
||||
return (this.ch == Character.toLowerCase(Character.toUpperCase(testString.charAt(strIndex)))) ? 1 : -1;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -24,12 +24,12 @@ package org.teavm.classlib.java.util.regex;
|
|||
* CANON_EQ flag of Pattern class
|
||||
* is specified.
|
||||
*/
|
||||
class UCIDecomposedCharSet extends DecomposedCharSet{
|
||||
class TUCIDecomposedCharSet extends TDecomposedCharSet{
|
||||
|
||||
/*
|
||||
* Just only a stub
|
||||
*/
|
||||
public UCIDecomposedCharSet(int [] decomp, int decomposedCharLength) {
|
||||
public TUCIDecomposedCharSet(int [] decomp, int decomposedCharLength) {
|
||||
super(decomp, decomposedCharLength);
|
||||
}
|
||||
}
|
|
@ -27,19 +27,19 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UCIRangeSet extends LeafSet {
|
||||
class TUCIRangeSet extends TLeafSet {
|
||||
|
||||
private AbstractCharClass chars;
|
||||
private TAbstractCharClass chars;
|
||||
|
||||
private boolean alt = false;
|
||||
|
||||
public UCIRangeSet(AbstractCharClass cs, AbstractSet next) {
|
||||
public TUCIRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
super(next);
|
||||
this.chars = cs.getInstance();
|
||||
this.alt = cs.alt;
|
||||
}
|
||||
|
||||
public UCIRangeSet(AbstractCharClass cc) {
|
||||
public TUCIRangeSet(TAbstractCharClass cc) {
|
||||
this.chars = cc.getInstance();
|
||||
this.alt = cc.alt;
|
||||
}
|
|
@ -25,11 +25,11 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UCISequenceSet extends LeafSet {
|
||||
class TUCISequenceSet extends TLeafSet {
|
||||
|
||||
private String string = null;
|
||||
|
||||
UCISequenceSet(StringBuffer substring) {
|
||||
TUCISequenceSet(StringBuffer substring) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int i = 0; i < substring.length(); i++) {
|
||||
res.append(Character.toLowerCase(Character.toUpperCase(substring.charAt(i))));
|
|
@ -86,12 +86,12 @@ package org.teavm.classlib.java.util.regex;
|
|||
* Represents node accepting single supplementary codepoint in Unicode case
|
||||
* insensitive manner.
|
||||
*/
|
||||
class UCISupplCharSet extends LeafSet {
|
||||
class TUCISupplCharSet extends TLeafSet {
|
||||
|
||||
// int value of this supplementary codepoint
|
||||
private int ch;
|
||||
|
||||
public UCISupplCharSet(int ch) {
|
||||
public TUCISupplCharSet(int ch) {
|
||||
charCount = 2;
|
||||
this.ch = Character.toLowerCase(Character.toUpperCase(ch));
|
||||
}
|
|
@ -88,13 +88,13 @@ package org.teavm.classlib.java.util.regex;
|
|||
* This character can be supplementary (2 chars to represent) or from
|
||||
* basic multilingual pane (1 char to represent).
|
||||
*/
|
||||
class UCISupplRangeSet extends SupplRangeSet{
|
||||
class TUCISupplRangeSet extends TSupplRangeSet {
|
||||
|
||||
public UCISupplRangeSet(AbstractCharClass cs, AbstractSet next) {
|
||||
public TUCISupplRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
super(cs, next);
|
||||
}
|
||||
|
||||
public UCISupplRangeSet(AbstractCharClass cc) {
|
||||
public TUCISupplRangeSet(TAbstractCharClass cc) {
|
||||
super(cc);
|
||||
}
|
||||
|
|
@ -25,16 +25,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
final class UEOLSet extends AbstractSet {
|
||||
final class TUEOLSet extends TAbstractSet {
|
||||
|
||||
private int consCounter;
|
||||
|
||||
public UEOLSet(int counter) {
|
||||
public TUEOLSet(int counter) {
|
||||
this.consCounter = counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int rightBound = matchResult.hasAnchoringBounds() ? matchResult.getRightBound() : testString.length();
|
||||
|
||||
if (strIndex >= rightBound) {
|
||||
|
@ -52,7 +52,7 @@ final class UEOLSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
matchResult.setConsumed(consCounter, -1);
|
|
@ -25,16 +25,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UMultiLineEOLSet extends AbstractSet {
|
||||
class TUMultiLineEOLSet extends TAbstractSet {
|
||||
|
||||
private int consCounter;
|
||||
|
||||
public UMultiLineEOLSet(int counter) {
|
||||
public TUMultiLineEOLSet(int counter) {
|
||||
this.consCounter = counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strDif = matchResult.hasAnchoringBounds() ? matchResult.getRightBound() - strIndex : testString.length() -
|
||||
strIndex;
|
||||
if (strDif <= 0) {
|
||||
|
@ -48,7 +48,7 @@ class UMultiLineEOLSet extends AbstractSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
matchResult.setConsumed(consCounter, -1);
|
|
@ -25,11 +25,11 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UnicodeCategory extends AbstractCharClass {
|
||||
class TUnicodeCategory extends TAbstractCharClass {
|
||||
|
||||
protected int category;
|
||||
|
||||
public UnicodeCategory(int category) {
|
||||
public TUnicodeCategory(int category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
|
@ -24,9 +24,9 @@ package org.teavm.classlib.java.util.regex;
|
|||
* Unicode category scope (i.e IsL, IsM, ...)
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UnicodeCategoryScope extends UnicodeCategory {
|
||||
class TUnicodeCategoryScope extends TUnicodeCategory {
|
||||
|
||||
public UnicodeCategoryScope(int category) {
|
||||
public TUnicodeCategoryScope(int category) {
|
||||
super(category);
|
||||
}
|
||||
|
|
@ -26,20 +26,20 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class UnifiedQuantifierSet extends LeafQuantifierSet {
|
||||
class TUnifiedQuantifierSet extends TLeafQuantifierSet {
|
||||
|
||||
public UnifiedQuantifierSet(LeafSet innerSet, AbstractSet next, int type) {
|
||||
public TUnifiedQuantifierSet(TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
}
|
||||
|
||||
public UnifiedQuantifierSet(LeafQuantifierSet quant) {
|
||||
super((LeafSet)quant.getInnerSet(), quant.getNext(), quant.getType());
|
||||
public TUnifiedQuantifierSet(TLeafQuantifierSet quant) {
|
||||
super((TLeafSet)quant.getInnerSet(), quant.getNext(), quant.getType());
|
||||
innerSet.setNext(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
||||
leaf.accepts(stringIndex, testString) > 0)
|
||||
stringIndex += leaf.charCount();
|
||||
|
@ -48,7 +48,7 @@ class UnifiedQuantifierSet extends LeafQuantifierSet {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int startSearch = next.find(stringIndex, testString, matchResult);
|
||||
if (startSearch < 0)
|
||||
return -1;
|
|
@ -26,16 +26,16 @@ package org.teavm.classlib.java.util.regex;
|
|||
*
|
||||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class WordBoundary extends AbstractSet {
|
||||
class TWordBoundary extends TAbstractSet {
|
||||
|
||||
boolean positive;
|
||||
|
||||
public WordBoundary(boolean positive) {
|
||||
public TWordBoundary(boolean positive) {
|
||||
this.positive = positive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, MatchResultImpl matchResult) {
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
boolean left;
|
||||
boolean right;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class WordBoundary extends AbstractSet {
|
|||
* do not move string index.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasConsumed(MatchResultImpl matchResult) {
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
// only checks boundary, do not consumes characters
|
||||
return false;
|
||||
}
|
|
@ -625,42 +625,6 @@ public class MatcherTest {
|
|||
assertTrue(matcher.matches());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllCodePoints() {
|
||||
// Regression for HARMONY-3145
|
||||
int[] codePoint = new int[1];
|
||||
Pattern p = Pattern.compile("(\\p{all})+");
|
||||
boolean res = true;
|
||||
int cnt = 0;
|
||||
String s;
|
||||
for (int i = 0; i < 0x110000; i++) {
|
||||
codePoint[0] = i;
|
||||
s = new String(codePoint, 0, 1);
|
||||
if (!s.matches(p.toString())) {
|
||||
cnt++;
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
assertTrue(res);
|
||||
assertEquals(0, cnt);
|
||||
|
||||
p = Pattern.compile("(\\P{all})+");
|
||||
res = true;
|
||||
cnt = 0;
|
||||
|
||||
for (int i = 0; i < 0x110000; i++) {
|
||||
codePoint[0] = i;
|
||||
s = new String(codePoint, 0, 1);
|
||||
if (!s.matches(p.toString())) {
|
||||
cnt++;
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
||||
assertFalse(res);
|
||||
assertEquals(0x110000, cnt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindRegionChanged() {
|
||||
// Regression for HARMONY-625
|
||||
|
@ -705,8 +669,7 @@ public class MatcherTest {
|
|||
|
||||
@Test
|
||||
public void testGeneralPunctuationCategory() {
|
||||
String[] s = { ",", "!", "\"", "#", "%", "&", "'", "(", ")", "-", ".",
|
||||
"/" };
|
||||
String[] s = { ",", "!", "\"", "#", "%", "&", "'", "(", ")", "-", ".", "/" };
|
||||
String regexp = "\\p{P}";
|
||||
|
||||
for (int i = 0; i < s.length; i++) {
|
||||
|
@ -728,12 +691,9 @@ public class MatcherTest {
|
|||
|
||||
String floatRegex = getHexFloatRegex();
|
||||
hitEndTest(true, "#03.0", floatRegex, Double.toHexString(-1.234d), true);
|
||||
hitEndTest(true, "#03.1", floatRegex, "1 ABC"
|
||||
+ Double.toHexString(Double.NaN) + "buhuhu", false);
|
||||
hitEndTest(true, "#03.2", floatRegex, Double.toHexString(-0.0) + "--",
|
||||
false);
|
||||
hitEndTest(true, "#03.3", floatRegex, "--"
|
||||
+ Double.toHexString(Double.MIN_VALUE) + "--", false);
|
||||
hitEndTest(true, "#03.1", floatRegex, "1 ABC" + Double.toHexString(Double.NaN) + "buhuhu", false);
|
||||
hitEndTest(true, "#03.2", floatRegex, Double.toHexString(-0.0) + "--", false);
|
||||
hitEndTest(true, "#03.3", floatRegex, "--" + Double.toHexString(Double.MIN_VALUE) + "--", false);
|
||||
|
||||
hitEndTest(true, "#04.0", "(\\d+) fish (\\d+) fish (\\w+) fish (\\d+)",
|
||||
"1 fish 2 fish red fish 5", true);
|
||||
|
@ -743,10 +703,8 @@ public class MatcherTest {
|
|||
|
||||
@Test
|
||||
public void testToString() {
|
||||
String result = Pattern.compile("(\\d{1,3})").matcher(
|
||||
"aaaa123456789045").toString();
|
||||
assertTrue("The result doesn't contain pattern info", result
|
||||
.contains("(\\d{1,3})"));
|
||||
String result = Pattern.compile("(\\d{1,3})").matcher("aaaa123456789045").toString();
|
||||
assertTrue("The result doesn't contain pattern info", result.contains("(\\d{1,3})"));
|
||||
}
|
||||
|
||||
private void hitEndTest(boolean callFind, String testNo, String regex,
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.junit.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class ModeTest extends TestCase {
|
||||
@Test
|
||||
public void testCase() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -54,6 +55,7 @@ public class ModeTest extends TestCase {
|
|||
assertFalse(m.find());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiline() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.junit.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class Pattern2Test extends TestCase {
|
||||
@Test
|
||||
public void testSimpleMatch() throws PatternSyntaxException {
|
||||
Pattern p = Pattern.compile("foo.*");
|
||||
|
||||
|
@ -48,6 +49,7 @@ public class Pattern2Test extends TestCase {
|
|||
assertTrue(Pattern.matches("", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCursors() {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -103,6 +105,7 @@ public class Pattern2Test extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroups() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -156,6 +159,7 @@ public class Pattern2Test extends TestCase {
|
|||
assertFalse(m.find());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplace() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -197,12 +201,11 @@ public class Pattern2Test extends TestCase {
|
|||
p = Pattern.compile("([CcPp][hl]e[ea]se)");
|
||||
|
||||
m = p.matcher("I want cheese. Please.");
|
||||
assertTrue(m.replaceFirst("<b> $1 </b>").equals(
|
||||
"I want <b> cheese </b>. Please."));
|
||||
assertTrue(m.replaceAll("<b> $1 </b>").equals(
|
||||
"I want <b> cheese </b>. <b> Please </b>."));
|
||||
assertTrue(m.replaceFirst("<b> $1 </b>").equals("I want <b> cheese </b>. Please."));
|
||||
assertTrue(m.replaceAll("<b> $1 </b>").equals("I want <b> cheese </b>. <b> Please </b>."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEscapes() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -239,7 +242,7 @@ public class Pattern2Test extends TestCase {
|
|||
assertFalse(m.find());
|
||||
|
||||
// Test \\u and \\x sequences
|
||||
p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
||||
p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
||||
m = p.matcher("11:;22 ;33-;44!;");
|
||||
assertTrue(m.find());
|
||||
assertEquals("11", m.group(1));
|
||||
|
@ -396,6 +399,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// }
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterClasses() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -654,6 +658,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPOSIXGroups() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -795,6 +800,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnicodeCategories() throws PatternSyntaxException {
|
||||
// Test Unicode categories using \p and \P
|
||||
// One letter codes: L, M, N, P, S, Z, C
|
||||
|
@ -843,6 +849,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// Cn
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnicodeBlocks() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -912,6 +919,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCapturingGroups() throws PatternSyntaxException {
|
||||
// Test simple capturing groups
|
||||
// TODO
|
||||
|
@ -929,6 +937,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepeats() {
|
||||
// Test ?
|
||||
// TODO
|
||||
|
@ -949,6 +958,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAnchors() throws PatternSyntaxException {
|
||||
// Test ^, default and MULTILINE
|
||||
// TODO
|
||||
|
@ -987,6 +997,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMisc() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -1048,6 +1059,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
// TODO
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompile1() throws PatternSyntaxException {
|
||||
Pattern pattern = Pattern
|
||||
.compile("[0-9A-Za-z][0-9A-Za-z\\x2e\\x3a\\x2d\\x5f]*");
|
||||
|
@ -1055,6 +1067,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
assertTrue(pattern.matcher(name).matches());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompile2() throws PatternSyntaxException {
|
||||
String findString = "\\Qimport\\E";
|
||||
|
||||
|
@ -1065,6 +1078,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
assertTrue(matcher.find(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompile3() throws PatternSyntaxException {
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
@ -1144,6 +1158,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
assertFalse(m.find());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompile4() throws PatternSyntaxException {
|
||||
String findString = "\\Qpublic\\E";
|
||||
StringBuffer text = new StringBuffer(" public class Class {\n"
|
||||
|
@ -1166,6 +1181,7 @@ p = Pattern.compile("([0-9]+)[\\u0020:\\x21];");
|
|||
assertFalse(found);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompile5() throws PatternSyntaxException {
|
||||
Pattern p = Pattern.compile("^[0-9]");
|
||||
String s[] = p.split("12", -1);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.teavm.classlib.java.util.regex;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class PatternErrorTest extends TestCase {
|
||||
@Test
|
||||
public void testCompileErrors() throws Exception {
|
||||
// null regex string - should get NullPointerException
|
||||
try {
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.junit.Test;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class PatternSyntaxExceptionTest extends TestCase {
|
||||
@Test
|
||||
public void testCase() {
|
||||
String regex = "(";
|
||||
try {
|
||||
|
@ -43,6 +44,7 @@ public class PatternSyntaxExceptionTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCase2() {
|
||||
String regex = "[4-";
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue
Block a user