refactoring: moved objects used in all serialisers to abstract superclasses
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
index 6985371..120fc53 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
@@ -2,6 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -20,6 +21,35 @@
 	public abstract void process(String query) throws QueryException;
 	
 	public static final Integer MAXIMUM_DISTANCE = 100; 
+	
+	/**
+	 * Top-level map representing the whole request.
+	 */
+	LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
+	/**
+	 * Keeps track of open node categories
+	 */
+	LinkedList<String> openNodeCats = new LinkedList<String>();
+	/**
+	 * Keeps track of all visited nodes in a tree
+	 */
+	List<ParseTree> visited = new ArrayList<ParseTree>();
+	/**
+	 * Keeps track of active object.
+	 */
+	LinkedList<LinkedHashMap<String, Object>> objectStack = new LinkedList<LinkedHashMap<String, Object>>();
+	/**
+	 * Keeps track of how many objects there are to pop after every recursion of {@link #processNode(ParseTree)}
+	 */
+	LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
+	/**
+	 * If true, print debug statements
+	 */
+	public static boolean verbose = false;
+	ParseTree currentNode = null;
+	Integer stackedObjects = 0;
+	ArrayList<String> errorMsgs = new ArrayList<String>();
+	ArrayList<String> warningMsgs = new ArrayList<String>();
 
 	protected LinkedHashMap<String, Object> makeSpan() {
 		LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
index 216cfb0..25d0fb9 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
@@ -11,7 +11,11 @@
 
 public abstract class Antlr4AbstractSyntaxTree extends AbstractSyntaxTree {
 
-	public Parser parser;
+
+	/**
+	 * Parser object deriving the ANTLR parse tree.
+	 */
+	protected Parser parser;
 
 	 /**
      * Returns the category (or 'label') of the root of a (sub-) ParseTree (ANTLR 4).
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
index f84c789..8cbaf19 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
@@ -33,34 +33,13 @@
 	private org.slf4j.Logger log = LoggerFactory
 			.getLogger(AqlTree.class);
 	/**
-	 * Top-level map representing the whole request.
-	 */
-	LinkedHashMap<String,Object> requestMap = new LinkedHashMap<String,Object>();
-	/**
-	 * Keeps track of open node categories
-	 */
-	LinkedList<String> openNodeCats = new LinkedList<String>();
-	/**
 	 * Flag that indicates whether token fields or meta fields are currently being processed
 	 */
 	boolean inMeta = false;
 	/**
-	 * Parser object deriving the ANTLR parse tree.
-	 */
-	Parser parser;
-	/**
-	 * Keeps track of all visited nodes in a tree
-	 */
-	List<ParseTree> visited = new ArrayList<ParseTree>();
-	/**
-	 * Keeps track of active object.
-	 */
-	LinkedList<LinkedHashMap<String,Object>> objectStack = new LinkedList<LinkedHashMap<String,Object>>();
-	/**
 	 * Keeps track of operands that are to be integrated into yet uncreated objects.
 	 */
 	LinkedList<LinkedHashMap<String,Object>> operandStack = new LinkedList<LinkedHashMap<String,Object>>();
-
 	/**
 	 * Keeps track of explicitly (by #-var definition) or implicitly (number as reference) introduced entities (for later reference by #-operator)
 	 */
@@ -79,11 +58,6 @@
 	 */
 	private LinkedList<ArrayList<Object>> invertedOperandsLists = new LinkedList<ArrayList<Object>>();
 	/**
-	 * Keeps track of how many objects there are to pop after every recursion of {@link #processNode(ParseTree)}
-	 */
-	LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
-	Integer stackedObjects = 0;
-	/**
 	 * Keeps track of operation:class numbers.
 	 */
 	int classCounter = 0;
@@ -97,7 +71,6 @@
 	 * nodes here and exclude the operands from being written into the query map individually.   
 	 */
 	private LinkedList<String> operandOnlyNodeRefs = new LinkedList<String>();
-
 	private List<ParseTree> globalLingTermNodes = new ArrayList<ParseTree>();
 	private int totalRelationCount;
 	/**
@@ -107,7 +80,6 @@
 	private LinkedHashMap<String, Integer> refClassMapping = new LinkedHashMap<String, Integer>();
 	private LinkedHashMap<String, Integer> nodeReferencesTotal = new LinkedHashMap<String, Integer>();
 	private LinkedHashMap<String, Integer> nodeReferencesProcessed = new LinkedHashMap<String, Integer>();
-	public static boolean verbose = false;
 
 	/**
 	 * 
@@ -124,33 +96,6 @@
 		System.out.println(">>> "+requestMap.get("query")+" <<<");
 	}
 
-	@SuppressWarnings("unused")
-	private void prepareContext() {
-		LinkedHashMap<String,Object> context = new LinkedHashMap<String,Object>();
-		LinkedHashMap<String,Object> operands = new LinkedHashMap<String,Object>();
-		LinkedHashMap<String,Object> relation = new LinkedHashMap<String,Object>();
-		LinkedHashMap<String,Object> classMap = new LinkedHashMap<String,Object>();
-
-		operands.put("@id", "korap:operands");
-		operands.put("@container", "@list");
-
-		relation.put("@id", "korap:relation");
-		relation.put("@type", "korap:relation#types");
-
-		classMap.put("@id", "korap:class");
-		classMap.put("@type", "xsd:integer");
-
-		context.put("korap", "http://korap.ids-mannheim.de/ns/query");
-		context.put("@language", "de");
-		context.put("operands", operands);
-		context.put("relation", relation);
-		context.put("class", classMap);
-		context.put("query", "korap:query");
-		context.put("filter", "korap:filter");
-		context.put("meta", "korap:meta");
-
-		requestMap.put("@context", context);		
-	}
 
 	@Override
 	public Map<String, Object> getRequestMap() {
@@ -756,6 +701,11 @@
 		 */
 		String[] queries = new String[] {
 				"cat=\"NP\" & cat=\"VP\" & #1 $ #2 ",
+				"Haus",
+				"lemma=\"Haus\"",
+				"Katze=\"Hund\"",
+				"cnx/c=\"NP\"",
+				"cat=\"NP\""
 		};
 		//		AqlTree.verbose=true;
 		for (String q : queries) {
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 60eadf9..dc58dac 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
@@ -26,32 +26,16 @@
     private static Logger log = LoggerFactory.getLogger(CosmasTree.class);
 
     String query;
-    LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
-    /**
-     * Keeps track of active object.
-     */
-    LinkedList<LinkedHashMap<String, Object>> objectStack = new LinkedList<LinkedHashMap<String, Object>>();
-    /**
-     * Makes it possible to store several distantTokenGroups
-     */
     LinkedList<LinkedHashMap[]> toWrapStack = new LinkedList<LinkedHashMap[]>();
     /**
      * Field for repetition query (Kleene + or * operations, or min/max queries: {2,4}
      */
     String repetition = "";
     /**
-     * Keeps track of open node categories
-     */
-    LinkedList<String> openNodeCats = new LinkedList<String>();
-    /**
      * Global control structure for fieldGroups, keeps track of open fieldGroups.
      */
     LinkedList<ArrayList<Object>> openFieldGroups = new LinkedList<ArrayList<Object>>();
     /**
-     * Keeps track of how many objects there are to pop after every recursion of {@link #processNode(ParseTree)}
-     */
-    LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
-    /**
      * Keeps track of how many toWrap objects there are to pop after every recursion of {@link #processNode(ParseTree)}
      */
     LinkedList<Integer> toWrapsToPop = new LinkedList<Integer>();
@@ -75,10 +59,7 @@
      */
     List<Tree> visited = new ArrayList<Tree>();
 
-    Integer stackedObjects = 0;
     Integer stackedToWrap = 0;
-
-    private static boolean debug = false;
     /**
      * A list of node categories that can be sequenced (i.e. which can be in a sequence with any number of other nodes in this list)
      */
@@ -150,7 +131,7 @@
         stackedObjects = 0;
         stackedToWrap = 0;
 
-        if (debug) {
+        if (verbose) {
             System.err.println(" " + objectStack);
             System.out.println(openNodeCats);
         }
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 c2620e4..fc9cead 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
@@ -20,36 +20,6 @@
 public class PoliqarpPlusTree extends Antlr4AbstractSyntaxTree {
 
 	Logger log = LoggerFactory.getLogger(PoliqarpPlusTree.class);
-	/**
-	 * Top-level map representing the whole request.
-	 */
-	LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
-	/**
-	 * Keeps track of open node categories
-	 */
-	LinkedList<String> openNodeCats = new LinkedList<String>();
-	/**
-	 * Parser object deriving the ANTLR parse tree.
-	 */
-	private Parser parser;
-	/**
-	 * Keeps track of all visited nodes in a tree
-	 */
-	private List<ParseTree> visited = new ArrayList<ParseTree>();
-	/**
-	 * Keeps track of active object.
-	 */
-	private LinkedList<LinkedHashMap<String, Object>> objectStack = new LinkedList<LinkedHashMap<String, Object>>();
-	/**
-	 * Keeps track of how many objects there are to pop after every recursion of {@link #processNode(ParseTree)}
-	 */
-	private LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
-	/**
-	 * If true, print debug statements
-	 */
-	public static boolean verbose = false;
-	ParseTree currentNode = null;
-	Integer stackedObjects = 0;
 
 	/**
 	 * Most centrally, this class maintains a set of nested maps and lists which represent the JSON tree, which is built by the JSON serialiser
@@ -589,7 +559,10 @@
 				"focus([orth=Der]{[orth=Mann]})",
 				"shrink([orth=Der]{[orth=Mann]})",
 				"[mate/m=number:sg]",
-				"z.B./x"
+				"z.B./x",
+				"\".*?Mann.\"",
+				"\".*?Mann.*?\"",
+				"[orth=\".*?l(au|ie)fen.*?*\"]"
 		};
 //		PoliqarpPlusTree.verbose=true;
 		for (String q : queries) {