本文整理了Java中org.antlr.v4.runtime.Parser.getVocabulary()
方法的一些代码示例,展示了Parser.getVocabulary()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getVocabulary()
方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:getVocabulary
暂无
代码示例来源:origin: prestodb/presto
Analyzer analyzer = new Analyzer(atn, parser.getVocabulary(), specialRules, specialTokens, ignoredRules, parser.getTokenStream());
Multimap<Integer, String> candidates = analyzer.process(currentState, currentToken.getTokenIndex(), context);
代码示例来源:origin: confluentinc/ksql
protected void reportMissingToken(final Parser recognizer) {
if (!this.inErrorRecoveryMode(recognizer)) {
this.beginErrorCondition(recognizer);
final Token t = recognizer.getCurrentToken();
final IntervalSet expecting = this.getExpectedTokens(recognizer);
final String msg =
"missing " + expecting.toString(recognizer.getVocabulary()) + " at " + this
.getTokenErrorDisplay(t);
recognizer.notifyErrorListeners(t, msg, (RecognitionException) null);
}
}
}
代码示例来源:origin: confluentinc/ksql
protected void reportUnwantedToken(final Parser recognizer) {
if (!this.inErrorRecoveryMode(recognizer)) {
this.beginErrorCondition(recognizer);
final Token t = recognizer.getCurrentToken();
final String tokenName = this.getTokenErrorDisplay(t);
final IntervalSet expecting = this.getExpectedTokens(recognizer);
final String msg =
"extraneous input " + tokenName + " expecting "
+ expecting.toString(recognizer.getVocabulary());
recognizer.notifyErrorListeners(t, msg, (RecognitionException) null);
}
}
代码示例来源:origin: org.antlr/antlr4-runtime
public String getTokenName(int t) {
if (t == Token.EOF) {
return "EOF";
}
Vocabulary vocabulary = parser != null ? parser.getVocabulary() : VocabularyImpl.EMPTY_VOCABULARY;
String displayName = vocabulary.getDisplayName(t);
if (displayName.equals(Integer.toString(t))) {
return displayName;
}
return displayName + "<" + t + ">";
}
代码示例来源:origin: org.antlr/antlr4-runtime
/** For debugging and other purposes. */
public List<String> getDFAStrings() {
synchronized (_interp.decisionToDFA) {
List<String> s = new ArrayList<String>();
for (int d = 0; d < _interp.decisionToDFA.length; d++) {
DFA dfa = _interp.decisionToDFA[d];
s.add( dfa.toString(getVocabulary()) );
}
return s;
}
}
代码示例来源:origin: org.antlr/antlr4-runtime
/** For debugging and other purposes. */
public void dumpDFA() {
synchronized (_interp.decisionToDFA) {
boolean seenOne = false;
for (int d = 0; d < _interp.decisionToDFA.length; d++) {
DFA dfa = _interp.decisionToDFA[d];
if ( !dfa.states.isEmpty() ) {
if ( seenOne ) System.out.println();
System.out.println("Decision " + dfa.decision + ":");
System.out.print(dfa.toString(getVocabulary()));
seenOne = true;
}
}
}
}
代码示例来源:origin: org.antlr/antlr4-runtime
System.out.println("DFA=\n"+dfa.toString(parser!=null?parser.getVocabulary():VocabularyImpl.EMPTY_VOCABULARY));
代码示例来源:origin: org.antlr/antlr4-runtime
/**
* This is called by {@link #reportError} when the exception is an
* {@link InputMismatchException}.
*
* @see #reportError
*
* @param recognizer the parser instance
* @param e the recognition exception
*/
protected void reportInputMismatch(Parser recognizer,
InputMismatchException e)
{
String msg = "mismatched input "+getTokenErrorDisplay(e.getOffendingToken())+
" expecting "+e.getExpectedTokens().toString(recognizer.getVocabulary());
recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
代码示例来源:origin: org.antlr/antlr4-runtime
/**
* This method is called to report a syntax error which requires the
* insertion of a missing token into the input stream. At the time this
* method is called, the missing token has not yet been inserted. When this
* method returns, {@code recognizer} is in error recovery mode.
*
* <p>This method is called when {@link #singleTokenInsertion} identifies
* single-token insertion as a viable recovery strategy for a mismatched
* input error.</p>
*
* <p>The default implementation simply returns if the handler is already in
* error recovery mode. Otherwise, it calls {@link #beginErrorCondition} to
* enter error recovery mode, followed by calling
* {@link Parser#notifyErrorListeners}.</p>
*
* @param recognizer the parser instance
*/
protected void reportMissingToken(Parser recognizer) {
if (inErrorRecoveryMode(recognizer)) {
return;
}
beginErrorCondition(recognizer);
Token t = recognizer.getCurrentToken();
IntervalSet expecting = getExpectedTokens(recognizer);
String msg = "missing "+expecting.toString(recognizer.getVocabulary())+
" at "+getTokenErrorDisplay(t);
recognizer.notifyErrorListeners(t, msg, null);
}
代码示例来源:origin: org.antlr/antlr4-runtime
/**
* This method is called to report a syntax error which requires the removal
* of a token from the input stream. At the time this method is called, the
* erroneous symbol is current {@code LT(1)} symbol and has not yet been
* removed from the input stream. When this method returns,
* {@code recognizer} is in error recovery mode.
*
* <p>This method is called when {@link #singleTokenDeletion} identifies
* single-token deletion as a viable recovery strategy for a mismatched
* input error.</p>
*
* <p>The default implementation simply returns if the handler is already in
* error recovery mode. Otherwise, it calls {@link #beginErrorCondition} to
* enter error recovery mode, followed by calling
* {@link Parser#notifyErrorListeners}.</p>
*
* @param recognizer the parser instance
*/
protected void reportUnwantedToken(Parser recognizer) {
if (inErrorRecoveryMode(recognizer)) {
return;
}
beginErrorCondition(recognizer);
Token t = recognizer.getCurrentToken();
String tokenName = getTokenErrorDisplay(t);
IntervalSet expecting = getExpectedTokens(recognizer);
String msg = "extraneous input "+tokenName+" expecting "+
expecting.toString(recognizer.getVocabulary());
recognizer.notifyErrorListeners(t, msg, null);
}
代码示例来源:origin: org.antlr/antlr4-runtime
parser.getVocabulary(),
Arrays.asList(parser.getRuleNames()),
parser.getATNWithBypassAlts(),
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
/** For debugging and other purposes. */
public List<String> getDFAStrings() {
synchronized (_interp.decisionToDFA) {
List<String> s = new ArrayList<String>();
for (int d = 0; d < _interp.decisionToDFA.length; d++) {
DFA dfa = _interp.decisionToDFA[d];
s.add( dfa.toString(getVocabulary()) );
}
return s;
}
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
public String getTokenName(int t) {
if (t == Token.EOF) {
return "EOF";
}
Vocabulary vocabulary = parser != null ? parser.getVocabulary() : VocabularyImpl.EMPTY_VOCABULARY;
String displayName = vocabulary.getDisplayName(t);
if (displayName.equals(Integer.toString(t))) {
return displayName;
}
return displayName + "<" + t + ">";
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
/** For debugging and other purposes. */
public List<String> getDFAStrings() {
synchronized (_interp.decisionToDFA) {
List<String> s = new ArrayList<String>();
for (int d = 0; d < _interp.decisionToDFA.length; d++) {
DFA dfa = _interp.decisionToDFA[d];
s.add( dfa.toString(getVocabulary()) );
}
return s;
}
}
代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime
@NotNull
public String getTokenName(int t) {
if (t == Token.EOF) {
return "EOF";
}
Vocabulary vocabulary = parser != null ? parser.getVocabulary() : VocabularyImpl.EMPTY_VOCABULARY;
String displayName = vocabulary.getDisplayName(t);
if (displayName.equals(Integer.toString(t))) {
return displayName;
}
return displayName + "<" + t + ">";
}
代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime
/** For debugging and other purposes. */
public List<String> getDFAStrings() {
List<String> s = new ArrayList<String>();
for (int d = 0; d < _interp.atn.decisionToDFA.length; d++) {
DFA dfa = _interp.atn.decisionToDFA[d];
s.add( dfa.toString(getVocabulary(), getRuleNames()) );
}
return s;
}
代码示例来源:origin: org.antlr/antlr4-runtime
else tokenText = "<missing "+recognizer.getVocabulary().getDisplayName(expectedTokenType)+">";
Token current = currentSymbol;
Token lookback = recognizer.getInputStream().LT(-1);
代码示例来源:origin: org.antlr/antlr4-runtime
if ( debug ) System.out.println("DFA after predictATN: "+ dfa.toString(parser.getVocabulary()));
return alt;
代码示例来源:origin: org.codelibs.elasticsearch.module/lang-painless
@Override
public Token recoverInline(final Parser recognizer) throws RecognitionException {
final Token token = recognizer.getCurrentToken();
final String message = "unexpected token [" + getTokenErrorDisplay(token) + "]" +
" was expecting one of [" + recognizer.getExpectedTokens().toString(recognizer.getVocabulary()) + "].";
Location location = new Location(sourceName, token.getStartIndex());
throw location.createError(new IllegalArgumentException(message));
}
代码示例来源:origin: org.ballerinalang/ballerina-lang
@Override
public void reportInputMismatch(Parser parser, InputMismatchException e) {
setErrorState(parser);
Token offendingToken = e.getOffendingToken();
String mismatchedToken = getTokenErrorDisplay(offendingToken);
String expectedToken = e.getExpectedTokens().toString(parser.getVocabulary());
DiagnosticPos pos = getPosition(offendingToken);
dlog.error(pos, DiagnosticCode.MISMATCHED_INPUT, mismatchedToken, expectedToken);
}
内容来源于网络,如有侵权,请联系作者删除!