Parser
v2.1

Parser
Class REProcessor

java.lang.Object
  |
  +--Parser.REProcessor
Direct Known Subclasses:
SubProductionProcessor

public class REProcessor
extends java.lang.Object

The REProcessor class handles processing of regular expression groups. For instance, it is often useful to match regular expression A and not match regular expression B, or match A as many times as possible. In other words, this class allows rules to be treated as elements of a regular expression. (i.e. English ::= Sentence*). Unary operations include: star (A*), plus (A+), maybe (A?), and follow (A). Binary operations include: andnot (A-B), or (A|B), and follow (AB).


Field Summary
protected static byte ANDNOT
          Denotes the and-not option.
protected static byte FOLLOW
          Denotes the follow option.
protected static byte MAYBE
          Denotes the ? option.
protected static byte OR
          Denotes the or option.
protected static byte PLUS
          Denotes the + option.
protected static byte STAR
          Denotes the * option.
 
Constructor Summary
REProcessor()
          Empty constructor
REProcessor(java.lang.Object A, java.lang.Object B, byte mode)
          Constructs a new REProcessor with the specified objects to be matched and a specified mode of operation.
 
Method Summary
 RETree beginningMatches(java.lang.String input)
          Returns a tree if the beginning of the specified string is matched, otherwise returns null.
protected  RETree evaluate(java.lang.Object automaton, java.lang.String input)
          Returns the result of beginningMatches for the appropriate type (RE or REProcessor).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANDNOT

protected static final byte ANDNOT
Denotes the and-not option. Used to match A but not B over the same section of text.

OR

protected static final byte OR
Denotes the or option. Used to match A or B over the same section of text.

FOLLOW

protected static final byte FOLLOW
Denotes the follow option. Used to match A or A then B.

STAR

protected static final byte STAR
Denotes the * option. Used to match A zero or more times.

PLUS

protected static final byte PLUS
Denotes the + option. Used to match A one or more times.

MAYBE

protected static final byte MAYBE
Denotes the ? option. Used to match A zero or one times.
Constructor Detail

REProcessor

public REProcessor()
Empty constructor

REProcessor

public REProcessor(java.lang.Object A,
                   java.lang.Object B,
                   byte mode)
Constructs a new REProcessor with the specified objects to be matched and a specified mode of operation.
Parameters:
A - the left hand side of the operation.
B - the right hand side of the operation.
mode - the mode of operation.
Method Detail

beginningMatches

public RETree beginningMatches(java.lang.String input)
                        throws java.lang.Exception
Returns a tree if the beginning of the specified string is matched, otherwise returns null.
Parameters:
input - the string to be tested and parsed.
Returns:
a tree (match) or null (no match).

evaluate

protected RETree evaluate(java.lang.Object automaton,
                          java.lang.String input)
                   throws java.lang.Exception
Returns the result of beginningMatches for the appropriate type (RE or REProcessor).
Parameters:
automaton - the RE or REProcessor to call beginningMatches on.
input - the string to be tested and parsed.
Returns:
the result of beginningMatches being called on the specified RE object or REProcessor object.

Parser
v2.1