- improved error notifications
- re-included KorAP-Entities in mvn dependencies
diff --git a/pom.xml b/pom.xml
index a625004..b3b66f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,11 @@
<artifactId>cql-java</artifactId>
<version>1.12</version>
</dependency>
+ <dependency>
+ <groupId>KorAP-modules</groupId>
+ <artifactId>KorAP-Entities</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
diff --git a/src/main/antlr/cosmas/c2ps.g b/src/main/antlr/cosmas/c2ps.g
index cd3b823..ed62c4b 100644
--- a/src/main/antlr/cosmas/c2ps.g
+++ b/src/main/antlr/cosmas/c2ps.g
@@ -26,11 +26,25 @@
@header {package de.ids_mannheim.korap.query.parse.cosmas;}
@lexer::header {package de.ids_mannheim.korap.query.parse.cosmas;}
-@members {
+@lexer::members {
private IErrorReporter errorReporter = null;
+
public void setErrorReporter(IErrorReporter errorReporter) {
this.errorReporter = errorReporter;
}
+
+ public void emitErrorMessage(String msg) {
+ errorReporter.reportError(msg);
+ }
+}
+
+@parser::members {
+ private IErrorReporter errorReporter = null;
+
+ public void setErrorReporter(IErrorReporter errorReporter) {
+ this.errorReporter = errorReporter;
+ }
+
public void emitErrorMessage(String msg) {
errorReporter.reportError(msg);
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
index 9909d25..82a46aa 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
@@ -60,7 +60,7 @@
} else {
throw new NullPointerException("Parser has not been instantiated!");
}
- log.info("Processing collection query");
+ log.info("Processing collection query: "+query);
if (verbose) System.out.println(tree.toStringTree(parser));
processNode(tree);
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
index 162b17c..c2d846a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
@@ -1110,6 +1110,7 @@
org.antlr.runtime.CommonTokenStream tokens = new org.antlr.runtime.CommonTokenStream(lex); //v3
parser = new c2psParser(tokens);
+ lex.setErrorReporter(errorListener); // Use the custom error reporter
((c2psParser) parser).setErrorReporter(errorListener); // Use the custom error reporter
c2psParser.c2ps_query_return c2Return = ((c2psParser) parser).c2ps_query(); // statt t().
// AST Tree anzeigen:
@@ -1129,7 +1130,6 @@
if (erroneous || treestring.contains("<mismatched token") ||
treestring.contains("<error") || treestring.contains("<unexpected")) {
- log.error("Could not parse query. Please make sure it is well-formed.");
log.error(errorListener.generateFullErrorMsg().toString());
addError(errorListener.generateFullErrorMsg());
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index 0c1da76..f3c51e3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -43,7 +43,7 @@
ParseTree tree;
tree = parsePoliqarpQuery(query);
super.parser = this.parser;
- log.info("Processing PoliqarpPlus");
+ log.info("Processing PoliqarpPlus query: "+query);
if (tree != null) {
log.debug("ANTLR parse tree: "+tree.toStringTree(parser));
processNode(tree);
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr3DescriptiveErrorListener.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr3DescriptiveErrorListener.java
index 6ae78b9..7a2d3bb 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr3DescriptiveErrorListener.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr3DescriptiveErrorListener.java
@@ -73,6 +73,10 @@
msg = unbalanced.getKey();
charPosition = unbalanced.getValue();
}
+ // check if more more arguments expected before closing operator
+ if (String.valueOf(offendingSymbol).equals(")")) {
+ msg = "Early closing parenthesis. Possibly lacking arguments for operator.";
+ }
return msg;
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr4DescriptiveErrorListener.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr4DescriptiveErrorListener.java
index 5b7115e..fd38556 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr4DescriptiveErrorListener.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/Antlr4DescriptiveErrorListener.java
@@ -63,7 +63,10 @@
msg = unbalanced.getKey();
charPosition = unbalanced.getValue();
}
-
+ // check if more more arguments expected before closing operator
+ if (String.valueOf(offendingSymbol).equals(")")) {
+ msg = "Early closing parenthesis. Possibly lacking arguments for operator.";
+ }
return msg;
}
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index acde5a6..a2e6442 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import de.ids_mannheim.korap.query.serialize.CollectionQueryBuilder;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.util.QueryException;
+import de.ids_mannheim.korap.query.serialize.util.QueryException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;