public abstract class IlrAbstractCodeGenerator extends java.lang.Object implements IlrCodeGenerator, IlrIntermediateForm.Visitor
Provides a set of printXXX methods and a simple code generator extension mechanism.
| Modifier and Type | Field and Description |
|---|---|
IlrRuleStatement |
currentRuleStatement
Public attribute for the current rule statement cursor.
|
| Constructor and Description |
|---|
IlrAbstractCodeGenerator()
Creates a new
IlrAbstractCodeGenerator. |
| Modifier and Type | Method and Description |
|---|---|
void |
addIndent(int count)
Increments the indentation by the given amount.
|
void |
close()
Closes the stream.
|
void |
flush()
Flushes the stream.
|
void |
generateCode(IlrIntermediateForm iform,
java.io.Writer writer)
Generates the code for the specified
IlrIntermediateForm instance,
and into the provided writer. |
IlrCodeGeneratorExtender |
getExtender(IlrSyntaxTree.Node node)
Returns the extender registered for the grammar node of
node. |
int |
getIndent()
Gets the indentation multiplied by the indent size.
|
int |
getIndentSize()
Gets the indent size.
|
IlrTranslationSupport |
getTranslationSupport()
Gets the translation support.
|
IlrBRLTranslator |
getTranslator()
Returns the translator of this code generator.
|
IlrVocabulary |
getVocabulary()
Returns the vocabulary.
|
boolean |
ignoreNewline()
Returns the value of the IgnoreLine flag.
|
void |
ignoreNewline(boolean flag)
Sets the IgnoreNewline flag.
|
void |
indent()
Prints getIndent() white spaces.
|
void |
indent(int count)
Prints the given number of white spaces.
|
void |
newline()
Prints a newline.
|
void |
print(char ch)
Prints a character.
|
void |
print(java.lang.String text)
Prints a string.
|
void |
println(java.lang.String str)
Prints a string followed by a newline.
|
boolean |
reportDuplicateVariables()
This method returns whether this code generator should reprot duplicate variables
|
void |
reportDuplicateVariables(boolean flag)
this method set whether this code generator should report duplicate variables
|
protected void |
reset()
Resets this code generator and prepare it for a new code
generation.
|
void |
setIndentSize(int size)
Sets the indent size.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTargetLanguage, setTranslatorpublic IlrRuleStatement currentRuleStatement
public IlrAbstractCodeGenerator()
IlrAbstractCodeGenerator.protected void reset()
public void generateCode(IlrIntermediateForm iform, java.io.Writer writer)
IlrIntermediateForm instance,
and into the provided writer.generateCode in interface IlrCodeGeneratoriform - The intermediate form.writer - The writer.public void reportDuplicateVariables(boolean flag)
public boolean reportDuplicateVariables()
public IlrBRLTranslator getTranslator()
getTranslator in interface IlrCodeGeneratorpublic IlrTranslationSupport getTranslationSupport()
public IlrVocabulary getVocabulary()
public IlrCodeGeneratorExtender getExtender(IlrSyntaxTree.Node node)
node.node - The node.null if no code generator extender
has been registered for this node.public void print(java.lang.String text)
text - The string to print.public void println(java.lang.String str)
str - The string to print.public void print(char ch)
ch - The character to print.public void indent(int count)
count - The number of white space characters to print.public void indent()
public int getIndent()
public void addIndent(int count)
count - The amount by which the indentation is to be increased.public void setIndentSize(int size)
size - The size of the indent.public int getIndentSize()
public void newline()
public void ignoreNewline(boolean flag)
When true, the newLine property is not taken in account by the printToken() methods.
flag - The new value for the IgnoreNewline flag.public boolean ignoreNewline()
ignoreNewline(boolean)public void flush()
public void close()
© Copyright IBM Corp. 1987, 2017