Package org.antlr.v4.codegen.target
Class CppTarget
- java.lang.Object
-
- org.antlr.v4.codegen.Target
-
- org.antlr.v4.codegen.target.CppTarget
-
public class CppTarget extends Target
-
-
Field Summary
Fields Modifier and Type Field Description protected static HashSet<String>
reservedWords
protected static Map<Character,String>
targetCharValueEscape
-
Fields inherited from class org.antlr.v4.codegen.Target
defaultCharValueEscape, gen
-
-
Constructor Summary
Constructors Constructor Description CppTarget(CodeGenerator gen)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.protected Set<String>
getReservedWords()
Map<Character,String>
getTargetCharValueEscape()
For pure strings of Unicode char, how can we display it in the target language as a literal.String
getVisitorFileName(boolean header)
A given grammar T, return the visitor name such as TVisitor.java, if we're using the Java target.boolean
needsHeader()
protected boolean
shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(int codePoint)
-
Methods inherited from class org.antlr.v4.codegen.Target
addEscapedChar, addEscapedChar, appendUnicodeEscapedCodePoint, encodeInt16AsCharEscape, escapeChar, escapeIfNeeded, escapeWord, genFile, getAltLabelContextStructName, getCodeGenerator, getElementListName, getElementName, getImplicitRuleLabel, getImplicitSetLabel, getImplicitTokenLabel, getInlineTestSetWordSize, getLanguage, getListLabel, getLoopCounter, getLoopLabel, getRuleFunctionContextStructName, getRuleFunctionContextStructName, getSerializedATNSegmentLimit, getTargetStringLiteralFromANTLRStringLiteral, getTargetStringLiteralFromANTLRStringLiteral, getTargetStringLiteralFromString, getTargetStringLiteralFromString, getTemplates, getTokenTypeAsTargetLabel, getTokenTypesAsTargetLabels, getVersion, grammarSymbolCausesIssueInGeneratedCode, isATNSerializedAsInts, loadTemplates, supportsOverloadedMethods, templatesExist, visibleGrammarSymbolCausesIssueInGeneratedCode, wantsBaseListener, wantsBaseVisitor
-
-
-
-
Constructor Detail
-
CppTarget
public CppTarget(CodeGenerator gen)
-
-
Method Detail
-
getTargetCharValueEscape
public Map<Character,String> getTargetCharValueEscape()
Description copied from class:Target
For pure strings of Unicode char, how can we display it in the target language as a literal. Useful for dumping predicates and such that may refer to chars that need to be escaped when represented as strings. Also, templates need to be escaped so that the target language can hold them as a string. Each target can have a different set in memory at same time.- Overrides:
getTargetCharValueEscape
in classTarget
-
getReservedWords
protected Set<String> getReservedWords()
- Specified by:
getReservedWords
in classTarget
-
needsHeader
public boolean needsHeader()
- Overrides:
needsHeader
in classTarget
-
shouldUseUnicodeEscapeForCodePointInDoubleQuotedString
protected boolean shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(int codePoint)
- Overrides:
shouldUseUnicodeEscapeForCodePointInDoubleQuotedString
in classTarget
-
getRecognizerFileName
public String getRecognizerFileName(boolean header)
Description copied from class:Target
Generate TParser.java and TLexer.java from T.g4 if combined, else just use T.java as output regardless of type.- Overrides:
getRecognizerFileName
in classTarget
-
getListenerFileName
public String getListenerFileName(boolean header)
Description copied from class:Target
A given grammar T, return the listener name such as TListener.java, if we're using the Java target.- Overrides:
getListenerFileName
in classTarget
-
getVisitorFileName
public String getVisitorFileName(boolean header)
Description copied from class:Target
A given grammar T, return the visitor name such as TVisitor.java, if we're using the Java target.- Overrides:
getVisitorFileName
in classTarget
-
getBaseListenerFileName
public String getBaseListenerFileName(boolean header)
Description copied from class:Target
A given grammar T, return a blank listener implementation such as TBaseListener.java, if we're using the Java target.- Overrides:
getBaseListenerFileName
in classTarget
-
getBaseVisitorFileName
public String getBaseVisitorFileName(boolean header)
Description copied from class:Target
A given grammar T, return a blank listener implementation such as TBaseListener.java, if we're using the Java target.- Overrides:
getBaseVisitorFileName
in classTarget
-
-