org.inxar.syntacs.analyzer.syntactic
Interface ParserInterpreter
- All Superinterfaces:
- LRTranslationComponent
- All Known Subinterfaces:
- LRTranslatorInterpreter
- public interface ParserInterpreter
- extends LRTranslationComponent
The ParserInterpreter
interface is reponsible for
handling "parser events". A parser "event" is triggered when a
reduction occurs. The ParserInterpreter
is informed of
the reduction type (the unique ID of a production in the grammar)
and the top of the parse symbol stack (the Sentence
).
A Symbol
object is returned back to the parser which
is placed on the symbol stack.
Method Summary |
void |
accept()
This method will be called by the parser when the
ACCEPT instruction occurs. |
Recovery |
recover(int type,
Sentence left_context)
This method will be called by the parser when an
ERROR instruction is hit. |
Symbol |
reduce(int type,
Sentence left_context)
ParserInterpreter.reduce(int, Sentence) is called
when a reduction occurs. |
reduce
public Symbol reduce(int type,
Sentence left_context)
throws TranslationException
ParserInterpreter.reduce(int, Sentence)
is called
when a reduction occurs. The type of the reduction (from the
grammar) as well as the top of the parse stack is passed to the
method. The ParserInterpreter
is expected to
construct a Symbol
and return it back to the
Parser
(to be placed at the top of the parse
stack).
recover
public Recovery recover(int type,
Sentence left_context)
throws TranslationException
- This method will be called by the parser when an
ERROR
instruction is hit. The argument is the
Symbol
type that was being parsed at the time of
error. The return value should be a Symbol
to try
instead of the one that invoked the error. If the return value
is null
, the error will be ignored. If the return
value is not null and another error is encountered, one symbol
will be removed from the stack and the parser will try again
wil the given return symbol. This will happen recursively
until the error is resolved and the parse can continue or the
stack is empty.
accept
public void accept()
throws TranslationException
- This method will be called by the parser when the
ACCEPT
instruction occurs.