| Modifier and Type | Field and Description |
|---|---|
| protected static final Map | |
| protected final CodeGenerator | |
| private static final Map |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected static void | |
| protected static void | |
| private void | |
| protected void | appendUnicodeEscapedCodePoint(int codePoint, StringBuilder sb)
Escape the Unicode code point appropriately for this language
and append the escaped value to |
| public String | |
| protected String | |
| public String | |
| protected String | |
| protected void | |
| public String | |
| public String | getBaseListenerFileName(boolean header)
A given grammar T, return a blank listener implementation such as TBaseListener.java, if we're using the Java target. |
| public String | getBaseVisitorFileName(boolean header)
A given grammar T, return a blank listener implementation such as TBaseListener.java, if we're using the Java target. |
| public CodeGenerator | |
| public String | |
| public String | |
| public String | |
| public String | |
| public String | |
| public int | |
| public String | |
| public String | getListenerFileName(boolean header)
A given grammar T, return the listener name such as TListener.java, if we're using the Java target. |
| public String | |
| public String | |
| public String | |
| public 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 abstract Set | |
| public String | |
| public String | getRuleFunctionContextStructName(RuleFunction function)
If we know which actual function, we can provide the actual ctx type. |
| public int | Returns: the serialized ATN segment limitGets the maximum number of 16-bit unsigned integers that can be encoded in a single segment (a declaration in target language) of the serialized ATN. |
| public Map | getTargetCharValueEscape()
For pure strings of Unicode char, how can we display it in the target language as a literal. |
| public String | getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal, boolean addQuotes)
|
| public String | getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal, boolean addQuotes, boolean escapeSpecial)
Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language. |
| public 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. |
| public String | |
| public synchronized STGroup | |
| public String | getTokenTypeAsTargetLabel(Grammar g, int ttype)
Get a meaningful name for a token type useful during code generation. |
| public String[] | |
| public String | getVersion()
ANTLR tool should check output templates / target are compatible with tool code generation. |
| public String | getVisitorFileName(boolean header)
A given grammar T, return the visitor name such as TVisitor.java, if we're using the Java target. |
| public boolean | |
| public boolean | |
| protected STGroup | |
| private STGroup | |
| public boolean | |
| protected boolean | |
| public boolean | |
| public boolean | |
| protected boolean | |
| public boolean | |
| public boolean |
| defaultCharValueEscape | back to summary |
|---|---|
| protected static final Map<Character, String> defaultCharValueEscape | |
| gen | back to summary |
|---|---|
| protected final CodeGenerator gen | |
| languageTemplates | back to summary |
|---|---|
| private static final Map<String, STGroup> languageTemplates | |
| Target | back to summary |
|---|---|
| protected Target(CodeGenerator gen) | |
| addEscapedChar | back to summary |
|---|---|
| protected static void addEscapedChar(HashMap<Character, String> map, char key) | |
| addEscapedChar | back to summary |
|---|---|
| protected static void addEscapedChar(HashMap<Character, String> map, char key, char representation) | |
| appendUnicodeEscapedCodePoint | back to summary |
|---|---|
| private void appendUnicodeEscapedCodePoint(int codePoint, StringBuilder sb, boolean escape) | |
| appendUnicodeEscapedCodePoint | back to summary |
|---|---|
| protected void appendUnicodeEscapedCodePoint(int codePoint, StringBuilder sb) Escape the Unicode code point appropriately for this language
and append the escaped value to | |
| encodeInt16AsCharEscape | back to summary |
|---|---|
| public String encodeInt16AsCharEscape(int v) Assume 16-bit char | |
| escapeChar | back to summary |
|---|---|
| protected String escapeChar(int v) | |
| escapeIfNeeded | back to summary |
|---|---|
| public String escapeIfNeeded(String identifier) | |
| escapeWord | back to summary |
|---|---|
| protected String escapeWord(String word) | |
| genFile | back to summary |
|---|---|
| protected void genFile(Grammar g, ST outputFileST, String fileName) | |
| getAltLabelContextStructName | back to summary |
|---|---|
| public String getAltLabelContextStructName(String label) | |
| getBaseListenerFileName | back to summary |
|---|---|
| public String getBaseListenerFileName(boolean header) A given grammar T, return a blank listener implementation such as TBaseListener.java, if we're using the Java target. | |
| getBaseVisitorFileName | back to summary |
|---|---|
| public String getBaseVisitorFileName(boolean header) A given grammar T, return a blank listener implementation such as TBaseListener.java, if we're using the Java target. | |
| getCodeGenerator | back to summary |
|---|---|
| public CodeGenerator getCodeGenerator() | |
| getElementListName | back to summary |
|---|---|
| public String getElementListName(String name) | |
| getElementName | back to summary |
|---|---|
| public String getElementName(String name) | |
| getImplicitRuleLabel | back to summary |
|---|---|
| public String getImplicitRuleLabel(String ruleName) | |
| getImplicitSetLabel | back to summary |
|---|---|
| public String getImplicitSetLabel(String id) | |
| getImplicitTokenLabel | back to summary |
|---|---|
| public String getImplicitTokenLabel(String tokenName) | |
| getInlineTestSetWordSize | back to summary |
|---|---|
| public int getInlineTestSetWordSize() How many bits should be used to do inline token type tests? Java assumes a 64-bit word for bitsets. Must be a valid wordsize for your target like 8, 16, 32, 64, etc...
| |
| getLanguage | back to summary |
|---|---|
| public String getLanguage() | |
| getListenerFileName | back to summary |
|---|---|
| public String getListenerFileName(boolean header) A given grammar T, return the listener name such as TListener.java, if we're using the Java target. | |
| getListLabel | back to summary |
|---|---|
| public String getListLabel(String label) | |
| getLoopCounter | back to summary |
|---|---|
| public String getLoopCounter(GrammarAST ast) | |
| getLoopLabel | back to summary |
|---|---|
| public String getLoopLabel(GrammarAST ast) | |
| getRecognizerFileName | back to summary |
|---|---|
| public 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. | |
| getReservedWords | back to summary |
|---|---|
| protected abstract Set | |
| getRuleFunctionContextStructName | back to summary |
|---|---|
| public String getRuleFunctionContextStructName(Rule r) | |
| getRuleFunctionContextStructName | back to summary |
|---|---|
| public String getRuleFunctionContextStructName(RuleFunction function) If we know which actual function, we can provide the actual ctx type. This will contain implicit labels etc... From outside, though, we see only ParserRuleContext unless there are externally visible stuff like args, locals, explicit labels, etc... | |
| getSerializedATNSegmentLimit | back to summary |
|---|---|
| public int getSerializedATNSegmentLimit() Gets the maximum number of 16-bit unsigned integers that can be encoded in a single segment (a declaration in target language) of the serialized ATN. E.g., in C++, a small segment length results in multiple decls like: static const int32_t serializedATNSegment1[] = { 0x7, 0x12, 0x2, 0x13, 0x7, 0x13, 0x2, 0x14, 0x7, 0x14, 0x2, 0x15, 0x7, 0x15, 0x2, 0x16, 0x7, 0x16, 0x2, 0x17, 0x7, 0x17, 0x2, 0x18, 0x7, 0x18, 0x2, 0x19, 0x7, 0x19, 0x2, 0x1a, 0x7, 0x1a, 0x2, 0x1b, 0x7, 0x1b, 0x2, 0x1c, 0x7, 0x1c, 0x2, 0x1d, 0x7, 0x1d, 0x2, 0x1e, 0x7, 0x1e, 0x2, 0x1f, 0x7, 0x1f, 0x2, 0x20, 0x7, 0x20, 0x2, 0x21, 0x7, 0x21, 0x2, 0x22, 0x7, 0x22, 0x2, 0x23, 0x7, 0x23, 0x2, 0x24, 0x7, 0x24, 0x2, 0x25, 0x7, 0x25, 0x2, 0x26, }; instead of one big one. Targets are free to ignore this like JavaScript does. This is primarily needed by Java target to limit size of any single ATN string to 65k length.
| |
| getTargetCharValueEscape | back to summary |
|---|---|
| public Map 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. | |
| getTargetStringLiteralFromANTLRStringLiteral | back to summary |
|---|---|
| public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal, boolean addQuotes) | |
| getTargetStringLiteralFromANTLRStringLiteral | back to summary |
|---|---|
| public String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, String literal, boolean addQuotes, boolean escapeSpecial) 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
Note that we have decided to allow people to use '\"' without penalty, so
we must build the target string in a loop as | |
| getTargetStringLiteralFromString | back to summary |
|---|---|
| public 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. For example, if the incoming string has actual newline characters, the output of this method would convert them to the two char sequence \n for Java, C, C++, ... The new string has double-quotes around it as well. Example String in memory: a"[newlinechar]b'c[carriagereturnchar]d[tab]e\f would be converted to the valid Java s: "a\"\nb'c\rd\te\\f" or a\"\nb'c\rd\te\\f depending on the quoted arg. | |
| getTargetStringLiteralFromString | back to summary |
|---|---|
| public String getTargetStringLiteralFromString(String s) | |
| getTemplates | back to summary |
|---|---|
| public synchronized STGroup getTemplates() | |
| getTokenTypeAsTargetLabel | back to summary |
|---|---|
| public String getTokenTypeAsTargetLabel(Grammar g, int ttype) Get a meaningful name for a token type useful during code generation. Literals without associated names are converted to the string equivalent of their integer values. Used to generate x==ID and x==34 type comparisons etc... Essentially we are looking for the most obvious way to refer to a token type in the generated code. | |
| getTokenTypesAsTargetLabels | back to summary |
|---|---|
| public String[] getTokenTypesAsTargetLabels(Grammar g, int[] ttypes) | |
| getVersion | back to summary |
|---|---|
| public String getVersion() ANTLR tool should check output templates / target are compatible with tool code generation. For now, a simple string match used on x.y of x.y.z scheme. We use a method to avoid mismatches between a template called VERSION. This value is checked against Tool.VERSION during load of templates. This additional method forces all targets 4.3 and beyond to add this method.
| |
| getVisitorFileName | back to summary |
|---|---|
| public String getVisitorFileName(boolean header) A given grammar T, return the visitor name such as TVisitor.java, if we're using the Java target. | |
| grammarSymbolCausesIssueInGeneratedCode | back to summary |
|---|---|
| public boolean grammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode) | |
| isATNSerializedAsInts | back to summary |
|---|---|
| public boolean isATNSerializedAsInts() | |
| loadTemplates | back to summary |
|---|---|
| protected STGroup loadTemplates() | |
| loadTemplatesHelper | back to summary |
|---|---|
| private STGroup loadTemplatesHelper(boolean reportErrorIfFail) | |
| needsHeader | back to summary |
|---|---|
public boolean needsHeader()
| |
| shouldUseUnicodeEscapeForCodePointInDoubleQuotedString | back to summary |
|---|---|
| protected boolean shouldUseUnicodeEscapeForCodePointInDoubleQuotedString(int codePoint) | |
| supportsOverloadedMethods | back to summary |
|---|---|
public boolean supportsOverloadedMethods()
| |
| templatesExist | back to summary |
|---|---|
| public boolean templatesExist() | |
| visibleGrammarSymbolCausesIssueInGeneratedCode | back to summary |
|---|---|
| protected boolean visibleGrammarSymbolCausesIssueInGeneratedCode(GrammarAST idNode)
Deprecated
| |
| wantsBaseListener | back to summary |
|---|---|
public boolean wantsBaseListener()
| |
| wantsBaseVisitor | back to summary |
|---|---|
public boolean wantsBaseVisitor()
| |