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 gen,
String language) |
Modifier and Type | Method and Description |
---|---|
String |
encodeIntAsCharEscape(int v)
Assume 16-bit char
|
protected void |
genFile(Grammar g,
org.stringtemplate.v4.ST outputFileST,
String fileName) |
protected void |
genListenerFile(Grammar g,
org.stringtemplate.v4.ST outputFileST) |
protected void |
genRecognizerHeaderFile(Grammar g,
org.stringtemplate.v4.ST headerFileST,
String extName) |
String |
getAltLabelContextStructName(String label) |
CodeGenerator |
getCodeGenerator() |
String |
getElementListName(String name) |
String |
getElementName(String name) |
String |
getImplicitRuleLabel(String ruleName) |
String |
getImplicitSetLabel(String id) |
String |
getImplicitTokenLabel(String tokenName) |
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 label) |
String |
getLoopCounter(GrammarAST ast) |
String |
getLoopLabel(GrammarAST ast) |
String |
getRuleFunctionContextStructName(Rule r) |
String |
getRuleFunctionContextStructName(RuleFunction function)
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 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.
|
String |
getTargetStringLiteralFromString(String s) |
String |
getTargetStringLiteralFromString(String s,
boolean quoted)
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.
|
org.stringtemplate.v4.STGroup |
getTemplates() |
String |
getTokenTypeAsTargetLabel(Grammar g,
int ttype)
Get a meaningful name for a token type useful during code generation.
|
String[] |
getTokenTypesAsTargetLabels(Grammar g,
int[] ttypes) |
abstract String |
getVersion()
ANTLR tool should check output templates / target are compatible with tool code generation.
|
boolean |
grammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) |
protected org.stringtemplate.v4.STGroup |
loadTemplates() |
boolean |
supportsOverloadedMethods() |
boolean |
templatesExist() |
protected abstract boolean |
visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) |
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(CodeGenerator gen, String language)
public CodeGenerator getCodeGenerator()
public String getLanguage()
public abstract String getVersion()
public org.stringtemplate.v4.STGroup getTemplates()
protected void genListenerFile(Grammar g, org.stringtemplate.v4.ST outputFileST)
protected void genRecognizerHeaderFile(Grammar g, org.stringtemplate.v4.ST headerFileST, String extName)
public String getTokenTypeAsTargetLabel(Grammar g, int ttype)
public String getTargetStringLiteralFromString(String s, boolean quoted)
public String getTargetStringLiteralFromANTLRStringLiteral(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.replace(char, char)
cannot handle both \"
and "
without a lot of messing
around.
public String encodeIntAsCharEscape(int v)
public String getLoopLabel(GrammarAST ast)
public String getLoopCounter(GrammarAST ast)
public String getRuleFunctionContextStructName(RuleFunction function)
public int getSerializedATNSegmentLimit()
SerializedATN.getSegments()
public int getInlineTestSetWordSize()
public boolean grammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode)
protected abstract boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode)
public boolean templatesExist()
protected org.stringtemplate.v4.STGroup loadTemplates()
public boolean wantsBaseListener()
public boolean wantsBaseVisitor()
public boolean supportsOverloadedMethods()
Copyright © 1992–2020 ANTLR. All rights reserved.