本文整理汇总了Java中org.parboiled.parserunners.RecoveringParseRunner.run方法的典型用法代码示例。如果您正苦于以下问题:Java RecoveringParseRunner.run方法的具体用法?Java RecoveringParseRunner.run怎么用?Java RecoveringParseRunner.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.parboiled.parserunners.RecoveringParseRunner
的用法示例。
在下文中一共展示了RecoveringParseRunner.run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inlineTemplate
import org.parboiled.parserunners.RecoveringParseRunner; //导入方法依赖的package包/类
@Test(dataProvider = "inlineTemplateData")
public void inlineTemplate(String input, List<String> expected)
{
InlineTemplateParser parser = Parboiled
.createParser(InlineTemplateParser.class);
RecoveringParseRunner<String> runner = new RecoveringParseRunner<String>(
parser.inlineTemplate());
ParsingResult<String> result = runner.run(input);
List<String> actual = new ArrayList<String>();
for (String s : result.valueStack)
{
actual.add(0, s);
}
assertThat(actual, equalTo(expected));
}
示例2: parse
import org.parboiled.parserunners.RecoveringParseRunner; //导入方法依赖的package包/类
@Override
public void parse(Snapshot snapshot, Task task, SourceModificationEvent sme) throws ParseException {
logger.fine("Parsing...");
this.snapshot = snapshot;
RecoveringParseRunner runner = new RecoveringParseRunner(parboiled.cfgProps());
parboiled.reset();
parbResult = runner.run(snapshot.getText().toString());
logParsingResult();
}
示例3: getParseTree
import org.parboiled.parserunners.RecoveringParseRunner; //导入方法依赖的package包/类
/**
* Parse the {@link Reader} and get the parsing tree by its root
* {@link AbcNode}.
*
* @param abcString
*/
protected AbcNode getParseTree(String abcString) {
long startTime = System.currentTimeMillis();
AbcGrammar grammar = AbcGrammar.getInstance();
// AbcGrammar parser = Parboiled.createParser(AbcGrammar.class);
ParsingResult<?> result = RecoveringParseRunner.run(grammar.AbcFile(),
abcString);
if (DEBUG) {
System.out.println("Parse : "+(System.currentTimeMillis() - startTime) + "ms");
}
if (result.hasErrors()) {
System.err.println("Parse errors: "
+ result.parseErrors.size());
/*Iterator it = result.parseErrors.iterator();
while (it.hasNext()) {
ParseError pe = (ParseError) it.next();
System.err.println("- " + pe.getErrorMessage()
+ "("+pe.getStartIndex()+"->"+pe.getEndIndex()+")");
}*/
}
AbcNode abcRoot = new AbcNode(result.parseTreeRoot, result.inputBuffer,
result.parseErrors, new AbcInputBuffer(abcString.toCharArray()));
if (result.hasErrors() || DEBUG)
debugTree(abcRoot);
return abcRoot;
}