Java.target.apidocs.org.antlr.v4.runtime.Vocabulary.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of antlr4-perf-testsuite Show documentation
Show all versions of antlr4-perf-testsuite Show documentation
The ANTLR 4 grammar compiler.
Vocabulary (ANTLR 4 Runtime (Optimized) 4.7.3 API)
org.antlr.v4.runtime
Interface Vocabulary
-
- All Known Implementing Classes:
- VocabularyImpl
public interface Vocabulary
This interface provides information about the vocabulary used by a
recognizer.
- Author:
- Sam Harwell
- See Also:
Recognizer.getVocabulary()
-
-
Method Summary
Methods
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.
-
-
Method Detail
-
getMaxTokenType
int getMaxTokenType()
Returns the highest token type value. It can be used to iterate from
zero to that number, inclusively, thus querying all stored entries.
- Returns:
- the highest token type value
-
getLiteralName
@Nullable
String getLiteralName(int tokenType)
Gets the string literal associated with a token type. The string returned
by this method, when not 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
- Parameters:
tokenType
- The token type.
- Returns:
- The string literal associated with the specified token type, or
null
if no string literal is associated with the type.
-
getSymbolicName
@Nullable
String getSymbolicName(int tokenType)
Gets the symbolic name associated with a token type. The string returned
by this method, when not 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 created by lexer rules.
- Tokens defined in a
tokens{}
block in a lexer or parser
grammar.
- The implicitly defined
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
- Parameters:
tokenType
- The token type.
- Returns:
- The symbolic name associated with the specified token type, or
null
if no symbolic name is associated with the type.
-
getDisplayName
@NotNull
String getDisplayName(int tokenType)
Gets the display name of a token type.
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.
- The result of
getLiteralName(int)
- The result of
getSymbolicName(int)
- The result of
Integer.toString(int, int)
- Parameters:
tokenType
- The token type.
- Returns:
- The display name of the token type, for use in error reporting or
other user-visible messages which reference specific token types.
Copyright © 1992–2019 Tunnel Vision Laboratories, LLC. All rights reserved.