public class RECompiler extends Object
REMatcher| Modifier and Type | Class and Description |
|---|---|
(package private) class |
RECompiler.BackReference
For convenience a back-reference is treated as an CharacterClass, although this a fiction
|
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
bracketMax |
(package private) int |
bracketMin |
(package private) IntHashSet |
captures |
(package private) int |
capturingOpenParenCount |
(package private) boolean |
hasBackReferences |
(package private) int |
idx |
(package private) boolean |
isXPath |
(package private) boolean |
isXPath30 |
(package private) boolean |
isXSD11 |
(package private) int |
len |
(package private) static int |
NODE_NORMAL |
(package private) static int |
NODE_TOPLEVEL |
(package private) UnicodeString |
pattern |
(package private) REFlags |
reFlags |
(package private) List<String> |
warnings |
| Constructor and Description |
|---|
RECompiler()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
bracket()
Match bracket {m,n} expression, putting the results in bracket member variables
|
REProgram |
compile(UnicodeString pattern)
Compiles a regular expression pattern into a program runnable by the pattern
matcher class 'RE'.
|
(package private) CharacterClass |
escape(boolean inSquareBrackets)
Match an escape sequence.
|
List<String> |
getWarnings()
On completion of compilation, get any warnings that were generated
|
(package private) void |
internalError()
Throws a new internal error exception
|
static CharacterClass |
makeComplement(CharacterClass p1)
Make the complement of an IntPredicate (matches if p1 does not match)
|
static CharacterClass |
makeDifference(CharacterClass p1,
CharacterClass p2)
Make the difference of two IntPredicates (matches if p1 matches and p2 does not match)
|
static CharacterClass |
makeUnion(CharacterClass p1,
CharacterClass p2)
Make the union of two IntPredicates (matches if p1 matches or p2 matches)
|
(package private) static boolean |
noAmbiguity(Operation op0,
Operation op1,
boolean caseBlind,
boolean reluctant)
Determine that there is no ambiguity between two branches, that is, if one of them matches then the
other cannot possibly match.
|
(package private) Operation |
parseAtom()
Absorb an atomic character string.
|
(package private) Operation |
parseBranch()
Compile body of one branch of an or operator (implements concatenation)
|
(package private) CharacterClass |
parseCharacterClass()
Compile a character class (in square brackets)
|
(package private) Operation |
parseTerminal(int[] flags)
Match a terminal symbol.
|
(package private) Operation |
piece(int[] flags)
Compile a piece consisting of an atom and optional quantifier
|
void |
setFlags(REFlags flags)
Set the regular expression flags to be used
|
(package private) void |
syntaxError(String s)
Throws a new syntax error exception
|
(package private) static Operation |
trace(Operation base)
Optionally add trace code around an operation
|
UnicodeString pattern
int len
int idx
int capturingOpenParenCount
static final int NODE_NORMAL
static final int NODE_TOPLEVEL
int bracketMin
int bracketMax
boolean isXPath
boolean isXPath30
boolean isXSD11
IntHashSet captures
boolean hasBackReferences
REFlags reFlags
public RECompiler()
public void setFlags(REFlags flags)
flags - the regular expression flagspublic List<String> getWarnings()
void internalError()
throws Error
Error - Thrown in the event of an internal error.void syntaxError(String s) throws RESyntaxException
s - the error messageRESyntaxException - Thrown if the regular expression has invalid syntax.static Operation trace(Operation base)
base - the operation to which trace code is to be addedvoid bracket()
throws RESyntaxException
RESyntaxException - Thrown if the regular expression has invalid syntax.CharacterClass escape(boolean inSquareBrackets) throws RESyntaxException
inSquareBrackets - true if the escape sequence is within square bracketsRESyntaxException - Thrown if the regular expression has invalid syntax.CharacterClass parseCharacterClass() throws RESyntaxException
RESyntaxException - Thrown if the regular expression has invalid syntax.public static CharacterClass makeUnion(CharacterClass p1, CharacterClass p2)
p1 - the firstp2 - the secondpublic static CharacterClass makeDifference(CharacterClass p1, CharacterClass p2)
p1 - the firstp2 - the secondpublic static CharacterClass makeComplement(CharacterClass p1)
p1 - the operandOperation parseAtom() throws RESyntaxException
RESyntaxException - Thrown if the regular expression has invalid syntax.Operation parseTerminal(int[] flags) throws RESyntaxException
flags - FlagsRESyntaxException - Thrown if the regular expression has invalid syntax.Operation piece(int[] flags) throws RESyntaxException
flags - Flags passed by referenceRESyntaxException - Thrown if the regular expression has invalid syntax.Operation parseBranch() throws RESyntaxException
RESyntaxException - Thrown if the regular expression has invalid syntax.public REProgram compile(UnicodeString pattern) throws RESyntaxException
pattern - Regular expression pattern to compile (see RECompiler class
for details).RESyntaxException - Thrown if the regular expression has invalid syntax.RECompiler,
REMatcherstatic boolean noAmbiguity(Operation op0, Operation op1, boolean caseBlind, boolean reluctant)
op0 - the first branchop1 - the second branchcaseBlind - true if the "i" flag is in forcereluctant - true if the first branch is a repeat branch with a reluctant quantifier