org.inxar.syntacs.grammar.regular
Interface RegularExpression

All Superinterfaces:
Cloneable
All Known Subinterfaces:
CharClass, CharString, Closure, Concatenation, Epsilon, ExpressionTerminator, Interval, Option, PositiveClosure, Union

public interface RegularExpression
extends Cloneable

The RegularExpression interface is a base interface for all specific RegularExpression constructs. Each regex needs to know how to build its first and last sets, and what to do inside its follow() method. For more information about what these methods really mean, refer to Chapter 3 in the Dragon Book.

This interface extends Cloneable, but the semantics of cloning go beyond what one might expect. For example, if we have the regex '(a|b|c)+', this needs to be deconstructed into it's more fundamental form '(a|b|c)-(a|b|c)*' where '-' means Concatenation. However, we cannot simply copy the Union object as its members (a, b, c) would have the same id and thus indistinguishable. Therefore, the clone() operation will end up making *new* members (a', b', c') and thus id(a) != id(a').


Method Summary
 Object clone()
          See the general explanation of clone() given above.
 void follow()
          Triggers the process of computing the follow sets.
 IntSet getFirstSet()
          Returns the IntSet of Intervals which are visible at the logical beginning of the the expression.
 IntSet getLastSet()
          Returns the IntSet of Intervals which are visible at the logical end of the the expression.
 boolean isNullable()
          Returns true if this RegularExpression either *is* Epsilon or derives it.
 

Method Detail

isNullable

public boolean isNullable()
Returns true if this RegularExpression either *is* Epsilon or derives it.

getFirstSet

public IntSet getFirstSet()
Returns the IntSet of Intervals which are visible at the logical beginning of the the expression.

getLastSet

public IntSet getLastSet()
Returns the IntSet of Intervals which are visible at the logical end of the the expression.

follow

public void follow()
Triggers the process of computing the follow sets.

clone

public Object clone()
             throws CloneNotSupportedException
See the general explanation of clone() given above.