本文整理汇总了Java中org.parboiled.parserunners.ReportingParseRunner类的典型用法代码示例。如果您正苦于以下问题:Java ReportingParseRunner类的具体用法?Java ReportingParseRunner怎么用?Java ReportingParseRunner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportingParseRunner类属于org.parboiled.parserunners包,在下文中一共展示了ReportingParseRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
public static void main(String... args) {
Parser templateParser = Parboiled.createParser(Parser.class);
ParsingResult<Object> result = new ReportingParseRunner<>(templateParser.Unit()).run(input2);
ImmutableList<Object> copy = ImmutableList.copyOf(result.valueStack.iterator());
if (!copy.isEmpty()) {
Unit unit = (Unit) copy.get(0);
Unit balance = Balancing.balance(unit);
System.out.println(balance);
}
if (result.hasErrors()) {
System.err.println(ErrorUtils.printParseErrors(result.parseErrors));
}
// System.out.println(ParseTreeUtils.printNodeTree(result));
}
示例2: setUp
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
public void setUp() {
String input = getFile("src/test/resources/test.query");
System.out.println(input);
DELPParser parser = Parboiled.createParser(DELPParser.class);
parser.setResolver(IRIResolver.create());
ParsingResult<OBEPQuery> result = new ReportingParseRunner(parser.Query()).run(input);
if (result.hasErrors()) {
System.out.println("Errors have been found!");
for (ParseError arg : result.parseErrors) {
System.out.println(input.substring(0, arg.getStartIndex()) + "|->" + input.substring(arg.getStartIndex(), arg.getEndIndex()) + "<-|" + input.substring(arg.getEndIndex(), input.length() - 1));
}
}
OBEPQueryImpl q = (OBEPQueryImpl) result.resultValue;
for (EventDecl event : q.getEventCalculusDecls()) {
EventCalculusDecl ecd = (EventCalculusDecl) event;
System.out.println(ecd);
}
}
示例3: setUp
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
public void setUp() {
testEngine = new OBEPTestEngine();
cep = new EventProcessorImpl();
cep.init(testEngine);
String input = getFile("src/test/resources/test2.query");
DELPParser parser = Parboiled.createParser(DELPParser.class);
parser.setResolver(IRIResolver.create());
ParsingResult<OBEPQuery> result = new ReportingParseRunner(parser.Query()).run(input);
if (result.hasErrors()) {
System.out.println("Errors have been found!");
for (ParseError arg : result.parseErrors) {
System.out.println(input.substring(0, arg.getStartIndex()) + "|->" + input.substring(arg.getStartIndex(), arg.getEndIndex()) + "<-|" + input.substring(arg.getEndIndex(), input.length() - 1));
}
}
OBEPQuery q = result.resultValue;
cep.registerQuery(q);
}
示例4: main
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
PegParser parser = Parboiled.createParser(PegParser.class);
ReportingParseRunner runner = new ReportingParseRunner(parser.Grammar());
String input = "";
try (
BufferedReader reader = Files.newBufferedReader(Paths.get("src/main/resources/peg.peg"))
) {
String line = "";
while ((line = reader.readLine())!=null) {
input += line + "\n";
}
}
ParsingResult<?> result = runner.run(input);
if (!result.parseErrors.isEmpty())
System.out.println(ErrorUtils.printParseError(result.parseErrors.get(0)));
else {
System.out.println(printNodeTree(result) + '\n');
}
}
示例5: parse
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
public static Ndfa<Character> parse(String text) {
if (text == null) {
return NfaUtils.<Character>createEmptyLanguageNfa();
}
if (text.equals("")) {
return NfaUtils.<Character>createEmptyStringNfa();
}
final RegexpParser parser = Parboiled.createParser(RegexpParser.class);
final ParsingResult<?> result = new ReportingParseRunner(parser.regexp()).run(text);
if (!result.matched || result.parseTreeRoot.getEndIndex() < text.length()) {
throw new IllegalArgumentException("Could not parse: " + text);
}
return NfaUtils.minimize(RegexpNodeTreeParser.getNfaBase(result.parseTreeRoot, text));
}
示例6: testJavaError2
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void testJavaError2() {
String sourceWithErrors = "package org.parboiled.examples;\n" +
"public class JavaTestSource {\n" +
" @SuppressWarnings({\"UnnecessaryLocalVariable\", \"UnusedDeclaration\"})\n" +
" public String method(int param) {\n" +
" String name toString();\n" +
" return name;\n" +
" }\n" +
"}";
JavaParser parser = Parboiled.createParser(JavaParser.class);
Rule rule = parser.CompilationUnit();
ParsingResult result = new ReportingParseRunner(rule).run(sourceWithErrors);
assertEquals(result.parseErrors.size(), 1);
assertEquals(printParseErrors(result), "" +
"Invalid input 't', expected Whitespace, \"/*\", \"//\", Dim, '=', ',' or ';' (line 5, pos 22):\n" +
" String name toString();\n" +
" ^\n");
}
示例7: main
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
public static void main(String[] args) {
SimpleIndent parser = Parboiled.createParser(SimpleIndent.class);
String input = "NodeA \n\tNodeB\n\tNodeC \n\t\tNodeD \nNodeE";
ParsingResult<?> result = new ReportingParseRunner(parser.Parent())
.run(new IndentDedentInputBuffer(input.toCharArray(), 2, ";", true, true));
if (!result.parseErrors.isEmpty()) {
System.out.println(ErrorUtils.printParseError(result.parseErrors
.get(0)));
} else {
System.out.println("NodeTree: " + printNodeTree(result) + '\n');
Object value = result.parseTreeRoot.getValue();
System.out.println(value.toString());
}
}
示例8: empty
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void empty() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT EMPTY");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.Two, point.getDimension());
assertTrue(point.isEmpty());
assertTrue(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.Two);
assertTrue(Double.isNaN(point.getCoordinate().getX()));
assertTrue(Double.isNaN(point.getCoordinate().getY()));
assertTrue(Double.isNaN(point.getCoordinate().getM()));
assertTrue(Double.isNaN(point.getCoordinate().getZ()));
assertNull(point.getSrid());
assertEquals(0, point.getNumberOfCoordinates());
assertEquals("POINT EMPTY", point.toString());
}
示例9: twoDimensional
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void twoDimensional() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT (1 2)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.Two, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.Two);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertTrue(Double.isNaN(point.getCoordinate().getM()));
assertTrue(Double.isNaN(point.getCoordinate().getZ()));
assertNull(point.getSrid());
assertEquals("POINT (1.0 2.0)", point.toString());
assertEquals(1, point.getNumberOfCoordinates());
}
示例10: twoDimensionalMeasured
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void twoDimensionalMeasured() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT M (1 2 3)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.TwoMeasured, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.TwoMeasured);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertEquals(3, point.getCoordinate().getM(), 0.001);
assertTrue(Double.isNaN(point.getCoordinate().getZ()));
assertNull(point.getSrid());
assertEquals("POINT M (1.0 2.0 3.0)", point.toString());
}
示例11: threeDimensional
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void threeDimensional() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT Z (1 2 3)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.Three, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.Three);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertEquals(3, point.getCoordinate().getZ(), 0.001);
assertTrue(Double.isNaN(point.getCoordinate().getM()));
assertNull(point.getSrid());
assertEquals("POINT Z (1.0 2.0 3.0)", point.toString());
}
示例12: threeDimensionalMeasured
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void threeDimensionalMeasured() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT ZM (1 2 3 4)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.ThreeMeasured, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.ThreeMeasured);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertEquals(3, point.getCoordinate().getZ(), 0.001);
assertEquals(4, point.getCoordinate().getM(), 0.001);
assertNull(point.getSrid());
assertEquals("POINT ZM (1.0 2.0 3.0 4.0)", point.toString());
}
示例13: twoDimensionalWithSrid
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void twoDimensionalWithSrid() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("SRID=4326;POINT (1 2)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.Two, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.Two);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertTrue(Double.isNaN(point.getCoordinate().getM()));
assertTrue(Double.isNaN(point.getCoordinate().getZ()));
assertEquals("4326", point.getSrid());
assertEquals("SRID=4326;POINT (1.0 2.0)", point.toString());
}
示例14: threeDimensionalWithoutZ
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void threeDimensionalWithoutZ() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT (1 2 5)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.Three, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.Three);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertEquals(5, point.getCoordinate().getZ(), 0.001);
assertTrue(Double.isNaN(point.getCoordinate().getM()));
assertNull(point.getSrid());
assertEquals("POINT Z (1.0 2.0 5.0)", point.toString());
}
示例15: threeDimensionalMeasuredWithoutZM
import org.parboiled.parserunners.ReportingParseRunner; //导入依赖的package包/类
@Test
public void threeDimensionalMeasuredWithoutZM() {
WKTParser parser = Parboiled.createParser(WKTParser.class);
ParsingResult<Geometry> result = new ReportingParseRunner(parser.WKT()).run("POINT (1 2 5 4)");
Geometry geometry = result.resultValue;
assertNotNull(geometry);
assertTrue(geometry instanceof Point);
Point point = (Point) geometry;
assertEquals(Dimension.ThreeMeasured, point.getDimension());
assertFalse(point.getCoordinate().isEmpty());
assertTrue(point.getCoordinate().getDimension() == Dimension.ThreeMeasured);
assertEquals(1, point.getCoordinate().getX(), 0.001);
assertEquals(2, point.getCoordinate().getY(), 0.001);
assertEquals(5, point.getCoordinate().getZ(), 0.001);
assertEquals(4, point.getCoordinate().getM(), 0.001);
assertNull(point.getSrid());
assertEquals("POINT ZM (1.0 2.0 5.0 4.0)", point.toString());
}