org.inxar.syntacs.analyzer.syntactic
Interface Correction


public interface Correction

A Correction is a discrete instruction for a Parser to execute (apply) during an error recovery.


Field Summary
static int ABORT
          The "Abort" correction instruction causes the Parser to immediately bail by throwing a TranslationException.
static int NOOP
          The "No Operation" correction instruction.
static int TUMBLE
          The "Tumble" correction instruction.
static int WAIT
          The "Wait" correction instruction.
 
Method Summary
 int getType()
          Returns the type of this Correction as one of the constants in this interface.
 Object getValue()
          Returns some value associated with this Correction.
 

Field Detail

NOOP

public static final int NOOP
The "No Operation" correction instruction. The semantics of a NOOP is to do nothing (the error is ignored).

WAIT

public static final int WAIT
The "Wait" correction instruction. The semantics of WAIT is closely tied to the notion of "synchonizing tokens"; when the Parser sees a WAIT instruction, it calls Correction.getValue() and expects an Integer. The value of this Integer should correspond to a terminal Symbol. The Parser will then discard incoming terminals from the LexerInterpreter until it sees one that whose type matches the given Integer. When that happens, the Parser will advance to the next Correction in the scheduled Recovery. For example, if the symbol type for a semicolon in some grammar is 12, then WAIT 12 means discard all input until you see a semicolon; when you do, go ahead to the next correction in the recovery plan. In this hypothetical grammar then, the semicolon is a synchronizing token.

TUMBLE

public static final int TUMBLE
The "Tumble" correction instruction. Tumbling is a recovery state such that the Parser iteratively challenges DPA.action() method with the current input token and the current state on the top of the state stack until it returns a non-error Action from the DPA. After each unsuccessful challenge, the state stack is popped.

This has the effect of backing up through the state graph until one can move forward again. It is called "tumble" because it hybridizes the is loose notion of finding the right configuration in a lock (finding the right input), and the notion of falling (the depth of the stack).

The "Wait and Tumble" is a useful recovery plan.


ABORT

public static final int ABORT
The "Abort" correction instruction causes the Parser to immediately bail by throwing a TranslationException.
Method Detail

getType

public int getType()
Returns the type of this Correction as one of the constants in this interface.

getValue

public Object getValue()
Returns some value associated with this Correction. The specifics of what this object should be (if anything) varies according to the type of correction.