Save This Page
Home » jakarta-regexp-1.5 » org.apache » regexp » [javadoc | source]
org.apache.regexp
public class: RECompiler [javadoc | source]
java.lang.Object
   org.apache.regexp.RECompiler

Direct Known Subclasses:
    REDebugCompiler

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.
Nested Class Summary:
class  RECompiler.RERange  Local, nested class for maintaining character ranges for character classes. 
Field Summary
 char[] instruction     
 int lenInstruction     
 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     
static final  int bracketUnbounded     
 int bracketMin     
 int bracketOpt     
static final  Hashtable hashPOSIX     
Constructor:
 public RECompiler() 
Method from org.apache.regexp.RECompiler Summary:
atom,   bracket,   branch,   characterClass,   closure,   compile,   emit,   ensure,   escape,   expr,   internalError,   node,   nodeInsert,   setNextOfEnd,   syntaxError,   terminal
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.regexp.RECompiler Detail:
 int atom() throws RESyntaxException 
    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)*).
  void bracket() throws RESyntaxException 
    Match bracket {m,n} expression put results in bracket member variables
 int branch(int[] flags) throws RESyntaxException 
    Compile body of one branch of an or operator (implements concatenation)
 int characterClass() throws RESyntaxException 
    Compile a character class
 int closure(int[] flags) throws RESyntaxException 
    Compile a possibly closured terminal
 public REProgram compile(String pattern) throws RESyntaxException 
    Compiles a regular expression pattern into a program runnable by the pattern matcher class 'RE'.
  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. If n more can't fit, then the size is doubled until it can.
 int escape() throws RESyntaxException 
    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].
 int expr(int[] flags) throws RESyntaxException 
    Compile an expression with possible parens around it. Paren matching is done at this level so we can tie the branch tails together.
  void internalError() throws Error 
    Throws a new internal error exception
 int node(char opcode,
    int opdata) 
    Adds a new node
  void nodeInsert(char opcode,
    int opdata,
    int insertAt) 
    Inserts a node with a given opcode and opdata at insertAt. The node relative next pointer is initialized to 0.
  void setNextOfEnd(int node,
    int pointTo) 
    Appends a node to the end of a node chain
  void syntaxError(String s) throws RESyntaxException 
    Throws a new syntax error exception
 int terminal(int[] flags) throws RESyntaxException 
    Match a terminal node.