public abstract class Target extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
targetCharValueEscape
For pure strings of Java 16-bit Unicode char, how can we display it in the target language as a literal.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Target(CodeGenerator
|
| Modifier and Type | Method and Description |
|---|---|
String |
encodeIntAsCharEscape(int v)
Assume 16-bit char
|
protected void |
genFile(Grammar
|
protected void |
genListenerFile(Grammar
|
protected void |
genRecognizerHeaderFile(Grammar
|
String |
getAltLabelContextStructName(String
|
CodeGenerator |
getCodeGenerator()
|
String |
getElementListName(String
|
String |
getElementName(String
|
String |
getImplicitRuleLabel(String
|
String |
getImplicitSetLabel(String
|
String |
getImplicitTokenLabel(String
|
int |
getInlineTestSetWordSize()
How many bits should be used to do inline token type tests? Java assumes a 64-bit word for bitsets.
|
String |
getLanguage()
|
String |
getListLabel(String
|
String |
getLoopCounter(GrammarAST
|
String |
getLoopLabel(GrammarAST
|
String |
getRuleFunctionContextStructName(Rule
|
String |
getRuleFunctionContextStructName(RuleFunction
If we know which actual function, we can provide the actual ctx type.
|
int |
getSerializedATNSegmentLimit()
Gets the maximum number of 16-bit unsigned integers that can be encoded in a single segment of the serialized ATN.
|
String |
getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator
Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language.
|
String |
getTargetStringLiteralFromString(String
|
String |
getTargetStringLiteralFromString(String
Given a random string of Java unicode chars, return a new string with optionally appropriate quote characters for target language and possibly with some escaped characters.
|
STGroup |
getTemplates()
|
String |
getTokenTypeAsTargetLabel(Grammar
Get a meaningful name for a token type useful during code generation.
|
String |
getTokenTypesAsTargetLabels(Grammar
|
abstract String |
getVersion()
ANTLR tool should check output templates / target are compatible with tool code generation.
|
boolean |
grammarSymbolCausesIssueInGeneratedCode(GrammarAST
|
protected STGroup |
loadTemplates()
|
boolean |
supportsOverloadedMethods()
|
boolean |
templatesExist()
|
protected abstract boolean |
visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST
|
boolean |
wantsBaseListener()
|
boolean |
wantsBaseVisitor()
|
protected String[] targetCharValueEscape
Target subclass is free to alter the translated chars or add more definitions. This is non-static so each target can have a different set in memory at same time.
protected Target(CodeGeneratorgen, String language)
public CodeGeneratorgetCodeGenerator()
public StringgetLanguage()
public abstract StringgetVersion()
public STGroup getTemplates()
protected void genListenerFile(Grammarg, ST outputFileST)
protected void genRecognizerHeaderFile(Grammarg, ST headerFileST, String extName)
public StringgetTokenTypeAsTargetLabel(Grammar g, int ttype)
public StringgetTargetStringLiteralFromString(String s, boolean quoted)
public StringgetTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal, boolean addQuotes)
Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language.
For Java, this is the translation 'a\n"' → "a\n\"". Expect single quotes around the incoming literal. Just flip the quotes and replace double quotes with \".
Note that we have decided to allow people to use '\"' without penalty, so we must build the target string in a loop as String cannot handle both \" and " without a lot of messing around.
public StringencodeIntAsCharEscape(int v)
public StringgetLoopLabel(GrammarAST ast)
public StringgetLoopCounter(GrammarAST ast)
public StringgetRuleFunctionContextStructName(RuleFunction function)
public int getSerializedATNSegmentLimit()
SerializedATN.getSegments()
public int getInlineTestSetWordSize()
public boolean grammarSymbolCausesIssueInGeneratedCode(GrammarASTidNode)
protected abstract boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarASTidNode)
public boolean templatesExist()
protected STGroup loadTemplates()
public boolean wantsBaseListener()
public boolean wantsBaseVisitor()
public boolean supportsOverloadedMethods()