public class CppTarget extends Target
Modifier and Type | Field | 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 | Description |
---|---|
CppTarget(CodeGenerator gen) |
Modifier and Type | Method | 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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
genFile, getAltLabelContextStructName, getCodeGenerator, getElementListName, getElementName, getImplicitRuleLabel, getImplicitSetLabel, getImplicitTokenLabel, getInlineTestSetWordSize, getLanguage, getListLabel, getLoopCounter, getLoopLabel, getRuleFunctionContextStructName, getRuleFunctionContextStructName, getTargetStringLiteralFromString, getTargetStringLiteralFromString, getTemplates, getTokenTypeAsTargetLabel, getTokenTypesAsTargetLabels, grammarSymbolCausesIssueInGeneratedCode, supportsOverloadedMethods, templatesExist, wantsBaseListener, wantsBaseVisitor
protected static final String[] cppKeywords
public CppTarget(CodeGenerator gen)
public String getVersion()
Target
getVersion
in class Target
public boolean needsHeader()
needsHeader
in class Target
protected 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 Target
public String encodeIntAsCharEscape(int v)
Target
encodeIntAsCharEscape
in class Target
public int getSerializedATNSegmentLimit()
Target
getSerializedATNSegmentLimit
in class Target
SerializedATN.getSegments()
public String getRecognizerFileName(boolean header)
Target
getRecognizerFileName
in class Target
public String getListenerFileName(boolean header)
Target
getListenerFileName
in class Target
public String getVisitorFileName(boolean header)
Target
getVisitorFileName
in class Target
public String getBaseListenerFileName(boolean header)
Target
getBaseListenerFileName
in class Target
public String getBaseVisitorFileName(boolean header)
Target
getBaseVisitorFileName
in class Target
protected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode)
visibleGrammarSymbolCausesIssueInGeneratedCode
in class Target
protected org.stringtemplate.v4.STGroup loadTemplates()
loadTemplates
in class Target
Copyright © 1992–2018 ANTLR. All rights reserved.