| |
|
| java.lang.Object org.apache.regexp.RECompiler
All known Subclasses: org.apache.regexp.REDebugCompiler,
RECompiler | public class RECompiler (Code) | | 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: RE See Also: recompile author: Jonathan Locke version: $Id: RECompiler.java,v 1.1.1.1 2002/01/31 03:14:36 rcm Exp $ |
Inner Class :class RERange | |
Constructor Summary | |
public | RECompiler() Constructor. |
Method Summary | |
void | allocBrackets() | int | atom() Absorb an atomic character string. | void | bracket() | int | branch(int[] flags) | int | characterClass() | int | closure(int[] flags) | public REProgram | compile(String pattern) Compiles a regular expression pattern into a program runnable by the pattern
matcher class 'RE'.
Parameters: pattern - Regular expression pattern to compile (see RECompiler classfor details). | void | emit(char c) Emit a single character into the program stream. | void | ensure(int n) Ensures that n more characters can fit in the program buffer. | char | escape() Match an escape sequence. | int | expr(int[] flags) Compile an expression with possible parens around it. | void | internalError() | int | node(char opcode, int opdata) | void | nodeInsert(char opcode, int opdata, int insertAt) Inserts a node with a given opcode and opdata at insertAt. | void | setNextOfEnd(int node, int pointTo) | void | syntaxError(String s) | int | terminal(int[] flags) Match a terminal node. |
ESC_BACKREF | final static char ESC_BACKREF(Code) | | |
ESC_CLASS | final static char ESC_CLASS(Code) | | |
ESC_COMPLEX | final static char ESC_COMPLEX(Code) | | |
ESC_MASK | final static char ESC_MASK(Code) | | |
NODE_NORMAL | final static int NODE_NORMAL(Code) | | |
NODE_NULLABLE | final static int NODE_NULLABLE(Code) | | |
NODE_TOPLEVEL | final static int NODE_TOPLEVEL(Code) | | |
bracketEnd | static int[] bracketEnd(Code) | | |
bracketFinished | final static int bracketFinished(Code) | | |
bracketMin | static int[] bracketMin(Code) | | |
bracketOpt | static int[] bracketOpt(Code) | | |
bracketStart | static int[] bracketStart(Code) | | |
bracketUnbounded | final static int bracketUnbounded(Code) | | |
brackets | static int brackets(Code) | | |
instruction | char[] instruction(Code) | | |
lenInstruction | int lenInstruction(Code) | | |
maxBrackets | final static int maxBrackets(Code) | | |
RECompiler | public RECompiler()(Code) | | Constructor. Creates (initially empty) storage for a regular expression program.
|
allocBrackets | void allocBrackets()(Code) | | Allocate storage for brackets only as needed
|
atom | int atom() throws RESyntaxException(Code) | | Absorb an atomic character string. This method is a little tricky because
it can un-include the last character of string if a closure operator follows.
This is correct because *+? have higher precedence than concatentation (thus
ABC* means AB(C*) and NOT (ABC)*).
Index of new atom node exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
bracket | void bracket() throws RESyntaxException(Code) | | Match bracket {m,n} expression put results in bracket member variables
exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
branch | int branch(int[] flags) throws RESyntaxException(Code) | | Compile one branch of an or operator (implements concatenation)
Parameters: flags - Flags passed by reference Pointer to branch node exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
closure | int closure(int[] flags) throws RESyntaxException(Code) | | Compile a possibly closured terminal
Parameters: flags - Flags passed by reference Index of closured node exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
compile | public REProgram compile(String pattern) throws RESyntaxException(Code) | | Compiles a regular expression pattern into a program runnable by the pattern
matcher class 'RE'.
Parameters: pattern - Regular expression pattern to compile (see RECompiler classfor details). A compiled regular expression program. exception: RESyntaxException - Thrown if the regular expression has invalid syntax. See Also: RECompiler See Also: RE |
emit | void emit(char c)(Code) | | Emit a single character into the program stream.
Parameters: c - Character to add |
ensure | void ensure(int n)(Code) | | Ensures that n more characters can fit in the program buffer.
If n more can't fit, then the size is doubled until it can.
Parameters: n - Number of additional characters to ensure will fit. |
escape | char escape() throws RESyntaxException(Code) | | Match an escape sequence. Handles quoted chars and octal escapes as well
as normal escape characters. Always advances the input stream by the
right amount. This code "understands" the subtle difference between an
octal escape and a backref. You can access the type of ESC_CLASS or
ESC_COMPLEX or ESC_BACKREF by looking at pattern[idx - 1].
ESC_* code or character if simple escape exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
expr | int expr(int[] flags) throws RESyntaxException(Code) | | Compile an expression with possible parens around it. Paren matching
is done at this level so we can tie the branch tails together.
Parameters: flags - Flag value passed by reference Node index of expression in instruction array exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
internalError | void internalError() throws Error(Code) | | Throws a new internal error exception
exception: Error - Thrown in the event of an internal error. |
node | int node(char opcode, int opdata)(Code) | | Adds a new node
Parameters: opcode - Opcode for node Parameters: opdata - Opdata for node (only the low 16 bits are currently used) Index of new node in program |
nodeInsert | void nodeInsert(char opcode, int opdata, int insertAt)(Code) | | Inserts a node with a given opcode and opdata at insertAt. The node relative next
pointer is initialized to 0.
Parameters: opcode - Opcode for new node Parameters: opdata - Opdata for new node (only the low 16 bits are currently used) Parameters: insertAt - Index at which to insert the new node in the program |
setNextOfEnd | void setNextOfEnd(int node, int pointTo)(Code) | | Appends a node to the end of a node chain
Parameters: node - Start of node chain to traverse Parameters: pointTo - Node to have the tail of the chain point to |
terminal | int terminal(int[] flags) throws RESyntaxException(Code) | | Match a terminal node.
Parameters: flags - Flags Index of terminal node (closeable) exception: RESyntaxException - Thrown if the regular expression has invalid syntax. |
|
|
|