Package net.emustudio.edigen.generation
Class Generator
- java.lang.Object
-
- net.emustudio.edigen.generation.Generator
-
- Direct Known Subclasses:
DecoderGenerator,DisassemblerGenerator
public abstract class Generator extends java.lang.ObjectAn output code generator.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGenerator(java.lang.String defaultTemplate, java.lang.String name)Constructs the part of the generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfillTemplate(Template template)Sets the variables used in the template file.voidgenerate()Generates the output file from the current AST.java.lang.StringgetClassName()Returns the class name (without the package name).java.lang.StringgetPackageName()Returns the package name.voidsetOutputDirectory(java.lang.String outputDirectory)Sets the directory to write the generated file to.voidsetTemplateFile(java.lang.String templateFile)Sets the template file to use instead of the default one.
-
-
-
Method Detail
-
getPackageName
public java.lang.String getPackageName()
Returns the package name.- Returns:
- the package name (using the dot notation)
-
getClassName
public java.lang.String getClassName()
Returns the class name (without the package name).- Returns:
- the class name
-
setTemplateFile
public void setTemplateFile(java.lang.String templateFile)
Sets the template file to use instead of the default one.- Parameters:
templateFile- the template path
-
setOutputDirectory
public void setOutputDirectory(java.lang.String outputDirectory)
Sets the directory to write the generated file to.- Parameters:
outputDirectory- the output directory name
-
generate
public void generate() throws java.io.IOException, SemanticExceptionGenerates the output file from the current AST.- Throws:
java.io.IOException- when the file can not be read / writtenSemanticException- when there is a semantic error in the input file
-
fillTemplate
protected void fillTemplate(Template template) throws SemanticException
Sets the variables used in the template file.- Parameters:
template- the template object- Throws:
SemanticException- on template filling / code generation failure
-
-