本文整理汇总了Java中org.parboiled.errors.ParserRuntimeException类的典型用法代码示例。如果您正苦于以下问题:Java ParserRuntimeException类的具体用法?Java ParserRuntimeException怎么用?Java ParserRuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParserRuntimeException类属于org.parboiled.errors包,在下文中一共展示了ParserRuntimeException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
import org.parboiled.errors.ParserRuntimeException; //导入依赖的package包/类
@Override
public Node parse(Environment environment, ResourceReference resource) {
ResourceService resourceService = environment.getResourceEnvironment().getResourceService();
BasicParseRunner<Node> runner = new BasicParseRunner<Node>(
ParserContext.instance(resource, configuration,
configuration.getAddonParserProviders(),
configuration.getUnaryOperators(),
configuration.getBinaryOperators(),
configuration.getTestExpressionParsers())
.parser(DocumentParser.class)
.NodeRule()
);
try {
ResourceMetadata resourceMetadata = resourceService.loadMetadata(resource);
Charset charset = resourceMetadata.getCharset()
.or(environment.getResourceEnvironment().getDefaultInputCharset());
ParsingResult<Node> result = runner.run(readAllText(resourceMetadata.load(), charset));
if (result.hasErrors()) {
throw new ParseException(toMessage(result.parseErrors));
} else if (!result.matched) {
throw new ParseException("Invalid template format");
} else {
return result.valueStack.pop();
}
} catch (ParserRuntimeException e) {
if ((e.getCause() != null) && (e.getCause() instanceof ParseException)) {
ParseException cause = (ParseException) e.getCause();
throw new ParseException(String.format("%s\n%s", cause.getMessage(), exceptionMessageExtractor.extract(e)), cause.getCause());
} else {
throw new ParseException(e);
}
}
}
开发者ID:jtwig,项目名称:jtwig-core,代码行数:35,代码来源:ParboiledJtwigParser.java
示例2: defaultProcess
import org.parboiled.errors.ParserRuntimeException; //导入依赖的package包/类
/**
* Default processing of any documentation node.
*
* @param doc The documentation.
* @param fixLeadingSpaces `true` if leading spaces should be fixed.
*
* @see Options#toHtml(String, boolean)
*/
protected void defaultProcess(Doc doc, boolean fixLeadingSpaces) {
try {
StringBuilder buf = new StringBuilder();
buf.append(getOptions().toHtml(doc.commentText(), fixLeadingSpaces));
buf.append('\n');
for ( Tag tag : doc.tags() ) {
processTag(tag, buf);
buf.append('\n');
}
doc.setRawCommentText(buf.toString());
}
catch ( final ParserRuntimeException e ) {
if ( doc instanceof RootDoc ) {
printError(new SourcePosition() {
@Override
public File file() {
return options.getOverviewFile();
}
@Override
public int line() {
return 0;
}
@Override
public int column() {
return 0;
}
}, e.getMessage());
}
else {
printError(doc.position(), e.getMessage());
}
}
}
开发者ID:Abnaxos,项目名称:markdown-doclet,代码行数:42,代码来源:MarkdownDoclet.java
示例3: testValueType
import org.parboiled.errors.ParserRuntimeException; //导入依赖的package包/类
@Test(expected = ParserRuntimeException.class)
public void testValueType() {
testOperator("selector !in (1, 2, '3')", ListOperatorType.NOT_IN);
}
开发者ID:edmocosta,项目名称:queryfy,代码行数:5,代码来源:ListOperatorTest.java
示例4: extract
import org.parboiled.errors.ParserRuntimeException; //导入依赖的package包/类
public String extract (ParserRuntimeException exception) {
String[] split = exception.getMessage().split("\n");
return split[1] + "\n" + split[2];
}
开发者ID:jtwig,项目名称:jtwig-core,代码行数:5,代码来源:ParboiledExceptionMessageExtractor.java
示例5: throwParsingException
import org.parboiled.errors.ParserRuntimeException; //导入依赖的package包/类
private char throwParsingException() {
throw new ParserRuntimeException("Parser read more than 100K chars beyond EOI, " +
"verify that your grammar does not consume EOI indefinitely!");
}
开发者ID:parboiled1,项目名称:parboiled,代码行数:5,代码来源:DefaultInputBuffer.java
注:本文中的org.parboiled.errors.ParserRuntimeException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论