|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.regexp.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.
RE
,
recompile
Nested Class Summary | |
(package private) class |
RECompiler.RERange
Local, nested class for maintaining character ranges for character classes. |
Field Summary | |
(package private) int[] |
bracketEnd
|
(package private) int[] |
bracketMin
|
(package private) int[] |
bracketOpt
|
(package private) int |
brackets
|
(package private) int[] |
bracketStart
|
(package private) static int |
bracketUnbounded
|
(package private) static int |
ESC_BACKREF
|
(package private) static int |
ESC_CLASS
|
(package private) static int |
ESC_COMPLEX
|
(package private) static int |
ESC_MASK
|
(package private) static java.util.Hashtable |
hashPOSIX
|
(package private) int |
idx
|
(package private) char[] |
instruction
|
(package private) int |
len
|
(package private) int |
lenInstruction
|
(package private) int |
maxBrackets
|
(package private) static int |
NODE_NORMAL
|
(package private) static int |
NODE_NULLABLE
|
(package private) static int |
NODE_TOPLEVEL
|
(package private) int |
parens
|
(package private) java.lang.String |
pattern
|
Constructor Summary | |
RECompiler()
Constructor. |
Method Summary | |
(package private) void |
allocBrackets()
Allocate storage for brackets only as needed |
(package private) int |
atom()
Absorb an atomic character string. |
(package private) void |
bracket()
Match bracket {m,n} expression put results in bracket member variables |
(package private) int |
branch(int[] flags)
Compile one branch of an or operator (implements concatenation) |
(package private) int |
characterClass()
Compile a character class |
(package private) int |
closure(int[] flags)
Compile a possibly closured terminal |
REProgram |
compile(java.lang.String pattern)
Compiles a regular expression pattern into a program runnable by the pattern matcher class 'RE'. |
(package private) void |
emit(char c)
Emit a single character into the program stream. |
(package private) void |
ensure(int n)
Ensures that n more characters can fit in the program buffer. |
(package private) int |
escape()
Match an escape sequence. |
(package private) int |
expr(int[] flags)
Compile an expression with possible parens around it. |
(package private) void |
internalError()
Throws a new internal error exception |
(package private) int |
node(char opcode,
int opdata)
Adds a new node |
(package private) void |
nodeInsert(char opcode,
int opdata,
int insertAt)
Inserts a node with a given opcode and opdata at insertAt. |
(package private) void |
reallocBrackets()
Enlarge storage for brackets only as needed. |
(package private) void |
setNextOfEnd(int node,
int pointTo)
Appends a node to the end of a node chain |
(package private) void |
syntaxError(java.lang.String s)
Throws a new syntax error exception |
(package private) int |
terminal(int[] flags)
Match a terminal node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
char[] instruction
int lenInstruction
java.lang.String pattern
int len
int idx
int parens
static final int NODE_NORMAL
static final int NODE_NULLABLE
static final int NODE_TOPLEVEL
static final int ESC_MASK
static final int ESC_BACKREF
static final int ESC_COMPLEX
static final int ESC_CLASS
int maxBrackets
static final int bracketUnbounded
int brackets
int[] bracketStart
int[] bracketEnd
int[] bracketMin
int[] bracketOpt
static java.util.Hashtable hashPOSIX
Constructor Detail |
public RECompiler()
Method Detail |
void ensure(int n)
n
- Number of additional characters to ensure will fit.void emit(char c)
c
- Character to addvoid nodeInsert(char opcode, int opdata, int insertAt)
opcode
- Opcode for new nodeopdata
- Opdata for new node (only the low 16 bits are currently used)insertAt
- Index at which to insert the new node in the programvoid setNextOfEnd(int node, int pointTo)
node
- Start of node chain to traversepointTo
- Node to have the tail of the chain point toint node(char opcode, int opdata)
opcode
- Opcode for nodeopdata
- Opdata for node (only the low 16 bits are currently used)
void internalError() throws java.lang.Error
java.lang.Error
- Thrown in the event of an internal error.void syntaxError(java.lang.String s) throws RESyntaxException
RESyntaxException
- Thrown if the regular expression has invalid syntax.void allocBrackets()
void reallocBrackets()
void bracket() throws RESyntaxException
RESyntaxException
- Thrown if the regular expression has invalid syntax.int escape() throws RESyntaxException
RESyntaxException
- Thrown if the regular expression has invalid syntax.int characterClass() throws RESyntaxException
RESyntaxException
- Thrown if the regular expression has invalid syntax.int atom() throws RESyntaxException
RESyntaxException
- Thrown if the regular expression has invalid syntax.int terminal(int[] flags) throws RESyntaxException
flags
- Flags
RESyntaxException
- Thrown if the regular expression has invalid syntax.int closure(int[] flags) throws RESyntaxException
flags
- Flags passed by reference
RESyntaxException
- Thrown if the regular expression has invalid syntax.int branch(int[] flags) throws RESyntaxException
flags
- Flags passed by reference
RESyntaxException
- Thrown if the regular expression has invalid syntax.int expr(int[] flags) throws RESyntaxException
flags
- Flag value passed by reference
RESyntaxException
- Thrown if the regular expression has invalid syntax.public REProgram compile(java.lang.String pattern) throws RESyntaxException
pattern
- Regular expression pattern to compile (see RECompiler class
for details).
RESyntaxException
- Thrown if the regular expression has invalid syntax.RECompiler
,
RE
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |