public class IlrBRLTranslator
extends java.lang.Object
implements ilog.rules.brl.syntaxtree.IlrSyntaxTreeTranslator
A translator needs to be provided with two things:
IlrCodeGenerator that is in charge of producing code for
a specific target language.
IlrTranslationSupport that will provide translation services.
Once an instance of IlrBRLTranslator has been created, it can accept a new translation
input as an IlrTranslatorInput.
To start a translation and get the resulting string, you have to call printTranslation(Writer).
The translation is done in two phases:
IlrNodeTranslator.process(IlrSyntaxTree.Node, IlrTranslationContext) of the
IlrNodeTranslator attached to the node, if there is one. In this method, an intermediate form
of the rule is progressively built. Note that this first phase of construction of the intermediate form
must be done independently of the target language. The intermediate form is then passed to the second phase of
the translation.
IlrCodeGenerator explores
the produced IlrIntermediateForm, and prints the code for a specific target language.
The same instance of this class may be used for translating several sources. Call
setTranslatorInput(IlrTranslatorInput) to change the input and start a new translation with
printTranslation(Writer).
It is not necessary to subclass this class. Translator extension can be done by :
IlrNodeTranslator instance for new grammar nodes.
IlrCodeGeneatorExtender instance to generate specific code for a new language construct.
For more information on translation extensions, please read the BRLDF Translation manual.
| Constructor and Description |
|---|
IlrBRLTranslator(IlrCodeGenerator codeGenerator,
IlrTranslationSupport support)
Creates a new instance of
IlrBRLTranslator with a codeGenerator and
a support. |
IlrBRLTranslator(IlrCodeGenerator codeGenerator,
IlrTranslationSupport support,
java.lang.ClassLoader cl)
Creates a new instance of
IlrBRLTranslator with a codeGenerator,
a support and the specified ClassLoader to load required classes (node translators,
and value translators). |
| Modifier and Type | Method and Description |
|---|---|
java.lang.ClassLoader |
getClassLoader()
Returns the class loader.
|
IlrCodeGenerator |
getCodeGenerator()
Returns the code generator attached to this translator.
|
IlrTranslationSupport |
getTranslationSupport()
Returns the translation support of this translator.
|
IlrTranslatorInput |
getTranslatorInput()
Returns the current translator input.
|
IlrVocabulary |
getVocabulary()
Returns the vocabulary.
|
void |
printTranslation(java.io.Writer writer)
Translates the current translator input to the specified
writer. |
void |
setClassLoader(java.lang.ClassLoader cl)
Sets a specific class loader.
|
void |
setTranslatorInput(IlrTranslatorInput input)
Sets a new translator input.
|
public IlrBRLTranslator(IlrCodeGenerator codeGenerator, IlrTranslationSupport support)
IlrBRLTranslator with a codeGenerator and
a support. It will use the default class loader of the class.codeGenerator - The code generator.support - The translation support.public IlrBRLTranslator(IlrCodeGenerator codeGenerator, IlrTranslationSupport support, java.lang.ClassLoader cl)
IlrBRLTranslator with a codeGenerator,
a support and the specified ClassLoader to load required classes (node translators,
and value translators).codeGenerator - The code generator.support - The translation support.cl - The class loader.public void setTranslatorInput(IlrTranslatorInput input)
input - The new translator input.public void setClassLoader(java.lang.ClassLoader cl)
cl - The class loader.public void printTranslation(java.io.Writer writer)
writer.writer - The writer.public IlrTranslationSupport getTranslationSupport()
public IlrVocabulary getVocabulary()
null if there is no input.public IlrTranslatorInput getTranslatorInput()
public IlrCodeGenerator getCodeGenerator()
public java.lang.ClassLoader getClassLoader()
setClassLoader(ClassLoader),
then the class loader of the BRLDefinition of the syntax tree is used.© Copyright IBM Corp. 1987, 2017