本文整理了Java中org.antlr.v4.runtime.Parser.getTokenStream()
方法的一些代码示例,展示了Parser.getTokenStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.getTokenStream()
方法的具体详情如下:
包路径:org.antlr.v4.runtime.Parser
类名称:Parser
方法名:getTokenStream
暂无
代码示例来源: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: org.antlr/antlr4-runtime
@Override
public TokenStream getInputStream() { return getTokenStream(); }
代码示例来源:origin: org.antlr/antlr4-runtime
/**
* The preferred method of getting a tree pattern. For example, here's a
* sample use:
*
* <pre>
* ParseTree t = parser.expr();
* ParseTreePattern p = parser.compileParseTreePattern("<ID>+0", MyParser.RULE_expr);
* ParseTreeMatch m = p.match(t);
* String id = m.get("ID");
* </pre>
*/
public ParseTreePattern compileParseTreePattern(String pattern, int patternRuleIndex) {
if ( getTokenStream()!=null ) {
TokenSource tokenSource = getTokenStream().getTokenSource();
if ( tokenSource instanceof Lexer ) {
Lexer lexer = (Lexer)tokenSource;
return compileParseTreePattern(pattern, patternRuleIndex, lexer);
}
}
throw new UnsupportedOperationException("Parser can't discover a lexer to use");
}
代码示例来源:origin: org.antlr/antlr4-runtime
@Override
public void reportContextSensitivity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
int prediction,
ATNConfigSet configs)
{
String format = "reportContextSensitivity d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: org.antlr/antlr4-runtime
@Override
public void reportAttemptingFullContext(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
BitSet conflictingAlts,
ATNConfigSet configs)
{
String format = "reportAttemptingFullContext d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: org.antlr/antlr4-runtime
@Override
public void reportAmbiguity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
boolean exact,
BitSet ambigAlts,
ATNConfigSet configs)
{
if (exactOnly && !exact) {
return;
}
String format = "reportAmbiguity d=%s: ambigAlts=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
BitSet conflictingAlts = getConflictingAlts(ambigAlts, configs);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, conflictingAlts, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public TokenStream getInputStream() { return getTokenStream(); }
代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime
@Override
public TokenStream getInputStream() { return getTokenStream(); }
代码示例来源:origin: io.virtdata/virtdata-lib-realer
@Override
public TokenStream getInputStream() { return getTokenStream(); }
代码示例来源:origin: org.ballerinalang/language-server-core
@Override
public void reportInputMismatch(Parser parser, InputMismatchException e) {
if (!parser.getContext().start.getTokenSource().getSourceName()
.equals(context.get(DocumentServiceKeys.RELATIVE_FILE_PATH_KEY).replace("\\", "/"))) {
return;
}
this.context.put(CompletionKeys.TOKEN_STREAM_KEY, parser.getTokenStream());
}
代码示例来源:origin: org.ballerinalang/language-server-core
@Override
public void reportMissingToken(Parser parser) {
if (!parser.getContext().start.getTokenSource().getSourceName()
.equals(context.get(DocumentServiceKeys.RELATIVE_FILE_PATH_KEY).replace("\\", "/"))) {
return;
}
this.context.put(CompletionKeys.TOKEN_STREAM_KEY, parser.getTokenStream());
}
代码示例来源:origin: org.ballerinalang/language-server-core
@Override
public void reportNoViableAlternative(Parser parser, NoViableAltException e) {
if (!parser.getContext().start.getTokenSource().getSourceName()
.equals(context.get(DocumentServiceKeys.RELATIVE_FILE_PATH_KEY).replace("\\", "/"))) {
return;
}
this.context.put(CompletionKeys.TOKEN_STREAM_KEY, parser.getTokenStream());
}
代码示例来源:origin: syhily/elasticsearch-jdbc
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
int charPositionInLine, String msg, RecognitionException e) {
String position = "line " + line + ", pos " + charPositionInLine;
String tokenName = "";
String hint = "";
if (offendingSymbol != null && offendingSymbol instanceof Token && recognizer != null && recognizer instanceof Parser) {
Token token = (Token) offendingSymbol;
tokenName = token.getText();
String fullText = ((Parser) recognizer).getTokenStream().getTokenSource().getInputStream().toString();
hint = AntlrUtils.underlineError(fullText, tokenName, line, charPositionInLine);
}
throw new SyntaxErrorException(position + " near " + tokenName + " : " + msg + "\n" + hint, e);
}
}
代码示例来源:origin: org.ballerinalang/language-server-core
@Override
public void reportUnwantedToken(Parser parser) {
if (!parser.getContext().start.getTokenSource().getSourceName()
.equals(context.get(DocumentServiceKeys.RELATIVE_FILE_PATH_KEY).replace("\\", "/"))) {
return;
}
this.context.put(CompletionKeys.TOKEN_STREAM_KEY, parser.getTokenStream());
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
@Override
public void reportAttemptingFullContext(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
BitSet conflictingAlts,
ATNConfigSet configs)
{
String format = "reportAttemptingFullContext d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: io.virtdata/virtdata-lib-realer
@Override
public void reportContextSensitivity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
int prediction,
ATNConfigSet configs)
{
String format = "reportContextSensitivity d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public void reportAttemptingFullContext(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
BitSet conflictingAlts,
ATNConfigSet configs)
{
String format = "reportAttemptingFullContext d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public void reportContextSensitivity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
int prediction,
ATNConfigSet configs)
{
String format = "reportContextSensitivity d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime
@Override
public void reportContextSensitivity(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
int prediction,
ATNConfigSet configs)
{
String format = "reportContextSensitivity d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
代码示例来源:origin: uk.co.nichesolutions/antlr4-runtime
@Override
public void reportAttemptingFullContext(Parser recognizer,
DFA dfa,
int startIndex,
int stopIndex,
BitSet conflictingAlts,
ATNConfigSet configs)
{
String format = "reportAttemptingFullContext d=%s, input='%s'";
String decision = getDecisionDescription(recognizer, dfa);
String text = recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex));
String message = String.format(format, decision, text);
recognizer.notifyErrorListeners(message);
}
内容来源于网络,如有侵权,请联系作者删除!