public class CodeGenerator extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_LANGUAGE |
Grammar |
g |
String |
language |
int |
lineWidth |
static String |
TEMPLATE_ROOT |
Tool |
tool |
static String |
VOCAB_FILE_EXTENSION |
static String |
vocabFilePattern |
Constructor and Description |
---|
CodeGenerator(Grammar g) |
CodeGenerator(Tool tool,
Grammar g,
String language) |
Modifier and Type | Method and Description |
---|---|
org.stringtemplate.v4.ST |
generateBaseListener() |
org.stringtemplate.v4.ST |
generateBaseVisitor() |
org.stringtemplate.v4.ST |
generateLexer() |
org.stringtemplate.v4.ST |
generateListener() |
org.stringtemplate.v4.ST |
generateParser() |
org.stringtemplate.v4.ST |
generateVisitor() |
String |
getBaseListenerFileName()
A given grammar T, return a blank listener implementation
such as TBaseListener.java, if we're using the Java target.
|
String |
getBaseVisitorFileName()
A given grammar T, return a blank listener implementation
such as TBaseListener.java, if we're using the Java target.
|
String |
getHeaderFileName() |
String |
getListenerFileName()
A given grammar T, return the listener name such as
TListener.java, if we're using the Java target.
|
String |
getRecognizerFileName()
Generate TParser.java and TLexer.java from T.g4 if combined, else
just use T.java as output regardless of type.
|
Target |
getTarget() |
org.stringtemplate.v4.STGroup |
getTemplates() |
String |
getVisitorFileName()
A given grammar T, return the visitor name such as
TVisitor.java, if we're using the Java target.
|
String |
getVocabFileName()
What is the name of the vocab file generated for this grammar?
Returns null if no .tokens file should be generated.
|
protected void |
loadLanguageTarget(String language) |
static boolean |
targetExists(String language) |
void |
write(org.stringtemplate.v4.ST code,
String fileName) |
void |
writeBaseListener(org.stringtemplate.v4.ST outputFileST) |
void |
writeBaseVisitor(org.stringtemplate.v4.ST outputFileST) |
void |
writeHeaderFile() |
void |
writeListener(org.stringtemplate.v4.ST outputFileST) |
void |
writeRecognizer(org.stringtemplate.v4.ST outputFileST) |
void |
writeVisitor(org.stringtemplate.v4.ST outputFileST) |
void |
writeVocabFile() |
public static final String TEMPLATE_ROOT
public static final String VOCAB_FILE_EXTENSION
public static final String DEFAULT_LANGUAGE
public static final String vocabFilePattern
public final Grammar g
public final Tool tool
public final String language
public int lineWidth
public CodeGenerator(Grammar g)
public static boolean targetExists(String language)
public Target getTarget()
public org.stringtemplate.v4.STGroup getTemplates()
protected void loadLanguageTarget(String language)
public org.stringtemplate.v4.ST generateLexer()
public org.stringtemplate.v4.ST generateParser()
public org.stringtemplate.v4.ST generateListener()
public org.stringtemplate.v4.ST generateBaseListener()
public org.stringtemplate.v4.ST generateVisitor()
public org.stringtemplate.v4.ST generateBaseVisitor()
public void writeRecognizer(org.stringtemplate.v4.ST outputFileST)
public void writeListener(org.stringtemplate.v4.ST outputFileST)
public void writeBaseListener(org.stringtemplate.v4.ST outputFileST)
public void writeVisitor(org.stringtemplate.v4.ST outputFileST)
public void writeBaseVisitor(org.stringtemplate.v4.ST outputFileST)
public void writeHeaderFile()
public void writeVocabFile()
public void write(org.stringtemplate.v4.ST code, String fileName)
public String getRecognizerFileName()
public String getListenerFileName()
public String getVisitorFileName()
public String getBaseListenerFileName()
public String getBaseVisitorFileName()
public String getVocabFileName()
public String getHeaderFileName()
Copyright © 1992-2016 ANTLR. All Rights Reserved.