A Lex is a state machine. Transitions can be activated
arbitrarily and can consume arbitrary amounts of text.
A transition simply says it can consume the next character
and returns the state that the machine should transition into.
States that are > 0 are final states and cause the nextToken
routine to return a value.
Inner Class :public interface Transition
Inner Class :abstractpublic static class BaseTransition implements Transition
Inner Class :final public static class EOFTransition extends BaseTransition
Inner Class :final public static class DefaultTransition extends BaseTransition
Inner Class :final public static class StringTransition extends BaseTransition
Inner Class :final public static class CharTransition extends BaseTransition
Inner Class :final public static class ExceptionTransition extends BaseTransition
Inner Class :final public static class ParseException extends IOException
Inner Class :final public static class ParseExceptionTransition implements Transition
Lex(Transition[][] states) Construct a new machine.
public
Lex(Transition[][] statesIn, PushbackReader inputIn) Construct a new machine.
Method Summary
public void
accept(int neededState) Get the next token and throw an acception if
the state machine is not in the specified state.
public void
accept(int neededState, String neededValue) Get the next token and throw an exception if the
state machine is not in the specified state and the
value returned by getData() does not match the
specified value.
public void
appendDataTo(StringBuffer buffer) Append the data returned from getData() to the
specified StringBuffer.
Get the next token and throw an exception if the
state machine is not in the specified state and the
value returned by getData() does not match the
specified value.
Return true if the specified string equals the
string returned by getData(). This routine
may be faster than calling getData because
it does not create a string on the heap.
Get the next token from the input stream. The
dataBuffer is cleared and the state is set to zero before
parsing begins. Parsing continues until a state
greater of equal to 0 s reached or an exception is thrown.
After each non-terminal transition, the state machine
walks through all the transitions, in order, for the current
state until it finds one that will accept the current
input character and then calls doAction on that transition.