• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FailedPredicateException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



FailedPredicateException类属于org.antlr.v4.runtime包,在下文中一共展示了FailedPredicateException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: reportError

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
public void reportError(Parser recognizer, RecognitionException e) {
  if (!this.inErrorRecoveryMode(recognizer)) {
    this.beginErrorCondition(recognizer);
    if (e instanceof NoViableAltException) {
      this.reportNoViableAlternative(recognizer, (NoViableAltException) e);
    } else if (e instanceof InputMismatchException) {
      this.reportInputMismatch(recognizer, (InputMismatchException) e);
    } else if (e instanceof FailedPredicateException) {
      this.reportFailedPredicate(recognizer, (FailedPredicateException) e);
    } else {
      System.err.println("unknown recognition error type: " + e.getClass().getName());
      recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e);
    }

  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:17,代码来源:KsqlParserErrorStrategy.java


示例2: recover

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
@Override
public void recover(Parser recognizer, RecognitionException e) {
    for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
        context.exception = e;
    }

    if (PredictionMode.LL.equals(recognizer.getInterpreter().getPredictionMode())) {
        if (e instanceof NoViableAltException) {
            this.reportNoViableAlternative(recognizer, (NoViableAltException) e);
        } else if (e instanceof InputMismatchException) {
            this.reportInputMismatch(recognizer, (InputMismatchException) e);
        } else if (e instanceof FailedPredicateException) {
            this.reportFailedPredicate(recognizer, (FailedPredicateException) e);
        }
    }

    throw new ParseCancellationException(e);
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:DescriptiveErrorStrategy.java


示例3: exceptionString

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
public static String exceptionString(Parser parser, RecognitionException ex) {
    if (ex instanceof FailedPredicateException) {
        return failedPredicate((FailedPredicateException) ex);
    } else if (ex instanceof InputMismatchException) {
        return inputMismatch((InputMismatchException) ex);
    } else if (ex instanceof NoViableAltException) {
        return noViableAlt(parser, (NoViableAltException) ex);
    } else {
        System.err.println("unknown recognition exception:" + ex);
        return ex.toString();
    }
}
 
开发者ID:kasonyang,项目名称:kalang,代码行数:13,代码来源:AntlrErrorString.java


示例4: reportError

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
@Override
public void reportError(Parser recognizer, RecognitionException e)
{
	// if we've already reported an error and have not matched a token
	// yet successfully, don't report any errors.
	if (inErrorRecoveryMode(recognizer))
	{
		//			System.err.print("[SPURIOUS] ");
		return; // don't report spurious errors
	}
	beginErrorCondition(recognizer);
	if (e instanceof NoViableAltException)
	{
		reportNoViableAlternative(recognizer, (NoViableAltException) e);
	}
	else if (e instanceof InputMismatchException)
	{
		reportInputMismatch(recognizer, (InputMismatchException) e);
	}
	else if (e instanceof FailedPredicateException)
	{
		reportFailedPredicate(recognizer, (FailedPredicateException) e);
	}
	else
	{
		//			System.err.println("unknown recognition error type: " + e.getClass().getName());
		BeetlException exception = new BeetlException(BeetlException.PARSER_UNKNOW_ERROR, e.getClass().getName(), e);
		//			exception.token = this.getGrammarToken(e.getOffendingToken());
		exception.pushToken(this.getGrammarToken(e.getOffendingToken()));

		throw exception;
	}
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:34,代码来源:BeetlAntlrErrorStrategy.java


示例5: reportFailedPredicate

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
protected void reportFailedPredicate(@NotNull Parser recognizer, @NotNull FailedPredicateException e)
{
	String ruleName = recognizer.getRuleNames()[recognizer.getContext().getRuleIndex()];
	BeetlException exception = new BeetlParserException(BeetlException.PARSER_PREDICATE_ERROR, ruleName, e);
	//		exception.token = this.getGrammarToken(e.getOffendingToken());
	exception.pushToken(this.getGrammarToken(e.getOffendingToken()));

	throw exception;
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:10,代码来源:BeetlAntlrErrorStrategy.java


示例6: failedPredicate

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
public static String failedPredicate(FailedPredicateException e) {
    String ruleName = e.getRecognizer().getRuleNames()[e.getRuleIndex()];
    return "rule<" + ruleName + ">:" + e.getMessage();
}
 
开发者ID:kasonyang,项目名称:kalang,代码行数:5,代码来源:AntlrErrorString.java


示例7: createFailedPredicateErrorMessage

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
protected String createFailedPredicateErrorMessage(Parser recognizer,
                                                   FailedPredicateException e) {
    return e.getMessage();
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:DescriptiveErrorStrategy.java


示例8: reportFailedPredicate

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
protected void reportFailedPredicate(Parser recognizer,
                                     FailedPredicateException e) {
    notifyErrorListeners(recognizer, this.createFailedPredicateErrorMessage(recognizer, e), e);
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:DescriptiveErrorStrategy.java


示例9: reportFailedPredicate

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
/**
 * @see DefaultErrorStrategy#reportFailedPredicate
 */
@Override
protected void reportFailedPredicate(Parser recognizer, FailedPredicateException e) {
    super.reportFailedPredicate(recognizer, e);
}
 
开发者ID:globalforge,项目名称:infix,代码行数:8,代码来源:FixRulesErrorStrategy.java


示例10: parseJavadocAsDetailNode

import org.antlr.v4.runtime.FailedPredicateException; //导入依赖的package包/类
/**
 * Parses Javadoc comment as DetailNode tree.
 * @param javadocCommentAst
 *        DetailAST of Javadoc comment
 * @return DetailNode tree of Javadoc comment
 */
public ParseStatus parseJavadocAsDetailNode(DetailAST javadocCommentAst) {
    blockCommentLineNumber = javadocCommentAst.getLineNo();

    final String javadocComment = JavadocUtils.getJavadocCommentContent(javadocCommentAst);

    // Use a new error listener each time to be able to use
    // one check instance for multiple files to be checked
    // without getting side effects.
    errorListener = new DescriptiveErrorListener();

    // Log messages should have line number in scope of file,
    // not in scope of Javadoc comment.
    // Offset is line number of beginning of Javadoc comment.
    errorListener.setOffset(javadocCommentAst.getLineNo() - 1);

    final ParseStatus result = new ParseStatus();

    try {
        final JavadocParser javadocParser = createJavadocParser(javadocComment);

        final ParseTree javadocParseTree = javadocParser.javadoc();

        final DetailNode tree = convertParseTreeToDetailNode(javadocParseTree);
        // adjust first line to indent of /**
        adjustFirstLineToJavadocIndent(tree,
                    javadocCommentAst.getColumnNo()
                            + JAVADOC_START.length());
        result.setTree(tree);
        result.firstNonTightHtmlTag = getFirstNonTightHtmlTag(javadocParser);
    }
    catch (ParseCancellationException | IllegalArgumentException ex) {
        ParseErrorMessage parseErrorMessage = null;

        if (ex.getCause() instanceof FailedPredicateException
                || ex.getCause() instanceof NoViableAltException) {
            final RecognitionException recognitionEx = (RecognitionException) ex.getCause();
            if (recognitionEx.getCtx() instanceof JavadocParser.HtmlTagContext) {
                final Token htmlTagNameStart = getMissedHtmlTag(recognitionEx);
                parseErrorMessage = new ParseErrorMessage(
                        errorListener.offset + htmlTagNameStart.getLine(),
                        MSG_JAVADOC_MISSED_HTML_CLOSE,
                        htmlTagNameStart.getCharPositionInLine(),
                        htmlTagNameStart.getText());
            }
        }

        if (parseErrorMessage == null) {
            // If syntax error occurs then message is printed by error listener
            // and parser throws this runtime exception to stop parsing.
            // Just stop processing current Javadoc comment.
            parseErrorMessage = errorListener.getErrorMessage();
        }

        result.setParseErrorMessage(parseErrorMessage);
    }

    return result;
}
 
开发者ID:checkstyle,项目名称:checkstyle,代码行数:65,代码来源:JavadocDetailNodeParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NonMonotonicSequenceException类代码示例发布时间:2022-05-21
下一篇:
Java VertexBufferObjectManager类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap