Package net.sf.saxon.regex
Class RECompiler
java.lang.Object
net.sf.saxon.regex.RECompiler
A regular expression compiler class. This class compiles a pattern string into a
regular expression program interpretable by the RE evaluator class. The 'recompile'
command line tool uses this compiler to pre-compile regular expressions for use
with RE. For a description of the syntax accepted by RECompiler and what you can
do with regular expressions, see the documentation for the RE matcher class.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompile
(UnicodeString pattern) Compiles a regular expression pattern into a program runnable by the pattern matcher class 'RE'.On completion of compilation, get any warnings that were generatedstatic CharacterClass
Make the complement of an IntPredicate (matches if p1 does not match)static CharacterClass
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)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.void
Set the regular expression flags to be used
-
Constructor Details
-
RECompiler
public RECompiler()Constructor. Creates (initially empty) storage for a regular expression program.
-
-
Method Details
-
setFlags
Set the regular expression flags to be used- Parameters:
flags
- the regular expression flags
-
getWarnings
On completion of compilation, get any warnings that were generated- Returns:
- the list of warning messages
-
makeUnion
Make the union of two IntPredicates (matches if p1 matches or p2 matches)- Parameters:
p1
- the firstp2
- the second- Returns:
- the result
-
makeDifference
Make the difference of two IntPredicates (matches if p1 matches and p2 does not match)- Parameters:
p1
- the firstp2
- the second- Returns:
- the result
-
makeComplement
Make the complement of an IntPredicate (matches if p1 does not match)- Parameters:
p1
- the operand- Returns:
- the result
-
compile
Compiles a regular expression pattern into a program runnable by the pattern matcher class 'RE'.- Parameters:
pattern
- Regular expression pattern to compile (see RECompiler class for details).- Returns:
- A compiled regular expression program.
- Throws:
RESyntaxException
- Thrown if the regular expression has invalid syntax.- See Also:
-
noAmbiguity
public 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. (This is for optimization, so it does not have to detect all cases; but if it returns true, then the result must be dependable.)- Parameters:
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- Returns:
- true if it can be established that there is no input sequence that will match both instructions
-