本文整理了Java中org.antlr.v4.runtime.Parser.getRuleContext()
方法的一些代码示例,展示了Parser.getRuleContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getRuleContext()
方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:getRuleContext
暂无
代码示例来源:origin: org.bitbucket.goalhub.grammar/languageTools
/**
* We use a general RecognitionException with a particular text to signal to
* the error strategy what type of issue we found.
*
* @param text
* Label to indicate error type
* @param parser
* @return The recognition exception
*/
private RecognitionException getException(String text, Parser parser) {
return new RecognitionException(text, parser, parser.getInputStream(), parser.getRuleContext());
}
代码示例来源:origin: org.bitbucket.goalhub.krTools.krLanguages/swiprolog
/**
* We use a general RecognitionException with a particular text to signal to
* the error strategy what type of issue we found.
*
* @param text
* Label to indicate error type
* @param parser
* @return The recognition exception
*/
private RecognitionException getException(String text, Parser parser) {
return new RecognitionException(text, parser, parser.getInputStream(), parser.getRuleContext());
}
代码示例来源:origin: batfish/batfish
@Override
protected void beginErrorCondition(Parser parser) {
if (inErrorRecoveryMode(parser)) {
return;
}
_parserStateAtRecovery = parser.getRuleContext().toString(Arrays.asList(parser.getRuleNames()));
super.beginErrorCondition(parser);
}
代码示例来源:origin: antlr/antlr4-intellij-adaptor
@Override
protected void consumeUntil(Parser recognizer, IntervalSet set) {
Token o = recognizer.getCurrentToken();
if ( o.getType()==Token.EOF ) {
recognizer.getRuleContext().addErrorNode(o);
}
super.consumeUntil(recognizer, set);
}
代码示例来源:origin: org.bitbucket.goalhub.krTools.krLanguages/swiprolog
/**
* Helper method for reporting multiple expected alternatives
*
* @param tokens
* Set of expected tokens
* @return String representation of token set
*/
private String getExpectationTxt(Parser parser) {
IntervalSet tokens = getExpectedTokens(parser);
if (tokens.size() < 5) { // list all expected tokens if less than 5
int size = tokens.toList().size();
String str = (size > 1 ? "either " : "");
for (int i = 0; i < size; i++) {
int type = tokens.toList().get(i);
str += prettyPrintToken(type);
str += (i < size - 2 ? ", " : "");
str += (i == size - 2 ? " or " : "");
}
return str;
} else { // otherwise output parser rule context
return prettyPrintRuleContext(parser.getRuleContext().getRuleIndex());
}
}
代码示例来源:origin: org.bitbucket.goalhub.grammar/languageTools
/**
* Helper method for reporting multiple expected alternatives
*
* @param tokens
* Set of expected tokens
* @return String representation of token set
*/
private String getExpectationTxt(Parser parser) {
String str;
IntervalSet tokens = getExpectedTokens(parser);
if (tokens.size() < 7) { // list all expected tokens if less than 7
int size = tokens.toList().size();
str = (size > 1 ? "either " : "");
for (int i = 0; i < size; i++) {
int type = tokens.toList().get(i);
str += prettyPrintToken(type);
str += (i < size - 2 ? ", " : "");
str += (i == size - 2 ? " or " : "");
}
} else { // otherwise output parser rule context
str = prettyPrintRuleContext(parser.getRuleContext().getRuleIndex());
}
return str;
}
内容来源于网络,如有侵权,请联系作者删除!