PROX: Tests with RecognitionExceptions removed. All Error Codes in StatusCodes.java.

Change-Id: Id6355ddf859f35b8d0f20b4ce53c0f3da2122b03
diff --git a/src/main/antlr/cosmas/c2ps_opPROX.g b/src/main/antlr/cosmas/c2ps_opPROX.g
index 9193de0..1bf077e 100644
--- a/src/main/antlr/cosmas/c2ps_opPROX.g
+++ b/src/main/antlr/cosmas/c2ps_opPROX.g
@@ -49,15 +49,9 @@
 
 // proxDist: e.g. +5w or -s0 or /w2:4 etc.
 // kein proxDirection? hier, weil der Default erst innerhalb von Regel proxDirection erzeugt werden kann.
-/* incomplete original version:
-proxDist:	proxDirection (v1=proxDistValue m1=proxMeasure | m2=proxMeasure v2=proxDistValue)
-
-		-> {$v1.tree != null}? ^(DIST {$proxDirection.tree} {$v1.tree} {$m1.tree})
-		->		 		       ^(DIST {$proxDirection.tree} {$v2.tree} {$m2.tree});
-*/
 
 // new rule: accepts options in any order:
-// count each option type and find out if any one  is missing or occures multiple times.
+// count each option type and find out if any one is missing or occures multiple times.
 // 28.11.23/FB
 
 proxDist[int pos]
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opPROX.java b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opPROX.java
index 7987168..da3ea4a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opPROX.java
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/cosmas/c2ps_opPROX.java
@@ -17,15 +17,9 @@
 {
 	// type of an Error CommonToken:
 	final static int typeERROR = 1; 
-	// error codes returned to client:
-	final public static int ERR_PROX_UNKNOWN 	= 300;
-	final static int ERR_MEAS_NULL 		= 301;
-	final static int ERR_MEAS_TOOGREAT 	= 302;
-	final static int ERR_VAL_NULL 		= 303;
-	final static int ERR_VAL_TOOGREAT 	= 304;
-	final static int ERR_DIR_TOOGREAT 	= 305;
+	// Prox error codes defined in StatusCodes.java.
 	
-	private static CommonTree buildErrorTree(String text, int errCode, int typeDIST, int pos) throws RecognitionException
+	private static CommonTree buildErrorTree(String text, int errCode, int typeDIST, int pos) 
 	
 	{
 	CommonTree
@@ -43,24 +37,24 @@
 	
 	switch( errCode )
 		{
-	case ERR_MEAS_NULL:
+	case StatusCodes.ERR_PROX_MEAS_NULL:
 		mess      = String.format("Abstandsoperator an der Stelle '%s' es fehlt eine der folgenden Angaben: w,s,p!", text);
 		errorMes  = new CommonTree(new CommonToken(typeERROR, mess));
 		break;
-	case ERR_MEAS_TOOGREAT:
+	case StatusCodes.ERR_PROX_MEAS_TOOGREAT:
 		mess      = String.format("Abstandsoperator an der Stelle '%s': Bitte nur 1 der folgenden Angaben einsetzen: w,s,p! " +
 							 "Falls Mehrfachangabe erwünscht, müssen diese durch Kommata getrennt werden (z.B.: /+w2,s0).", text);
 		errorMes  = new CommonTree(new CommonToken(typeERROR, mess));
 		break;
-	case ERR_VAL_NULL:
+	case StatusCodes.ERR_PROX_VAL_NULL:
 		mess      = String.format("Abstandsoperator an der Stelle '%s': Bitte einen numerischen Wert einsetzen (z.B. /+w5)! ", text);
 		errorMes  = new CommonTree(new CommonToken(typeERROR, mess));
 		break;
-	case ERR_VAL_TOOGREAT:
+	case StatusCodes.ERR_PROX_VAL_TOOGREAT:
 		mess      = String.format("Abstandsoperator an der Stelle '%s': Bitte nur 1 numerischen Wert einsetzen (z.B. /+w5)! ", text);
 		errorMes  = new CommonTree(new CommonToken(typeERROR, mess));
 		break;
-	case ERR_DIR_TOOGREAT:
+	case StatusCodes.ERR_PROX_DIR_TOOGREAT:
 		mess      = String.format("Abstandsoperator an der Stelle '%s': Bitte nur 1 Angabe '+' oder '-' oder keine! ", text);
 		errorMes  = new CommonTree(new CommonToken(typeERROR, mess));
 		break;
@@ -97,7 +91,6 @@
 	
 	public static Object encodeDIST(int typeDIST, int typeDIR, Object ctDir, Object ctMeas, Object ctVal, String text,
 									int countD, int countM, int countV, int pos)  
-									throws RecognitionException
 			
 	{
 		CommonTree tree1 = (CommonTree)ctDir;
@@ -108,13 +101,13 @@
 					text, countM, countD, countV, pos);
 
 		if( countM == 0 )
-			return buildErrorTree(text, ERR_MEAS_NULL, typeDIST, pos);
+			return buildErrorTree(text, StatusCodes.ERR_PROX_MEAS_NULL, typeDIST, pos);
 		if( countM > 1 )
-			return buildErrorTree(text, ERR_MEAS_TOOGREAT, typeDIST, pos);
+			return buildErrorTree(text, StatusCodes.ERR_PROX_MEAS_TOOGREAT, typeDIST, pos);
 		if( countV == 0 )
-			return buildErrorTree(text, ERR_VAL_NULL, typeDIST, pos);
+			return buildErrorTree(text, StatusCodes.ERR_PROX_VAL_NULL, typeDIST, pos);
 		if( countV > 1 )
-			return buildErrorTree(text, ERR_VAL_TOOGREAT, typeDIST, pos);
+			return buildErrorTree(text, StatusCodes.ERR_PROX_VAL_TOOGREAT, typeDIST, pos);
 		
 		if( countD == 0 )
 			{
@@ -128,7 +121,7 @@
 			tree1 = treeDIR;
 			}
 		else if( countD > 1 )
-			return buildErrorTree(text, ERR_DIR_TOOGREAT, typeDIST, pos);
+			return buildErrorTree(text, StatusCodes.ERR_PROX_DIR_TOOGREAT, typeDIST, pos);
 	
 		// create DIST tree:
 		CommonTree 
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index 525bcb6..e733f52 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -177,7 +177,7 @@
     		int
     			errPos  = node.getChild(0) != null ? Integer.parseInt(node.getChild(0).getText()) : 0;
     		int
-    			errCode = node.getChild(1) != null ? Integer.parseInt(node.getChild(1).getText()) : c2ps_opPROX.ERR_PROX_UNKNOWN; 
+    			errCode = node.getChild(1) != null ? Integer.parseInt(node.getChild(1).getText()) : StatusCodes.ERR_PROX_UNKNOWN; 
     		String
     			errMess = node.getChild(2) != null ? node.getChild(2).getText() : "Genaue Fehlermeldung nicht auffindbar.";
     		
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java
index 656228d..9dab811 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/StatusCodes.java
@@ -14,4 +14,12 @@
 	public final static int QUERY_TOO_COMPLEX = 311;
 	public final static int UNKNOWN_QUERY_ERROR = 399;
 	public final static int SERIALIZATION_FAILED = 300;
+	
+	// error codes for PROX syntax errors:
+	final public static int ERR_PROX_UNKNOWN 		= 320;
+	public final static int ERR_PROX_MEAS_NULL 		= 321;
+	public final static int ERR_PROX_MEAS_TOOGREAT 	= 322;
+	public final static int ERR_PROX_VAL_NULL 		= 323;
+	public final static int ERR_PROX_VAL_TOOGREAT 	= 324;
+	public final static int ERR_PROX_DIR_TOOGREAT 	= 325;
 }
\ No newline at end of file