public interface Vocabulary
Recognizer.getVocabulary()
Modifier and Type | Method and Description |
---|---|
String |
getDisplayName(int tokenType)
Gets the display name of a token type.
|
String |
getLiteralName(int tokenType)
Gets the string literal associated with a token type.
|
int |
getMaxTokenType()
Returns the highest token type value.
|
String |
getSymbolicName(int tokenType)
Gets the symbolic name associated with a token type.
|
int getMaxTokenType()
String getLiteralName(int tokenType)
null
, can be used unaltered in a parser
grammar to represent this token type.
The following table shows examples of lexer rules and the literal names assigned to the corresponding token types.
Rule | Literal Name | Java String Literal |
---|---|---|
THIS : 'this'; |
'this' |
"'this'" |
SQUOTE : '\''; |
'\'' |
"'\\''" |
ID : [A-Z]+; |
n/a | null |
tokenType
- The token type.null
if no string literal is associated with the type.String getSymbolicName(int tokenType)
null
, can be used unaltered in a parser
grammar to represent this token type.
This method supports token types defined by any of the following methods:
tokens{}
block in a lexer or parser
grammar.EOF
token, which has the token type
Token.EOF
.The following table shows examples of lexer rules and the literal names assigned to the corresponding token types.
Rule | Symbolic Name |
---|---|
THIS : 'this'; |
THIS |
SQUOTE : '\''; |
SQUOTE |
ID : [A-Z]+; |
ID |
tokenType
- The token type.null
if no symbolic name is associated with the type.String getDisplayName(int tokenType)
ANTLR provides a default implementation of this method, but
applications are free to override the behavior in any manner which makes
sense for the application. The default implementation returns the first
result from the following list which produces a non-null
result.
getLiteralName(int)
getSymbolicName(int)
Integer.toString(int, int)
tokenType
- The token type.Copyright © 1992–2018 ANTLR. All rights reserved.