本文整理汇总了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);
}
}
}
示例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());
}
}
}
示例3: testValueType
import org.parboiled.errors.ParserRuntimeException; //导入依赖的package包/类
@Test(expected = ParserRuntimeException.class)
public void testValueType() {
testOperator("selector !in (1, 2, '3')", ListOperatorType.NOT_IN);
}
示例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];
}
示例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!");
}