mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Reformat classlib according to checkstyle rules
This commit is contained in:
parent
cdec4560ba
commit
248d62ff12
|
@ -87,7 +87,6 @@
|
|||
|
||||
<build>
|
||||
<plugins>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
|
@ -95,7 +94,6 @@
|
|||
<configLocation>../checkstyle.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
-->
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
|
|
|
@ -28,12 +28,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.teavm.backend.javascript.codegen.SourceWriter;
|
||||
import org.teavm.backend.javascript.spi.Generator;
|
||||
import org.teavm.backend.javascript.spi.GeneratorContext;
|
||||
import org.teavm.dependency.AbstractDependencyListener;
|
||||
import org.teavm.dependency.DependencyAgent;
|
||||
import org.teavm.dependency.DependencyNode;
|
||||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.backend.javascript.spi.Generator;
|
||||
import org.teavm.backend.javascript.spi.GeneratorContext;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.MethodDescriptor;
|
||||
import org.teavm.model.MethodReference;
|
||||
|
|
|
@ -414,8 +414,7 @@ public class ZoneInfoCompiler {
|
|||
/**
|
||||
* Adds a recurring savings rule to the builder.
|
||||
*/
|
||||
public void addRecurring(DateTimeZoneBuilder builder, int saveMillis, int fromYear, int toYear)
|
||||
{
|
||||
public void addRecurring(DateTimeZoneBuilder builder, int saveMillis, int fromYear, int toYear) {
|
||||
builder.addRecurringSavings(saveMillis,
|
||||
fromYear, toYear,
|
||||
iZoneChar,
|
||||
|
|
|
@ -185,6 +185,11 @@ public class TObject {
|
|||
return identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return equals0((TObject) obj);
|
||||
}
|
||||
|
||||
@Rename("equals")
|
||||
public boolean equals0(TObject other) {
|
||||
return this == other;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2016 Sergey Kapralov.
|
||||
*
|
||||
|
|
|
@ -17,9 +17,11 @@ package org.teavm.classlib.java.lang.reflect;
|
|||
|
||||
import java.io.IOException;
|
||||
import org.teavm.backend.javascript.codegen.SourceWriter;
|
||||
import org.teavm.dependency.*;
|
||||
import org.teavm.backend.javascript.spi.Generator;
|
||||
import org.teavm.backend.javascript.spi.GeneratorContext;
|
||||
import org.teavm.dependency.DependencyAgent;
|
||||
import org.teavm.dependency.DependencyPlugin;
|
||||
import org.teavm.dependency.MethodDependency;
|
||||
import org.teavm.model.CallLocation;
|
||||
import org.teavm.model.ClassReader;
|
||||
import org.teavm.model.MethodDescriptor;
|
||||
|
|
|
@ -160,7 +160,6 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
||||
|
@ -171,6 +170,11 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
|
|||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return equals0((TObject) obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Rename("equals")
|
||||
public boolean equals0(TObject other) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public interface TComparator<T> {
|
|||
}
|
||||
|
||||
default <U extends Comparable<? super U>> TComparator<T> thenComparing(
|
||||
TFunction<? super T,? extends U> keyExtractor) {
|
||||
TFunction<? super T, ? extends U> keyExtractor) {
|
||||
return (a, b) -> {
|
||||
int r = compare(a, b);
|
||||
if (r == 0) {
|
||||
|
|
|
@ -31,7 +31,12 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
*/
|
||||
protected TProperties defaults;
|
||||
|
||||
private static final int NONE = 0, SLASH = 1, UNICODE = 2, CONTINUE = 3, KEY_DONE = 4, IGNORE = 5;
|
||||
private static final int NONE = 0;
|
||||
private static final int SLASH = 1;
|
||||
private static final int UNICODE = 2;
|
||||
private static final int CONTINUE = 3;
|
||||
private static final int KEY_DONE = 4;
|
||||
private static final int IGNORE = 5;
|
||||
|
||||
public TProperties() {
|
||||
super();
|
||||
|
@ -42,7 +47,8 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
}
|
||||
|
||||
private void dumpString(StringBuilder buffer, String string, boolean isKey) {
|
||||
int index = 0, length = string.length();
|
||||
int index = 0;
|
||||
int length = string.length();
|
||||
if (!isKey && index < length && string.charAt(index) == ' ') {
|
||||
buffer.append("\\ "); //$NON-NLS-1$
|
||||
index++;
|
||||
|
@ -78,7 +84,9 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
|
||||
private char[] toHexaDecimal(final int ch) {
|
||||
char[] hexChars = { '\\', 'u', '0', '0', '0', '0' };
|
||||
int hexChar, index = hexChars.length, copyOfCh = ch;
|
||||
int hexChar;
|
||||
int index = hexChars.length;
|
||||
int copyOfCh = ch;
|
||||
do {
|
||||
hexChar = copyOfCh & 15;
|
||||
if (hexChar > 9) {
|
||||
|
@ -87,7 +95,8 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
hexChar += '0';
|
||||
}
|
||||
hexChars[--index] = (char) hexChar;
|
||||
} while ((copyOfCh >>>= 4) != 0);
|
||||
copyOfCh >>>= 4;
|
||||
} while (copyOfCh != 0);
|
||||
return hexChars;
|
||||
}
|
||||
|
||||
|
@ -144,9 +153,14 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
if (in == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
int mode = NONE, unicode = 0, count = 0;
|
||||
char nextChar, buf[] = new char[40];
|
||||
int offset = 0, keyLength = -1, intVal;
|
||||
int mode = NONE;
|
||||
int unicode = 0;
|
||||
int count = 0;
|
||||
char nextChar;
|
||||
char[] buf = new char[40];
|
||||
int offset = 0;
|
||||
int keyLength = -1;
|
||||
int intVal;
|
||||
boolean firstChar = true;
|
||||
TBufferedInputStream bis = new TBufferedInputStream(in);
|
||||
|
||||
|
@ -214,7 +228,8 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
break;
|
||||
case 'u':
|
||||
mode = UNICODE;
|
||||
unicode = count = 0;
|
||||
unicode = 0;
|
||||
count = 0;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -242,7 +257,13 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
continue;
|
||||
}
|
||||
// fall into the next case
|
||||
break;
|
||||
case '\r':
|
||||
if (mode == CONTINUE) { // Part of a \r\n sequence
|
||||
mode = IGNORE; // Ignore whitespace on the next line
|
||||
continue;
|
||||
}
|
||||
|
||||
mode = NONE;
|
||||
firstChar = true;
|
||||
if (offset > 0 || (offset == 0 && keyLength == 0)) {
|
||||
|
@ -311,7 +332,7 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
}
|
||||
|
||||
private void selectProperties(THashtable<Object, Object> selected) {
|
||||
if(defaults != null) {
|
||||
if (defaults != null) {
|
||||
defaults.selectProperties(selected);
|
||||
}
|
||||
selected.putAll(this);
|
||||
|
@ -322,6 +343,7 @@ public class TProperties extends THashtable<Object, Object> {
|
|||
try {
|
||||
store(out, comment);
|
||||
} catch (TIOException e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,9 @@ public class TRandom extends TObject implements TSerializable {
|
|||
return storedGaussian;
|
||||
}
|
||||
|
||||
double v1, v2, s;
|
||||
double v1;
|
||||
double v2;
|
||||
double s;
|
||||
do {
|
||||
v1 = 2 * nextDouble() - 1;
|
||||
v2 = 2 * nextDouble() - 1;
|
||||
|
|
|
@ -91,7 +91,7 @@ public class TTimer extends TObject {
|
|||
return;
|
||||
}
|
||||
long nextDelay = nextStartTime[0] - System.currentTimeMillis();
|
||||
if (nextDelay < 0 ) {
|
||||
if (nextDelay < 0) {
|
||||
nextDelay = 0;
|
||||
}
|
||||
task.nativeTimerId = Window.setTimeout(this, (int) nextDelay);
|
||||
|
|
|
@ -1,16 +1,29 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
package org.teavm.classlib.java.util.concurrent;
|
||||
|
||||
import org.teavm.classlib.java.util.TCollection;
|
||||
import org.teavm.classlib.java.util.TLinkedList;
|
||||
|
||||
public class TLinkedBlockingDeque<T> extends TLinkedList<T> {
|
||||
public TLinkedBlockingDeque() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TLinkedBlockingDeque() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TLinkedBlockingDeque(TCollection<T> coll) {
|
||||
super(coll);
|
||||
}
|
||||
|
||||
public TLinkedBlockingDeque(TCollection<T> coll) {
|
||||
super(coll);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.teavm.classlib.java.util.function;
|
|||
public interface TBiConsumer<T, U> {
|
||||
void accept(T t, U u);
|
||||
|
||||
default TBiConsumer<T,U> andThen(TBiConsumer<? super T,? super U> after) {
|
||||
default TBiConsumer<T, U> andThen(TBiConsumer<? super T, ? super U> after) {
|
||||
return (t, u) -> {
|
||||
this.accept(t, u);
|
||||
after.accept(t, u);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.teavm.classlib.java.util.function;
|
|||
public interface TBiFunction<T, U, R> {
|
||||
R apply(T t, U u);
|
||||
|
||||
default <V> TBiFunction<T,U,V> andThen(TFunction<? super R, ? extends V> after) {
|
||||
default <V> TBiFunction<T, U, V> andThen(TFunction<? super R, ? extends V> after) {
|
||||
return (t, u) -> after.apply(apply(t, u));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ package org.teavm.classlib.java.util.regex;
|
|||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
abstract class TAbstractLineTerminator {
|
||||
static TAbstractLineTerminator unixLT = null;
|
||||
static TAbstractLineTerminator unixLT;
|
||||
|
||||
static TAbstractLineTerminator unicodeLT = null;
|
||||
static TAbstractLineTerminator unicodeLT;
|
||||
|
||||
public abstract boolean isLineTerminator(int ch);
|
||||
|
||||
|
@ -51,8 +51,9 @@ abstract class TAbstractLineTerminator {
|
|||
|
||||
public static TAbstractLineTerminator getInstance(int flag) {
|
||||
if ((flag & TPattern.UNIX_LINES) != 0) {
|
||||
if (unixLT != null)
|
||||
if (unixLT != null) {
|
||||
return unixLT;
|
||||
}
|
||||
unixLT = new TAbstractLineTerminator() {
|
||||
@Override
|
||||
public boolean isLineTerminator(int ch) {
|
||||
|
@ -66,12 +67,13 @@ abstract class TAbstractLineTerminator {
|
|||
};
|
||||
return unixLT;
|
||||
} else {
|
||||
if (unicodeLT != null)
|
||||
if (unicodeLT != null) {
|
||||
return unicodeLT;
|
||||
}
|
||||
unicodeLT = new TAbstractLineTerminator() {
|
||||
@Override
|
||||
public boolean isLineTerminator(int ch) {
|
||||
return (ch == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029');
|
||||
return ch == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,11 +61,11 @@ abstract class TAbstractSet {
|
|||
*/
|
||||
static int counter = 1;
|
||||
|
||||
protected boolean isSecondPassVisited = false;
|
||||
protected boolean isSecondPassVisited;
|
||||
|
||||
protected String index = new Integer(TAbstractSet.counter++).toString();
|
||||
|
||||
private int type = 0;
|
||||
private int type;
|
||||
|
||||
public TAbstractSet() {
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ abstract class TAbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
if (next instanceof TSingleSet && ((TFSet)((TJointSet)next).fSet).isBackReferenced) {
|
||||
if (next instanceof TSingleSet && ((TFSet) ((TJointSet) next).fSet).isBackReferenced) {
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,9 @@ class TAltGroupQuantifierSet extends TGroupQuantifierSet {
|
|||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
if (!innerSet.hasConsumed(matchResult)) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
int nextIndex = innerSet.matches(stringIndex, testString, matchResult);
|
||||
|
||||
|
|
|
@ -48,13 +48,9 @@ class TAltQuantifierSet extends TLeafQuantifierSet {
|
|||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
int shift = innerSet.matches(stringIndex, testString, matchResult);
|
||||
|
||||
if ((shift = innerSet.matches(stringIndex, testString, matchResult)) >= 0) {
|
||||
return shift;
|
||||
} else {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
return shift >= 0 ? shift : next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -63,7 +63,7 @@ class TAtomicJointSet extends TNonCapJointSet {
|
|||
if (shift >= 0) {
|
||||
// AtomicFset always returns true, but saves the index to run
|
||||
// this next.match() from;
|
||||
return next.matches(((TAtomicFSet)fSet).getIndex(), testString, matchResult);
|
||||
return next.matches(((TAtomicFSet) fSet).getIndex(), testString, matchResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,9 @@ class TBackReferenceSet extends TCIBackReferenceSet {
|
|||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound())
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound()) {
|
||||
return -1;
|
||||
}
|
||||
int shift = testString.toString().startsWith(group, stringIndex) ? group.length() : -1;
|
||||
|
||||
if (shift < 0) {
|
||||
|
@ -65,16 +66,18 @@ class TBackReferenceSet extends TCIBackReferenceSet {
|
|||
String group = getString(matchResult);
|
||||
int strLength = matchResult.getLeftBound();
|
||||
|
||||
if (group == null || (strIndex + group.length()) > strLength)
|
||||
if (group == null || (strIndex + group.length()) > strLength) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
String testStr = testString.toString();
|
||||
|
||||
while (strIndex <= strLength) {
|
||||
strIndex = testStr.indexOf(group, strIndex);
|
||||
|
||||
if (strIndex < 0)
|
||||
if (strIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (next.matches(strIndex + group.length(), testString, matchResult) >= 0) {
|
||||
return strIndex;
|
||||
}
|
||||
|
@ -89,16 +92,18 @@ class TBackReferenceSet extends TCIBackReferenceSet {
|
|||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
|
||||
if (group == null)
|
||||
if (group == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
String testStr = testString.toString();
|
||||
|
||||
while (lastIndex >= strIndex) {
|
||||
lastIndex = testStr.lastIndexOf(group, lastIndex);
|
||||
|
||||
if (lastIndex < 0 || lastIndex < strIndex)
|
||||
if (lastIndex < 0 || lastIndex < strIndex) {
|
||||
return -1;
|
||||
}
|
||||
if (next.matches(lastIndex + group.length(), testString, matchResult) >= 0) {
|
||||
return lastIndex;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class TBackReferencedSingleSet extends TSingleSet {
|
|||
}
|
||||
|
||||
public TBackReferencedSingleSet(TSingleSet node) {
|
||||
super(node.kid, ((TFSet)node.fSet));
|
||||
super(node.kid, (TFSet) node.fSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,12 +57,13 @@ class TCIBackReferenceSet extends TJointSet {
|
|||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound())
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < group.length(); i++) {
|
||||
if (group.charAt(i) != testString.charAt(stringIndex + i) &&
|
||||
TPattern.getSupplement(group.charAt(i)) != testString.charAt(stringIndex + i)) {
|
||||
if (group.charAt(i) != testString.charAt(stringIndex + i)
|
||||
&& TPattern.getSupplement(group.charAt(i)) != testString.charAt(stringIndex + i)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +93,7 @@ class TCIBackReferenceSet extends TJointSet {
|
|||
|
||||
@Override
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
boolean res = matchResult.getConsumed(consCounter) != 0;
|
||||
matchResult.setConsumed(consCounter, -1);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
* @author Nikolay A. Kuznetsov
|
||||
*/
|
||||
class TCISequenceSet extends TLeafSet {
|
||||
private String string = null;
|
||||
private String string;
|
||||
|
||||
TCISequenceSet(StringBuffer substring) {
|
||||
this.string = substring.toString();
|
||||
|
@ -51,8 +51,8 @@ class TCISequenceSet extends TLeafSet {
|
|||
@Override
|
||||
public int accepts(int strIndex, CharSequence testString) {
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
if (string.charAt(i) != testString.charAt(strIndex + i) &&
|
||||
TPattern.getSupplement(string.charAt(i)) != testString.charAt(strIndex + i)) {
|
||||
if (string.charAt(i) != testString.charAt(strIndex + i)
|
||||
&& TPattern.getSupplement(string.charAt(i)) != testString.charAt(strIndex + i)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,22 +45,22 @@ import java.util.BitSet;
|
|||
*/
|
||||
class TCharClass extends TAbstractCharClass {
|
||||
// Flag indicates if we add supplement upper/lower case
|
||||
boolean ci = false;
|
||||
boolean ci;
|
||||
|
||||
boolean uci = false;
|
||||
boolean uci;
|
||||
|
||||
// Flag indicates if there are unicode supplements
|
||||
boolean hasUCI = false;
|
||||
boolean hasUCI;
|
||||
|
||||
boolean invertedSurrogates = false;
|
||||
boolean invertedSurrogates;
|
||||
|
||||
boolean inverted = false;
|
||||
boolean inverted;
|
||||
|
||||
boolean hideBits = false;
|
||||
boolean hideBits;
|
||||
|
||||
BitSet bits = new BitSet();
|
||||
|
||||
TAbstractCharClass nonBitSet = null;
|
||||
TAbstractCharClass nonBitSet;
|
||||
|
||||
public TCharClass() {
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
if (ci) {
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
|
||||
if (!inverted) {
|
||||
bits.set(TPattern.getSupplement((char)ch));
|
||||
bits.set(TPattern.getSupplement((char) ch));
|
||||
} else {
|
||||
bits.clear(TPattern.getSupplement((char)ch));
|
||||
bits.clear(TPattern.getSupplement((char) ch));
|
||||
}
|
||||
} else if (uci && ch > 128) {
|
||||
hasUCI = true;
|
||||
|
@ -104,8 +104,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
|
||||
if (!inverted) {
|
||||
bits.set(ch);
|
||||
} else
|
||||
} else {
|
||||
bits.clear(ch);
|
||||
}
|
||||
|
||||
if (!mayContainSupplCodepoints && Character.isSupplementaryCodePoint(ch)) {
|
||||
mayContainSupplCodepoints = true;
|
||||
|
@ -242,8 +243,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
}
|
||||
|
||||
public TCharClass add(int st, int end) {
|
||||
if (st > end)
|
||||
if (st > end) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (!ci
|
||||
|
||||
// no intersection with surrogate characters
|
||||
|
@ -268,8 +270,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
mayContainSupplCodepoints = true;
|
||||
}
|
||||
|
||||
if (clazz.hasUCI())
|
||||
if (clazz.hasUCI()) {
|
||||
this.hasUCI = true;
|
||||
}
|
||||
|
||||
if (altSurrogates ^ clazz.altSurrogates) {
|
||||
|
||||
|
@ -395,8 +398,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
mayContainSupplCodepoints = true;
|
||||
}
|
||||
|
||||
if (clazz.hasUCI())
|
||||
if (clazz.hasUCI()) {
|
||||
this.hasUCI = true;
|
||||
}
|
||||
|
||||
if (altSurrogates ^ clazz.altSurrogates) {
|
||||
|
||||
|
@ -538,8 +542,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
|
||||
@Override
|
||||
protected BitSet getBits() {
|
||||
if (hideBits)
|
||||
if (hideBits) {
|
||||
return null;
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
|
@ -568,8 +573,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
temp.append('|');
|
||||
}
|
||||
|
||||
if (temp.length() > 0)
|
||||
if (temp.length() > 0) {
|
||||
temp.deleteCharAt(temp.length() - 1);
|
||||
}
|
||||
|
||||
return temp.toString();
|
||||
}
|
||||
|
@ -590,8 +596,9 @@ class TCharClass extends TAbstractCharClass {
|
|||
temp.append('|');
|
||||
}
|
||||
|
||||
if (temp.length() > 0)
|
||||
if (temp.length() > 0) {
|
||||
temp.deleteCharAt(temp.length() - 1);
|
||||
}
|
||||
|
||||
return temp.toString();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*/
|
||||
class TCharSet extends TLeafSet {
|
||||
|
||||
private char ch = 0;
|
||||
private char ch;
|
||||
|
||||
public TCharSet(char ch) {
|
||||
this.ch = ch;
|
||||
|
@ -61,13 +61,14 @@ class TCharSet extends TLeafSet {
|
|||
@Override
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
while (strIndex < strLength) {
|
||||
strIndex = testStr.indexOf(ch, strIndex);
|
||||
if (strIndex < 0)
|
||||
if (strIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (next.matches(strIndex + 1, testString, matchResult) >= 0) {
|
||||
return strIndex;
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ class TCharSet extends TLeafSet {
|
|||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
|
||||
while (lastIndex >= strIndex) {
|
||||
lastIndex = testStr.lastIndexOf(ch, lastIndex);
|
||||
|
@ -116,11 +117,11 @@ class TCharSet extends TLeafSet {
|
|||
@Override
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return ((TCharSet)set).getChar() == ch;
|
||||
return ((TCharSet) set).getChar() == ch;
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return ((TRangeSet)set).accepts(0, Character.toString(ch)) > 0;
|
||||
return ((TRangeSet) set).accepts(0, Character.toString(ch)) > 0;
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return ((TSupplRangeSet)set).contains(ch);
|
||||
return ((TSupplRangeSet) set).contains(ch);
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*/
|
||||
class TCompositeGroupQuantifierSet extends TGroupQuantifierSet {
|
||||
|
||||
protected TQuantifier quantifier = null;
|
||||
protected TQuantifier quantifier;
|
||||
|
||||
int setCounter;
|
||||
|
||||
|
@ -57,8 +57,9 @@ class TCompositeGroupQuantifierSet extends TGroupQuantifierSet {
|
|||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int enterCounter = matchResult.getEnterCounter(setCounter);
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
if (!innerSet.hasConsumed(matchResult)) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
// can't go inner set;
|
||||
if (enterCounter >= quantifier.max()) {
|
||||
|
|
|
@ -42,7 +42,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*/
|
||||
class TCompositeQuantifierSet extends TLeafQuantifierSet {
|
||||
|
||||
protected TQuantifier quantifier = null;
|
||||
protected TQuantifier quantifier;
|
||||
|
||||
public TCompositeQuantifierSet(TQuantifier quant, TLeafSet innerSet, TAbstractSet next, int type) {
|
||||
super(innerSet, next, type);
|
||||
|
@ -71,8 +71,11 @@ class TCompositeQuantifierSet extends TLeafQuantifierSet {
|
|||
|
||||
for (; i < max; i++) {
|
||||
int shift;
|
||||
if (stringIndex + leaf.charCount() > matchResult.getRightBound() ||
|
||||
(shift = leaf.accepts(stringIndex, testString)) < 1) {
|
||||
if (stringIndex + leaf.charCount() > matchResult.getRightBound()) {
|
||||
break;
|
||||
}
|
||||
shift = leaf.accepts(stringIndex, testString);
|
||||
if (shift < 1) {
|
||||
break;
|
||||
}
|
||||
stringIndex += shift;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -32,7 +48,7 @@ class TDecomposedCharSet extends TJointSet {
|
|||
/**
|
||||
* UTF-16 encoding of decomposedChar
|
||||
*/
|
||||
private String decomposedCharUTF16 = null;
|
||||
private String decomposedCharUTF16;
|
||||
|
||||
/**
|
||||
* Decomposition of the Unicode codepoint
|
||||
|
@ -109,7 +125,7 @@ class TDecomposedCharSet extends TJointSet {
|
|||
* Read testString until we met a decomposed char boundary and
|
||||
* decompose obtained portion of testString
|
||||
*/
|
||||
while ((readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH)) {
|
||||
while (readCodePoints < TLexer.MAX_DECOMPOSITION_LENGTH) {
|
||||
|
||||
if (TLexer.hasDecompositionNonNullCanClass(curChar)) {
|
||||
|
||||
|
@ -214,8 +230,8 @@ class TDecomposedCharSet extends TJointSet {
|
|||
|
||||
@Override
|
||||
public boolean first(TAbstractSet set) {
|
||||
return (set instanceof TDecomposedCharSet) ? ((TDecomposedCharSet)set).getDecomposedChar().equals(
|
||||
getDecomposedChar()) : true;
|
||||
return !(set instanceof TDecomposedCharSet)
|
||||
|| ((TDecomposedCharSet) set).getDecomposedChar().equals(getDecomposedChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -30,8 +46,9 @@ class TEOISet extends TAbstractSet {
|
|||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int rightBound = matchResult.hasTransparentBounds() ? testString.length() : matchResult.getRightBound();
|
||||
if (stringIndex < rightBound)
|
||||
if (stringIndex < rightBound) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
matchResult.hitEnd = true;
|
||||
matchResult.requireEnd = true;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -42,17 +58,19 @@ final class TEOLSet extends TAbstractSet {
|
|||
}
|
||||
|
||||
// check final line terminator;
|
||||
if ((rightBound - strIndex) == 2 && testString.charAt(strIndex) == '\r' &&
|
||||
testString.charAt(strIndex + 1) == '\n') {
|
||||
if ((rightBound - strIndex) == 2 && testString.charAt(strIndex) == '\r'
|
||||
&& testString.charAt(strIndex + 1) == '\n') {
|
||||
matchResult.setConsumed(consCounter, 0);
|
||||
return next.matches(strIndex, testString, matchResult);
|
||||
}
|
||||
char ch;
|
||||
|
||||
if ((rightBound - strIndex) == 1 &&
|
||||
(((ch = testString.charAt(strIndex)) == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029'))) {
|
||||
matchResult.setConsumed(consCounter, 0);
|
||||
return next.matches(strIndex, testString, matchResult);
|
||||
if ((rightBound - strIndex) == 1) {
|
||||
ch = testString.charAt(strIndex);
|
||||
if (ch == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029') {
|
||||
matchResult.setConsumed(consCounter, 0);
|
||||
return next.matches(strIndex, testString, matchResult);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -60,8 +78,7 @@ final class TEOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
boolean res = matchResult.getConsumed(consCounter) != 0;
|
||||
matchResult.setConsumed(consCounter, -1);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -29,7 +45,7 @@ class TFSet extends TAbstractSet {
|
|||
|
||||
static PossessiveFSet posFSet = new PossessiveFSet();
|
||||
|
||||
boolean isBackReferenced = false;
|
||||
boolean isBackReferenced;
|
||||
|
||||
private int groupIndex;
|
||||
|
||||
|
@ -46,8 +62,9 @@ class TFSet extends TAbstractSet {
|
|||
* if(shift >=0 && matchResult.getEnd(groupIndex) == -1) {
|
||||
* matchResult.setEnd(groupIndex, stringIndex); }
|
||||
*/
|
||||
if (shift < 0)
|
||||
if (shift < 0) {
|
||||
matchResult.setEnd(groupIndex, end);
|
||||
}
|
||||
return shift;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -35,8 +51,10 @@ class TGroupQuantifierSet extends TQuantifierSet {
|
|||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
if (!innerSet.hasConsumed(matchResult)) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
int nextIndex = innerSet.matches(stringIndex, testString, matchResult);
|
||||
|
||||
if (nextIndex < 0) {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -31,7 +47,7 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
/**
|
||||
* String representing syllable
|
||||
*/
|
||||
private String decomposedCharUTF16 = null;
|
||||
private String decomposedCharUTF16;
|
||||
|
||||
/**
|
||||
* Length of useful part of decomposedChar decomposedCharLength <=
|
||||
|
@ -69,7 +85,10 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
* @return - string representation.
|
||||
*/
|
||||
private String getDecomposedChar() {
|
||||
return (decomposedCharUTF16 == null) ? (decomposedCharUTF16 = new String(decomposedChar)) : decomposedCharUTF16;
|
||||
if (decomposedCharUTF16 == null) {
|
||||
decomposedCharUTF16 = new String(decomposedChar);
|
||||
}
|
||||
return decomposedCharUTF16;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,7 +104,7 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
* equal Lexer.MAX_DECOMPOSITION_LENGTH
|
||||
*/
|
||||
int rightBound = matchResult.getRightBound();
|
||||
int SyllIndex = 0;
|
||||
int syllIndex = 0;
|
||||
int[] decompSyllable = new int[TLexer.MAX_HANGUL_DECOMPOSITION_LENGTH];
|
||||
int[] decompCurSymb;
|
||||
char curSymb;
|
||||
|
@ -95,9 +114,9 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
* http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf
|
||||
* "3.12 Conjoining Jamo Behavior"
|
||||
*/
|
||||
int LIndex = -1;
|
||||
int VIndex = -1;
|
||||
int TIndex = -1;
|
||||
int lIndex;
|
||||
int vIndex = -1;
|
||||
int tIndex = -1;
|
||||
|
||||
if (strIndex >= rightBound) {
|
||||
return -1;
|
||||
|
@ -111,10 +130,10 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
* We deal with ordinary letter or sequence of jamos at strIndex at
|
||||
* testString.
|
||||
*/
|
||||
decompSyllable[SyllIndex++] = curSymb;
|
||||
LIndex = curSymb - TLexer.LBase;
|
||||
decompSyllable[syllIndex++] = curSymb;
|
||||
lIndex = curSymb - TLexer.LBase;
|
||||
|
||||
if ((LIndex < 0) || (LIndex >= TLexer.LCount)) {
|
||||
if ((lIndex < 0) || (lIndex >= TLexer.LCount)) {
|
||||
|
||||
/*
|
||||
* Ordinary letter, that doesn't match this
|
||||
|
@ -124,10 +143,10 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
|
||||
if (strIndex < rightBound) {
|
||||
curSymb = testString.charAt(strIndex);
|
||||
VIndex = curSymb - TLexer.VBase;
|
||||
vIndex = curSymb - TLexer.VBase;
|
||||
}
|
||||
|
||||
if ((VIndex < 0) || (VIndex >= TLexer.VCount)) {
|
||||
if ((vIndex < 0) || (vIndex >= TLexer.VCount)) {
|
||||
|
||||
/*
|
||||
* Single L jamo doesn't compose Hangul syllable, so doesn't
|
||||
|
@ -136,30 +155,33 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
return -1;
|
||||
}
|
||||
strIndex++;
|
||||
decompSyllable[SyllIndex++] = curSymb;
|
||||
decompSyllable[syllIndex++] = curSymb;
|
||||
|
||||
if (strIndex < rightBound) {
|
||||
curSymb = testString.charAt(strIndex);
|
||||
TIndex = curSymb - TLexer.TBase;
|
||||
tIndex = curSymb - TLexer.TBase;
|
||||
}
|
||||
|
||||
if ((TIndex < 0) || (TIndex >= TLexer.TCount)) {
|
||||
if ((tIndex < 0) || (tIndex >= TLexer.TCount)) {
|
||||
|
||||
/*
|
||||
* We deal with LV syllable at testString, so compare it to this
|
||||
*/
|
||||
return ((decomposedCharLength == 2) && (decompSyllable[0] == decomposedChar[0]) && (decompSyllable[1] == decomposedChar[1])) ? next
|
||||
.matches(strIndex, testString, matchResult) : -1;
|
||||
return decomposedCharLength == 2 && decompSyllable[0] == decomposedChar[0]
|
||||
&& decompSyllable[1] == decomposedChar[1]
|
||||
? next.matches(strIndex, testString, matchResult)
|
||||
: -1;
|
||||
}
|
||||
strIndex++;
|
||||
decompSyllable[SyllIndex++] = curSymb;
|
||||
decompSyllable[syllIndex++] = curSymb;
|
||||
|
||||
/*
|
||||
* We deal with LVT syllable at testString, so compare it to this
|
||||
*/
|
||||
return ((decomposedCharLength == 3) && (decompSyllable[0] == decomposedChar[0]) &&
|
||||
(decompSyllable[1] == decomposedChar[1]) && (decompSyllable[2] == decomposedChar[2])) ? next
|
||||
.matches(strIndex, testString, matchResult) : -1;
|
||||
return decomposedCharLength == 3 && decompSyllable[0] == decomposedChar[0]
|
||||
&& decompSyllable[1] == decomposedChar[1] && decompSyllable[2] == decomposedChar[2]
|
||||
? next.matches(strIndex, testString, matchResult)
|
||||
: -1;
|
||||
} else {
|
||||
|
||||
/*
|
||||
|
@ -183,8 +205,8 @@ class THangulDecomposedCharSet extends TJointSet {
|
|||
|
||||
@Override
|
||||
public boolean first(TAbstractSet set) {
|
||||
return (set instanceof THangulDecomposedCharSet) ? ((THangulDecomposedCharSet)set).getDecomposedChar().equals(
|
||||
getDecomposedChar()) : true;
|
||||
return !(set instanceof THangulDecomposedCharSet)
|
||||
|| ((THangulDecomposedCharSet) set).getDecomposedChar().equals(getDecomposedChar());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -151,14 +167,15 @@ class THighSurrogateCharSet extends TJointSet {
|
|||
@Override
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
while (strIndex < strLength) {
|
||||
|
||||
strIndex = testStr.indexOf(high, strIndex);
|
||||
if (strIndex < 0)
|
||||
if (strIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strIndex + 1 < strLength) {
|
||||
|
||||
|
@ -187,7 +204,7 @@ class THighSurrogateCharSet extends TJointSet {
|
|||
@Override
|
||||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
while (lastIndex >= strIndex) {
|
||||
|
@ -243,7 +260,7 @@ class THighSurrogateCharSet extends TJointSet {
|
|||
} else if (set instanceof TLowSurrogateCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof THighSurrogateCharSet) {
|
||||
return ((THighSurrogateCharSet)set).high == this.high;
|
||||
return ((THighSurrogateCharSet) set).high == this.high;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -41,7 +57,7 @@ class TIntArrHash {
|
|||
int i = 0;
|
||||
int hashCode = key & mask;
|
||||
|
||||
for (; ; ) {
|
||||
while (true) {
|
||||
if (table[hashCode] == 0 // empty
|
||||
|| table[hashCode] == key) { // rewrite
|
||||
table[hashCode] = key;
|
||||
|
@ -61,7 +77,7 @@ class TIntArrHash {
|
|||
int i = 0;
|
||||
int storedKey;
|
||||
|
||||
for (; ; ) {
|
||||
while (true) {
|
||||
storedKey = table[hashCode];
|
||||
|
||||
if (storedKey == 0) { // empty
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -43,7 +59,7 @@ class TIntHash {
|
|||
int i = 0;
|
||||
int hashCode = key & mask;
|
||||
|
||||
for (; ; ) {
|
||||
while (true) {
|
||||
if (table[hashCode] == 0 // empty
|
||||
|| table[hashCode] == key) { // rewrite
|
||||
table[hashCode] = key;
|
||||
|
@ -63,7 +79,7 @@ class TIntHash {
|
|||
int i = 0;
|
||||
int storedKey;
|
||||
|
||||
for (; ; ) {
|
||||
while (true) {
|
||||
storedKey = table[hashCode];
|
||||
|
||||
if (storedKey == 0) { // empty
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -37,8 +53,11 @@ class TLeafQuantifierSet extends TQuantifierSet {
|
|||
int i = 0;
|
||||
int shift = 0;
|
||||
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
||||
(shift = leaf.accepts(stringIndex, testString)) > 0) {
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound()) {
|
||||
shift = leaf.accepts(stringIndex, testString);
|
||||
if (shift <= 0) {
|
||||
break;
|
||||
}
|
||||
stringIndex += shift;
|
||||
i++;
|
||||
}
|
||||
|
@ -67,9 +86,10 @@ class TLeafQuantifierSet extends TQuantifierSet {
|
|||
*/
|
||||
@Override
|
||||
public void setInnerSet(TAbstractSet innerSet) {
|
||||
if (!(innerSet instanceof TLeafSet))
|
||||
if (!(innerSet instanceof TLeafSet)) {
|
||||
throw new RuntimeException("");
|
||||
}
|
||||
super.setInnerSet(innerSet);
|
||||
this.leaf = (TLeafSet)innerSet;
|
||||
this.leaf = (TLeafSet) innerSet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -145,23 +161,23 @@ class TLexer {
|
|||
static final int NCount = 588;
|
||||
|
||||
// table that contains canonical decomposition mappings
|
||||
private static TIntArrHash decompTable = null;
|
||||
private static TIntArrHash decompTable;
|
||||
/*
|
||||
* Table that contains information about Unicode codepoints with single
|
||||
* codepoint decomposition
|
||||
*/
|
||||
private static TIntHash singleDecompTable = null;
|
||||
private static TIntHash singleDecompTable;
|
||||
|
||||
private static int singleDecompTableSize;
|
||||
|
||||
private char[] pattern = null;
|
||||
private char[] pattern;
|
||||
|
||||
private int flags = 0;
|
||||
private int flags;
|
||||
|
||||
private int mode = 1;
|
||||
|
||||
// when in literal mode, this field will save the previous one
|
||||
private int saved_mode = 0;
|
||||
private int savedMode;
|
||||
|
||||
// previous char read
|
||||
private int lookBack;
|
||||
|
@ -173,28 +189,28 @@ class TLexer {
|
|||
private int lookAhead;
|
||||
|
||||
// index of last char in pattern plus one
|
||||
private int patternFullLength = 0;
|
||||
private int patternFullLength;
|
||||
|
||||
// cur special token
|
||||
private TSpecialToken curST = null;
|
||||
private TSpecialToken curST;
|
||||
|
||||
// next special token
|
||||
private TSpecialToken lookAheadST = null;
|
||||
private TSpecialToken lookAheadST;
|
||||
|
||||
// cur char being processed
|
||||
private int index = 0;
|
||||
private int index;
|
||||
|
||||
// previous non-whitespace character index;
|
||||
private int prevNW = 0;
|
||||
private int prevNW;
|
||||
|
||||
// cur token start index
|
||||
private int curToc = 0;
|
||||
private int curToc;
|
||||
|
||||
// look ahead token index
|
||||
private int lookAheadToc = 0;
|
||||
private int lookAheadToc;
|
||||
|
||||
// original string representing pattern
|
||||
private String orig = null;
|
||||
private String orig;
|
||||
|
||||
public TLexer(String pattern, int flags) {
|
||||
orig = pattern;
|
||||
|
@ -353,7 +369,7 @@ class TLexer {
|
|||
|
||||
switch (lookAhead) {
|
||||
case 'E': {
|
||||
mode = saved_mode;
|
||||
mode = savedMode;
|
||||
|
||||
lookAhead = (index <= pattern.length - 2) ? nextCodePoint() : 0;
|
||||
break;
|
||||
|
@ -381,8 +397,9 @@ class TLexer {
|
|||
String cs = parseCharClassName();
|
||||
boolean negative = false;
|
||||
|
||||
if (lookAhead == 'P')
|
||||
if (lookAhead == 'P') {
|
||||
negative = true;
|
||||
}
|
||||
try {
|
||||
lookAheadST = TAbstractCharClass.getPredefinedClass(cs, negative);
|
||||
} catch (MissingResourceException mre) {
|
||||
|
@ -404,7 +421,7 @@ class TLexer {
|
|||
}
|
||||
|
||||
case 'Q': {
|
||||
saved_mode = mode;
|
||||
savedMode = mode;
|
||||
mode = TLexer.MODE_ESCAPE;
|
||||
reread = true;
|
||||
break;
|
||||
|
@ -476,7 +493,7 @@ class TLexer {
|
|||
if (index < pattern.length - 2) {
|
||||
|
||||
// need not care about supplementary codepoints here
|
||||
lookAhead = (pattern[nextIndex()] & 0x1f);
|
||||
lookAhead = pattern[nextIndex()] & 0x1f;
|
||||
break;
|
||||
} else {
|
||||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
|
@ -585,7 +602,7 @@ class TLexer {
|
|||
if (lookAhead >= 256) {
|
||||
|
||||
// Erase auxiliary bit
|
||||
lookAhead = (lookAhead & 0xff);
|
||||
lookAhead = lookAhead & 0xff;
|
||||
flags = lookAhead;
|
||||
lookAhead = lookAhead << 16;
|
||||
lookAhead = CHAR_FLAGS | lookAhead;
|
||||
|
@ -682,19 +699,26 @@ class TLexer {
|
|||
|
||||
nextIndex();
|
||||
char ch = 0;
|
||||
while (index < pattern.length - 2 && (ch = pattern[nextIndex()]) != '}') {
|
||||
while (index < pattern.length - 2) {
|
||||
ch = pattern[nextIndex()];
|
||||
if (ch == '}') {
|
||||
break;
|
||||
}
|
||||
sb.append(ch);
|
||||
}
|
||||
if (ch != '}')
|
||||
if (ch != '}') {
|
||||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.length() == 0)
|
||||
if (sb.length() == 0) {
|
||||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
}
|
||||
|
||||
String res = sb.toString();
|
||||
if (res.length() == 1)
|
||||
if (res.length() == 1) {
|
||||
return "Is" + res;
|
||||
}
|
||||
return (res.length() > 3 && (res.startsWith("Is") || res.startsWith("In"))) ? res.substring(2) : res;
|
||||
}
|
||||
|
||||
|
@ -705,7 +729,11 @@ class TLexer {
|
|||
StringBuilder sb = new StringBuilder(4);
|
||||
int min = -1;
|
||||
int max = Integer.MAX_VALUE;
|
||||
while (index < pattern.length && (ch = pattern[nextIndex()]) != '}') {
|
||||
while (index < pattern.length) {
|
||||
ch = pattern[nextIndex()];
|
||||
if (ch == '}') {
|
||||
break;
|
||||
}
|
||||
if (ch == ',' && min < 0) {
|
||||
try {
|
||||
min = Integer.parseInt(sb.toString(), 10);
|
||||
|
@ -714,7 +742,7 @@ class TLexer {
|
|||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
}
|
||||
} else {
|
||||
sb.append((char)ch);
|
||||
sb.append((char) ch);
|
||||
}
|
||||
}
|
||||
if (ch != '}') {
|
||||
|
@ -723,8 +751,9 @@ class TLexer {
|
|||
if (sb.length() > 0) {
|
||||
try {
|
||||
max = Integer.parseInt(sb.toString(), 10);
|
||||
if (min < 0)
|
||||
if (min < 0) {
|
||||
min = max;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
}
|
||||
|
@ -818,6 +847,7 @@ class TLexer {
|
|||
try {
|
||||
return Integer.parseInt(st.toString(), 16);
|
||||
} catch (NumberFormatException nfe) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,18 +864,24 @@ class TLexer {
|
|||
int res;
|
||||
int length = pattern.length - 2;
|
||||
|
||||
switch (first = Character.digit(pattern[index], 8)) {
|
||||
first = Character.digit(pattern[index], 8);
|
||||
switch (first) {
|
||||
case -1:
|
||||
throw new TPatternSyntaxException("", this.toString(), index);
|
||||
default: {
|
||||
if (first > 3)
|
||||
if (first > 3) {
|
||||
max--;
|
||||
}
|
||||
nextIndex();
|
||||
res = first;
|
||||
}
|
||||
}
|
||||
|
||||
while (i < max && index < length && (first = Character.digit(pattern[index], 8)) >= 0) {
|
||||
while (i < max && index < length) {
|
||||
first = Character.digit(pattern[index], 8);
|
||||
if (first < 0) {
|
||||
break;
|
||||
}
|
||||
res = res * 8 + first;
|
||||
nextIndex();
|
||||
i++;
|
||||
|
@ -938,19 +974,22 @@ class TLexer {
|
|||
int length = pattern.length - 2;
|
||||
index++;
|
||||
do {
|
||||
while (index < length && Character.isWhitespace(pattern[index]))
|
||||
while (index < length && Character.isWhitespace(pattern[index])) {
|
||||
index++;
|
||||
}
|
||||
if (index < length && pattern[index] == '#') {
|
||||
index++;
|
||||
while (index < length && !isLineSeparator(pattern[index]))
|
||||
while (index < length && !isLineSeparator(pattern[index])) {
|
||||
index++;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return index;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
private boolean isLineSeparator(int ch) {
|
||||
return (ch == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029');
|
||||
return ch == '\n' || ch == '\r' || ch == '\u0085' || (ch | 1) == '\u2029';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -975,21 +1014,21 @@ class TLexer {
|
|||
* @return canonical decomposition of ch.
|
||||
*/
|
||||
static int[] getHangulDecomposition(int ch) {
|
||||
int SIndex = ch - SBase;
|
||||
int sIndex = ch - SBase;
|
||||
|
||||
if (SIndex < 0 || SIndex >= SCount) {
|
||||
if (sIndex < 0 || sIndex >= SCount) {
|
||||
return null;
|
||||
} else {
|
||||
int L = LBase + SIndex / NCount;
|
||||
int V = VBase + (SIndex % NCount) / TCount;
|
||||
int T = SIndex % TCount;
|
||||
int decomp[];
|
||||
int l = LBase + sIndex / NCount;
|
||||
int v = VBase + (sIndex % NCount) / TCount;
|
||||
int t = sIndex % TCount;
|
||||
int[] decomp;
|
||||
|
||||
if (T == 0) {
|
||||
decomp = new int[] { L, V };
|
||||
if (t == 0) {
|
||||
decomp = new int[] { l, v };
|
||||
} else {
|
||||
T = TBase + T;
|
||||
decomp = new int[] { L, V, T };
|
||||
t = TBase + t;
|
||||
decomp = new int[] { l, v, t };
|
||||
}
|
||||
return decomp;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -89,7 +105,7 @@ class TLowHighSurrogateRangeSet extends TJointSet {
|
|||
|
||||
protected TAbstractCharClass surrChars;
|
||||
|
||||
protected boolean alt = false;
|
||||
protected boolean alt;
|
||||
|
||||
public TLowHighSurrogateRangeSet(TAbstractCharClass surrChars, TAbstractSet next) {
|
||||
this.surrChars = surrChars.getInstance();
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -149,15 +165,16 @@ class TLowSurrogateCharSet extends TJointSet {
|
|||
@Override
|
||||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
int startStr = matchResult.getLeftBound();
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
while (strIndex < strLength) {
|
||||
|
||||
strIndex = testStr.indexOf(low, strIndex);
|
||||
if (strIndex < 0)
|
||||
if (strIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strIndex > startStr) {
|
||||
|
||||
|
@ -187,7 +204,7 @@ class TLowSurrogateCharSet extends TJointSet {
|
|||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (testString instanceof String) {
|
||||
int startStr = matchResult.getLeftBound();
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
|
||||
while (lastIndex >= strIndex) {
|
||||
lastIndex = testStr.lastIndexOf(low, lastIndex);
|
||||
|
@ -242,7 +259,7 @@ class TLowSurrogateCharSet extends TJointSet {
|
|||
} else if (set instanceof THighSurrogateCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof TLowSurrogateCharSet) {
|
||||
return ((TLowSurrogateCharSet)set).low == this.low;
|
||||
return ((TLowSurrogateCharSet) set).low == this.low;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -30,17 +46,17 @@ import java.util.Arrays;
|
|||
*/
|
||||
class TMatchResultImpl implements TMatchResult {
|
||||
|
||||
private int[] groupBounds = null;
|
||||
private int[] groupBounds;
|
||||
|
||||
private int[] consumers = null;
|
||||
private int[] consumers;
|
||||
|
||||
private int[] compQuantCounters = null;
|
||||
private int[] compQuantCounters;
|
||||
|
||||
private CharSequence string = null;
|
||||
private CharSequence string;
|
||||
|
||||
private int groupCount = 0;
|
||||
private int groupCount;
|
||||
|
||||
private boolean valid = false;
|
||||
private boolean valid;
|
||||
|
||||
private int leftBound;
|
||||
|
||||
|
@ -48,13 +64,13 @@ class TMatchResultImpl implements TMatchResult {
|
|||
|
||||
int startIndex;
|
||||
|
||||
private boolean transparentBounds = false;
|
||||
private boolean transparentBounds;
|
||||
|
||||
private boolean anchoringBounds = false;
|
||||
private boolean anchoringBounds;
|
||||
|
||||
boolean hitEnd = false;
|
||||
boolean hitEnd;
|
||||
|
||||
boolean requireEnd = false;
|
||||
boolean requireEnd;
|
||||
|
||||
int previousMatch = -1;
|
||||
|
||||
|
@ -68,15 +84,16 @@ class TMatchResultImpl implements TMatchResult {
|
|||
this.consumers = new int[consumersCount];
|
||||
Arrays.fill(consumers, -1);
|
||||
|
||||
if (compQuantCount > 0)
|
||||
if (compQuantCount > 0) {
|
||||
this.compQuantCounters = new int[compQuantCount];
|
||||
}
|
||||
Arrays.fill(groupBounds, -1);
|
||||
reset(string, leftBound, rightBound);
|
||||
}
|
||||
|
||||
TMatchResult cloneImpl() {
|
||||
TMatchResultImpl res = new TMatchResultImpl(this.string, this.leftBound, this.rightBound, this.groupCount - 1, 0,
|
||||
0);
|
||||
TMatchResultImpl res = new TMatchResultImpl(this.string, this.leftBound, this.rightBound, this.groupCount - 1,
|
||||
0, 0);
|
||||
|
||||
res.valid = valid;
|
||||
if (valid) {
|
||||
|
@ -127,16 +144,18 @@ class TMatchResultImpl implements TMatchResult {
|
|||
|
||||
@Override
|
||||
public String group(int group) {
|
||||
if (start(group) < 0)
|
||||
if (start(group) < 0) {
|
||||
return null;
|
||||
}
|
||||
return string.subSequence(start(group), end(group)).toString();
|
||||
}
|
||||
|
||||
String getGroupNoCheck(int group) {
|
||||
int st = getStart(group);
|
||||
int end = getEnd(group);
|
||||
if ((end | st | (end - st)) < 0 || end > string.length())
|
||||
if ((end | st | (end - st)) < 0 || end > string.length()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return string.subSequence(st, end).toString();
|
||||
}
|
||||
|
@ -208,10 +227,12 @@ class TMatchResultImpl implements TMatchResult {
|
|||
Arrays.fill(groupBounds, -1);
|
||||
Arrays.fill(consumers, -1);
|
||||
|
||||
if (newSequence != null)
|
||||
if (newSequence != null) {
|
||||
this.string = newSequence;
|
||||
if (leftBound >= 0)
|
||||
}
|
||||
if (leftBound >= 0) {
|
||||
this.setBounds(leftBound, rightBound);
|
||||
}
|
||||
this.startIndex = this.leftBound;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -48,17 +64,17 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public final class TMatcher implements TMatchResult {
|
||||
|
||||
static int MODE_FIND = 1;
|
||||
static final int MODE_FIND = 1;
|
||||
|
||||
static int MODE_MATCH = 1 << 1;
|
||||
static final int MODE_MATCH = 1 << 1;
|
||||
|
||||
private TPattern pat = null;
|
||||
private TPattern pat;
|
||||
|
||||
private TAbstractSet start = null;
|
||||
private TAbstractSet start;
|
||||
|
||||
private CharSequence string = null;
|
||||
private CharSequence string;
|
||||
|
||||
private TMatchResultImpl matchResult = null;
|
||||
private TMatchResultImpl matchResult;
|
||||
|
||||
// bounds
|
||||
private int leftBound = -1;
|
||||
|
@ -66,13 +82,13 @@ public final class TMatcher implements TMatchResult {
|
|||
private int rightBound = -1;
|
||||
|
||||
// replacements
|
||||
private int appendPos = 0;
|
||||
private int appendPos;
|
||||
|
||||
private String replacement = null;
|
||||
private String replacement;
|
||||
|
||||
private String processedRepl = null;
|
||||
private String processedRepl;
|
||||
|
||||
private ArrayList<Object> replacementParts = null;
|
||||
private ArrayList<Object> replacementParts;
|
||||
|
||||
/**
|
||||
* Appends a literal part of the input plus a replacement for the current
|
||||
|
@ -379,15 +395,16 @@ public final class TMatcher implements TMatchResult {
|
|||
*/
|
||||
public boolean find() {
|
||||
int length = string.length();
|
||||
if (!hasTransparentBounds())
|
||||
if (!hasTransparentBounds()) {
|
||||
length = rightBound;
|
||||
}
|
||||
if (matchResult.startIndex >= 0 && matchResult.mode() == TMatcher.MODE_FIND) {
|
||||
matchResult.startIndex = matchResult.end();
|
||||
if (matchResult.end() == matchResult.start()) {
|
||||
matchResult.startIndex++;
|
||||
}
|
||||
|
||||
return matchResult.startIndex <= length ? find(matchResult.startIndex) : false;
|
||||
return matchResult.startIndex <= length && find(matchResult.startIndex);
|
||||
} else {
|
||||
return find(leftBound);
|
||||
}
|
||||
|
@ -447,15 +464,16 @@ public final class TMatcher implements TMatchResult {
|
|||
*/
|
||||
public static String quoteReplacement(String s) {
|
||||
// first check whether we have smth to quote
|
||||
if (s.indexOf('\\') < 0 && s.indexOf('$') < 0)
|
||||
if (s.indexOf('\\') < 0 && s.indexOf('$') < 0) {
|
||||
return s;
|
||||
}
|
||||
StringBuilder res = new StringBuilder(s.length() * 2);
|
||||
char ch;
|
||||
int len = s.length();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
switch (ch = s.charAt(i)) {
|
||||
ch = s.charAt(i);
|
||||
switch (ch) {
|
||||
case '$':
|
||||
res.append('\\');
|
||||
res.append('$');
|
||||
|
@ -680,7 +698,8 @@ public final class TMatcher implements TMatchResult {
|
|||
this.string = cs;
|
||||
this.leftBound = 0;
|
||||
this.rightBound = string.length();
|
||||
matchResult = new TMatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(), pat.consCount());
|
||||
matchResult = new TMatchResultImpl(cs, leftBound, rightBound, pat.groupCount(), pat.compCount(),
|
||||
pat.consCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -689,8 +708,9 @@ public final class TMatcher implements TMatchResult {
|
|||
try {
|
||||
lastMatch = Integer.toString(start());
|
||||
} catch (IllegalStateException e) {
|
||||
// do nothing
|
||||
}
|
||||
return "Regex[pattern=" + pat + " region=" + matchResult.getLeftBound() + "," + matchResult.getRightBound() +
|
||||
" lastmatch=" + lastMatch + "]";
|
||||
return "Regex[pattern=" + pat + " region=" + matchResult.getLeftBound() + "," + matchResult.getRightBound()
|
||||
+ " lastmatch=" + lastMatch + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -35,8 +51,9 @@ class TMultiLineEOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strDif = matchResult.hasAnchoringBounds() ? matchResult.getLeftBound() - strIndex : testString.length() -
|
||||
strIndex;
|
||||
int strDif = matchResult.hasAnchoringBounds()
|
||||
? matchResult.getLeftBound() - strIndex
|
||||
: testString.length() - strIndex;
|
||||
char ch1;
|
||||
char ch2;
|
||||
if (strDif == 0) {
|
||||
|
@ -75,8 +92,7 @@ class TMultiLineEOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
boolean res = matchResult.getConsumed(consCounter) != 0;
|
||||
matchResult.setConsumed(consCounter, -1);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -35,9 +51,9 @@ class TMultiLineSOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
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)))) {
|
||||
if (strIndex != matchResult.getRightBound()
|
||||
&& ((strIndex == 0 || (matchResult.hasAnchoringBounds() && strIndex == matchResult.getLeftBound()))
|
||||
|| lt.isAfterLineTerminator(testString.charAt(strIndex - 1), testString.charAt(strIndex)))) {
|
||||
return next.matches(strIndex, testString, matchResult);
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -42,8 +58,9 @@ class TNegativeLookAhead extends TAtomicJointSet {
|
|||
|
||||
for (int i = 0; i < size; i++) {
|
||||
TAbstractSet e = children.get(i);
|
||||
if (e.matches(stringIndex, testString, matchResult) >= 0)
|
||||
if (e.matches(stringIndex, testString, matchResult) >= 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -118,28 +134,28 @@ public final class TPattern implements Serializable {
|
|||
/**
|
||||
* Bit mask that includes all defined match flags
|
||||
*/
|
||||
static final int flagsBitMask = TPattern.UNIX_LINES | TPattern.CASE_INSENSITIVE | TPattern.COMMENTS |
|
||||
TPattern.MULTILINE | TPattern.LITERAL | TPattern.DOTALL | TPattern.UNICODE_CASE | TPattern.CANON_EQ;
|
||||
static final int flagsBitMask = TPattern.UNIX_LINES | TPattern.CASE_INSENSITIVE | TPattern.COMMENTS
|
||||
| TPattern.MULTILINE | TPattern.LITERAL | TPattern.DOTALL | TPattern.UNICODE_CASE | TPattern.CANON_EQ;
|
||||
|
||||
/**
|
||||
* Current <code>pattern</code> to be compiled;
|
||||
*/
|
||||
private transient TLexer lexemes = null;
|
||||
private transient TLexer lexemes;
|
||||
|
||||
/**
|
||||
* Pattern compile flags;
|
||||
*/
|
||||
private int flags = 0;
|
||||
private int flags;
|
||||
|
||||
/*
|
||||
* All backreferences that may be used in pattern.
|
||||
*/
|
||||
transient private TFSet backRefs[] = new TFSet[BACK_REF_NUMBER];
|
||||
transient private TFSet[] backRefs = new TFSet[BACK_REF_NUMBER];
|
||||
|
||||
/*
|
||||
* Is true if backreferenced sets replacement is needed
|
||||
*/
|
||||
transient private boolean needsBackRefReplacement = false;
|
||||
transient private boolean needsBackRefReplacement;
|
||||
|
||||
transient private int globalGroupIndex = -1;
|
||||
|
||||
|
@ -147,7 +163,7 @@ public final class TPattern implements Serializable {
|
|||
|
||||
transient private int consCount = -1;
|
||||
|
||||
transient TAbstractSet start = null;
|
||||
transient TAbstractSet start;
|
||||
|
||||
/**
|
||||
* Returns a {@link TMatcher} for the {@code Pattern} and a given input. The
|
||||
|
@ -332,12 +348,14 @@ public final class TPattern implements Serializable {
|
|||
*/
|
||||
private TAbstractSet processAlternations(TAbstractSet last) {
|
||||
TCharClass auxRange = new TCharClass(hasFlag(TPattern.CASE_INSENSITIVE), hasFlag(TPattern.UNICODE_CASE));
|
||||
while (!lexemes.isEmpty() &&
|
||||
lexemes.isLetter() &&
|
||||
(lexemes.lookAhead() == 0 || lexemes.lookAhead() == TLexer.CHAR_VERTICAL_BAR || lexemes.lookAhead() == TLexer.CHAR_RIGHT_PARENTHESIS)) {
|
||||
while (!lexemes.isEmpty()
|
||||
&& lexemes.isLetter()
|
||||
&& (lexemes.lookAhead() == 0 || lexemes.lookAhead() == TLexer.CHAR_VERTICAL_BAR
|
||||
|| lexemes.lookAhead() == TLexer.CHAR_RIGHT_PARENTHESIS)) {
|
||||
auxRange.add(lexemes.next());
|
||||
if (lexemes.peek() == TLexer.CHAR_VERTICAL_BAR)
|
||||
if (lexemes.peek() == TLexer.CHAR_VERTICAL_BAR) {
|
||||
lexemes.next();
|
||||
}
|
||||
}
|
||||
TAbstractSet rangeSet = processRangeSet(auxRange);
|
||||
rangeSet.setNext(last);
|
||||
|
@ -467,24 +485,24 @@ public final class TPattern implements Serializable {
|
|||
private TAbstractSet processSequence() {
|
||||
StringBuffer substring = new StringBuffer();
|
||||
|
||||
while (!lexemes.isEmpty() &&
|
||||
lexemes.isLetter() &&
|
||||
!lexemes.isHighSurrogate() &&
|
||||
!lexemes.isLowSurrogate() &&
|
||||
((!lexemes.isNextSpecial() && lexemes.lookAhead() == 0) // end
|
||||
while (!lexemes.isEmpty()
|
||||
&& lexemes.isLetter()
|
||||
&& !lexemes.isHighSurrogate()
|
||||
&& !lexemes.isLowSurrogate()
|
||||
&& ((!lexemes.isNextSpecial() && lexemes.lookAhead() == 0) // end
|
||||
// of
|
||||
// pattern
|
||||
||
|
||||
(!lexemes.isNextSpecial() && TLexer.isLetter(lexemes.lookAhead())) ||
|
||||
lexemes.lookAhead() == TLexer.CHAR_RIGHT_PARENTHESIS ||
|
||||
(lexemes.lookAhead() & 0x8000ffff) == TLexer.CHAR_LEFT_PARENTHESIS ||
|
||||
lexemes.lookAhead() == TLexer.CHAR_VERTICAL_BAR || lexemes.lookAhead() == TLexer.CHAR_DOLLAR)) {
|
||||
|| (!lexemes.isNextSpecial() && TLexer.isLetter(lexemes.lookAhead()))
|
||||
|| lexemes.lookAhead() == TLexer.CHAR_RIGHT_PARENTHESIS
|
||||
|| (lexemes.lookAhead() & 0x8000ffff) == TLexer.CHAR_LEFT_PARENTHESIS
|
||||
|| lexemes.lookAhead() == TLexer.CHAR_VERTICAL_BAR
|
||||
|| lexemes.lookAhead() == TLexer.CHAR_DOLLAR)) {
|
||||
int ch = lexemes.next();
|
||||
|
||||
if (Character.isSupplementaryCodePoint(ch)) {
|
||||
substring.append(Character.toChars(ch));
|
||||
} else {
|
||||
substring.append((char)ch);
|
||||
substring.append((char) ch);
|
||||
}
|
||||
}
|
||||
if (!hasFlag(TPattern.CASE_INSENSITIVE)) {
|
||||
|
@ -519,17 +537,17 @@ public final class TPattern implements Serializable {
|
|||
*/
|
||||
if ((curSymbIndex >= 0) && (curSymbIndex < TLexer.LCount)) {
|
||||
codePointsHangul = new char[TLexer.MAX_HANGUL_DECOMPOSITION_LENGTH];
|
||||
codePointsHangul[readCodePoints++] = (char)curSymb;
|
||||
codePointsHangul[readCodePoints++] = (char) curSymb;
|
||||
|
||||
curSymb = lexemes.peek();
|
||||
curSymbIndex = curSymb - TLexer.VBase;
|
||||
if ((curSymbIndex >= 0) && (curSymbIndex < TLexer.VCount)) {
|
||||
codePointsHangul[readCodePoints++] = (char)curSymb;
|
||||
codePointsHangul[readCodePoints++] = (char) curSymb;
|
||||
lexemes.next();
|
||||
curSymb = lexemes.peek();
|
||||
curSymbIndex = curSymb - TLexer.TBase;
|
||||
if ((curSymbIndex >= 0) && (curSymbIndex < TLexer.TCount)) {
|
||||
codePointsHangul[readCodePoints++] = (char)curSymb;
|
||||
codePointsHangul[readCodePoints++] = (char) curSymb;
|
||||
lexemes.next();
|
||||
|
||||
// LVT syllable
|
||||
|
@ -590,8 +608,8 @@ public final class TPattern implements Serializable {
|
|||
if (!lexemes.isEmpty()
|
||||
|
||||
/* && !pattern.isQuantifier() */
|
||||
&& (lexemes.peek() != TLexer.CHAR_RIGHT_PARENTHESIS || last instanceof TFinalSet) &&
|
||||
lexemes.peek() != TLexer.CHAR_VERTICAL_BAR && !lexemes.isLetter()) {
|
||||
&& (lexemes.peek() != TLexer.CHAR_RIGHT_PARENTHESIS || last instanceof TFinalSet)
|
||||
&& lexemes.peek() != TLexer.CHAR_VERTICAL_BAR && !lexemes.isLetter()) {
|
||||
cur = processQuantifier(last, cur);
|
||||
}
|
||||
} else if (lexemes.isHighSurrogate() || lexemes.isLowSurrogate()) {
|
||||
|
@ -613,23 +631,21 @@ public final class TPattern implements Serializable {
|
|||
|
||||
if (!lexemes.isEmpty()
|
||||
// && !pattern.isQuantifier()
|
||||
&&
|
||||
(lexemes.peek() != TLexer.CHAR_RIGHT_PARENTHESIS || last instanceof TFinalSet) &&
|
||||
lexemes.peek() != TLexer.CHAR_VERTICAL_BAR) {
|
||||
&& (lexemes.peek() != TLexer.CHAR_RIGHT_PARENTHESIS || last instanceof TFinalSet)
|
||||
&& lexemes.peek() != TLexer.CHAR_VERTICAL_BAR) {
|
||||
TAbstractSet next = processSubExpression(last);
|
||||
if (cur instanceof TLeafQuantifierSet
|
||||
// TODO create personal UnifiedQuantifierSet for composite
|
||||
// quantifiers
|
||||
// to take into account Quantifier counters
|
||||
// ////
|
||||
&&
|
||||
!(cur instanceof TCompositeQuantifierSet) &&
|
||||
!(cur instanceof TGroupQuantifierSet) &&
|
||||
!(cur instanceof TAltQuantifierSet) && !next.first(((TLeafQuantifierSet)cur).getInnerSet())) {
|
||||
cur = new TUnifiedQuantifierSet((TLeafQuantifierSet)cur);
|
||||
&& !(cur instanceof TCompositeQuantifierSet)
|
||||
&& !(cur instanceof TGroupQuantifierSet)
|
||||
&& !(cur instanceof TAltQuantifierSet) && !next.first(((TLeafQuantifierSet) cur).getInnerSet())) {
|
||||
cur = new TUnifiedQuantifierSet((TLeafQuantifierSet) cur);
|
||||
}
|
||||
if (((char)next.getType()) == '+') {
|
||||
cur.setNext(((TLeafQuantifierSet)next).getInnerSet());
|
||||
if (((char) next.getType()) == '+') {
|
||||
cur.setNext(((TLeafQuantifierSet) next).getInnerSet());
|
||||
} else {
|
||||
cur.setNext(next);
|
||||
}
|
||||
|
@ -639,8 +655,8 @@ public final class TPattern implements Serializable {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (((char)cur.getType()) == '+') {
|
||||
return ((TQuantifierSet)cur).getInnerSet();
|
||||
if (((char) cur.getType()) == '+') {
|
||||
return ((TQuantifierSet) cur).getInnerSet();
|
||||
} else {
|
||||
return cur;
|
||||
}
|
||||
|
@ -715,20 +731,20 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
case TLexer.QUANT_COMP: {
|
||||
TCompositeGroupQuantifierSet q = new TCompositeGroupQuantifierSet((TQuantifier)lexemes.nextSpecial(),
|
||||
term, last, TLexer.QUANT_ALT, ++compCount);
|
||||
TCompositeGroupQuantifierSet q = new TCompositeGroupQuantifierSet(
|
||||
(TQuantifier) lexemes.nextSpecial(), term, last, TLexer.QUANT_ALT, ++compCount);
|
||||
term.setNext(q);
|
||||
return q;
|
||||
}
|
||||
|
||||
case TLexer.QUANT_COMP_P: {
|
||||
return new TPosCompositeGroupQuantifierSet((TQuantifier)lexemes.nextSpecial(), term, last,
|
||||
return new TPosCompositeGroupQuantifierSet((TQuantifier) lexemes.nextSpecial(), term, last,
|
||||
TLexer.QUANT_ALT, ++compCount);
|
||||
}
|
||||
|
||||
case TLexer.QUANT_COMP_R: {
|
||||
TRelCompositeGroupQuantifierSet q = new TRelCompositeGroupQuantifierSet(
|
||||
(TQuantifier)lexemes.nextSpecial(), term, last, TLexer.QUANT_ALT, ++compCount);
|
||||
(TQuantifier) lexemes.nextSpecial(), term, last, TLexer.QUANT_ALT, ++compCount);
|
||||
term.setNext(q);
|
||||
return q;
|
||||
}
|
||||
|
@ -738,8 +754,9 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
} else {
|
||||
TLeafSet leaf = null;
|
||||
if (term != null)
|
||||
leaf = (TLeafSet)term;
|
||||
if (term != null) {
|
||||
leaf = (TLeafSet) term;
|
||||
}
|
||||
switch (quant) {
|
||||
case TLexer.QUANT_STAR:
|
||||
case TLexer.QUANT_PLUS: {
|
||||
|
@ -781,15 +798,16 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
case TLexer.QUANT_COMP: {
|
||||
return new TCompositeQuantifierSet((TQuantifier)lexemes.nextSpecial(), leaf, last, TLexer.QUANT_COMP);
|
||||
return new TCompositeQuantifierSet((TQuantifier) lexemes.nextSpecial(), leaf, last,
|
||||
TLexer.QUANT_COMP);
|
||||
}
|
||||
|
||||
case TLexer.QUANT_COMP_P: {
|
||||
return new TPossessiveCompositeQuantifierSet((TQuantifier)lexemes.nextSpecial(), leaf, last,
|
||||
return new TPossessiveCompositeQuantifierSet((TQuantifier) lexemes.nextSpecial(), leaf, last,
|
||||
TLexer.QUANT_COMP_P);
|
||||
}
|
||||
case TLexer.QUANT_COMP_R: {
|
||||
return new TReluctantCompositeQuantifierSet((TQuantifier)lexemes.nextSpecial(), leaf, last,
|
||||
return new TReluctantCompositeQuantifierSet((TQuantifier) lexemes.nextSpecial(), leaf, last,
|
||||
TLexer.QUANT_COMP_R);
|
||||
}
|
||||
|
||||
|
@ -822,7 +840,7 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
lexemes.next();
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
switch (ch) {
|
||||
case TLexer.CHAR_LEFT_SQUARE_BRACKET: {
|
||||
lexemes.next();
|
||||
|
@ -833,8 +851,9 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
term = processRange(negative, last);
|
||||
if (lexemes.peek() != TLexer.CHAR_RIGHT_SQUARE_BRACKET)
|
||||
if (lexemes.peek() != TLexer.CHAR_RIGHT_SQUARE_BRACKET) {
|
||||
throw new TPatternSyntaxException("", lexemes.toString(), lexemes.getIndex());
|
||||
}
|
||||
lexemes.setMode(TLexer.MODE_PATTERN);
|
||||
lexemes.next();
|
||||
break;
|
||||
|
@ -949,13 +968,13 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
case 0: {
|
||||
TAbstractCharClass cc = null;
|
||||
if ((cc = (TAbstractCharClass)lexemes.peekSpecial()) != null) {
|
||||
TAbstractCharClass cc = (TAbstractCharClass) lexemes.peekSpecial();
|
||||
if (cc != null) {
|
||||
term = processRangeSet(cc);
|
||||
} else if (!lexemes.isEmpty()) {
|
||||
|
||||
// ch == 0
|
||||
term = new TCharSet((char)ch);
|
||||
term = new TCharSet((char) ch);
|
||||
} else {
|
||||
term = new TEmptySet(last);
|
||||
break;
|
||||
|
@ -977,11 +996,14 @@ public final class TPattern implements Serializable {
|
|||
term = new TEmptySet(last);
|
||||
}
|
||||
} else {
|
||||
throw new TPatternSyntaxException((lexemes.isSpecial() ? lexemes.peekSpecial().toString()
|
||||
: Character.toString((char)ch)), lexemes.toString(), lexemes.getIndex());
|
||||
throw new TPatternSyntaxException(
|
||||
lexemes.isSpecial() ? lexemes.peekSpecial().toString()
|
||||
: Character.toString((char) ch),
|
||||
lexemes.toString(), lexemes.getIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (ch == TLexer.CHAR_FLAGS);
|
||||
return term;
|
||||
}
|
||||
|
@ -1004,12 +1026,17 @@ public final class TPattern implements Serializable {
|
|||
boolean notClosed = false;
|
||||
boolean firstInClass = true;
|
||||
|
||||
while (!lexemes.isEmpty() && (notClosed = (lexemes.peek()) != TLexer.CHAR_RIGHT_SQUARE_BRACKET || firstInClass)) {
|
||||
while (!lexemes.isEmpty()) {
|
||||
notClosed = lexemes.peek() != TLexer.CHAR_RIGHT_SQUARE_BRACKET || firstInClass;
|
||||
if (!notClosed) {
|
||||
break;
|
||||
}
|
||||
switch (lexemes.peek()) {
|
||||
|
||||
case TLexer.CHAR_RIGHT_SQUARE_BRACKET: {
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
}
|
||||
buffer = ']';
|
||||
lexemes.next();
|
||||
break;
|
||||
|
@ -1026,18 +1053,20 @@ public final class TPattern implements Serializable {
|
|||
negative = true;
|
||||
}
|
||||
|
||||
if (intersection)
|
||||
if (intersection) {
|
||||
res.intersection(processRangeExpression(negative));
|
||||
else
|
||||
} else {
|
||||
res.union(processRangeExpression(negative));
|
||||
}
|
||||
intersection = false;
|
||||
lexemes.next();
|
||||
break;
|
||||
}
|
||||
|
||||
case TLexer.CHAR_AMPERSAND: {
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
}
|
||||
buffer = lexemes.next();
|
||||
|
||||
/*
|
||||
|
@ -1075,11 +1104,12 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
case TLexer.CHAR_HYPHEN: {
|
||||
if (firstInClass || lexemes.lookAhead() == TLexer.CHAR_RIGHT_SQUARE_BRACKET ||
|
||||
lexemes.lookAhead() == TLexer.CHAR_LEFT_SQUARE_BRACKET || buffer < 0) {
|
||||
if (firstInClass || lexemes.lookAhead() == TLexer.CHAR_RIGHT_SQUARE_BRACKET
|
||||
|| lexemes.lookAhead() == TLexer.CHAR_LEFT_SQUARE_BRACKET || buffer < 0) {
|
||||
// treat hypen as normal character
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
}
|
||||
buffer = '-';
|
||||
lexemes.next();
|
||||
// range
|
||||
|
@ -1087,9 +1117,9 @@ public final class TPattern implements Serializable {
|
|||
lexemes.next();
|
||||
int cur = lexemes.peek();
|
||||
|
||||
if (!lexemes.isSpecial() &&
|
||||
(cur >= 0 || lexemes.lookAhead() == TLexer.CHAR_RIGHT_SQUARE_BRACKET ||
|
||||
lexemes.lookAhead() == TLexer.CHAR_LEFT_SQUARE_BRACKET || buffer < 0)) {
|
||||
if (!lexemes.isSpecial()
|
||||
&& (cur >= 0 || lexemes.lookAhead() == TLexer.CHAR_RIGHT_SQUARE_BRACKET
|
||||
|| lexemes.lookAhead() == TLexer.CHAR_LEFT_SQUARE_BRACKET || buffer < 0)) {
|
||||
|
||||
try {
|
||||
if (!TLexer.isLetter(cur)) {
|
||||
|
@ -1110,17 +1140,19 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
case TLexer.CHAR_CARET: {
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
}
|
||||
buffer = '^';
|
||||
lexemes.next();
|
||||
break;
|
||||
}
|
||||
|
||||
case 0: {
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
TAbstractCharClass cs = (TAbstractCharClass)lexemes.peekSpecial();
|
||||
}
|
||||
TAbstractCharClass cs = (TAbstractCharClass) lexemes.peekSpecial();
|
||||
if (cs != null) {
|
||||
res.add(cs);
|
||||
buffer = -1;
|
||||
|
@ -1133,8 +1165,9 @@ public final class TPattern implements Serializable {
|
|||
}
|
||||
|
||||
default: {
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
}
|
||||
buffer = lexemes.next();
|
||||
break;
|
||||
}
|
||||
|
@ -1145,8 +1178,9 @@ public final class TPattern implements Serializable {
|
|||
if (notClosed) {
|
||||
throw new TPatternSyntaxException("", pattern(), lexemes.getIndex() - 1);
|
||||
}
|
||||
if (buffer >= 0)
|
||||
if (buffer >= 0) {
|
||||
res.add(buffer);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1156,20 +1190,20 @@ public final class TPattern implements Serializable {
|
|||
if (hasFlag(TPattern.CASE_INSENSITIVE)) {
|
||||
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
|
||||
return new TCICharSet((char)ch);
|
||||
return new TCICharSet((char) ch);
|
||||
} else if (hasFlag(TPattern.UNICODE_CASE) && ch > 128) {
|
||||
if (isSupplCodePoint) {
|
||||
return new TUCISupplCharSet(ch);
|
||||
} else if (TLexer.isLowSurrogate(ch)) {
|
||||
|
||||
// we need no UCILowSurrogateCharSet
|
||||
return new TLowSurrogateCharSet((char)ch);
|
||||
return new TLowSurrogateCharSet((char) ch);
|
||||
} else if (TLexer.isHighSurrogate(ch)) {
|
||||
|
||||
// we need no UCIHighSurrogateCharSet
|
||||
return new THighSurrogateCharSet((char)ch);
|
||||
return new THighSurrogateCharSet((char) ch);
|
||||
} else {
|
||||
return new TUCICharSet((char)ch);
|
||||
return new TUCICharSet((char) ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1177,11 +1211,11 @@ public final class TPattern implements Serializable {
|
|||
if (isSupplCodePoint) {
|
||||
return new TSupplCharSet(ch);
|
||||
} else if (TLexer.isLowSurrogate(ch)) {
|
||||
return new TLowSurrogateCharSet((char)ch);
|
||||
return new TLowSurrogateCharSet((char) ch);
|
||||
} else if (TLexer.isHighSurrogate(ch)) {
|
||||
return new THighSurrogateCharSet((char)ch);
|
||||
return new THighSurrogateCharSet((char) ch);
|
||||
} else {
|
||||
return new TCharSet((char)ch);
|
||||
return new TCharSet((char) ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -39,7 +55,11 @@ class TPosCompositeGroupQuantifierSet extends TCompositeGroupQuantifierSet {
|
|||
int counter = 0;
|
||||
int max = quantifier.max();
|
||||
|
||||
while ((nextIndex = innerSet.matches(stringIndex, testString, matchResult)) > stringIndex && counter < max) {
|
||||
while (true) {
|
||||
nextIndex = innerSet.matches(stringIndex, testString, matchResult);
|
||||
if (nextIndex <= stringIndex || counter >= max) {
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
stringIndex = nextIndex;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -34,8 +50,8 @@ class TPosPlusGroupQuantifierSet extends TGroupQuantifierSet {
|
|||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int nextIndex;
|
||||
if ((nextIndex = innerSet.matches(stringIndex, testString, matchResult)) < 0) {
|
||||
int nextIndex = innerSet.matches(stringIndex, testString, matchResult);
|
||||
if (nextIndex < 0) {
|
||||
return -1;
|
||||
} else if (nextIndex > stringIndex) {
|
||||
stringIndex = nextIndex;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -34,9 +50,11 @@ class TPossessiveAltQuantifierSet extends TAltQuantifierSet {
|
|||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
|
||||
if (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
||||
(shift = leaf.accepts(stringIndex, testString)) >= 1) {
|
||||
stringIndex += shift;
|
||||
if (stringIndex + leaf.charCount() <= matchResult.getRightBound()) {
|
||||
shift = leaf.accepts(stringIndex, testString);
|
||||
if (shift >= 1) {
|
||||
stringIndex += shift;
|
||||
}
|
||||
}
|
||||
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -50,8 +66,11 @@ class TPossessiveCompositeQuantifierSet extends TCompositeQuantifierSet {
|
|||
|
||||
for (; i < max; i++) {
|
||||
int shift;
|
||||
if (stringIndex + leaf.charCount() > matchResult.getRightBound() ||
|
||||
(shift = leaf.accepts(stringIndex, testString)) < 1) {
|
||||
if (stringIndex + leaf.charCount() > matchResult.getRightBound()) {
|
||||
break;
|
||||
}
|
||||
shift = leaf.accepts(stringIndex, testString);
|
||||
if (shift < 1) {
|
||||
break;
|
||||
}
|
||||
stringIndex += shift;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -34,8 +50,11 @@ class TPossessiveQuantifierSet extends TLeafQuantifierSet {
|
|||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift = 0;
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
||||
(shift = leaf.accepts(stringIndex, testString)) >= 1) {
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound()) {
|
||||
shift = leaf.accepts(stringIndex, testString);
|
||||
if (shift < 1) {
|
||||
break;
|
||||
}
|
||||
stringIndex += shift;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -33,10 +49,11 @@ class TQuantifier extends TSpecialToken implements Cloneable {
|
|||
|
||||
private int max;
|
||||
|
||||
private int counter = 0;
|
||||
private int counter;
|
||||
|
||||
public TQuantifier(int min) {
|
||||
this.min = this.max = min;
|
||||
this.min = min;
|
||||
this.max = min;
|
||||
}
|
||||
|
||||
public TQuantifier(int min, int max) {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -118,7 +134,7 @@ abstract class TQuantifierSet extends TAbstractSet {
|
|||
/*
|
||||
* Add here code to do during the pass
|
||||
*/
|
||||
if (innerSet instanceof TSingleSet && ((TFSet)((TJointSet)innerSet).fSet).isBackReferenced) {
|
||||
if (innerSet instanceof TSingleSet && ((TFSet) ((TJointSet) innerSet).fSet).isBackReferenced) {
|
||||
innerSet = innerSet.next;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -30,7 +46,7 @@ class TRangeSet extends TLeafSet {
|
|||
|
||||
private TAbstractCharClass chars;
|
||||
|
||||
private boolean alt = false;
|
||||
private boolean alt;
|
||||
|
||||
public TRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
super(next);
|
||||
|
@ -56,11 +72,11 @@ class TRangeSet extends TLeafSet {
|
|||
@Override
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TCharSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TCharSet)set).getChar());
|
||||
return TAbstractCharClass.intersects(chars, ((TCharSet) set).getChar());
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TRangeSet)set).chars);
|
||||
return TAbstractCharClass.intersects(chars, ((TRangeSet) set).chars);
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplRangeSet)set).getChars());
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplRangeSet) set).getChars());
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -34,15 +50,12 @@ class TRelAltGroupQuantifierSet extends TAltGroupQuantifierSet {
|
|||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
if (!innerSet.hasConsumed(matchResult)) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
int nextIndex = next.matches(stringIndex, testString, matchResult);
|
||||
|
||||
if (nextIndex < 0) {
|
||||
return innerSet.matches(stringIndex, testString, matchResult);
|
||||
} else {
|
||||
return nextIndex;
|
||||
}
|
||||
return nextIndex < 0 ? innerSet.matches(stringIndex, testString, matchResult) : nextIndex;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -36,8 +52,9 @@ class TRelCompositeGroupQuantifierSet extends TCompositeGroupQuantifierSet {
|
|||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int enterCounter = matchResult.getEnterCounter(setCounter);
|
||||
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
if (!innerSet.hasConsumed(matchResult)) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
// can't go inner set;
|
||||
if (enterCounter >= quantifier.max()) {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -32,9 +48,9 @@ class TReluctantAltQuantifierSet extends TAltQuantifierSet {
|
|||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int shift;
|
||||
int shift = next.matches(stringIndex, testString, matchResult);
|
||||
|
||||
if ((shift = next.matches(stringIndex, testString, matchResult)) >= 0) {
|
||||
if (shift >= 0) {
|
||||
return shift;
|
||||
} else {
|
||||
return innerSet.matches(stringIndex, testString, matchResult);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -32,8 +48,9 @@ class TReluctantGroupQuantifierSet extends TGroupQuantifierSet {
|
|||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
if (!innerSet.hasConsumed(matchResult))
|
||||
if (!innerSet.hasConsumed(matchResult)) {
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
||||
int res = next.matches(stringIndex, testString, matchResult);
|
||||
if (res < 0) {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -36,7 +52,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*/
|
||||
class TSequenceSet extends TLeafSet {
|
||||
|
||||
private String string = null;
|
||||
private String string;
|
||||
|
||||
private IntHash leftToRight;
|
||||
|
||||
|
@ -68,10 +84,12 @@ class TSequenceSet extends TLeafSet {
|
|||
while (strIndex <= strLength) {
|
||||
strIndex = indexOf(testString, strIndex, strLength);
|
||||
|
||||
if (strIndex < 0)
|
||||
if (strIndex < 0) {
|
||||
return -1;
|
||||
if (next.matches(strIndex + charCount, testString, matchResult) >= 0)
|
||||
}
|
||||
if (next.matches(strIndex + charCount, testString, matchResult) >= 0) {
|
||||
return strIndex;
|
||||
}
|
||||
|
||||
strIndex++;
|
||||
}
|
||||
|
@ -86,10 +104,12 @@ class TSequenceSet extends TLeafSet {
|
|||
while (lastIndex >= strIndex) {
|
||||
lastIndex = lastIndexOf(testString, strIndex, lastIndex);
|
||||
|
||||
if (lastIndex < 0)
|
||||
if (lastIndex < 0) {
|
||||
return -1;
|
||||
if (next.matches(lastIndex + charCount, testString, matchResult) >= 0)
|
||||
}
|
||||
if (next.matches(lastIndex + charCount, testString, matchResult) >= 0) {
|
||||
return lastIndex;
|
||||
}
|
||||
|
||||
lastIndex--;
|
||||
}
|
||||
|
@ -112,12 +132,10 @@ class TSequenceSet extends TLeafSet {
|
|||
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 TSupplCharSet)) {
|
||||
return (string.length() > 1)
|
||||
? ((TSupplCharSet) set).getCodePoint()
|
||||
== Character.toCodePoint(string.charAt(0),
|
||||
string.charAt(1))
|
||||
: false;
|
||||
} else if (set instanceof TSupplCharSet) {
|
||||
return (string.length() > 1)
|
||||
&& ((TSupplCharSet) set).getCodePoint() == Character.toCodePoint(string.charAt(0),
|
||||
string.charAt(1));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -141,8 +159,8 @@ class TSequenceSet extends TLeafSet {
|
|||
protected int lastIndexOf(CharSequence str, int to, int from) {
|
||||
int first = string.charAt(0);
|
||||
int size = str.length();
|
||||
int delta;
|
||||
int i = ((delta = size - from - charCount) > 0) ? from : from + delta;
|
||||
int delta = size - from - charCount;
|
||||
int i = delta > 0 ? from : from + delta;
|
||||
|
||||
while (i >= to) {
|
||||
char ch = str.charAt(i);
|
||||
|
@ -157,14 +175,16 @@ class TSequenceSet extends TLeafSet {
|
|||
|
||||
protected boolean startsWith(CharSequence str, int from) {
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
if (str.charAt(i + from) != string.charAt(i))
|
||||
if (str.charAt(i + from) != string.charAt(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static class IntHash {
|
||||
int[] table, values;
|
||||
int[] table;
|
||||
int[] values;
|
||||
|
||||
int mask;
|
||||
|
||||
|
@ -186,7 +206,7 @@ class TSequenceSet extends TLeafSet {
|
|||
|
||||
for (;;) {
|
||||
if (table[hashCode] == 0 // empty
|
||||
|| table[hashCode] == key) {// rewrite
|
||||
|| table[hashCode] == key) { // rewrite
|
||||
table[hashCode] = key;
|
||||
values[hashCode] = value;
|
||||
return;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -50,16 +66,18 @@ class TSingleSet extends TJointSet {
|
|||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int res = kid.find(stringIndex, testString, matchResult);
|
||||
if (res >= 0)
|
||||
if (res >= 0) {
|
||||
matchResult.setStart(groupIndex, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findBack(int stringIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int res = kid.findBack(stringIndex, lastIndex, testString, matchResult);
|
||||
if (res >= 0)
|
||||
if (res >= 0) {
|
||||
matchResult.setStart(groupIndex, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -90,9 +106,9 @@ class TSupplCharSet extends TLeafSet {
|
|||
/*
|
||||
* UTF-16 encoding of this supplementary codepoint
|
||||
*/
|
||||
private char high = 0;
|
||||
private char high;
|
||||
|
||||
private char low = 0;
|
||||
private char low;
|
||||
|
||||
// int value of this supplementary codepoint
|
||||
private int ch;
|
||||
|
@ -121,13 +137,14 @@ class TSupplCharSet extends TLeafSet {
|
|||
public int find(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
int strLength = matchResult.getRightBound();
|
||||
|
||||
while (strIndex < strLength) {
|
||||
strIndex = testStr.indexOf(high, strIndex);
|
||||
if (strIndex < 0)
|
||||
if (strIndex < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
strIndex++;
|
||||
if (strIndex < strLength) {
|
||||
|
@ -149,7 +166,7 @@ class TSupplCharSet extends TLeafSet {
|
|||
public int findBack(int strIndex, int lastIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
|
||||
if (testString instanceof String) {
|
||||
String testStr = (String)testString;
|
||||
String testStr = (String) testString;
|
||||
|
||||
while (lastIndex >= strIndex) {
|
||||
lastIndex = testStr.lastIndexOf(low, lastIndex);
|
||||
|
@ -182,9 +199,9 @@ class TSupplCharSet extends TLeafSet {
|
|||
@Override
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TSupplCharSet) {
|
||||
return ((TSupplCharSet)set).getCodePoint() == ch;
|
||||
return ((TSupplCharSet) set).getCodePoint() == ch;
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return ((TSupplRangeSet)set).contains(ch);
|
||||
return ((TSupplRangeSet) set).contains(ch);
|
||||
} else if (set instanceof TCharSet) {
|
||||
return false;
|
||||
} else if (set instanceof TRangeSet) {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2015 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -91,7 +107,7 @@ class TSupplRangeSet extends TJointSet {
|
|||
|
||||
protected TAbstractCharClass chars;
|
||||
|
||||
protected boolean alt = false;
|
||||
protected boolean alt;
|
||||
|
||||
public TSupplRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
this.chars = cs.getInstance();
|
||||
|
@ -112,8 +128,11 @@ class TSupplRangeSet extends TJointSet {
|
|||
if (stringIndex < strLength) {
|
||||
char high = testString.charAt(stringIndex++);
|
||||
|
||||
if (contains(high) && (offset = next.matches(stringIndex, testString, matchResult)) > 0) {
|
||||
return offset;
|
||||
if (contains(high)) {
|
||||
offset = next.matches(stringIndex, testString, matchResult);
|
||||
if (offset > 0) {
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
|
||||
if (stringIndex < strLength) {
|
||||
|
@ -140,13 +159,13 @@ class TSupplRangeSet extends TJointSet {
|
|||
@Override
|
||||
public boolean first(TAbstractSet set) {
|
||||
if (set instanceof TSupplCharSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplCharSet)set).getCodePoint());
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplCharSet) set).getCodePoint());
|
||||
} else if (set instanceof TCharSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TCharSet)set).getChar());
|
||||
return TAbstractCharClass.intersects(chars, ((TCharSet) set).getChar());
|
||||
} else if (set instanceof TSupplRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplRangeSet)set).chars);
|
||||
return TAbstractCharClass.intersects(chars, ((TSupplRangeSet) set).chars);
|
||||
} else if (set instanceof TRangeSet) {
|
||||
return TAbstractCharClass.intersects(chars, ((TRangeSet)set).getChars());
|
||||
return TAbstractCharClass.intersects(chars, ((TRangeSet) set).getChars());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -37,8 +53,9 @@ class TUCIBackReferenceSet extends TCIBackReferenceSet {
|
|||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
String group = getString(matchResult);
|
||||
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound())
|
||||
if (group == null || (stringIndex + group.length()) > matchResult.getRightBound()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < group.length(); i++) {
|
||||
if (Character.toLowerCase(Character.toUpperCase(group.charAt(i))) != Character.toLowerCase(Character
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -24,7 +40,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
* CANON_EQ flag of Pattern class
|
||||
* is specified.
|
||||
*/
|
||||
class TUCIDecomposedCharSet extends TDecomposedCharSet{
|
||||
class TUCIDecomposedCharSet extends TDecomposedCharSet {
|
||||
|
||||
/*
|
||||
* Just only a stub
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -31,7 +47,7 @@ class TUCIRangeSet extends TLeafSet {
|
|||
|
||||
private TAbstractCharClass chars;
|
||||
|
||||
private boolean alt = false;
|
||||
private boolean alt;
|
||||
|
||||
public TUCIRangeSet(TAbstractCharClass cs, TAbstractSet next) {
|
||||
super(next);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -27,7 +43,7 @@ package org.teavm.classlib.java.util.regex;
|
|||
*/
|
||||
class TUCISequenceSet extends TLeafSet {
|
||||
|
||||
private String string = null;
|
||||
private String string;
|
||||
|
||||
TUCISequenceSet(StringBuffer substring) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -53,8 +69,7 @@ final class TUEOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
boolean res = matchResult.getConsumed(consCounter) != 0;
|
||||
matchResult.setConsumed(consCounter, -1);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -35,8 +51,9 @@ class TUMultiLineEOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
public int matches(int strIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int strDif = matchResult.hasAnchoringBounds() ? matchResult.getRightBound() - strIndex : testString.length() -
|
||||
strIndex;
|
||||
int strDif = matchResult.hasAnchoringBounds()
|
||||
? matchResult.getRightBound() - strIndex
|
||||
: testString.length() - strIndex;
|
||||
if (strDif <= 0) {
|
||||
matchResult.setConsumed(consCounter, 0);
|
||||
return next.matches(strIndex, testString, matchResult);
|
||||
|
@ -49,8 +66,7 @@ class TUMultiLineEOLSet extends TAbstractSet {
|
|||
|
||||
@Override
|
||||
public boolean hasConsumed(TMatchResultImpl matchResult) {
|
||||
int cons;
|
||||
boolean res = ((cons = matchResult.getConsumed(consCounter)) < 0 || cons > 0);
|
||||
boolean res = matchResult.getConsumed(consCounter) != 0;
|
||||
matchResult.setConsumed(consCounter, -1);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -33,16 +49,17 @@ class TUnifiedQuantifierSet extends TLeafQuantifierSet {
|
|||
}
|
||||
|
||||
public TUnifiedQuantifierSet(TLeafQuantifierSet quant) {
|
||||
super((TLeafSet)quant.getInnerSet(), quant.getNext(), quant.getType());
|
||||
super((TLeafSet) quant.getInnerSet(), quant.getNext(), quant.getType());
|
||||
innerSet.setNext(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int matches(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound() &&
|
||||
leaf.accepts(stringIndex, testString) > 0)
|
||||
while (stringIndex + leaf.charCount() <= matchResult.getRightBound()
|
||||
&& leaf.accepts(stringIndex, testString) > 0) {
|
||||
stringIndex += leaf.charCount();
|
||||
}
|
||||
|
||||
return next.matches(stringIndex, testString, matchResult);
|
||||
}
|
||||
|
@ -50,8 +67,9 @@ class TUnifiedQuantifierSet extends TLeafQuantifierSet {
|
|||
@Override
|
||||
public int find(int stringIndex, CharSequence testString, TMatchResultImpl matchResult) {
|
||||
int startSearch = next.find(stringIndex, testString, matchResult);
|
||||
if (startSearch < 0)
|
||||
if (startSearch < 0) {
|
||||
return -1;
|
||||
}
|
||||
int newSearch = startSearch - leaf.charCount();
|
||||
while (newSearch >= stringIndex && leaf.accepts(newSearch, testString) > 0) {
|
||||
startSearch = newSearch;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright 2017 Alexey Andreev.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
|
@ -64,15 +80,18 @@ class TWordBoundary extends TAbstractSet {
|
|||
}
|
||||
|
||||
private boolean isSpace(char ch, int index, int leftBound, CharSequence testString) {
|
||||
if (Character.isLetterOrDigit(ch) || ch == '_')
|
||||
if (Character.isLetterOrDigit(ch) || ch == '_') {
|
||||
return false;
|
||||
}
|
||||
if (Character.getType(ch) == Character.NON_SPACING_MARK) {
|
||||
for (; --index >= leftBound;) {
|
||||
ch = testString.charAt(index);
|
||||
if (Character.isLetterOrDigit(ch))
|
||||
if (Character.isLetterOrDigit(ch)) {
|
||||
return false;
|
||||
if (Character.getType(ch) != Character.NON_SPACING_MARK)
|
||||
}
|
||||
if (Character.getType(ch) != Character.NON_SPACING_MARK) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user