|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.inxar.syntacs.translator.lr.AbstractLRTranslationComponent | +--com.inxar.syntacs.translator.lr.StandardLRTranslatorInterpreter
Concrete implementation of LRInterpreter
.
Constructor Summary | |
StandardLRTranslatorInterpreter()
Constructs the StandardLRInterpreter . |
Method Summary | |
void |
accept()
This method will be called by the parser when the ACCEPT instruction occurs. |
int |
error(int off,
int len)
Notify an error starting at the given offset having the given length. |
Parser |
getParser()
Gets the Parser object which this LexerInterpreter
may relay Symbol events to. |
Object |
getResult()
When translation is complete and there were no unrecoverable errors, the LRTranslatorInterpreter should be able
to produce some Object which was built from the
parse tree. |
void |
match(int type,
int off,
int len)
The match method is used by the Lexer
to inform the interpreter that a new token has been found at the
given offset with the given length. |
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 sentence)
ParserInterpreter.reduce(int, Sentence) is called
when a reduction occurs. |
void |
setParser(Parser parser)
Sets the Parser object to which this
LexerInterpreter may relay Symbol events to. |
void |
stop()
Notify that the end of the Input has been reached. |
Methods inherited from class com.inxar.syntacs.translator.lr.AbstractLRTranslationComponent |
getAuditor, getInput, getLRTranslatorGrammar, getProperties, initialize, reset, setAuditor, setInput, setLRTranslatorGrammar, setProperties |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.inxar.syntacs.translator.lr.LRTranslationComponent |
getAuditor, getInput, getLRTranslatorGrammar, getProperties, initialize, reset, setAuditor, setInput, setLRTranslatorGrammar, setProperties |
Constructor Detail |
public StandardLRTranslatorInterpreter()
StandardLRInterpreter
.Method Detail |
public void match(int type, int off, int len) throws TranslationException
LexerInterpreter
match
method is used by the Lexer
to inform the interpreter that a new token has been found at the
given offset with the given length.match
in interface LexerInterpreter
public int error(int off, int len) throws TranslationException
LexerInterpreter
error
in interface LexerInterpreter
public void stop() throws TranslationException
LexerInterpreter
Input
has been reached.stop
in interface LexerInterpreter
public void setParser(Parser parser)
LexerInterpreter
Parser
object to which this
LexerInterpreter
may relay Symbol events to.setParser
in interface LexerInterpreter
public Parser getParser()
LexerInterpreter
LexerInterpreter
may relay Symbol
events to.getParser
in interface LexerInterpreter
public Symbol reduce(int type, Sentence sentence) throws TranslationException
ParserInterpreter
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).reduce
in interface ParserInterpreter
public Recovery recover(int type, Sentence left_context) throws TranslationException
ParserInterpreter
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.recover
in interface ParserInterpreter
public void accept() throws TranslationException
ParserInterpreter
ACCEPT
instruction occurs.accept
in interface ParserInterpreter
public Object getResult()
LRTranslatorInterpreter
LRTranslatorInterpreter
should be able
to produce some Object
which was built from the
parse tree. This Object
will be returned by the
Translator
if appropriate.getResult
in interface LRTranslatorInterpreter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |