public class CppTarget extends Target
| Modifier and Type | Field and Description |
|---|---|
protected Set<String> |
badWords
Avoid grammar symbols in this set to prevent conflicts in gen'd code.
|
protected static String[] |
cppKeywords |
gen, targetCharValueEscape| Constructor and Description |
|---|
CppTarget(CodeGenerator gen) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addBadWords() |
String |
encodeIntAsCharEscape(int v)
Assume 16-bit char
|
Set<String> |
getBadWords() |
String |
getBaseListenerFileName(boolean header)
A given grammar T, return a blank listener implementation
such as TBaseListener.java, if we're using the Java target.
|
String |
getBaseVisitorFileName(boolean header)
A given grammar T, return a blank listener implementation
such as TBaseListener.java, if we're using the Java target.
|
String |
getListenerFileName(boolean header)
A given grammar T, return the listener name such as
TListener.java, if we're using the Java target.
|
String |
getRecognizerFileName(boolean header)
Generate TParser.java and TLexer.java from T.g4 if combined, else
just use T.java as output regardless of 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 |
getVersion()
ANTLR tool should check output templates / target are compatible with tool code generation.
|
String |
getVisitorFileName(boolean header)
A given grammar T, return the visitor name such as
TVisitor.java, if we're using the Java target.
|
protected org.stringtemplate.v4.STGroup |
loadTemplates() |
boolean |
needsHeader() |
protected boolean |
visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) |
genFile, getAltLabelContextStructName, getCodeGenerator, getElementListName, getElementName, getImplicitRuleLabel, getImplicitSetLabel, getImplicitTokenLabel, getInlineTestSetWordSize, getLanguage, getListLabel, getLoopCounter, getLoopLabel, getRuleFunctionContextStructName, getRuleFunctionContextStructName, getTargetStringLiteralFromString, getTargetStringLiteralFromString, getTemplates, getTokenTypeAsTargetLabel, getTokenTypesAsTargetLabels, grammarSymbolCausesIssueInGeneratedCode, supportsOverloadedMethods, templatesExist, wantsBaseListener, wantsBaseVisitorprotected static final String[] cppKeywords
public CppTarget(CodeGenerator gen)
public String getVersion()
TargetgetVersion in class Targetpublic boolean needsHeader()
needsHeader in class Targetprotected void addBadWords()
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.
'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.getTargetStringLiteralFromANTLRStringLiteral in class Targetpublic String encodeIntAsCharEscape(int v)
TargetencodeIntAsCharEscape in class Targetpublic int getSerializedATNSegmentLimit()
TargetgetSerializedATNSegmentLimit in class TargetSerializedATN.getSegments()public String getRecognizerFileName(boolean header)
TargetgetRecognizerFileName in class Targetpublic String getListenerFileName(boolean header)
TargetgetListenerFileName in class Targetpublic String getVisitorFileName(boolean header)
TargetgetVisitorFileName in class Targetpublic String getBaseListenerFileName(boolean header)
TargetgetBaseListenerFileName in class Targetpublic String getBaseVisitorFileName(boolean header)
TargetgetBaseVisitorFileName in class Targetprotected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode)
visibleGrammarSymbolCausesIssueInGeneratedCode in class Targetprotected org.stringtemplate.v4.STGroup loadTemplates()
loadTemplates in class TargetCopyright © 1992–2016 ANTLR. All rights reserved.