当前位置: 首页>>代码示例>>Java>>正文


Java Parser.getCurrentToken方法代码示例

本文整理汇总了Java中org.antlr.v4.runtime.Parser.getCurrentToken方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.getCurrentToken方法的具体用法?Java Parser.getCurrentToken怎么用?Java Parser.getCurrentToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.antlr.v4.runtime.Parser的用法示例。


在下文中一共展示了Parser.getCurrentToken方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reportUnwantedToken

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
protected void reportUnwantedToken(@NotNull Parser recognizer)
{
	if (inErrorRecoveryMode(recognizer))
	{
		return;
	}

	beginErrorCondition(recognizer);

	Token t = recognizer.getCurrentToken();
	String tokenName = getTokenErrorDisplay(t);
	IntervalSet expecting = getExpectedTokens(recognizer);
	String msg = "多余输入 " + tokenName + " 期望 " + expecting.toString(recognizer.getTokenNames());
	BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg);
	//		exception.token = this.getGrammarToken(t);
	exception.pushToken(this.getGrammarToken(t));
	throw exception;
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:19,代码来源:BeetlAntlrErrorStrategy.java

示例2: reportUnwantedToken

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@Override
protected void reportUnwantedToken(Parser recognizer) {
	// change error message from default implementation
	if (inErrorRecoveryMode(recognizer)) {
		return;
	}

	beginErrorCondition(recognizer);

	Token t = recognizer.getCurrentToken();
	String tokenName = getTokenErrorDisplay(t);
	String msg = "extraneous input " + tokenName + " expecting operator";
	recognizer.notifyErrorListeners(t, msg, null);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:CapitulatingErrorStrategy.java

示例3: recoverInline

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@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));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ParserErrorStrategy.java

示例4: reportMissingToken

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@Override
public void reportMissingToken(Parser recognizer) {
	beginErrorCondition(recognizer);
	Token t = recognizer.getCurrentToken();
	IntervalSet expecting = getExpectedTokens(recognizer);
	String msg = "missing " + expecting.toString(recognizer.getTokenNames()) + " at " + getTokenErrorDisplay(t);
	throw new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext());
}
 
开发者ID:paypal,项目名称:digraph-parser,代码行数:9,代码来源:GraphParser.java

示例5: reportUnwantedToken

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
protected void reportUnwantedToken(Parser recognizer) {
  if (!this.inErrorRecoveryMode(recognizer)) {
    this.beginErrorCondition(recognizer);
    Token t = recognizer.getCurrentToken();
    String tokenName = this.getTokenErrorDisplay(t);
    IntervalSet expecting = this.getExpectedTokens(recognizer);
    String msg =
        "extraneous input " + tokenName + " expecting "
        + expecting.toString(recognizer.getVocabulary());
    recognizer.notifyErrorListeners(t, msg, (RecognitionException) null);
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:13,代码来源:KsqlParserErrorStrategy.java

示例6: reportMissingToken

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
protected void reportMissingToken(Parser recognizer) {
  if (!this.inErrorRecoveryMode(recognizer)) {
    this.beginErrorCondition(recognizer);
    Token t = recognizer.getCurrentToken();
    IntervalSet expecting = this.getExpectedTokens(recognizer);
    String msg =
        "missing " + expecting.toString(recognizer.getVocabulary()) + " at " + this
            .getTokenErrorDisplay(t);
    recognizer.notifyErrorListeners(t, msg, (RecognitionException) null);
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:12,代码来源:KsqlParserErrorStrategy.java

示例7: consumeUntil

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@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);
}
 
开发者ID:antlr,项目名称:jetbrains,代码行数:9,代码来源:ErrorStrategyAdaptor.java

示例8: getMissingSymbol

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
/** By default ANTLR makes the start/stop -1/-1 for invalid tokens
 *  which is reasonable but here we want to highlight the
 *  current position indicating that is where we lack a token.
 *  if no input, highlight at position 0.
 */
protected Token getMissingSymbol(Parser recognizer) {
	Token missingSymbol = super.getMissingSymbol(recognizer);
	// alter the default missing symbol.
	if ( missingSymbol instanceof CommonToken) {
		int start, stop;
		Token current = recognizer.getCurrentToken();
		start = current.getStartIndex();
		stop = current.getStopIndex();
		((CommonToken) missingSymbol).setStartIndex(start);
		((CommonToken) missingSymbol).setStopIndex(stop);
	}
	return missingSymbol;
}
 
开发者ID:antlr,项目名称:jetbrains,代码行数:19,代码来源:ErrorStrategyAdaptor.java

示例9: reportMissingToken

import org.antlr.v4.runtime.Parser; //导入方法依赖的package包/类
@Override
public void reportMissingToken(Parser recognizer) {
    beginErrorCondition(recognizer);
    Token t = recognizer.getCurrentToken();
    IntervalSet expecting = getExpectedTokens(recognizer);
    String msg = "";
    msg += "In file " + recognizer.getSourceName() + " at line " + recognizer.getContext().start.getLine() + ": ";
    msg += "Missing "+expecting.toString(recognizer.getTokenNames()) + " at " + getTokenErrorDisplay(t) + ";";
    //msg += "Line Number " + recognizer.getContext().start.getLine() + ", Column " + recognizer.getContext().start.getCharPositionInLine() + ";";
    throw new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext());
}
 
开发者ID:FIWARE-Middleware,项目名称:KIARA,代码行数:12,代码来源:ParserExceptionErrorStrategyImpl.java


注:本文中的org.antlr.v4.runtime.Parser.getCurrentToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。