Index: /branches/HeuristicLab.Problems.GPDL/CocoR/Parser.frame
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/CocoR/Parser.frame	(revision 9724)
+++ /branches/HeuristicLab.Problems.GPDL/CocoR/Parser.frame	(revision 9724)
@@ -0,0 +1,156 @@
+/*----------------------------------------------------------------------
+Compiler Generator Coco/R,
+Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
+extended by M. Loeberbauer & A. Woess, Univ. of Linz
+with improvements by Pat Terry, Rhodes University
+
+This program is free software; you can redistribute it and/or modify it 
+under the terms of the GNU General Public License as published by the 
+Free Software Foundation; either version 2, or (at your option) any 
+later version.
+
+This program is distributed in the hope that it will be useful, but 
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
+for more details.
+
+You should have received a copy of the GNU General Public License along 
+with this program; if not, write to the Free Software Foundation, Inc., 
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As an exception, it is allowed to write an extension of Coco/R that is
+used as a plugin in non-free software.
+
+If not otherwise stated, any source code generated by Coco/R (other than 
+Coco/R itself) does not fall under the GNU General Public License.
+----------------------------------------------------------------------*/
+-->begin
+using System;
+
+-->namespace
+
+public class Parser {
+-->constants
+	const bool T = true;
+	const bool x = false;
+	const int minErrDist = 2;
+	
+	public Scanner scanner;
+	public Errors  errors;
+
+	public Token t;    // last recognized token
+	public Token la;   // lookahead token
+	int errDist = minErrDist;
+
+-->declarations
+
+	public Parser(Scanner scanner) {
+		this.scanner = scanner;
+		errors = new Errors();
+	}
+
+	void SynErr (int n) {
+		if (errDist >= minErrDist) errors.SynErr(la.line, la.col, n);
+		errDist = 0;
+	}
+
+	public void SemErr (string msg) {
+		if (errDist >= minErrDist) errors.SemErr(t.line, t.col, msg);
+		errDist = 0;
+	}
+	
+	void Get () {
+		for (;;) {
+			t = la;
+			la = scanner.Scan();
+			if (la.kind <= maxT) { ++errDist; break; }
+-->pragmas
+			la = t;
+		}
+	}
+	
+	void Expect (int n) {
+		if (la.kind==n) Get(); else { SynErr(n); }
+	}
+	
+	bool StartOf (int s) {
+		return set[s, la.kind];
+	}
+	
+	void ExpectWeak (int n, int follow) {
+		if (la.kind == n) Get();
+		else {
+			SynErr(n);
+			while (!StartOf(follow)) Get();
+		}
+	}
+
+
+	bool WeakSeparator(int n, int syFol, int repFol) {
+		int kind = la.kind;
+		if (kind == n) {Get(); return true;}
+		else if (StartOf(repFol)) {return false;}
+		else {
+			SynErr(n);
+			while (!(set[syFol, kind] || set[repFol, kind] || set[0, kind])) {
+				Get();
+				kind = la.kind;
+			}
+			return StartOf(syFol);
+		}
+	}
+
+	
+-->productions
+
+	public void Parse() {
+		la = new Token();
+		la.val = "";		
+		Get();
+-->parseRoot
+	}
+	
+	static readonly bool[,] set = {
+-->initialization
+	};
+} // end Parser
+
+
+public class Errors {
+	public int count = 0;                                    // number of errors detected
+	public System.IO.TextWriter errorStream = Console.Out;   // error messages go to this stream
+	public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
+
+	public virtual void SynErr (int line, int col, int n) {
+		string s;
+		switch (n) {
+-->errors
+			default: s = "error " + n; break;
+		}
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+		count++;
+	}
+
+	public virtual void SemErr (int line, int col, string s) {
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+		count++;
+	}
+	
+	public virtual void SemErr (string s) {
+		errorStream.WriteLine(s);
+		count++;
+	}
+	
+	public virtual void Warning (int line, int col, string s) {
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+	}
+	
+	public virtual void Warning(string s) {
+		errorStream.WriteLine(s);
+	}
+} // Errors
+
+
+public class FatalError: Exception {
+	public FatalError(string m): base(m) {}
+}
Index: /branches/HeuristicLab.Problems.GPDL/CocoR/Scanner.frame
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/CocoR/Scanner.frame	(revision 9724)
+++ /branches/HeuristicLab.Problems.GPDL/CocoR/Scanner.frame	(revision 9724)
@@ -0,0 +1,381 @@
+/*----------------------------------------------------------------------
+Compiler Generator Coco/R,
+Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
+extended by M. Loeberbauer & A. Woess, Univ. of Linz
+with improvements by Pat Terry, Rhodes University
+
+This program is free software; you can redistribute it and/or modify it 
+under the terms of the GNU General Public License as published by the 
+Free Software Foundation; either version 2, or (at your option) any 
+later version.
+
+This program is distributed in the hope that it will be useful, but 
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
+for more details.
+
+You should have received a copy of the GNU General Public License along 
+with this program; if not, write to the Free Software Foundation, Inc., 
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+As an exception, it is allowed to write an extension of Coco/R that is
+used as a plugin in non-free software.
+
+If not otherwise stated, any source code generated by Coco/R (other than 
+Coco/R itself) does not fall under the GNU General Public License.
+-----------------------------------------------------------------------*/
+-->begin
+using System;
+using System.IO;
+using System.Collections;
+
+-->namespace
+
+public class Token {
+	public int kind;    // token kind
+	public int pos;     // token position in bytes in the source text (starting at 0)
+	public int charPos;  // token position in characters in the source text (starting at 0)
+	public int col;     // token column (starting at 1)
+	public int line;    // token line (starting at 1)
+	public string val;  // token value
+	public Token next;  // ML 2005-03-11 Tokens are kept in linked list
+}
+
+//-----------------------------------------------------------------------------------
+// Buffer
+//-----------------------------------------------------------------------------------
+public class Buffer {
+	// This Buffer supports the following cases:
+	// 1) seekable stream (file)
+	//    a) whole stream in buffer
+	//    b) part of stream in buffer
+	// 2) non seekable stream (network, console)
+
+	public const int EOF = char.MaxValue + 1;
+	const int MIN_BUFFER_LENGTH = 1024; // 1KB
+	const int MAX_BUFFER_LENGTH = MIN_BUFFER_LENGTH * 64; // 64KB
+	byte[] buf;         // input buffer
+	int bufStart;       // position of first byte in buffer relative to input stream
+	int bufLen;         // length of buffer
+	int fileLen;        // length of input stream (may change if the stream is no file)
+	int bufPos;         // current position in buffer
+	Stream stream;      // input stream (seekable)
+	bool isUserStream;  // was the stream opened by the user?
+	
+	public Buffer (Stream s, bool isUserStream) {
+		stream = s; this.isUserStream = isUserStream;
+		
+		if (stream.CanSeek) {
+			fileLen = (int) stream.Length;
+			bufLen = Math.Min(fileLen, MAX_BUFFER_LENGTH);
+			bufStart = Int32.MaxValue; // nothing in the buffer so far
+		} else {
+			fileLen = bufLen = bufStart = 0;
+		}
+
+		buf = new byte[(bufLen>0) ? bufLen : MIN_BUFFER_LENGTH];
+		if (fileLen > 0) Pos = 0; // setup buffer to position 0 (start)
+		else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
+		if (bufLen == fileLen && stream.CanSeek) Close();
+	}
+	
+	protected Buffer(Buffer b) { // called in UTF8Buffer constructor
+		buf = b.buf;
+		bufStart = b.bufStart;
+		bufLen = b.bufLen;
+		fileLen = b.fileLen;
+		bufPos = b.bufPos;
+		stream = b.stream;
+		// keep destructor from closing the stream
+		b.stream = null;
+		isUserStream = b.isUserStream;
+	}
+
+	~Buffer() { Close(); }
+	
+	protected void Close() {
+		if (!isUserStream && stream != null) {
+			stream.Close();
+			stream = null;
+		}
+	}
+	
+	public virtual int Read () {
+		if (bufPos < bufLen) {
+			return buf[bufPos++];
+		} else if (Pos < fileLen) {
+			Pos = Pos; // shift buffer start to Pos
+			return buf[bufPos++];
+		} else if (stream != null && !stream.CanSeek && ReadNextStreamChunk() > 0) {
+			return buf[bufPos++];
+		} else {
+			return EOF;
+		}
+	}
+
+	public int Peek () {
+		int curPos = Pos;
+		int ch = Read();
+		Pos = curPos;
+		return ch;
+	}
+	
+	// beg .. begin, zero-based, inclusive, in byte
+	// end .. end, zero-based, exclusive, in byte
+	public string GetString (int beg, int end) {
+		int len = 0;
+		char[] buf = new char[end - beg];
+		int oldPos = Pos;
+		Pos = beg;
+		while (Pos < end) buf[len++] = (char) Read();
+		Pos = oldPos;
+		return new String(buf, 0, len);
+	}
+
+	public int Pos {
+		get { return bufPos + bufStart; }
+		set {
+			if (value >= fileLen && stream != null && !stream.CanSeek) {
+				// Wanted position is after buffer and the stream
+				// is not seek-able e.g. network or console,
+				// thus we have to read the stream manually till
+				// the wanted position is in sight.
+				while (value >= fileLen && ReadNextStreamChunk() > 0);
+			}
+
+			if (value < 0 || value > fileLen) {
+				throw new FatalError("buffer out of bounds access, position: " + value);
+			}
+
+			if (value >= bufStart && value < bufStart + bufLen) { // already in buffer
+				bufPos = value - bufStart;
+			} else if (stream != null) { // must be swapped in
+				stream.Seek(value, SeekOrigin.Begin);
+				bufLen = stream.Read(buf, 0, buf.Length);
+				bufStart = value; bufPos = 0;
+			} else {
+				// set the position to the end of the file, Pos will return fileLen.
+				bufPos = fileLen - bufStart;
+			}
+		}
+	}
+	
+	// Read the next chunk of bytes from the stream, increases the buffer
+	// if needed and updates the fields fileLen and bufLen.
+	// Returns the number of bytes read.
+	private int ReadNextStreamChunk() {
+		int free = buf.Length - bufLen;
+		if (free == 0) {
+			// in the case of a growing input stream
+			// we can neither seek in the stream, nor can we
+			// foresee the maximum length, thus we must adapt
+			// the buffer size on demand.
+			byte[] newBuf = new byte[bufLen * 2];
+			Array.Copy(buf, newBuf, bufLen);
+			buf = newBuf;
+			free = bufLen;
+		}
+		int read = stream.Read(buf, bufLen, free);
+		if (read > 0) {
+			fileLen = bufLen = (bufLen + read);
+			return read;
+		}
+		// end of stream reached
+		return 0;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+// UTF8Buffer
+//-----------------------------------------------------------------------------------
+public class UTF8Buffer: Buffer {
+	public UTF8Buffer(Buffer b): base(b) {}
+
+	public override int Read() {
+		int ch;
+		do {
+			ch = base.Read();
+			// until we find a utf8 start (0xxxxxxx or 11xxxxxx)
+		} while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EOF));
+		if (ch < 128 || ch == EOF) {
+			// nothing to do, first 127 chars are the same in ascii and utf8
+			// 0xxxxxxx or end of file character
+		} else if ((ch & 0xF0) == 0xF0) {
+			// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+			int c1 = ch & 0x07; ch = base.Read();
+			int c2 = ch & 0x3F; ch = base.Read();
+			int c3 = ch & 0x3F; ch = base.Read();
+			int c4 = ch & 0x3F;
+			ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4;
+		} else if ((ch & 0xE0) == 0xE0) {
+			// 1110xxxx 10xxxxxx 10xxxxxx
+			int c1 = ch & 0x0F; ch = base.Read();
+			int c2 = ch & 0x3F; ch = base.Read();
+			int c3 = ch & 0x3F;
+			ch = (((c1 << 6) | c2) << 6) | c3;
+		} else if ((ch & 0xC0) == 0xC0) {
+			// 110xxxxx 10xxxxxx
+			int c1 = ch & 0x1F; ch = base.Read();
+			int c2 = ch & 0x3F;
+			ch = (c1 << 6) | c2;
+		}
+		return ch;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+// Scanner
+//-----------------------------------------------------------------------------------
+public class Scanner {
+	const char EOL = '\n';
+	const int eofSym = 0; /* pdt */
+-->declarations
+
+	public Buffer buffer; // scanner buffer
+	
+	Token t;          // current token
+	int ch;           // current input character
+	int pos;          // byte position of current character
+	int charPos;      // position by unicode characters starting with 0
+	int col;          // column number of current character
+	int line;         // line number of current character
+	int oldEols;      // EOLs that appeared in a comment;
+	static readonly Hashtable start; // maps first token character to start state
+
+	Token tokens;     // list of tokens already peeked (first token is a dummy)
+	Token pt;         // current peek token
+	
+	char[] tval = new char[128]; // text of current token
+	int tlen;         // length of current token
+	
+	static Scanner() {
+		start = new Hashtable(128);
+-->initialization
+	}
+	
+	public Scanner (string fileName) {
+		try {
+			Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
+			buffer = new Buffer(stream, false);
+			Init();
+		} catch (IOException) {
+			throw new FatalError("Cannot open file " + fileName);
+		}
+	}
+	
+	public Scanner (Stream s) {
+		buffer = new Buffer(s, true);
+		Init();
+	}
+	
+	void Init() {
+		pos = -1; line = 1; col = 0; charPos = -1;
+		oldEols = 0;
+		NextCh();
+		if (ch == 0xEF) { // check optional byte order mark for UTF-8
+			NextCh(); int ch1 = ch;
+			NextCh(); int ch2 = ch;
+			if (ch1 != 0xBB || ch2 != 0xBF) {
+				throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
+			}
+			buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
+			NextCh();
+		}
+		pt = tokens = new Token();  // first token is a dummy
+	}
+	
+	void NextCh() {
+		if (oldEols > 0) { ch = EOL; oldEols--; } 
+		else {
+			pos = buffer.Pos;
+			// buffer reads unicode chars, if UTF8 has been detected
+			ch = buffer.Read(); col++; charPos++;
+			// replace isolated '\r' by '\n' in order to make
+			// eol handling uniform across Windows, Unix and Mac
+			if (ch == '\r' && buffer.Peek() != '\n') ch = EOL;
+			if (ch == EOL) { line++; col = 0; }
+		}
+-->casing1
+	}
+
+	void AddCh() {
+		if (tlen >= tval.Length) {
+			char[] newBuf = new char[2 * tval.Length];
+			Array.Copy(tval, 0, newBuf, 0, tval.Length);
+			tval = newBuf;
+		}
+		if (ch != Buffer.EOF) {
+-->casing2
+			NextCh();
+		}
+	}
+
+
+-->comments
+
+	void CheckLiteral() {
+-->literals
+	}
+
+	Token NextToken() {
+		while (ch == ' ' ||
+-->scan1
+		) NextCh();
+-->scan2
+		int recKind = noSym;
+		int recEnd = pos;
+		t = new Token();
+		t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
+		int state;
+		if (start.ContainsKey(ch)) { state = (int) start[ch]; }
+		else { state = 0; }
+		tlen = 0; AddCh();
+		
+		switch (state) {
+			case -1: { t.kind = eofSym; break; } // NextCh already done
+			case 0: {
+				if (recKind != noSym) {
+					tlen = recEnd - t.pos;
+					SetScannerBehindT();
+				}
+				t.kind = recKind; break;
+			} // NextCh already done
+-->scan3
+		}
+		t.val = new String(tval, 0, tlen);
+		return t;
+	}
+	
+	private void SetScannerBehindT() {
+		buffer.Pos = t.pos;
+		NextCh();
+		line = t.line; col = t.col; charPos = t.charPos;
+		for (int i = 0; i < tlen; i++) NextCh();
+	}
+	
+	// get the next token (possibly a token already seen during peeking)
+	public Token Scan () {
+		if (tokens.next == null) {
+			return NextToken();
+		} else {
+			pt = tokens = tokens.next;
+			return tokens;
+		}
+	}
+
+	// peek for the next token, ignore pragmas
+	public Token Peek () {
+		do {
+			if (pt.next == null) {
+				pt.next = NextToken();
+			}
+			pt = pt.next;
+		} while (pt.kind > maxT); // skip pragmas
+	
+		return pt;
+	}
+
+	// make sure that peeking starts at the current scan position
+	public void ResetPeek () { pt = tokens; }
+
+} // end Scanner
Index: /branches/HeuristicLab.Problems.GPDL/GenerateFromAtg.cmd
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/GenerateFromAtg.cmd	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/GenerateFromAtg.cmd	(revision 9724)
@@ -1,6 +1,3 @@
-cd %SolutionDir%\Coco-2
-SG  %ProjectDir%\GPDef.atg
-PGT %ProjectDir%\GPDef.atg
+cd %SolutionDir%\CocoR
+Coco -frames . %ProjectDir%\GPDef.atg
 
-cd %ProjectDir%
-move %SolutionDir%\Coco-2\*.cs .
Index: /branches/HeuristicLab.Problems.GPDL/GpdlCompiler/Program.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/GpdlCompiler/Program.cs	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/GpdlCompiler/Program.cs	(revision 9724)
@@ -1,5 +1,3 @@
-﻿// ATTENTION: Replace all occurences of GpdlCompiler by the compiler name! 
-
-// GpdlCompiler.cs                                                        HDO, 2006-08-28
+﻿// GpdlCompiler.cs                                                        HDO, 2006-08-28
 // -----
 // Main program for compiler generated from GpdlCompiler.atg with Coco-2.
@@ -7,158 +5,17 @@
 
 using System;
-using System.IO;
-
-using Lex = GPDefLex;
-using Syn = GPDefSyn;
+using HeuristicLab.Problems.GPDL;
 
 public class GpdlCompiler {
 
-  private static String NAME = "GpdlCompiler";
-  private static bool interactiveMode;
-
-  private static void Abort(String abortKind, String moduleName,
-                            String methName, String descr) {
-    Console.WriteLine();
-    Console.WriteLine("*** {0} in class {1} method {2}",
-                      abortKind, moduleName, methName);
-    Console.WriteLine("*** {0}", descr);
-    Console.WriteLine();
-    Console.WriteLine();
-    Console.WriteLine(NAME + " aborted");
-    Utils.Modules(Utils.ModuleAction.cleanupModule);
-    if (interactiveMode) {
-      Console.Write("type [CR] to quit");
-      string dummy = Console.ReadLine();
-    } // if
-    Environment.Exit(Utils.EXIT_FAILURE);
-  } // Abort
-
-  private static int CompileFile(String srcFileName) {
-    FileStream srcFs = null;
-    try {
-      srcFs = new FileStream(srcFileName, FileMode.Open);
-    }
-    catch (Exception) {
-      Console.WriteLine("*** file \"{0}\" not found", srcFileName);
-      return Utils.EXIT_FAILURE;
-    } // try/catch
-    try {
-      Lex.src = new StreamReader(srcFs);
-      Console.WriteLine("parsing ...");
-      Syn.Parse();
-      Lex.src.Close();
-      Lex.src.Dispose();
-      Lex.src = null;
-      if (Errors.NumOfErrors() > 0) {
-        Console.WriteLine("listing ...");
-        String lstFileName = Path.ChangeExtension(srcFileName, ".lst");
-        FileStream lstFs = null;
-        try {
-          lstFs = new FileStream(lstFileName, FileMode.Create);
-        }
-        catch (Exception) {
-          Utils.FatalError(NAME, "CompileFile", "file \"{0}\" not created", lstFileName);
-          return Utils.EXIT_FAILURE;
-        } // try/catch
-        StreamWriter lstWriter = null;
-        try {
-          lstWriter = new StreamWriter(lstFs);
-          StreamReader srcFsReader = null;
-          try { // open the source file a second time to generate the error listing
-            srcFsReader = new StreamReader(new FileStream(srcFileName, FileMode.Open));
-            lstWriter.WriteLine(NAME + " (file: \"{0}\")", srcFileName);
-            Errors.GenerateListing(srcFsReader, lstWriter, Errors.ListingShape.longListing);
-          }
-          finally {
-            srcFsReader.Close();
-            srcFsReader.Dispose();
-          } // try/finally
-          Console.WriteLine("{0} error(s) detected", Errors.NumOfErrors());
-        }
-        finally {
-          lstWriter.Close();
-          lstWriter.Dispose();
-        } // try/finally
-      } else
-        Console.WriteLine("no errors detected");
-    }
-    finally {
-      if (Lex.src != null) {
-        Lex.src.Close();
-        Lex.src.Dispose();
-        Lex.src = null;
-      } // if
-      Utils.Modules(Utils.ModuleAction.resetModule);
-    } // try/finally to make sure srcFs and srcReader are closed
-    return Utils.EXIT_SUCCESS;
-  } // CompileFile
-
-
   public static void Main(String[] args) {
     //-----------------------------------|----------------------------------------
-    int result = 0;
+    if (args.Length > 0) {
+      Scanner scanner = new Scanner(args[0]);
+      Parser parser = new Parser(scanner);
+      parser.Parse();
+    } else
+      Console.WriteLine("-- No source file specified");
+  }
 
-    // --- install modules ---
-    Utils.InstallModule("Utils", new Utils.ModuleMethodDelegate(Utils.UtilsMethod));
-    Utils.InstallModule("Sets", new Utils.ModuleMethodDelegate(Sets.SetsMethod));
-    Utils.InstallModule("Errors", new Utils.ModuleMethodDelegate(Errors.ErrorsMethod));
-
-    Utils.InstallModule("GPDefLex", new Utils.ModuleMethodDelegate(GPDefLex.GPDefLexMethod));
-    Utils.InstallModule("GPDefSem", new Utils.ModuleMethodDelegate(GPDefSem.GPDefSemMethod));
-    Utils.InstallModule("GPDefSyn", new Utils.ModuleMethodDelegate(GPDefSyn.GPDefSynMethod));
-
-    // --- initialize modules ---
-    Utils.Modules(Utils.ModuleAction.initModule);
-
-    Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
-
-    Console.WriteLine("---------------------------");
-    Console.WriteLine(" {0} Compiler {1," + (5 - NAME.Length) + "} Version X  ", NAME, "");
-    Console.WriteLine(" Frontend gen. with Coco-2");
-    Console.WriteLine("---------------------------");
-    Console.WriteLine();
-
-    if (args.Length > 0) { // command line mode
-      interactiveMode = false;
-      Console.WriteLine();
-      int i = 0;
-      do {
-        Console.WriteLine("source file \"{0}\"", args[i]);
-        result = CompileFile(args[i]);
-        if (result != Utils.EXIT_SUCCESS)
-          Environment.Exit(result);
-        Console.WriteLine();
-        i++;
-      } while (i < args.Length);
-    } else { // args.Length == 0, interactive mode
-      interactiveMode = true;
-      for (; ; ) {
-        String srcFileName;
-        Utils.GetInputFileName("source file > ", out srcFileName);
-        if (srcFileName.Length > 0) {
-          result = CompileFile(srcFileName);
-          if (result != Utils.EXIT_SUCCESS)
-            Environment.Exit(result);
-        } // if
-        char answerCh;
-        do {
-          Console.WriteLine();
-          Console.Write("[c]ontinue or [q]uit > ");
-          answerCh = Char.ToUpper(Console.ReadKey().KeyChar);
-        } while (answerCh != 'C' && answerCh != 'Q');
-        if (answerCh == 'Q')
-          break;
-        else // answerCh == 'C'
-          Console.WriteLine();
-      } // for
-    } // else
-
-    Utils.Modules(Utils.ModuleAction.cleanupModule);
-    Environment.Exit(Utils.EXIT_SUCCESS);
-
-  } // Main
-
-} // GpdlCompiler
-
-// End of GpdlCompiler.cs
-//=====================================|========================================
+}
Index: /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/CodeEditor.xaml.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/CodeEditor.xaml.cs	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/CodeEditor.xaml.cs	(revision 9724)
@@ -57,8 +57,8 @@
     }
 
-    private void textEditor_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) {
+    private void textEditor_MouseWheel(object sender, MouseWheelEventArgs e) {
     }
 
-    private void textEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) {
+    private void textEditor_KeyDown(object sender, KeyEventArgs e) {
       if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) controlHeld = true;
     }
@@ -70,15 +70,15 @@
     internal void SetLexError(string msg, int line, int col) {
       errorLineTransformer.MarkLexError(msg, line, col);
-      textEditor.InvalidateVisual();
+      textEditor.TextArea.TextView.Redraw();
     }
 
     internal void SetSynError(string msg, int line, int col) {
       errorLineTransformer.MarkSynError(msg, line, col);
-      textEditor.InvalidateVisual();
+      textEditor.TextArea.TextView.Redraw();
     }
 
     internal void ClearErrors() {
       errorLineTransformer.ClearErrors();
-      textEditor.InvalidateVisual();
+      textEditor.TextArea.TextView.Redraw();
     }
 
Index: /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs	(revision 9724)
@@ -2,4 +2,5 @@
 using System.IO;
 using System.Linq;
+using System.Text;
 using HeuristicLab.MainForm.WindowsForms;
 using HeuristicLab.Problems.Instances;
@@ -19,41 +20,42 @@
 
     private void compileButton_Click(object sender, EventArgs e) {
-      Utils.InstallModule("Utils", Utils.UtilsMethod);
-      Utils.InstallModule("Sets", Sets.SetsMethod);
-      Utils.InstallModule("Errors", Errors.ErrorsMethod);
+      //Utils.InstallModule("Utils", Utils.UtilsMethod);
+      //Utils.InstallModule("Sets", Sets.SetsMethod);
+      //Utils.InstallModule("Errors", Errors.ErrorsMethod);
 
-      Utils.InstallModule("GPDefLex", GPDefLex.GPDefLexMethod);
-      Utils.InstallModule("GPDefSem", GPDefSem.GPDefSemMethod);
-      Utils.InstallModule("GPDefSyn", GPDefSyn.GPDefSynMethod);
+      //Utils.InstallModule("GPDefLex", GPDefLex.GPDefLexMethod);
+      //Utils.InstallModule("GPDefSem", GPDefSem.GPDefSemMethod);
+      //Utils.InstallModule("GPDefSyn", GPDefSyn.GPDefSynMethod);
 
-      // --- initialize modules ---
-      Utils.Modules(Utils.ModuleAction.initModule);
+      //// --- initialize modules ---
+      //Utils.Modules(Utils.ModuleAction.initModule);
 
-      Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
+      //Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
 
-      using (var src = new StringReader(codeEditor.textEditor.Text)) {
-        GPDefLex.src = src;
-        GPDefSyn.Parse();
+      using (var src = new MemoryStream(Encoding.UTF8.GetBytes(codeEditor.textEditor.Text))) {
+        Scanner scanner = new Scanner(src);
+        Parser parser = new Parser(scanner);
+        parser.Parse();
       }
 
       codeEditor.ClearErrors();
 
-      if (Errors.NumOfErrors() == 0) {
-        GPDefLex.InitLex();
-        GPDefSyn.Interpret();
+      //if (Errors.NumOfErrors() == 0) {
+      //  GPDefLex.InitLex();
+      //  GPDefSyn.Interpret();
 
-        MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
-      } else {
-        int nLexErrors = Errors.NumOfLexErrors();
-        for (int i = 0; i < nLexErrors; i++) {
-          var lexErr = Errors.GetLexError(i == 0);
-          codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col);
-        }
-        int nSynErrors = Errors.NumOfSynErrors();
-        for (int i = 0; i < nSynErrors; i++) {
-          var synErr = Errors.GetSynError(i == 0);
-          codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col);
-        }
-      }
+      //  MainForm.MainFormManager.MainForm.ShowContent(GPDefSem.problem);
+      //} else {
+      //  int nLexErrors = Errors.NumOfLexErrors();
+      //  for (int i = 0; i < nLexErrors; i++) {
+      //    var lexErr = Errors.GetLexError(i == 0);
+      //    codeEditor.SetLexError(lexErr.msg, lexErr.line, lexErr.col);
+      //  }
+      //  int nSynErrors = Errors.NumOfSynErrors();
+      //  for (int i = 0; i < nSynErrors; i++) {
+      //    var synErr = Errors.GetSynError(i == 0);
+      //    codeEditor.SetLexError(synErr.msg, synErr.line, synErr.col);
+      //  }
+      //}
     }
 
Index: /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDef.atg
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDef.atg	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDef.atg	(revision 9724)
@@ -1,78 +1,35 @@
+$namespace=HeuristicLab.Problems.GPDL
+
+using System.Text;
+using System.Collections.Generic;
+using IEnumerableConstraintNode = System.Collections.Generic.IEnumerable<ConstraintNode>;
+
 COMPILER GPDef
-SEM <<
   static StringBuilder srcText;
   public static HeuristicLab.Optimization.IProblem problem;
->>
-
-
-CHARACTER SETS
+  static string lastSrc;
+  
+CHARACTERS
   letter = 'A'..'Z' + 'a'..'z'.
   digit = '0'..'9'.
-  whiteSpace = CHR(9) + EOL IGNORE. /* ' ' ignored by default */
+
+TOKENS
+  ident = letter {letter | digit}  .
 
 COMMENTS
-  FROM '/*' TO '*/' NESTED.
-
-KEYWORDS
-  'PROBLEM'. 'END'. 'EPS'.
-  'LOCAL'. 'NONTERMINALS'. 'RULES'.
-  'SEM'. 'MAXIMIZE'. 'MINIMIZE'. 'TERMINALS'. 'CONSTRAINTS'. 'INIT'. 'MUTATE'. 'CODE'.
-  'IN'. 'SET'. 'RANGE'.
-
-TOKENS
-  '='. '|'. '.'. '('. ')'. '['. ']'. '{'. '}'. '..'.
-
-TOKEN CLASSES
-  ident<<out string identStr>> =
-    letter {letter | digit}        LEX << identStr = tokenStr; >>
-  .
-
-PRAGMAS
-  source       = '<<' SEM << GPDefSem.srcText = new StringBuilder();
-                             for (; ; ) {
-                              switch (GPDefLex.curCh) {
-                                case Utils.EF:
-                                  Errors.SemError(GPDefLex.curLine, GPDefLex.curCol, "end of file in source text");
-                                  return;
-                                case '<':
-                                  GPDefLex.NextCh();
-                                  if (GPDefLex.curCh == '<') {
-                                    GPDefSem.srcText.Append('<');
-                                    Errors.Warning(GPDefLex.curLine, GPDefLex.curCol, "non closed source text before?");
-                                    GPDefLex.NextCh();
-                                  }
-                                  GPDefSem.srcText.Append('<');
-                                  break;
-                                case '>':
-                                  GPDefLex.NextCh();
-                                  if (GPDefLex.curCh == '>') {
-                                    GPDefLex.curCh = ' ';          // force GPDefLex to get next character
-                                    SourceReader.Handle(GPDefSem.srcText.ToString());
-                                    return;
-                                  }
-                                  GPDefSem.srcText.Append('>');
-                                  break;
-                                default:
-                                  GPDefSem.srcText.Append(GPDefLex.curCh);
-                                  GPDefLex.NextCh();
-                                  break;
-                              }
-                            }
-                            >> .
-NONTERMINALS
-  GPDef.
-  NonterminalDecl<<out NonTerminalNode ntNode>>.
-  TerminalDecl<<out TerminalNode tNode>>.
-  RuleDef<<out RuleNode rNode>>.
-  SynExpr<<out RuleExprNode expr>>.
-  SynTerm<<out RuleExprNode expr>>.
-  SynFact<<out RuleExprNode expr>>.
-  SemAction<<out RuleActionNode action>>.
-  ConstraintDef<<out IEnumerable<ConstraintNode> constraints>>.
-  ConstraintRule<<out ConstraintNode constraint>>.
-  SetDefinition<<ConstraintNode constraint>>.
-
-RULES
-  GPDef =                                                                         LOCAL <<
+  FROM "/*" TO "*/" NESTED
+
+IGNORE '\t' + '\r' + '\n'
+
+
+PRODUCTIONS
+
+  SourceCode<out string src> =                                                    (. src = ""; .)
+   "<<"                                                                           (. int beg = la.pos; .)
+   {ANY}                                                                          (. int end = la.pos; .)
+   ">>"                                                                           (. if(end>beg) src = scanner.buffer.GetString(beg, end); .)
+  .
+
+  GPDef =                                                                         (.
                                                                                     string identStr = "";
                                                                                     RuleNode ruleNode = null;
@@ -82,70 +39,72 @@
                                                                                     TerminalNode tNode = null;
                                                                                     problem = null;
-                                                                                  >>
-    'PROBLEM' ident<<out identStr>>                                               SEM << gpDef.Name = identStr; >>
-    ['CODE' /* SourceText */                                                      SEM << SourceReader.WithNext((src) => gpDef.ClassCodeNode = new CodeNode{SrcCode = src});  >>
+                                                                                    string src = "";
+                                                                                  .)
+    "PROBLEM" ident                                                               (. gpDef.Name = t.val; .)
+    ["CODE" SourceCode<out src>                                                   (. gpDef.ClassCodeNode = new CodeNode{SrcCode = src}; .)
     ]
-    ['INIT' /* SourceText */                                                      SEM << SourceReader.WithNext((src) => gpDef.InitCodeNode = new CodeNode{SrcCode = src});  >>
+    ["INIT" SourceCode<out src>                                                   (. gpDef.InitCodeNode = new CodeNode{SrcCode = src}; .)
     ]
 
-    'NONTERMINALS' { NonterminalDecl<<out ntNode>>                                SEM << gpDef.NonTerminals.Add(ntNode); >>
-    }
-    'TERMINALS' { TerminalDecl<<out tNode>>                                       SEM << gpDef.Terminals.Add(tNode); >>
-    }
-    'RULES' { RuleDef<<out ruleNode>>                                                SEM << gpDef.Rules.Add(ruleNode); >>
-    }
-                                                                                  SEM << fitnessFunNode = new FitnessFunctionNode();
+    "NONTERMINALS" { NonterminalDecl<out ntNode>                                  (. gpDef.NonTerminals.Add(ntNode); .)
+    }
+    "TERMINALS" { TerminalDecl<out tNode>                                         (. gpDef.Terminals.Add(tNode); .)
+    }
+    "RULES" { RuleDef<out ruleNode>                                               (. gpDef.Rules.Add(ruleNode); .)
+    }
+                                                                                  (. fitnessFunNode = new FitnessFunctionNode();
                                                                                          gpDef.FitnessFunctionNode = fitnessFunNode;
-                                                                                  >>
-    ('MAXIMIZE'                                                                   SEM << fitnessFunNode.Maximization = true; >>
-    | 'MINIMIZE'                                                                  SEM << fitnessFunNode.Maximization = false; >>
+                                                                                  .)
+    ("MAXIMIZE"                                                                   (. fitnessFunNode.Maximization = true; .)
+    | "MINIMIZE"                                                                  (. fitnessFunNode.Maximization = false; .)
     )
-     /* SourceText */                                                             SEM << SourceReader.WithNext((src) => fitnessFunNode.SrcCode = src);  >>
-    'END' ident<<out identStr>> '.'                                               SEM <<
-                                                                                    SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
+     SourceCode<out src>                                                          (. fitnessFunNode.SrcCode = src; .)
+    "END" ident                                                                   (.
+                                                                                    // SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
                                                                                     var gen = new ProblemGenerator();
                                                                                     problem = gen.GenerateFromAst(gpDef);
-                                                                                  >>
-  .
-
-
-  /******************************************************/
-  SemAction<<out RuleActionNode action>> =                                        LOCAL << RuleActionNode myAction = null; action = null; >>
-    'SEM' /* SourceText */                                                        SEM <<
+                                                                                  .)
+    '.'
+  .
+
+
+  /******************************************************/
+  SemAction<out RuleActionNode action> =                                          (. RuleActionNode myAction = null; action = null; string src = ""; .)
+    "SEM" SourceCode<out src>                                                     (.
                                                                                     myAction = new RuleActionNode();
-                                                                                    SourceReader.WithNext((src) => {myAction.SrcCode = src;});
+                                                                                    myAction.SrcCode = src;
                                                                                     action = myAction;
-                                                                                  >>
-  .
-
-  /******************************************************/
-  NonterminalDecl<<out NonTerminalNode ntNode>> =                                 LOCAL << string identStr = ""; ntNode = null;>>
-    ident<<out identStr>> /* FormalAttrList */                                    SEM <<
+                                                                                  .)
+  .
+
+  /******************************************************/
+  NonterminalDecl<out NonTerminalNode ntNode> =                                   (. string identStr = ""; ntNode = null; string src = ""; .)
+    ident                                                                         (. identStr = t.val; .)
+    SourceCode<out src>                                                           (.
                                                                                     var myNtNode = new NonTerminalNode();
                                                                                     ntNode = myNtNode;
                                                                                     myNtNode.Ident = identStr;
-                                                                                    SourceReader.WithNext((src) => {myNtNode.FormalParameters = src;});
-                                                                                  >>
+                                                                                    myNtNode.FormalParameters = src;
+                                                                                  .)
     '.'
   .
 
   /******************************************************/
-  TerminalDecl<<out TerminalNode tNode>> =                                        LOCAL <<
+  TerminalDecl<out TerminalNode tNode> =                                          (.
                                                                                     string identStr = "";
                                                                                     tNode = null;
                                                                                     TerminalNode myTNode = null;
-                                                                                    IEnumerable<ConstraintNode> constraints = null;
-                                                                                  >>
-  ident<<out identStr>> /* FormalAttrList */                                      SEM <<
+                                                                                    IEnumerableConstraintNode constraints = null;
+                                                                                    string src = "";
+                                                                                  .)
+  ident                                                                           (. identStr = t.val; .) 
+  SourceCode<out src>                                                             (.
                                                                                          myTNode = new TerminalNode();
                                                                                          tNode = myTNode;
                                                                                          myTNode.Ident = identStr;
-                                                                                         SourceReader.WithNext((src) => {
-                                                                                           myTNode.FormalParameters = src;
-                                                                                           myTNode.FieldDefinitions = SourceReader.ExtractFormalParameters(src);
-                                                                                         });
-
-                                                                                  >>
-  [ 'CONSTRAINTS' ConstraintDef<<out constraints>>                                SEM << myTNode.Constraints = constraints; >>
+                                                                                         myTNode.FormalParameters = src;
+                                                                                         myTNode.FieldDefinitions = SourceReader.ExtractFormalParameters(src);
+                                                                                  .)
+  [ "CONSTRAINTS" ConstraintDef<out constraints>                                  (. myTNode.Constraints = constraints; .)
   ]
   '.'
@@ -154,96 +113,102 @@
 
   /******************************************************/
-  ConstraintDef<<out IEnumerable<ConstraintNode> constraints>>  =             LOCAL <<
+  ConstraintDef<out IEnumerableConstraintNode constraints>  =                   (.
                                                                                     List<ConstraintNode> constraintsList = new List<ConstraintNode>();
                                                                                     ConstraintNode n = null;
                                                                                     constraints = null;
-                                                                                  >>
-    { ConstraintRule<<out n>>                                                     SEM << constraintsList.Add(n); >>
-    }
-                                                                                  SEM << constraints = constraintsList; >>
-  .
-
-  /******************************************************/
-  ConstraintRule<<out ConstraintNode constraint>> =                               LOCAL <<
+                                                                                  .)
+    { ConstraintRule<out n>                                                       (. constraintsList.Add(n); .)
+    }
+                                                                                  (. constraints = constraintsList; .)
+  .
+
+  /******************************************************/
+  ConstraintRule<out ConstraintNode constraint> =                                 (.
                                                                                     string identStr = null;
                                                                                     constraint = null;
-                                                                                  >>
-    ident<<out identStr>>                                                         SEM << constraint = new ConstraintNode(identStr); >>
-    'IN' SetDefinition<<constraint>>                                              SEM << SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader  >>
-  .
-
-  /******************************************************/
-  SetDefinition<<ConstraintNode constraint>> =
-    'SET'                                                                        SEM << constraint.Type = ConstraintNodeType.Set; >>
-    /* SourceText */                                                              SEM << SourceReader.WithNext((src) => {constraint.SetExpression = src;}); >>
-    | 
-    'RANGE'                                                                       SEM << constraint.Type = ConstraintNodeType.Range; >>
-    /* SourceText */                                                              SEM << SourceReader.WithNext((src) => {constraint.RangeMinExpression = src;}); >>
-    '..' /* SourceText */                                                         SEM << SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader 
-                                                                                         SourceReader.WithNext((src) => {constraint.RangeMaxExpression = src;}); >>    
-  .
-
-  /******************************************************/
-  RuleDef<<out RuleNode rule>> =                                                  LOCAL <<
+                                                                                  .)
+    ident                                                                         (. constraint = new ConstraintNode(t.val); .)
+    "IN" SetDefinition<constraint>                                                // (. SourceReader.Handle(GPDefSem.srcText.ToString()); .) // flush the source reader 
+  .
+
+  /******************************************************/
+  SetDefinition<ConstraintNode constraint> =                                      (. string src = ""; .)
+    ("SET"                                                                        (. constraint.Type = ConstraintNodeType.Set; .)
+     SourceCode<out src>                                                          (. constraint.SetExpression = src; .)
+     |
+     "RANGE"                                                                      (. constraint.Type = ConstraintNodeType.Range; .)
+     SourceCode<out src>                                                          (. constraint.RangeMinExpression = src; .)
+     ".." SourceCode<out src>                                                     (. // SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader 
+                                                                                    constraint.RangeMaxExpression = src; .)
+    )
+  .
+
+  /******************************************************/
+  RuleDef<out RuleNode rule> =                                                    (.
                                                                                     RuleExprNode expr = null;
                                                                                     string identStr = null;
                                                                                     RuleNode myRule = null;
                                                                                     rule = null;
-                                                                                  >>
-  ident<<out identStr>> /* FormalAttrList */ '='                                  SEM <<
+                                                                                   string src = "";
+                                                                                  .)
+  ident                                                                           (. identStr = t.val; .) 
+  SourceCode<out src> '='                                                         (.
                                                                                       myRule = new RuleNode();
                                                                                       rule = myRule;
                                                                                       myRule.NtSymbol = identStr;
-                                                                                  >>
-  ['LOCAL' /* SourceText */                                                       SEM <<
-                                                                                    SourceReader.WithNext((src) => {myRule.LocalCode = src;});
-                                                                                  >>
+                                                                                  .)
+  ["LOCAL" SourceCode<out src>                                                    (.
+                                                                                    myRule.LocalCode = src;
+                                                                                  .)
   ]
-  SynExpr<<out expr>> '.'                                                        SEM <<
+  SynExpr<out expr> '.'                                                          (.
                                                                                     myRule.RuleExpr = expr;
-                                                                                 >>
-  .
-
-  /******************************************************/
-  SynExpr<<out RuleExprNode expr >> =                                             LOCAL <<
+                                                                                 .)
+  .
+
+  /******************************************************/
+  SynExpr<out RuleExprNode expr > =                                               (.
                                                                                     expr = null;
                                                                                     AlternativesNode alt = null;
-                                                                                  >>
-  SynTerm<<out expr>>                                                             SEM <<
+                                                                                  .)
+  SynTerm<out expr>                                                               (.
                                                                                     alt = new AlternativesNode();
                                                                                     alt.Add(expr);
-                                                                                   >>
+                                                                                  .)
   {
-    '|' SynTerm<<out expr>>                                                       SEM << alt.Add(expr); expr = alt; >>
+    '|' SynTerm<out expr>                                                         (. alt.Add(expr); expr = alt; .)
   }
   .
 
   /******************************************************/
-  SynTerm<<out RuleExprNode expr>> =                                             LOCAL << SequenceNode seq = null; expr = null; >>
-  SynFact<<out expr>>                                                            SEM <<
+  SynTerm<out RuleExprNode expr> =                                               (. SequenceNode seq = null; expr = null; .)
+  SynFact<out expr>                                                              (.
                                                                                    seq = new SequenceNode();
                                                                                    seq.Add(expr);
-                                                                                 >>
+                                                                                 .)
   {
-    SynFact<<out expr>>                                                          SEM << seq.Add(expr); expr = seq; >>
+    SynFact<out expr>                                                            (. seq.Add(expr); expr = seq; .)
   }
   .
 
   /******************************************************/
-  SynFact<<out RuleExprNode expr>> =                                             LOCAL <<
+  SynFact<out RuleExprNode expr> =                                               (.
                                                                                    string identStr = "";
                                                                                    RuleActionNode action = null;
                                                                                    expr = null;
-                                                                                 >>
-    ident<<out identStr>> /* ActualAttrList */                                   SEM <<
+                                                                                   string src = "";
+                                                                                 .)
+    (ident                                                                        (. identStr = t.val; .)
+     SourceCode<out src>                                                          (.
                                                                                     var callNode = new CallSymbolNode{Ident = identStr};
-                                                                                    SourceReader.WithNext((src) => {callNode.ActualParameter = src;});
+                                                                                    callNode.ActualParameter = src;
                                                                                     expr = callNode;
-                                                                                  >>
---    | 'EPS'
---    | '(' SynExpr<<ref rules, mBuilder>> ')'
---    | '[' SynExpr<<ref rules, mBuilder>> ']'
---    | '{' SynExpr<<ref rules, mBuilder>> '}'
-    | SemAction<<out action>>                                                    SEM << expr = action; >>
+                                                                                 .)
+// not implemented   | "EPS" 
+// not implemented   | '(' SynExpr<ref rules, mBuilder> ')'
+// not implemented   | '[' SynExpr<ref rules, mBuilder> ']'
+// not implemented   | '{' SynExpr<ref rules, mBuilder> '}'
+     | SemAction<out action>                                                      (. expr = action; .)
+    )
   .
 
Index: anches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDefLex.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDefLex.cs	(revision 9723)
+++ 	(revision )
@@ -1,425 +1,0 @@
-// GPDefLex.cs                                              HDO, 2006-08-28
-// -------------
-// Lexical analyzer (finite-state machine interpreter).
-// Generated by Coco-2 (SG).
-//=====================================|========================================
-
-#undef TEST_Lex
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.IO;
-using System.Text;
-
-public class GPDefLex {
-
-  public const String MODULENAME = "GPDefLex";
-  public const int    EOFSPIX    = 1;
-
-  public static TextReader src;
-
-  // --- token information ---
-  public static int    token;               // current token
-  public static int    tokenLine, tokenCol; // position of current token
-  public static String tokenStr;            // token string recognized
-
-  // --- current char. info, for "power users" only ---
-  public static char   curCh;               // current input character
-  public static int    curLine, curCol;     // position of curCh
-
-
-  public static void GPDefLexMethod(Utils.ModuleAction action, out String moduleName) {
-  //-----------------------------------|----------------------------------------
-    moduleName = MODULENAME;
-    switch (action) {
-      case Utils.ModuleAction.getModuleName:
-        return;
-      case Utils.ModuleAction.initModule:
-        caseSensitive = true;
-        lt            = new LexicalTable();
-        tokenStrArr   = new char[256];
-        kwHt          = CreateHashtable();
-        nHt           = CreateHashtable();
-        nl            = new ArrayList();
-        break;
-      case Utils.ModuleAction.resetModule:
-        kwHt.Clear();
-        nHt.Clear();
-        nl.Clear();
-        break;
-      case Utils.ModuleAction.cleanupModule:
-        lt            = null;
-        tokenStrArr   = null;
-        kwHt          = null;
-        nHt           = null;
-        nl            = null;
-        break;
-    } // switch
-  } // GPDefLexMethod
-
-  private static  Hashtable CreateHashtable() {
-    if (caseSensitive)
-      return new Hashtable();
-    else
-      return CollectionsUtil.CreateCaseInsensitiveHashtable();
-  } // CreateHashtable
-
-
-  public static void InitLex() {
-  //-----------------------------------|----------------------------------------
-    // --- initialize keyword hash table  ---
-    kwHt.Clear();
-    EnterKeyword(  1, "PROBLEM");
-    EnterKeyword(  2, "END");
-    EnterKeyword(  3, "EPS");
-    EnterKeyword(  4, "LOCAL");
-    EnterKeyword(  5, "NONTERMINALS");
-    EnterKeyword(  6, "RULES");
-    EnterKeyword(  7, "SEM");
-    EnterKeyword(  8, "MAXIMIZE");
-    EnterKeyword(  9, "MINIMIZE");
-    EnterKeyword( 10, "TERMINALS");
-    EnterKeyword( 11, "CONSTRAINTS");
-    EnterKeyword( 12, "INIT");
-    EnterKeyword( 13, "MUTATE");
-    EnterKeyword( 14, "CODE");
-    EnterKeyword( 15, "IN");
-    EnterKeyword( 16, "SET");
-    EnterKeyword( 17, "RANGE");
-    // --- initialize name data structures  ---
-    nHt.Clear();
-    nl.Clear();
-    nl.Add("");      // so spix = 0 is the empty string
-    nl.Add("!EOF!"); // so EOFSPIX = 1
-    // --- (re)set global data ---
-    curLineStr  = "";
-    curCh       = ' ';
-    curLine     = 0;
-    curCol      = 2;
-    tokenStr    = null;
-    token       = 0;
-    tokenCol    = 0;
-    tokenLine   = 0;
-    tokenStrLen = 0;
-    pendingEOLs = 0;
-    apxLen      = pendingEOLs; // to prevent warning
-  } // InitLex
-
-  private static void EnterKeyword(int token, String keyword) {
-    kwHt.Add(keyword, token);
-  } // EnterKeyword
-
-
-  // *** start of global LEX declarations from ATG ***
-  
-  // *** end of global LEX declarations from ATG ***
-
-
-  public static bool caseSensitive;
-
-  private class LexicalTable {
-    public int   header = 4;
-    public int[] startTab = {
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  4,  5,  0,  0,  0,  0, 15,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 12,  2,  0,  0,
-          0, 14, 14, 14, 14, 14, 11, 14, 11, 14, 11, 11, 14, 14, 14, 14,
-         14, 11, 14, 14, 14, 14, 11, 11, 14, 11, 14,  6,  0,  7,  0,  0,
-          0, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-         11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,  8,  3,  9,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
-      };
-    public Sets.Set256 ignoredChars = new Sets.Set256(
-         0x0600, 0x0000, 0x0001
-      );
-    public Sets.Set256 commentStart = new Sets.Set256(
-         0x0000, 0x0000, 0x8000
-      );
-    public Sets.Set256[] cls = {
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x0000, 0xfffe, 0x07ff, 0xfffe, 0x07ff),
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x03ff),
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x0000, 0xf2be, 0x053d),
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x0000, 0x0d40, 0x02c2, 0xfffe, 0x07ff)
-      };
-  } // LexicalTable
-
-  private static LexicalTable lt;
-  private static Hashtable    kwHt;  // hash table for keywords: string -> token 
-  private static Hashtable    nHt;   // hash table for names: string -> null 
-  private static ArrayList    nl;    // name list  for names, index is spix
-
-  private static String curLineStr;  // current source line
-  private static char[] tokenStrArr; // token string in an array
-  private static int    tokenStrLen; // length of token string in tokenStrArr
-  private static int    state;       // current automaton state
-  private static int    apxLen;      // length of appendix in token string
-  private static int    pendingEOLs; // nr of EOLs found in comment
-
-  // --- to save and restore scanner state ---
-  private static char   savedCh;
-  private static int    savedCol, savedLine;
-
-  private static void SaveScannerState() {
-    savedCh      = curCh;
-    savedCol     = curCol;
-    savedLine    = curLine;
-  } // SaveScannerState
-
-  private static void RestoreScannerState() {
-    tokenStrLen -= apxLen;
-    apxLen       = 0;
-    curCh        = savedCh;
-    curCol       = savedCol;
-    curLine      = savedLine;
-  } // RestoreScannerState
-
-
-  public static void NextCh() {
-  //-----------------------------------|----------------------------------------
-    for (;;) {
-      
-      if (curCol < curLineStr.Length) {         // within line
-        curCol++;
-        curCh = curLineStr[curCol - 1];
-        return;
-      } else if (curCol == curLineStr.Length) { // end of line
-        curCol++;
-        curCh = Utils.LF; // to separate lines
-        return;
-      } else { // curCol > curLineStr.Length
-        curLineStr = src.ReadLine();
-        curLine++;
-        curCol = 0;
-        if (curLineStr == null) {               // end of file
-          curLineStr = "";
-          curCh = Utils.EF;
-          return;
-        } // if
-      } // else
-    } // for
-  } // NextCh
-
-
-  private static void CommentErr() {
-    Errors.LexError(curLine, curCol, "end of file in comment");
-  } // CommentErr
-
-  private static bool Comment() {
-    
-    int level = 1;
-    
-    SaveScannerState();
-    // --- from '/' '*' to '*' '/' nested ---
-    NextCh();
-    if (curCh == '*') {
-      NextCh();
-      for (;;)
-        switch (curCh) {
-          case '*':
-            NextCh();
-            if (curCh == '/') {
-              NextCh();
-              level--;
-              if (level == 0) {
-                return true;
-              } // if
-            } // if
-            break;
-          case '/':
-            NextCh();
-            if (curCh == '*') {
-              level++;
-              NextCh();
-            }
-            break;
-          case Utils.EF:
-            CommentErr();
-            return true;
-          default:
-            NextCh();
-            break;
-        } // switch
-    } else
-      RestoreScannerState();
-    return false;
-  } // Comment
-
-  private static void HandleLexErr() {
-    Errors.LexError(curLine, curCol, 
-                    "invalid character '{0}' (hex {1:X})", curCh, (int)curCh);
-    if (apxLen > 0)
-      RestoreScannerState();
-  } // HandleLexErr
-
-
-  public static void GetToken() {
-  //-----------------------------------|----------------------------------------
-    token = -1;
-    tokenStr = null;
-    do {
-      // --- skip ignored chars and comments ---
-      for (;;) {
-        while (Sets.member(curCh, lt.ignoredChars))
-          NextCh();
-        if (!Sets.member(curCh, lt.commentStart))
-          break;
-        if (!Comment())
-          break;
-      } // for
-      // --- scan for next token ---
-      tokenLine   = curLine;
-      tokenCol    = curCol;
-      tokenStrLen = 0;
-      apxLen      = 0;
-      state = (curCh == Utils.EF) ? 1 : lt.startTab[curCh];
-      for (;;) {
-        tokenStrArr[tokenStrLen++]= curCh;
-        NextCh();
-        switch (state) {
-          case 0:
-            Errors.LexError(tokenLine, tokenCol, "invalid token start");
-            break;
-          case 1:
-            token = 0;
-            tokenStrLen = 0;
-            break;                      // EOF recognized
-          case 2:
-            token = 18;
-            break;                      // '=' recognized
-          case 3:
-            token = 19;
-            break;                      // '|' recognized
-          case 4:
-            token = 21;
-            break;                      // '(' recognized
-          case 5:
-            token = 22;
-            break;                      // ')' recognized
-          case 6:
-            token = 23;
-            break;                      // '[' recognized
-          case 7:
-            token = 24;
-            break;                      // ']' recognized
-          case 8:
-            token = 25;
-            break;                      // '{' recognized
-          case 9:
-            token = 26;
-            break;                      // '}' recognized
-          case 10:
-            token = 27;
-            break;                      // '..' recognized
-          case 11:
-            if (Sets.member(curCh, lt.cls[0])) {
-              state = 11;
-              continue;
-            } // if
-            else if (Sets.member(curCh, lt.cls[1])) {
-              state = 11;
-              continue;
-            } // if
-            else {
-              token = KeywordCheck();
-              if (token >= 0)
-                break;                  // keyword recognized
-              token = 28;
-              break;                    // ident recognized
-            } // else
-          case 12:
-            if (curCh == '<') {
-              state = 13;
-              continue;
-            } // if
-            else {
-              HandleLexErr();
-              break;
-            } // else
-          case 13:
-            token = 29;
-            break;                      // source recognized
-          case 14:
-            if (Sets.member(curCh, lt.cls[1])) {
-              state = 11;
-              continue;
-            } // if
-            else if (Sets.member(curCh, lt.cls[2])) {
-              state = 14;
-              continue;
-            } // if
-            else if (Sets.member(curCh, lt.cls[3])) {
-              state = 11;
-              continue;
-            } // if
-            else {
-              token = KeywordCheck();
-              if (token >= 0)
-                break;                  // keyword recognized
-              token = 28;
-              break;                    // ident recognized
-            } // else
-          case 15:
-            if (curCh == '.') {
-              state = 10;
-              continue;
-            } // if
-            else {
-              token = 20;
-              break;                    // '.' recognized
-            } // else
-        } // switch
-        break;
-      } // for
-    } while (token < 0);
-    if (tokenStr == null)
-      tokenStr = new String(tokenStrArr, 0, tokenStrLen);
-  } // GetToken
-
-  private static int KeywordCheck() {
-    tokenStr = new String(tokenStrArr, 0, tokenStrLen - apxLen);
-    Object token = kwHt[tokenStr];
-    return (token == null) ? -1 : (int)token;
-  } // KeywordCheck
-
-
-  public static int Hash(String s) {
-  //-----------------------------------|----------------------------------------
-    Object spix = nHt[s];
-    if (spix == null) {
-      if (caseSensitive)
-        nl.Add(s);
-      else
-        nl.Add(s.ToUpper());
-      spix   = nl.Count - 1;
-      nHt[s] = spix;
-    } // if
-    return (int)spix;
-  } // Hash
-  
-  
-  public static String HashedStr(int spix) {
-  //-----------------------------------|----------------------------------------
-    return (String)nl[spix];
-  } // HashedStr
-
-
-  public static void GETidentAttr(out string identStr) {
-    identStr = tokenStr;
-  } // GETidentAttr
-  
-  public static void GETsourceAttr()  {
-  } // GETsourceAttr
-
-} // GPDefLex
-
-// End of GPDefLex.cs
-//=====================================|========================================
Index: anches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDefSem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDefSem.cs	(revision 9723)
+++ 	(revision )
@@ -1,427 +1,0 @@
-// GPDefSem.cs                                              HDO, 2006-08-28
-// -------------
-// Semantic evaluator for table-driven top-down parsing.
-// Generated by Coco-2 (PGT).
-//=====================================|========================================
-
-using System;
-using System.Text;
-using System.Collections;
-using System.Collections.Generic;
-
-using Lex = GPDefLex;
-using Syn = GPDefSyn;
-
-public class GPDefSem {
-
-
-  public const String MODULENAME = "GPDefSem";
-
-  public static void GPDefSemMethod(Utils.ModuleAction action, out String moduleName) {
-  //-----------------------------------|----------------------------------------
-    moduleName = MODULENAME;
-    switch (action) {
-      case Utils.ModuleAction.getModuleName:
-        return;
-      case Utils.ModuleAction.initModule:
-        break;
-      case Utils.ModuleAction.resetModule:
-        break;
-      case Utils.ModuleAction.cleanupModule:
-        return;
-    } // switch
-  } // GPDefSemMethod
-
-
-  // *** start of global SYN and SEM declarations from ATG ***
-  
-  static StringBuilder srcText;
-  public static HeuristicLab.Optimization.IProblem problem;
-
-  // *** end of global SYN and SEM declarations from ATG ***
-
-  
-  private static void P_source() {
-    Lex.GETsourceAttr();
-    GPDefSem.srcText = new StringBuilder();
-    for (; ; ) {
-     switch (GPDefLex.curCh) {
-       case Utils.EF:
-         Errors.SemError(GPDefLex.curLine, GPDefLex.curCol, "end of file in source text");
-         return;
-       case '<':
-         GPDefLex.NextCh();
-         if (GPDefLex.curCh == '<') {
-           GPDefSem.srcText.Append('<');
-           Errors.Warning(GPDefLex.curLine, GPDefLex.curCol, "non closed source text before?");
-           GPDefLex.NextCh();
-         }
-         GPDefSem.srcText.Append('<');
-         break;
-       case '>':
-         GPDefLex.NextCh();
-         if (GPDefLex.curCh == '>') {
-           GPDefLex.curCh = ' ';          // force GPDefLex to get next character
-           SourceReader.Handle(GPDefSem.srcText.ToString());
-           return;
-         }
-         GPDefSem.srcText.Append('>');
-         break;
-       default:
-         GPDefSem.srcText.Append(GPDefLex.curCh);
-         GPDefLex.NextCh();
-         break;
-     }
-    }
-
-  } // P_source
-
-
-  private static void NT_GPDef() {
-    string identStr = "";
-    RuleNode ruleNode = null;
-    GPDefNode gpDef = new GPDefNode();
-    NonTerminalNode ntNode = null;
-    FitnessFunctionNode fitnessFunNode = null;
-    TerminalNode tNode = null;
-    problem = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 2: // SEM
-          gpDef.Name = identStr;
-          break;
-        case 3: // SEM
-          SourceReader.WithNext((src) => gpDef.ClassCodeNode = new CodeNode{SrcCode = src});
-          break;
-        case 4: // SEM
-          SourceReader.WithNext((src) => gpDef.InitCodeNode = new CodeNode{SrcCode = src});
-          break;
-        case 5:
-          NT_NonterminalDecl(out ntNode);
-          break;
-        case 6: // SEM
-          gpDef.NonTerminals.Add(ntNode);
-          break;
-        case 7:
-          NT_TerminalDecl(out tNode);
-          break;
-        case 8: // SEM
-          gpDef.Terminals.Add(tNode);
-          break;
-        case 9:
-          NT_RuleDef(out ruleNode);
-          break;
-        case 10: // SEM
-          gpDef.Rules.Add(ruleNode);
-          break;
-        case 11: // SEM
-          fitnessFunNode = new FitnessFunctionNode();
-          gpDef.FitnessFunctionNode = fitnessFunNode;
-
-          break;
-        case 12: // SEM
-          fitnessFunNode.Maximization = true;
-          break;
-        case 13: // SEM
-          fitnessFunNode.Maximization = false;
-          break;
-        case 14: // SEM
-          SourceReader.WithNext((src) => fitnessFunNode.SrcCode = src);
-          break;
-        case 15:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 16: // SEM
-          SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
-          var gen = new ProblemGenerator();
-          problem = gen.GenerateFromAst(gpDef);
-
-          break;
-      } // switch
-    } // for
-  } // NT_GPDef
-
-  private static void NT_SemAction(out RuleActionNode action) {
-    RuleActionNode myAction = null; action = null;
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1: // SEM
-          myAction = new RuleActionNode();
-          SourceReader.WithNext((src) => {myAction.SrcCode = src;});
-          action = myAction;
-
-          break;
-      } // switch
-    } // for
-  } // NT_SemAction
-
-  private static void NT_NonterminalDecl(out NonTerminalNode ntNode) {
-    string identStr = ""; ntNode = null;
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 2: // SEM
-          var myNtNode = new NonTerminalNode();
-          ntNode = myNtNode;
-          myNtNode.Ident = identStr;
-          SourceReader.WithNext((src) => {myNtNode.FormalParameters = src;});
-
-          break;
-      } // switch
-    } // for
-  } // NT_NonterminalDecl
-
-  private static void NT_TerminalDecl(out TerminalNode tNode) {
-    string identStr = "";
-    tNode = null;
-    TerminalNode myTNode = null;
-    IEnumerable<ConstraintNode> constraints = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 2: // SEM
-          myTNode = new TerminalNode();
-          tNode = myTNode;
-          myTNode.Ident = identStr;
-          SourceReader.WithNext((src) => {
-            myTNode.FormalParameters = src;
-            myTNode.FieldDefinitions = SourceReader.ExtractFormalParameters(src);
-          });
-          
-
-          break;
-        case 3:
-          NT_ConstraintDef(out constraints);
-          break;
-        case 4: // SEM
-          myTNode.Constraints = constraints;
-          break;
-      } // switch
-    } // for
-  } // NT_TerminalDecl
-
-  private static void NT_ConstraintDef(out IEnumerable<ConstraintNode> constraints) {
-    List<ConstraintNode> constraintsList = new List<ConstraintNode>();
-    ConstraintNode n = null;
-    constraints = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_ConstraintRule(out n);
-          break;
-        case 2: // SEM
-          constraintsList.Add(n);
-          break;
-        case 3: // SEM
-          constraints = constraintsList;
-          break;
-      } // switch
-    } // for
-  } // NT_ConstraintDef
-
-  private static void NT_ConstraintRule(out ConstraintNode constraint) {
-    string identStr = null;
-    constraint = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 2: // SEM
-          constraint = new ConstraintNode(identStr);
-          break;
-        case 3:
-          NT_SetDefinition(constraint);
-          break;
-        case 4: // SEM
-          SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
-          break;
-      } // switch
-    } // for
-  } // NT_ConstraintRule
-
-  private static void NT_SetDefinition(ConstraintNode constraint) {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1: // SEM
-          constraint.Type = ConstraintNodeType.Set;
-          break;
-        case 2: // SEM
-          SourceReader.WithNext((src) => {constraint.SetExpression = src;});
-          break;
-        case 3: // SEM
-          constraint.Type = ConstraintNodeType.Range;
-          break;
-        case 4: // SEM
-          SourceReader.WithNext((src) => {constraint.RangeMinExpression = src;});
-          break;
-        case 5: // SEM
-          SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
-          SourceReader.WithNext((src) => {constraint.RangeMaxExpression = src;});
-          break;
-      } // switch
-    } // for
-  } // NT_SetDefinition
-
-  private static void NT_RuleDef(out RuleNode rule) {
-    RuleExprNode expr = null;
-    string identStr = null;
-    RuleNode myRule = null;
-    rule = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 2: // SEM
-          myRule = new RuleNode();
-          rule = myRule;
-          myRule.NtSymbol = identStr;
-
-          break;
-        case 3: // SEM
-          SourceReader.WithNext((src) => {myRule.LocalCode = src;});
-
-          break;
-        case 4:
-          NT_SynExpr(out expr);
-          break;
-        case 5: // SEM
-          myRule.RuleExpr = expr;
-
-          break;
-      } // switch
-    } // for
-  } // NT_RuleDef
-
-  private static void NT_SynExpr(out RuleExprNode expr) {
-    expr = null;
-    AlternativesNode alt = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_SynTerm(out expr);
-          break;
-        case 2: // SEM
-          alt = new AlternativesNode();
-          alt.Add(expr);
-
-          break;
-        case 3:
-          NT_SynTerm(out expr);
-          break;
-        case 4: // SEM
-          alt.Add(expr); expr = alt;
-          break;
-      } // switch
-    } // for
-  } // NT_SynExpr
-
-  private static void NT_SynTerm(out RuleExprNode expr) {
-    SequenceNode seq = null; expr = null;
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_SynFact(out expr);
-          break;
-        case 2: // SEM
-          seq = new SequenceNode();
-          seq.Add(expr);
-
-          break;
-        case 3:
-          NT_SynFact(out expr);
-          break;
-        case 4: // SEM
-          seq.Add(expr); expr = seq;
-          break;
-      } // switch
-    } // for
-  } // NT_SynTerm
-
-  private static void NT_SynFact(out RuleExprNode expr) {
-    string identStr = "";
-    RuleActionNode action = null;
-    expr = null;
-
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr(out identStr);
-          break;
-        case 2: // SEM
-          var callNode = new CallSymbolNode{Ident = identStr};
-          SourceReader.WithNext((src) => {callNode.ActualParameter = src;});
-          expr = callNode;
-
-          break;
-        case 3:
-          NT_SemAction(out action);
-          break;
-        case 4: // SEM
-          expr = action;
-          break;
-      } // switch
-    } // for
-  } // NT_SynFact
-
-
-  public delegate void PragmaMethod();
-  public static PragmaMethod[] pragmaMethods = {
-      new PragmaMethod(P_source)
-    };
-
-
-  public static void StartSem() {
-  //-----------------------------------|----------------------------------------
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_GPDef();
-          break;
-      } // switch
-    } // for
-  } // StartSem
-
-    
-} // GPDefSem
-
-// End of GPDefSem.cs
-//=====================================|========================================
Index: anches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDefSyn.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDefSyn.cs	(revision 9723)
+++ 	(revision )
@@ -1,559 +1,0 @@
-// GPDefSyn.cs                                              HDO, 2006-08-28
-// -------------
-// Table-driven top-down syntax analyzer (G-code interpreter).
-// Generated by Coco-2 (PGT).
-//=====================================|========================================
-
-// --- call pragma mehts. and exec. sem. acts. after syntax errors? ---
-#define CONTPRAGMAACTS            // !!!must be defined for SG and PGT!!! 
-#undef  CONTSEMACTS               // should not be defined 
-
-using System;
-using System.Text;
-
-using Lex = GPDefLex;
-using Sem = GPDefSem;
-
-public class GPDefSyn {
-                   
-  public static String MODULENAME = "GPDefSyn";
-
-  // --- G-code instructions ---
-  public enum Instruction {
-    T, TA, TC, TCA, NT, NTA, ANY, ANYA, EPS, EPSA, JMP, RET
-  } // Instruction
-
-  private const int ROOTPC     =  209;
-  private const int LASTTERM   =   28;
-  private const int LASTPRAGMA =   29;
-
-
-  // --- other constants ---
-  private const int MINERRDIST   =   3;
-  private const int MAXSTACKLEN  = 100;
-  private const int EOFTOK       =   0;
-  private const int FIRSTNONTERM = LASTPRAGMA + 1;
-
-  public class NTData {
-    public int          startPC;
-    public bool         del;
-    public Sets.Set256  firstSet;
-    public NTData(int startPC, bool del, Sets.Set256 firstSet) {
-      this.startPC  = startPC;
-      this.del      = del;
-      this.firstSet = firstSet;
-    } // NTData
-  } // NTData
-  
-  private class GrammarTable {
-    public int[]  header = {
-      214, 28, 29, 40, 6, 0
-    };
-    public byte[] code = {
-         0,   1,   2,  28,   1,  14,   1,  14,  12,   0,  15,   1,  12,  17,
-         0,  16,   0,   5,   5,   1,  28,   0,   5,  18,  10,  19,   0,   0,
-        10,   5,   2,  39,   0,   7,  20,  10,  30,   0,   0,   6,   5,   3,
-        50,   0,   9,  22,  10,  41,   0,   8,   1,  23,   1,   8,  70,   0,
-        24,   8,   2,  26,   0,   2,   2,  28,  15,   0,  20,  28,  11,   0,
-         9,  25,  10,  58,   0,   2,  28,   1,  14,   0,  20,  11,   2,  28,
-         1,  14,   1,  11,  95,   0,   4,   8,   3,  16,   0,  20,  11,   2,
-        28,   1,   0,  18,  14,   1,   4, 109,   0,  15,   4,   4,   4,   0,
-        20,  17,  11,   4,   5,   1,  14,   1,  19, 131,   0,   4,   5,   3,
-        16,  10, 120,   0,   8,   3,  11,   4,   6,   1,  14,   5,   6, 147,
-         0,   3,  16,  10, 138,   0,   8,   4,  11,   3,  28, 157,   0,   1,
-        14,  11,   4,   7,   3,  16,  11,   0,   7,  13,  11,   5,   9, 175,
-         0,   1,  14,  10, 166,   0,   8,   3,  15,  11,   2,  28,   1,  14,
-         0,  15,   4,  10,   3,  16,  11,   1,  16, 199,   0,  13,   8,   6,
-        14,  11,   0,  17,  15,   8,   5,  16,   0,  27,  17,  11,   4,   0,
-         1,   0,   0,  11
-    };
-    public NTData[] nts = {
-      new NTData(   1, false, new Sets.Set256(0x0002)),
-      new NTData(  76, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData(  83, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData(  98, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData( 116, false, new Sets.Set256(0x0080, 0x1000)),
-      new NTData( 134, false, new Sets.Set256(0x0080, 0x1000)),
-      new NTData( 150, false, new Sets.Set256(0x0080, 0x1000)),
-      new NTData( 162, false, new Sets.Set256(0x0080)),
-      new NTData( 166, true , new Sets.Set256(0x0000, 0x1000)),
-      new NTData( 179, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData( 190, false, new Sets.Set256(0x0000, 0x0003))
-    };
-    public Sets.Set256[] epsSets = {
-      new Sets.Set256(0x0300),
-      new Sets.Set256(0x0004),
-      new Sets.Set256(0x0000, 0x0010),
-      new Sets.Set256(0x0000, 0x0018),
-      new Sets.Set256(0x0000, 0x0800),
-      new Sets.Set256(0x0000, 0x1010)
-    };
-    public Sets.Set256[] anySets = {
-      new Sets.Set256(0x0000)
-    };
-    public String[] names = {
-      "end of file", "PROBLEM", "END", "EPS", "LOCAL", "NONTERMINALS",
-      "RULES", "SEM", "MAXIMIZE", "MINIMIZE", "TERMINALS", "CONSTRAINTS",
-      "INIT", "MUTATE", "CODE", "IN", "SET", "RANGE", "=", "|", ".", "(",
-      ")", "[", "]", "{", "}", "..", "ident", "source", "GPDef",
-      "NonterminalDecl", "TerminalDecl", "RuleDef", "SynExpr", "SynTerm",
-      "SynFact", "SemAction", "ConstraintDef", "ConstraintRule",
-      "SetDefinition"
-    };
-  } // GrammarTable;
-
-  private static GrammarTable gt;
-
-  private static int   pc;             // G-code counter
-  private static int[] stk;            // stack of G-code return adresses
-  private static int   sp;             // stack pointer
-  private static bool  mustRead;       // next Lex.token to read
-  private static int   altRoot;        // root of alternative chain
-  private static bool  leaveOrEnter;   // leaveCnt > 0 OR enterCnt > 0
-  private static int   leaveCnt;       // nr. of sem. proc. to leave
-  private static int   enterCnt;       // nr. of sem. proc. to enter
-  private static int   errDist;        // current error distance
-  private static int[] stkAtErr;       // saved stack at error position
-  private static int[] newSP;          // new stack length
-  private static int[] newPC;          // pc after recovery
-
-
-  public static void GPDefSynMethod(Utils.ModuleAction action, out String moduleName) {
-  //-----------------------------------|----------------------------------------
-    moduleName = MODULENAME;
-    switch (action) {
-      case Utils.ModuleAction.getModuleName:
-        return;
-      case Utils.ModuleAction.initModule:
-        Errors.InstallStopParsingMethod(StopParsing);
-        gt       = new GrammarTable();
-        stk      = new int[MAXSTACKLEN];
-        stkAtErr = new int[MAXSTACKLEN];
-        newSP    = new int[LASTTERM + 1];
-        newPC    = new int[LASTTERM + 1];
-        break;
-      case Utils.ModuleAction.resetModule:
-        break;
-      case Utils.ModuleAction.cleanupModule:
-        gt       = null;
-        stk      = null;
-        stkAtErr = null;
-        newSP    = null;
-        newPC    = null;
-        break;
-    } // switch
-  } // GPDefSynMethod
-
-  private static void Push(int pc) {
-    if (sp < MAXSTACKLEN)
-      stk[sp++] = pc;
-    else
-      Errors.Restriction(MODULENAME, "Push", "parser stack overflow");
-  } // Push
-
-  private static int Pop() {
-    if (sp > 0)
-      return stk[--sp];
-    else {
-      Errors.CompilerError(MODULENAME, "Pop", "parser stack underflow");
-      return 0;
-    } // else
-  } // Pop
-
-  private static void GetNextToken() {
-    for (;;) {
-      Lex.GetToken(); // updates Lex.token
-      if (Lex.token <= LASTTERM)
-        return;
-  #if !CONTPRAGMAACTS
-      if (NumOfSynErrors() == 0)
-  #endif
-        Sem.pragmaMethods[Lex.token - LASTTERM - 1]();
-    } // for
-  } // GetNextToken
-
-  private static int AdrAt(int pc) {
-    return (gt.code[pc - 1] |
-           (gt.code[pc    ] << 8));
-  } // AdrAt
-
-  private static void AdjustPC(ref int pc) {
-    if (pc == 0)
-      return;
-    for (;;)
-      switch ((Instruction)gt.code[pc - 1]) {
-        case Instruction.T:
-        case Instruction.TA:
-        case Instruction.TC:
-        case Instruction.TCA:
-        case Instruction.NT:
-        case Instruction.NTA:
-        case Instruction.ANY:
-        case Instruction.ANYA:
-        case Instruction.EPS:
-        case Instruction.EPSA:
-          return;
-        case Instruction.JMP:
-          pc = AdrAt(pc + 1);
-          break;
-        case Instruction.RET:
-          pc = 0;
-          return;
-        default:
-          pc++; // syn. or sem. action
-          break;
-      } // switch
-  } // AdjustPC
-
-  private static void GetSymInstr(int pc, 
-                        out int opcode, out int sy, out int nextPC, out int altPC) {
-    opcode = gt.code[pc - 1];
-    nextPC = 0; // dummy init
-    altPC  = 0; // dummy init 
-    switch ((Instruction)opcode) {
-      case Instruction.T:
-      case Instruction.TA:
-      case Instruction.TC:
-      case Instruction.TCA:
-      case Instruction.ANYA:
-      case Instruction.EPS:
-      case Instruction.EPSA:
-        sy = gt.code[pc];
-        break;
-      case Instruction.NT:
-      case Instruction.NTA:
-        sy = gt.code[pc] + FIRSTNONTERM;
-        break;
-      default: // ANY, JMP, RET, SEM, SYN 
-        sy = 0;
-        break;
-    } // switch
-    switch ((Instruction)opcode) {
-      case Instruction.T:
-      case Instruction.EPS:
-        nextPC = pc + 2;
-        altPC = 0;
-        break;
-      case Instruction.TC:
-      case Instruction.NT:
-        nextPC = pc + 3;
-        altPC = 0;
-        break;
-      case Instruction.TA:
-      case Instruction.ANYA:
-      case Instruction.EPSA:
-        nextPC = pc + 4;
-        altPC = AdrAt(pc + 2);
-        break;
-      case Instruction.TCA:
-      case Instruction.NTA:
-        nextPC = pc + 5;
-        altPC = AdrAt(pc + 2);
-        break;
-      case Instruction.ANY:
-        nextPC = pc + 1;
-        altPC = 0;
-        break;
-    } // switch
-    AdjustPC(ref nextPC);
-    AdjustPC(ref altPC);
-  } // GetSymInstr
-
-  private static void Fill(int pc, int sp) {
-    int opcode, sy, nextPC, altPC, i;
-    AdjustPC(ref pc);
-    while (pc > 0) {
-      GetSymInstr(pc, out opcode, out sy, out nextPC, out altPC);
-      switch ((Instruction)opcode) {
-        case Instruction.T:
-        case Instruction.TA:
-        case Instruction.TC:
-        case Instruction.TCA:
-          newPC[sy] = pc;
-          newSP[sy] = sp;
-          break;
-        case Instruction.NT:
-        case Instruction.NTA:
-          for (i = 0; i <= LASTTERM; i++)
-            if (Sets.member((ushort)i, gt.nts[sy - FIRSTNONTERM].firstSet)) {
-              newPC[i] = pc;
-              newSP[i] = sp;
-            }
-          if (gt.nts[sy - FIRSTNONTERM].del)
-            Fill(nextPC, sp);
-          break;
-        case Instruction.EPS:
-        case Instruction.EPSA:
-          Fill(nextPC, sp);
-          break;
-      } // switch
-      pc = altPC;
-    } // while
-  } // Fill
-
-  private static void FillSucc(int pc, int sp) {
-    int opcode, sy, nextPC, altPC;
-    AdjustPC(ref pc);
-    while (pc > 0) {
-      GetSymInstr(pc, out opcode, out sy, out nextPC, out altPC);
-      if (nextPC > 0)
-        Fill(nextPC, sp);
-      pc = altPC;
-    } // while
-  } // FillSucc
-
-  private static void Triple(int altRoot) {
-    for (int i = 0; i <= LASTTERM; i++) { // clear triple list
-      newPC[i] = 0;
-      newSP[i] = 0;
-    } // for
-    for (int i = 1; i <= sp; i++) {       // successors of stacked nt's
-      FillSucc(stk[i - 1], i - 1);
-      Fill(stk[i - 1], i - 1);
-    } // for
-    FillSucc(altRoot, sp);                // successors of alt. chain
-    Fill(altRoot, sp);                    // current alt. chain
-  } // Triple
-
-  private static void HandleSynErr(ref int pc, ref int altRoot) {
-    int     opcode, sy, nextPC, altPC, adjPC, nwSP, eq;
-    bool    nameInMsg;
-    String  name;
-    StringBuilder msg = new StringBuilder();
-    leaveOrEnter = false;
-    if (errDist >= MINERRDIST) { // --- primary error
-      nameInMsg = false;
-      adjPC = altRoot;
-      AdjustPC(ref adjPC);
-      while (adjPC > 0) {
-        GetSymInstr(adjPC, out opcode, out sy, out nextPC, out altPC);
-        if ( (Instruction)opcode >= Instruction.T  && 
-             (Instruction)opcode <= Instruction.NTA  ) {
-          if ( gt.names[sy].IndexOf(' ') >= 0 || 
-               !Char.IsLetter(gt.names[sy][0]) )
-            name = "\"" + gt.names[sy] + "\"";
-          else
-            name = gt.names[sy];
-          if (name.IndexOf('{') > -1) // prevent formatting problems in Errors.SynError
-            name = name.Replace("{", "{{");
-          if (name.IndexOf('}') > -1) // prevent formatting problems in Errors.SynError
-            name = name.Replace("}", "}}");
-          if (msg.Length + name.Length + 2 > 80) {
-            msg.Append(" ...");
-            break;
-          } // if
-          if (!nameInMsg) {
-            nameInMsg = true;
-            msg.Append("expected: " + name);
-          } else {
-            msg.Append(", ");
-            msg.Append(name);
-          } // else
-        } // if
-        adjPC = altPC;
-      } // while
-      if (!nameInMsg)
-        msg.Append("syntax error");
-      Errors.SynError(Lex.tokenLine, Lex.tokenCol, msg.ToString(), "");
-      Triple(altRoot);
-      while (newPC[Lex.token] == 0) {
-        GetNextToken();      // may result in a call to StopParsing
-        if (leaveOrEnter)
-          return;
-      } // while
-      nwSP = newSP[Lex.token];
-      leaveCnt = sp - nwSP;
-      enterCnt = 0;
-      Array.Copy(stk, stkAtErr, stk.Length); // save stack
-    } else {                 // --- spurios error
-      if (errDist == 0) {    // no token used since last error
-        GetNextToken();      // may result in a call to StopParsing
-        if (leaveOrEnter)
-          return;
-      } // if
-      while (newPC[Lex.token] == 0) {
-        GetNextToken();      // may result in a call to StopParsing
-        if (leaveOrEnter) 
-          return;
-      } // while
-      nwSP = newSP[Lex.token];
-      eq = 2;                // compare stkAtErr and stk
-      while (eq <= sp && eq <= nwSP && stkAtErr[eq - 1] == stk[eq - 1])
-        eq++;
-      eq--;                  // stacks are equal up to index eq
-      leaveCnt = sp - eq;
-      if (nwSP < eq) {
-        leaveCnt = sp - nwSP;
-        enterCnt = 0;
-      } else if (nwSP > eq)
-        enterCnt = nwSP - eq;
-      else // nwSP == eq
-        enterCnt = 0;
-      Array.Copy(stkAtErr, stk, stk.Length); // restore stack
-    } // else
-    leaveOrEnter = (leaveCnt + enterCnt) > 0;
-    sp = nwSP;
-    pc = newPC[Lex.token];
-    altRoot = pc;
-    errDist = 0;
-  } // HandleSynErr
-
-  public static int Interpret() {
-  //-----------------------------------|----------------------------------------
-    int actionNr, opcode, currPC;
-    for (;;) {
-      opcode = gt.code[pc - 1];
-      if ( !leaveOrEnter && mustRead && 
-           (Instruction)opcode <= Instruction.EPSA ) {
-        GetNextToken();
-        mustRead = false;
-        errDist++;
-        altRoot = pc;
-      } // if
-      if (leaveOrEnter) {
-        if (leaveCnt > 0) {
-          leaveCnt--;
-          actionNr = 0;
-        } else { // enterCnt > 0
-          enterCnt--;
-          actionNr = gt.code[stkAtErr[sp - enterCnt - 1] - 2];
-        } // else
-        leaveOrEnter = (leaveCnt + enterCnt) > 0;
-        return actionNr;
-      } // if
-      pc++;
-      switch ((Instruction)opcode) {
-        case Instruction.T:
-          if (Lex.token == gt.code[pc - 1])
-            if (Lex.token != EOFTOK) {
-              pc++;
-              mustRead = true;
-            } else {
-              return 0;
-            } // else
-          else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.TA:
-          if (Lex.token == gt.code[pc - 1]) {
-            pc += 3;
-            mustRead = true;
-          } else
-            pc = AdrAt(pc + 1); // try alternative
-          break;
-        case Instruction.TC:
-          if (Lex.token == gt.code[pc - 1]) {
-            pc += 2;
-            mustRead = true;
-            actionNr = gt.code[pc - 2];
-            return actionNr;
-          } else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.TCA:
-          if (Lex.token == gt.code[pc - 1]) {
-            pc += 4;
-            mustRead = true;
-            actionNr = gt.code[pc - 2];
-            return actionNr;
-          } else
-            pc = AdrAt(pc + 1); // try alternative
-          break;
-        case Instruction.NT:
-          currPC = gt.code[pc - 1];
-          if ( gt.nts[currPC].del || 
-               Sets.member((ushort)Lex.token, gt.nts[currPC].firstSet) ) {
-            pc++;
-            actionNr = gt.code[pc - 1];
-            Push(pc + 1);
-            pc = gt.nts[currPC].startPC;
-            altRoot = pc;
-            return actionNr;
-          } else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.NTA:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.nts[currPC].firstSet)) {
-            pc += 3;
-            actionNr = gt.code[pc - 1];
-            Push(pc + 1);
-            pc = gt.nts[currPC].startPC;
-            altRoot = pc;
-            return actionNr;
-          } else
-            pc = AdrAt(pc + 1);
-          break;
-        case Instruction.ANY:
-          mustRead = true;
-          break;
-        case Instruction.ANYA:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.anySets[currPC - 1])) {
-            pc += 3;
-            mustRead = true;
-          } else
-            pc = AdrAt(pc + 1);
-          break;
-        case Instruction.EPS:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.epsSets[currPC - 1]))
-            pc++;
-          else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.EPSA:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.epsSets[currPC - 1]))
-            pc += 3;
-          else
-            pc = AdrAt(pc + 1);
-          break;
-        case Instruction.JMP:
-          pc = AdrAt(pc);
-          break;
-        case Instruction.RET:
-          pc = Pop();
-          altRoot = pc;
-          return 0;
-        default:
-          if (opcode <= 128) {
-  #if !CONTSEMACTS
-          if (Errors.NumOfSynErrors() == 0)
-  #endif
-            return opcode - 12;
-          } else // opcode > 128
-            return opcode - 128;
-          break;
-      } // switch
-    } // for
-  } // Interpret
-
-
-  public static bool Parse() {
-  //-----------------------------------|----------------------------------------
-    Lex.InitLex();
-    sp           = 0;
-    pc           = ROOTPC;
-    altRoot      = pc;
-    mustRead     = true;
-    errDist      = MINERRDIST + 1;
-    leaveOrEnter = false;
-    leaveCnt     = 0;
-    enterCnt     = 0;
-    Sem.StartSem();
-    return Errors.NumOfSynErrors() == 0;
-  } // Parse
-
-
-  public static void StopParsing() {
-  //-----------------------------------|----------------------------------------
-    leaveCnt     = sp + 1;
-    enterCnt     = 0;
-    leaveOrEnter = true;
-  } // StopParsing
-
-} // GPDefSyn
- 
-// End of GPDefSyn.cs
-//=====================================|========================================
Index: /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/HeuristicLab.Problems.GPDL-3.4.csproj
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/HeuristicLab.Problems.GPDL-3.4.csproj	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/HeuristicLab.Problems.GPDL-3.4.csproj	(revision 9724)
@@ -194,15 +194,11 @@
     <Compile Include="InterpreterBuilder.cs" />
     <Compile Include="MethodBuilder.cs" />
+    <Compile Include="Parser.cs" />
     <Compile Include="ProblemGenerator.cs" />
+    <Compile Include="Scanner.cs" />
     <Compile Include="SourceReader.cs" />
     <Compile Include="SymbolBuilder.cs" />
     <None Include="GPDef.atg" />
     <None Include="HeuristicLab.snk" />
-    <Compile Include="Coco-2\Errors.cs" />
-    <Compile Include="Coco-2\Sets.cs" />
-    <Compile Include="Coco-2\Utils.cs" />
-    <Compile Include="GPDefLex.cs" />
-    <Compile Include="GPDefSem.cs" />
-    <Compile Include="GPDefSyn.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -227,8 +223,4 @@
     </BootstrapperPackage>
   </ItemGroup>
-  <ItemGroup>
-    <Content Include="GPDef.pgt.lst" />
-    <Content Include="GPDef.sg.lst" />
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
Index: /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Parser.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Parser.cs	(revision 9724)
+++ /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Parser.cs	(revision 9724)
@@ -0,0 +1,407 @@
+using System.Text;
+using System.Collections.Generic;
+using IEnumerableConstraintNode = System.Collections.Generic.IEnumerable<ConstraintNode>;
+
+
+
+using System;
+
+namespace HeuristicLab.Problems.GPDL {
+
+
+
+public class Parser {
+	public const int _EOF = 0;
+	public const int _ident = 1;
+	public const int maxT = 23;
+
+	const bool T = true;
+	const bool x = false;
+	const int minErrDist = 2;
+	
+	public Scanner scanner;
+	public Errors  errors;
+
+	public Token t;    // last recognized token
+	public Token la;   // lookahead token
+	int errDist = minErrDist;
+
+static StringBuilder srcText;
+  public static HeuristicLab.Optimization.IProblem problem;
+  static string lastSrc;
+  
+
+
+	public Parser(Scanner scanner) {
+		this.scanner = scanner;
+		errors = new Errors();
+	}
+
+	void SynErr (int n) {
+		if (errDist >= minErrDist) errors.SynErr(la.line, la.col, n);
+		errDist = 0;
+	}
+
+	public void SemErr (string msg) {
+		if (errDist >= minErrDist) errors.SemErr(t.line, t.col, msg);
+		errDist = 0;
+	}
+	
+	void Get () {
+		for (;;) {
+			t = la;
+			la = scanner.Scan();
+			if (la.kind <= maxT) { ++errDist; break; }
+
+			la = t;
+		}
+	}
+	
+	void Expect (int n) {
+		if (la.kind==n) Get(); else { SynErr(n); }
+	}
+	
+	bool StartOf (int s) {
+		return set[s, la.kind];
+	}
+	
+	void ExpectWeak (int n, int follow) {
+		if (la.kind == n) Get();
+		else {
+			SynErr(n);
+			while (!StartOf(follow)) Get();
+		}
+	}
+
+
+	bool WeakSeparator(int n, int syFol, int repFol) {
+		int kind = la.kind;
+		if (kind == n) {Get(); return true;}
+		else if (StartOf(repFol)) {return false;}
+		else {
+			SynErr(n);
+			while (!(set[syFol, kind] || set[repFol, kind] || set[0, kind])) {
+				Get();
+				kind = la.kind;
+			}
+			return StartOf(syFol);
+		}
+	}
+
+	
+	void SourceCode(out string src) {
+		src = ""; 
+		Expect(2);
+		int beg = la.pos; 
+		while (StartOf(1)) {
+			Get();
+		}
+		int end = la.pos; 
+		Expect(3);
+		if(end>beg) src = scanner.buffer.GetString(beg, end); 
+	}
+
+	void GPDef() {
+		string identStr = "";
+		RuleNode ruleNode = null;
+		GPDefNode gpDef = new GPDefNode();
+		NonTerminalNode ntNode = null;
+		FitnessFunctionNode fitnessFunNode = null;
+		TerminalNode tNode = null;
+		problem = null;
+		string src = "";
+		
+		Expect(4);
+		Expect(1);
+		gpDef.Name = t.val; 
+		if (la.kind == 5) {
+			Get();
+			SourceCode(out src);
+			gpDef.ClassCodeNode = new CodeNode{SrcCode = src}; 
+		}
+		if (la.kind == 6) {
+			Get();
+			SourceCode(out src);
+			gpDef.InitCodeNode = new CodeNode{SrcCode = src}; 
+		}
+		Expect(7);
+		while (la.kind == 1) {
+			NonterminalDecl(out ntNode);
+			gpDef.NonTerminals.Add(ntNode); 
+		}
+		Expect(8);
+		while (la.kind == 1) {
+			TerminalDecl(out tNode);
+			gpDef.Terminals.Add(tNode); 
+		}
+		Expect(9);
+		while (la.kind == 1) {
+			RuleDef(out ruleNode);
+			gpDef.Rules.Add(ruleNode); 
+		}
+		fitnessFunNode = new FitnessFunctionNode();
+		   gpDef.FitnessFunctionNode = fitnessFunNode;
+		
+		if (la.kind == 10) {
+			Get();
+			fitnessFunNode.Maximization = true; 
+		} else if (la.kind == 11) {
+			Get();
+			fitnessFunNode.Maximization = false; 
+		} else SynErr(24);
+		SourceCode(out src);
+		fitnessFunNode.SrcCode = src; 
+		Expect(12);
+		Expect(1);
+		var gen = new ProblemGenerator();
+		problem = gen.GenerateFromAst(gpDef);
+		
+		Expect(13);
+	}
+
+	void NonterminalDecl(out NonTerminalNode ntNode) {
+		string identStr = ""; ntNode = null; string src = ""; 
+		Expect(1);
+		identStr = t.val; 
+		SourceCode(out src);
+		var myNtNode = new NonTerminalNode();
+		ntNode = myNtNode;
+		myNtNode.Ident = identStr;
+		myNtNode.FormalParameters = src;
+		
+		Expect(13);
+	}
+
+	void TerminalDecl(out TerminalNode tNode) {
+		string identStr = "";
+		tNode = null;
+		TerminalNode myTNode = null;
+		IEnumerableConstraintNode constraints = null;
+		string src = "";
+		
+		Expect(1);
+		identStr = t.val; 
+		SourceCode(out src);
+		myTNode = new TerminalNode();
+		tNode = myTNode;
+		myTNode.Ident = identStr;
+		myTNode.FormalParameters = src;
+		myTNode.FieldDefinitions = SourceReader.ExtractFormalParameters(src);
+		
+		if (la.kind == 15) {
+			Get();
+			ConstraintDef(out constraints);
+			myTNode.Constraints = constraints; 
+		}
+		Expect(13);
+	}
+
+	void RuleDef(out RuleNode rule) {
+		RuleExprNode expr = null;
+		string identStr = null;
+		RuleNode myRule = null;
+		rule = null;
+		string src = "";
+		
+		Expect(1);
+		identStr = t.val; 
+		SourceCode(out src);
+		Expect(20);
+		myRule = new RuleNode();
+		rule = myRule;
+		myRule.NtSymbol = identStr;
+		
+		if (la.kind == 21) {
+			Get();
+			SourceCode(out src);
+			myRule.LocalCode = src;
+			
+		}
+		SynExpr(out expr);
+		Expect(13);
+		myRule.RuleExpr = expr;
+		
+	}
+
+	void SemAction(out RuleActionNode action) {
+		RuleActionNode myAction = null; action = null; string src = ""; 
+		Expect(14);
+		SourceCode(out src);
+		myAction = new RuleActionNode();
+		myAction.SrcCode = src;
+		action = myAction;
+		
+	}
+
+	void ConstraintDef(out IEnumerableConstraintNode constraints) {
+		List<ConstraintNode> constraintsList = new List<ConstraintNode>();
+		ConstraintNode n = null;
+		constraints = null;
+		
+		while (la.kind == 1) {
+			ConstraintRule(out n);
+			constraintsList.Add(n); 
+		}
+		constraints = constraintsList; 
+	}
+
+	void ConstraintRule(out ConstraintNode constraint) {
+		string identStr = null;
+		constraint = null;
+		
+		Expect(1);
+		constraint = new ConstraintNode(t.val); 
+		Expect(16);
+		SetDefinition(constraint);
+	}
+
+	void SetDefinition(ConstraintNode constraint) {
+		string src = ""; 
+		if (la.kind == 17) {
+			Get();
+			constraint.Type = ConstraintNodeType.Set; 
+			SourceCode(out src);
+			constraint.SetExpression = src; 
+		} else if (la.kind == 18) {
+			Get();
+			constraint.Type = ConstraintNodeType.Range; 
+			SourceCode(out src);
+			constraint.RangeMinExpression = src; 
+			Expect(19);
+			SourceCode(out src);
+			constraint.RangeMaxExpression = src; 
+		} else SynErr(25);
+	}
+
+	void SynExpr(out RuleExprNode expr ) {
+		expr = null;
+		AlternativesNode alt = null;
+		
+		SynTerm(out expr);
+		alt = new AlternativesNode();
+		alt.Add(expr);
+		
+		while (la.kind == 22) {
+			Get();
+			SynTerm(out expr);
+			alt.Add(expr); expr = alt; 
+		}
+	}
+
+	void SynTerm(out RuleExprNode expr) {
+		SequenceNode seq = null; expr = null; 
+		SynFact(out expr);
+		seq = new SequenceNode();
+		seq.Add(expr);
+		
+		while (la.kind == 1 || la.kind == 14) {
+			SynFact(out expr);
+			seq.Add(expr); expr = seq; 
+		}
+	}
+
+	void SynFact(out RuleExprNode expr) {
+		string identStr = "";
+		RuleActionNode action = null;
+		expr = null;
+		string src = "";
+		
+		if (la.kind == 1) {
+			Get();
+			identStr = t.val; 
+			SourceCode(out src);
+			var callNode = new CallSymbolNode{Ident = identStr};
+			callNode.ActualParameter = src;
+			expr = callNode;
+			
+		} else if (la.kind == 14) {
+			SemAction(out action);
+			expr = action; 
+		} else SynErr(26);
+	}
+
+
+
+	public void Parse() {
+		la = new Token();
+		la.val = "";		
+		Get();
+		GPDef();
+		Expect(0);
+
+	}
+	
+	static readonly bool[,] set = {
+		{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x},
+		{x,T,T,x, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x}
+
+	};
+} // end Parser
+
+
+public class Errors {
+	public int count = 0;                                    // number of errors detected
+	public System.IO.TextWriter errorStream = Console.Out;   // error messages go to this stream
+	public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
+
+	public virtual void SynErr (int line, int col, int n) {
+		string s;
+		switch (n) {
+			case 0: s = "EOF expected"; break;
+			case 1: s = "ident expected"; break;
+			case 2: s = "\"<<\" expected"; break;
+			case 3: s = "\">>\" expected"; break;
+			case 4: s = "\"PROBLEM\" expected"; break;
+			case 5: s = "\"CODE\" expected"; break;
+			case 6: s = "\"INIT\" expected"; break;
+			case 7: s = "\"NONTERMINALS\" expected"; break;
+			case 8: s = "\"TERMINALS\" expected"; break;
+			case 9: s = "\"RULES\" expected"; break;
+			case 10: s = "\"MAXIMIZE\" expected"; break;
+			case 11: s = "\"MINIMIZE\" expected"; break;
+			case 12: s = "\"END\" expected"; break;
+			case 13: s = "\".\" expected"; break;
+			case 14: s = "\"SEM\" expected"; break;
+			case 15: s = "\"CONSTRAINTS\" expected"; break;
+			case 16: s = "\"IN\" expected"; break;
+			case 17: s = "\"SET\" expected"; break;
+			case 18: s = "\"RANGE\" expected"; break;
+			case 19: s = "\"..\" expected"; break;
+			case 20: s = "\"=\" expected"; break;
+			case 21: s = "\"LOCAL\" expected"; break;
+			case 22: s = "\"|\" expected"; break;
+			case 23: s = "??? expected"; break;
+			case 24: s = "invalid GPDef"; break;
+			case 25: s = "invalid SetDefinition"; break;
+			case 26: s = "invalid SynFact"; break;
+
+			default: s = "error " + n; break;
+		}
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+		count++;
+	}
+
+	public virtual void SemErr (int line, int col, string s) {
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+		count++;
+	}
+	
+	public virtual void SemErr (string s) {
+		errorStream.WriteLine(s);
+		count++;
+	}
+	
+	public virtual void Warning (int line, int col, string s) {
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+	}
+	
+	public virtual void Warning(string s) {
+		errorStream.WriteLine(s);
+	}
+} // Errors
+
+
+public class FatalError: Exception {
+	public FatalError(string m): base(m) {}
+}
+}
Index: /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Scanner.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Scanner.cs	(revision 9724)
+++ /branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Scanner.cs	(revision 9724)
@@ -0,0 +1,434 @@
+
+using System;
+using System.IO;
+using System.Collections;
+
+namespace HeuristicLab.Problems.GPDL {
+
+public class Token {
+	public int kind;    // token kind
+	public int pos;     // token position in bytes in the source text (starting at 0)
+	public int charPos;  // token position in characters in the source text (starting at 0)
+	public int col;     // token column (starting at 1)
+	public int line;    // token line (starting at 1)
+	public string val;  // token value
+	public Token next;  // ML 2005-03-11 Tokens are kept in linked list
+}
+
+//-----------------------------------------------------------------------------------
+// Buffer
+//-----------------------------------------------------------------------------------
+public class Buffer {
+	// This Buffer supports the following cases:
+	// 1) seekable stream (file)
+	//    a) whole stream in buffer
+	//    b) part of stream in buffer
+	// 2) non seekable stream (network, console)
+
+	public const int EOF = char.MaxValue + 1;
+	const int MIN_BUFFER_LENGTH = 1024; // 1KB
+	const int MAX_BUFFER_LENGTH = MIN_BUFFER_LENGTH * 64; // 64KB
+	byte[] buf;         // input buffer
+	int bufStart;       // position of first byte in buffer relative to input stream
+	int bufLen;         // length of buffer
+	int fileLen;        // length of input stream (may change if the stream is no file)
+	int bufPos;         // current position in buffer
+	Stream stream;      // input stream (seekable)
+	bool isUserStream;  // was the stream opened by the user?
+	
+	public Buffer (Stream s, bool isUserStream) {
+		stream = s; this.isUserStream = isUserStream;
+		
+		if (stream.CanSeek) {
+			fileLen = (int) stream.Length;
+			bufLen = Math.Min(fileLen, MAX_BUFFER_LENGTH);
+			bufStart = Int32.MaxValue; // nothing in the buffer so far
+		} else {
+			fileLen = bufLen = bufStart = 0;
+		}
+
+		buf = new byte[(bufLen>0) ? bufLen : MIN_BUFFER_LENGTH];
+		if (fileLen > 0) Pos = 0; // setup buffer to position 0 (start)
+		else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
+		if (bufLen == fileLen && stream.CanSeek) Close();
+	}
+	
+	protected Buffer(Buffer b) { // called in UTF8Buffer constructor
+		buf = b.buf;
+		bufStart = b.bufStart;
+		bufLen = b.bufLen;
+		fileLen = b.fileLen;
+		bufPos = b.bufPos;
+		stream = b.stream;
+		// keep destructor from closing the stream
+		b.stream = null;
+		isUserStream = b.isUserStream;
+	}
+
+	~Buffer() { Close(); }
+	
+	protected void Close() {
+		if (!isUserStream && stream != null) {
+			stream.Close();
+			stream = null;
+		}
+	}
+	
+	public virtual int Read () {
+		if (bufPos < bufLen) {
+			return buf[bufPos++];
+		} else if (Pos < fileLen) {
+			Pos = Pos; // shift buffer start to Pos
+			return buf[bufPos++];
+		} else if (stream != null && !stream.CanSeek && ReadNextStreamChunk() > 0) {
+			return buf[bufPos++];
+		} else {
+			return EOF;
+		}
+	}
+
+	public int Peek () {
+		int curPos = Pos;
+		int ch = Read();
+		Pos = curPos;
+		return ch;
+	}
+	
+	// beg .. begin, zero-based, inclusive, in byte
+	// end .. end, zero-based, exclusive, in byte
+	public string GetString (int beg, int end) {
+		int len = 0;
+		char[] buf = new char[end - beg];
+		int oldPos = Pos;
+		Pos = beg;
+		while (Pos < end) buf[len++] = (char) Read();
+		Pos = oldPos;
+		return new String(buf, 0, len);
+	}
+
+	public int Pos {
+		get { return bufPos + bufStart; }
+		set {
+			if (value >= fileLen && stream != null && !stream.CanSeek) {
+				// Wanted position is after buffer and the stream
+				// is not seek-able e.g. network or console,
+				// thus we have to read the stream manually till
+				// the wanted position is in sight.
+				while (value >= fileLen && ReadNextStreamChunk() > 0);
+			}
+
+			if (value < 0 || value > fileLen) {
+				throw new FatalError("buffer out of bounds access, position: " + value);
+			}
+
+			if (value >= bufStart && value < bufStart + bufLen) { // already in buffer
+				bufPos = value - bufStart;
+			} else if (stream != null) { // must be swapped in
+				stream.Seek(value, SeekOrigin.Begin);
+				bufLen = stream.Read(buf, 0, buf.Length);
+				bufStart = value; bufPos = 0;
+			} else {
+				// set the position to the end of the file, Pos will return fileLen.
+				bufPos = fileLen - bufStart;
+			}
+		}
+	}
+	
+	// Read the next chunk of bytes from the stream, increases the buffer
+	// if needed and updates the fields fileLen and bufLen.
+	// Returns the number of bytes read.
+	private int ReadNextStreamChunk() {
+		int free = buf.Length - bufLen;
+		if (free == 0) {
+			// in the case of a growing input stream
+			// we can neither seek in the stream, nor can we
+			// foresee the maximum length, thus we must adapt
+			// the buffer size on demand.
+			byte[] newBuf = new byte[bufLen * 2];
+			Array.Copy(buf, newBuf, bufLen);
+			buf = newBuf;
+			free = bufLen;
+		}
+		int read = stream.Read(buf, bufLen, free);
+		if (read > 0) {
+			fileLen = bufLen = (bufLen + read);
+			return read;
+		}
+		// end of stream reached
+		return 0;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+// UTF8Buffer
+//-----------------------------------------------------------------------------------
+public class UTF8Buffer: Buffer {
+	public UTF8Buffer(Buffer b): base(b) {}
+
+	public override int Read() {
+		int ch;
+		do {
+			ch = base.Read();
+			// until we find a utf8 start (0xxxxxxx or 11xxxxxx)
+		} while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EOF));
+		if (ch < 128 || ch == EOF) {
+			// nothing to do, first 127 chars are the same in ascii and utf8
+			// 0xxxxxxx or end of file character
+		} else if ((ch & 0xF0) == 0xF0) {
+			// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+			int c1 = ch & 0x07; ch = base.Read();
+			int c2 = ch & 0x3F; ch = base.Read();
+			int c3 = ch & 0x3F; ch = base.Read();
+			int c4 = ch & 0x3F;
+			ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4;
+		} else if ((ch & 0xE0) == 0xE0) {
+			// 1110xxxx 10xxxxxx 10xxxxxx
+			int c1 = ch & 0x0F; ch = base.Read();
+			int c2 = ch & 0x3F; ch = base.Read();
+			int c3 = ch & 0x3F;
+			ch = (((c1 << 6) | c2) << 6) | c3;
+		} else if ((ch & 0xC0) == 0xC0) {
+			// 110xxxxx 10xxxxxx
+			int c1 = ch & 0x1F; ch = base.Read();
+			int c2 = ch & 0x3F;
+			ch = (c1 << 6) | c2;
+		}
+		return ch;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+// Scanner
+//-----------------------------------------------------------------------------------
+public class Scanner {
+	const char EOL = '\n';
+	const int eofSym = 0; /* pdt */
+	const int maxT = 23;
+	const int noSym = 23;
+
+
+	public Buffer buffer; // scanner buffer
+	
+	Token t;          // current token
+	int ch;           // current input character
+	int pos;          // byte position of current character
+	int charPos;      // position by unicode characters starting with 0
+	int col;          // column number of current character
+	int line;         // line number of current character
+	int oldEols;      // EOLs that appeared in a comment;
+	static readonly Hashtable start; // maps first token character to start state
+
+	Token tokens;     // list of tokens already peeked (first token is a dummy)
+	Token pt;         // current peek token
+	
+	char[] tval = new char[128]; // text of current token
+	int tlen;         // length of current token
+	
+	static Scanner() {
+		start = new Hashtable(128);
+		for (int i = 65; i <= 90; ++i) start[i] = 1;
+		for (int i = 97; i <= 122; ++i) start[i] = 1;
+		start[60] = 2; 
+		start[62] = 4; 
+		start[46] = 9; 
+		start[61] = 7; 
+		start[124] = 8; 
+		start[Buffer.EOF] = -1;
+
+	}
+	
+	public Scanner (string fileName) {
+		try {
+			Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
+			buffer = new Buffer(stream, false);
+			Init();
+		} catch (IOException) {
+			throw new FatalError("Cannot open file " + fileName);
+		}
+	}
+	
+	public Scanner (Stream s) {
+		buffer = new Buffer(s, true);
+		Init();
+	}
+	
+	void Init() {
+		pos = -1; line = 1; col = 0; charPos = -1;
+		oldEols = 0;
+		NextCh();
+		if (ch == 0xEF) { // check optional byte order mark for UTF-8
+			NextCh(); int ch1 = ch;
+			NextCh(); int ch2 = ch;
+			if (ch1 != 0xBB || ch2 != 0xBF) {
+				throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
+			}
+			buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
+			NextCh();
+		}
+		pt = tokens = new Token();  // first token is a dummy
+	}
+	
+	void NextCh() {
+		if (oldEols > 0) { ch = EOL; oldEols--; } 
+		else {
+			pos = buffer.Pos;
+			// buffer reads unicode chars, if UTF8 has been detected
+			ch = buffer.Read(); col++; charPos++;
+			// replace isolated '\r' by '\n' in order to make
+			// eol handling uniform across Windows, Unix and Mac
+			if (ch == '\r' && buffer.Peek() != '\n') ch = EOL;
+			if (ch == EOL) { line++; col = 0; }
+		}
+
+	}
+
+	void AddCh() {
+		if (tlen >= tval.Length) {
+			char[] newBuf = new char[2 * tval.Length];
+			Array.Copy(tval, 0, newBuf, 0, tval.Length);
+			tval = newBuf;
+		}
+		if (ch != Buffer.EOF) {
+			tval[tlen++] = (char) ch;
+			NextCh();
+		}
+	}
+
+
+
+	bool Comment0() {
+		int level = 1, pos0 = pos, line0 = line, col0 = col, charPos0 = charPos;
+		NextCh();
+		if (ch == '*') {
+			NextCh();
+			for(;;) {
+				if (ch == '*') {
+					NextCh();
+					if (ch == '/') {
+						level--;
+						if (level == 0) { oldEols = line - line0; NextCh(); return true; }
+						NextCh();
+					}
+				} else if (ch == '/') {
+					NextCh();
+					if (ch == '*') {
+						level++; NextCh();
+					}
+				} else if (ch == Buffer.EOF) return false;
+				else NextCh();
+			}
+		} else {
+			buffer.Pos = pos0; NextCh(); line = line0; col = col0; charPos = charPos0;
+		}
+		return false;
+	}
+
+
+	void CheckLiteral() {
+		switch (t.val) {
+			case "PROBLEM": t.kind = 4; break;
+			case "CODE": t.kind = 5; break;
+			case "INIT": t.kind = 6; break;
+			case "NONTERMINALS": t.kind = 7; break;
+			case "TERMINALS": t.kind = 8; break;
+			case "RULES": t.kind = 9; break;
+			case "MAXIMIZE": t.kind = 10; break;
+			case "MINIMIZE": t.kind = 11; break;
+			case "END": t.kind = 12; break;
+			case "SEM": t.kind = 14; break;
+			case "CONSTRAINTS": t.kind = 15; break;
+			case "IN": t.kind = 16; break;
+			case "SET": t.kind = 17; break;
+			case "RANGE": t.kind = 18; break;
+			case "LOCAL": t.kind = 21; break;
+			default: break;
+		}
+	}
+
+	Token NextToken() {
+		while (ch == ' ' ||
+			ch >= 9 && ch <= 10 || ch == 13
+		) NextCh();
+		if (ch == '/' && Comment0()) return NextToken();
+		int recKind = noSym;
+		int recEnd = pos;
+		t = new Token();
+		t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
+		int state;
+		if (start.ContainsKey(ch)) { state = (int) start[ch]; }
+		else { state = 0; }
+		tlen = 0; AddCh();
+		
+		switch (state) {
+			case -1: { t.kind = eofSym; break; } // NextCh already done
+			case 0: {
+				if (recKind != noSym) {
+					tlen = recEnd - t.pos;
+					SetScannerBehindT();
+				}
+				t.kind = recKind; break;
+			} // NextCh already done
+			case 1:
+				recEnd = pos; recKind = 1;
+				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
+				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
+			case 2:
+				if (ch == '<') {AddCh(); goto case 3;}
+				else {goto case 0;}
+			case 3:
+				{t.kind = 2; break;}
+			case 4:
+				if (ch == '>') {AddCh(); goto case 5;}
+				else {goto case 0;}
+			case 5:
+				{t.kind = 3; break;}
+			case 6:
+				{t.kind = 19; break;}
+			case 7:
+				{t.kind = 20; break;}
+			case 8:
+				{t.kind = 22; break;}
+			case 9:
+				recEnd = pos; recKind = 13;
+				if (ch == '.') {AddCh(); goto case 6;}
+				else {t.kind = 13; break;}
+
+		}
+		t.val = new String(tval, 0, tlen);
+		return t;
+	}
+	
+	private void SetScannerBehindT() {
+		buffer.Pos = t.pos;
+		NextCh();
+		line = t.line; col = t.col; charPos = t.charPos;
+		for (int i = 0; i < tlen; i++) NextCh();
+	}
+	
+	// get the next token (possibly a token already seen during peeking)
+	public Token Scan () {
+		if (tokens.next == null) {
+			return NextToken();
+		} else {
+			pt = tokens = tokens.next;
+			return tokens;
+		}
+	}
+
+	// peek for the next token, ignore pragmas
+	public Token Peek () {
+		do {
+			if (pt.next == null) {
+				pt.next = NextToken();
+			}
+			pt = pt.next;
+		} while (pt.kind > maxT); // skip pragmas
+	
+		return pt;
+	}
+
+	// make sure that peeking starts at the current scan position
+	public void ResetPeek () { pt = tokens; }
+
+} // end Scanner
+}
Index: /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDef.atg
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDef.atg	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDef.atg	(revision 9724)
@@ -1,101 +1,63 @@
+$namespace=SyntaxAnalyzer
+
 COMPILER GPDefSyntaxAnalyzer
 
-CHARACTER SETS
+CHARACTERS
   letter = 'A'..'Z' + 'a'..'z'.
   digit = '0'..'9'.
-  whiteSpace = CHR(9) + EOL IGNORE. /* ' ' ignored by default */ 
+
+TOKENS
+  ident = letter {letter | digit} .
 
 COMMENTS
-  FROM '/*' TO '*/' NESTED.
+  FROM "/*" TO "*/" NESTED
 
-KEYWORDS
-  'PROBLEM'. 'END'. 'EPS'.
-  'LOCAL'. 'NONTERMINALS'. 'RULES'.
-  'SEM'. 'MAXIMIZE'. 'MINIMIZE'. 'TERMINALS'. 'CONSTRAINTS'. 'INIT'. 'CODE'. 
-  'IN'. 'SET'. 'RANGE'. 
+IGNORE '\t' + '\r' + '\n'
 
-TOKENS
-  '='. '|'. '.'. '('. ')'. '['. ']'. '{'. '}'. '>>'. '..'.
-
-TOKEN CLASSES
-  ident = letter {letter | digit}.
-
-PRAGMAS
-  source       = '<<' SEM <<for (; ; ) {
-                              switch (GPDefSyntaxAnalyzerLex.curCh) {
-                                case Utils.EF:
-                                  Errors.SemError(GPDefSyntaxAnalyzerLex.curLine, GPDefSyntaxAnalyzerLex.curCol, "end of file in source text");
-                                  return;
-                                case '<':
-                                  GPDefSyntaxAnalyzerLex.NextCh();
-                                  if (GPDefSyntaxAnalyzerLex.curCh == '<') {
-                                    Errors.Warning(GPDefSyntaxAnalyzerLex.curLine, GPDefSyntaxAnalyzerLex.curCol, "non closed source text before?");
-                                    GPDefSyntaxAnalyzerLex.NextCh();
-                                  }
-                                  break;
-                                case '>':
-                                  GPDefSyntaxAnalyzerLex.NextCh();
-                                  if (GPDefSyntaxAnalyzerLex.curCh == '>') {
-                                    GPDefSyntaxAnalyzerLex.curCh = ' ';          // force GPDefSyntaxAnalyzerLex to get next character 
-                                    return;
-                                  }
-                                  break;
-                                default:
-                                  GPDefSyntaxAnalyzerLex.NextCh();
-                                  break;
-                              }
-                            }>>
-  .
-NONTERMINALS
-  GPDefSyntaxAnalyzer.   
-  SemDecl. SemAction. NonterminalDecl.
-  RuleDef. SynExpr. SynTerm. SynFact. TerminalDecl. 
-  ConstraintDef. ConstraintRule. SetDefinition.
-
-RULES
+PRODUCTIONS
   GPDefSyntaxAnalyzer = 
-    'PROBLEM' ident 
-  ['CODE' /* SourceText */]
-  ['INIT' /* SourceText */]
-    'NONTERMINALS' { NonterminalDecl }
-    'TERMINALS' { TerminalDecl }
-    'RULES' { RuleDef } 
-    ('MAXIMIZE' | 'MINIMIZE') /* SourceText */
-    'END' ident '.'.
+    "PROBLEM" ident 
+    ["CODE" "<<" {ANY} ">>" ]
+    ["INIT" "<<" {ANY} ">>" ]
+    "NONTERMINALS" { NonterminalDecl }
+    "TERMINALS" { TerminalDecl }
+    "RULES" { RuleDef } 
+    ("MAXIMIZE" | "MINIMIZE") "<<" {ANY} ">>" 
+    "END" ident '.'.
 
 
-  SemDecl = 'LOCAL' /* SourceText */
+  SemDecl = "LOCAL" "<<" {ANY} ">>" 
   .
 
-  SemAction = 'SEM' /* SourceText */
+  SemAction = "SEM" "<<" {ANY} ">>" 
   .
 
-  NonterminalDecl = ident /* FormalAttrList */ '.'
+  NonterminalDecl = ident "<<" {ANY} ">>"  '.'
   .
 
-  TerminalDecl = ident /* FormalAttrList */
-    [ 'CONSTRAINTS' ConstraintDef ]
+  TerminalDecl = ident "<<" {ANY} ">>" 
+    [ "CONSTRAINTS" ConstraintDef ]
     '.'
   .
 
   ConstraintDef = { ConstraintRule }.
-  ConstraintRule = ident 'IN' SetDefinition .
+  ConstraintRule = ident "IN" SetDefinition .
   SetDefinition = 
-    'SET' /* SourceText */
-    | 'RANGE' /* SourceText */ '..' /* SourceText */
+    "SET" "<<" {ANY} ">>" 
+    | "RANGE" "<<" {ANY} ">>" ".." "<<" {ANY} ">>" 
   .
 
-  RuleDef = ident /* FormalAttrList */ '=' [SemDecl] SynExpr '.'
+  RuleDef = ident "<<" {ANY} ">>"  '=' [SemDecl] SynExpr '.'
   .
 
-  SynExpr = SynTerm {'|' SynTerm}
+  SynExpr = SynTerm { '|' SynTerm }
   .
 
-  SynTerm = SynFact {SynFact}
+  SynTerm = SynFact { SynFact }
   .
 
   SynFact = 
-    ident /* ActualAttrList */
-    | 'EPS'
+    ident "<<" {ANY} ">>" 
+    | "EPS"
     | '(' SynExpr ')'
     | '[' SynExpr ']'
Index: anches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzer.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzer.cs	(revision 9723)
+++ 	(revision )
@@ -1,159 +1,0 @@
-// ATTENTION: Replace all occurences of GPDefSyntaxAnalyzer by the compiler name! 
-
-// GPDefSyntaxAnalyzer.cs                                                        HDO, 2006-08-28
-// -----
-// Main program for compiler generated from GPDefSyntaxAnalyzer.atg with Coco-2.
-//=====================================|========================================
-
-using System;
-using System.IO;
-
-using Lex = GPDefSyntaxAnalyzerLex;
-using Syn = GPDefSyntaxAnalyzerSyn;
-
-public class GPDefSyntaxAnalyzer {
-
-  private static String NAME = "GPDefSyntaxAnalyzer";
-  private static bool interactiveMode;
-
-  private static void Abort(String abortKind, String moduleName,
-                            String methName,  String descr) {
-    Console.WriteLine();
-    Console.WriteLine("*** {0} in class {1} method {2}", 
-                      abortKind, moduleName, methName);
-    Console.WriteLine("*** {0}", descr);
-    Console.WriteLine();
-    Console.WriteLine();
-    Console.WriteLine(NAME + " aborted");
-    Utils.Modules(Utils.ModuleAction.cleanupModule);
-    if (interactiveMode) {
-      Console.Write("type [CR] to quit");
-      string dummy = Console.ReadLine();
-    } // if
-    Environment.Exit(Utils.EXIT_FAILURE);
-  } // Abort
-
-  private static int CompileFile(String srcFileName) {
-    FileStream srcFs = null;
-    try {
-      srcFs = new FileStream(srcFileName, FileMode.Open);
-    } catch (Exception) {
-      Console.WriteLine("*** file \"{0}\" not found", srcFileName);
-      return Utils.EXIT_FAILURE;
-    } // try/catch
-    try {
-      Lex.src = new StreamReader(srcFs);
-      Console.WriteLine("parsing ...");
-      Syn.Parse();
-      Lex.src.Close();
-      Lex.src.Dispose();
-      Lex.src = null;
-      if (Errors.NumOfErrors() > 0) {
-        Console.WriteLine("listing ...");
-        String lstFileName = Path.ChangeExtension(srcFileName, ".lst");
-        FileStream lstFs = null;
-        try {
-          lstFs = new FileStream(lstFileName, FileMode.Create);
-        } catch (Exception) {
-          Utils.FatalError(NAME, "CompileFile", "file \"{0}\" not created", lstFileName);
-          return Utils.EXIT_FAILURE;
-        } // try/catch
-        StreamWriter lstWriter = null;
-        try {
-          lstWriter = new StreamWriter(lstFs);
-          StreamReader srcFsReader = null;
-          try { // open the source file a second time to generate the error listing
-            srcFsReader = new StreamReader(new FileStream(srcFileName, FileMode.Open));
-            lstWriter.WriteLine(NAME + " (file: \"{0}\")", srcFileName);
-            Errors.GenerateListing(srcFsReader, lstWriter, Errors.ListingShape.longListing);
-          } finally {
-            srcFsReader.Close();
-            srcFsReader.Dispose();
-          } // try/finally
-          Console.WriteLine("{0} error(s) detected", Errors.NumOfErrors());
-        } finally {
-          lstWriter.Close();
-          lstWriter.Dispose();
-        } // try/finally
-      } else 
-        Console.WriteLine("no errors detected");
-    } finally {
-      if (Lex.src != null) {
-        Lex.src.Close();
-        Lex.src.Dispose();
-        Lex.src = null;
-      } // if
-      Utils.Modules(Utils.ModuleAction.resetModule);
-    } // try/finally to make sure srcFs and srcReader are closed
-    return Utils.EXIT_SUCCESS;
-  } // CompileFile
-
-
-  public static void Main(String[] args) {
-  //-----------------------------------|----------------------------------------
-    int result = 0;
-
-    // --- install modules ---
-    Utils.InstallModule("Utils",   new Utils.ModuleMethodDelegate(Utils.UtilsMethod ));
-    Utils.InstallModule("Sets",    new Utils.ModuleMethodDelegate(Sets.SetsMethod  ));
-    Utils.InstallModule("Errors",  new Utils.ModuleMethodDelegate(Errors.ErrorsMethod));
-
-    Utils.InstallModule("GPDefSyntaxAnalyzerLex",  new Utils.ModuleMethodDelegate(GPDefSyntaxAnalyzerLex.GPDefSyntaxAnalyzerLexMethod));
-    Utils.InstallModule("GPDefSyntaxAnalyzerSem",  new Utils.ModuleMethodDelegate(GPDefSyntaxAnalyzerSem.GPDefSyntaxAnalyzerSemMethod));
-    Utils.InstallModule("GPDefSyntaxAnalyzerSyn",  new Utils.ModuleMethodDelegate(GPDefSyntaxAnalyzerSyn.GPDefSyntaxAnalyzerSynMethod));
-
-    // --- initialize modules ---
-    Utils.Modules(Utils.ModuleAction.initModule);
-
-    Errors.PushAbortMethod(new Errors.AbortMethod(Abort));
-
-    Console.WriteLine("---------------------------");
-    Console.WriteLine(" {0} Compiler {1," + (5 - NAME.Length) +"} Version X  ", NAME, "");
-    Console.WriteLine(" Frontend gen. with Coco-2");
-    Console.WriteLine("---------------------------");
-    Console.WriteLine();
-
-    if (args.Length > 0) { // command line mode
-      interactiveMode = false;
-      Console.WriteLine();
-      int i = 0;
-      do {
-        Console.WriteLine("source file \"{0}\"", args[i]);
-        result = CompileFile(args[i]);
-        if (result != Utils.EXIT_SUCCESS)
-          Environment.Exit(result);
-        Console.WriteLine();
-        i++;
-      } while (i < args.Length);
-    } else { // args.Length == 0, interactive mode
-      interactiveMode = true;
-      for (;;) {
-        String srcFileName;
-        Utils.GetInputFileName("source file > ", out srcFileName);
-        if (srcFileName.Length > 0) {
-          result = CompileFile(srcFileName);
-          if (result != Utils.EXIT_SUCCESS)
-            Environment.Exit(result);
-        } // if
-        char answerCh;
-        do {
-          Console.WriteLine();
-          Console.Write("[c]ontinue or [q]uit > ");
-          answerCh = Char.ToUpper(Console.ReadKey().KeyChar);
-        } while (answerCh != 'C' && answerCh != 'Q');
-        if (answerCh == 'Q')
-          break;
-        else // answerCh == 'C'
-          Console.WriteLine();
-      } // for
-    } // else
-
-    Utils.Modules(Utils.ModuleAction.cleanupModule);
-    Environment.Exit(Utils.EXIT_SUCCESS);
-
-  } // Main
-
-} // GPDefSyntaxAnalyzer
-
-// End of GPDefSyntaxAnalyzer.cs
-//=====================================|========================================
Index: anches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzerLex.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzerLex.cs	(revision 9723)
+++ 	(revision )
@@ -1,435 +1,0 @@
-// GPDefSyntaxAnalyzerLex.cs                                              HDO, 2006-08-28
-// -------------
-// Lexical analyzer (finite-state machine interpreter).
-// Generated by Coco-2 (SG).
-//=====================================|========================================
-
-#undef TEST_Lex
-
-using System;
-using System.Collections;
-using System.Collections.Specialized;
-using System.IO;
-using System.Text;
-
-public class GPDefSyntaxAnalyzerLex {
-
-  public const String MODULENAME = "GPDefSyntaxAnalyzerLex";
-  public const int    EOFSPIX    = 1;
-
-  public static TextReader src;
-
-  // --- token information ---
-  public static int    token;               // current token
-  public static int    tokenLine, tokenCol; // position of current token
-  public static String tokenStr;            // token string recognized
-
-  // --- current char. info, for "power users" only ---
-  public static char   curCh;               // current input character
-  public static int    curLine, curCol;     // position of curCh
-
-
-  public static void GPDefSyntaxAnalyzerLexMethod(Utils.ModuleAction action, out String moduleName) {
-  //-----------------------------------|----------------------------------------
-    moduleName = MODULENAME;
-    switch (action) {
-      case Utils.ModuleAction.getModuleName:
-        return;
-      case Utils.ModuleAction.initModule:
-        caseSensitive = true;
-        lt            = new LexicalTable();
-        tokenStrArr   = new char[256];
-        kwHt          = CreateHashtable();
-        nHt           = CreateHashtable();
-        nl            = new ArrayList();
-        break;
-      case Utils.ModuleAction.resetModule:
-        kwHt.Clear();
-        nHt.Clear();
-        nl.Clear();
-        break;
-      case Utils.ModuleAction.cleanupModule:
-        lt            = null;
-        tokenStrArr   = null;
-        kwHt          = null;
-        nHt           = null;
-        nl            = null;
-        break;
-    } // switch
-  } // GPDefSyntaxAnalyzerLexMethod
-
-  private static  Hashtable CreateHashtable() {
-    if (caseSensitive)
-      return new Hashtable();
-    else
-      return CollectionsUtil.CreateCaseInsensitiveHashtable();
-  } // CreateHashtable
-
-
-  public static void InitLex() {
-  //-----------------------------------|----------------------------------------
-    // --- initialize keyword hash table  ---
-    kwHt.Clear();
-    EnterKeyword(  1, "PROBLEM");
-    EnterKeyword(  2, "END");
-    EnterKeyword(  3, "EPS");
-    EnterKeyword(  4, "LOCAL");
-    EnterKeyword(  5, "NONTERMINALS");
-    EnterKeyword(  6, "RULES");
-    EnterKeyword(  7, "SEM");
-    EnterKeyword(  8, "MAXIMIZE");
-    EnterKeyword(  9, "MINIMIZE");
-    EnterKeyword( 10, "TERMINALS");
-    EnterKeyword( 11, "CONSTRAINTS");
-    EnterKeyword( 12, "INIT");
-    EnterKeyword( 13, "CODE");
-    EnterKeyword( 14, "IN");
-    EnterKeyword( 15, "SET");
-    EnterKeyword( 16, "RANGE");
-    // --- initialize name data structures  ---
-    nHt.Clear();
-    nl.Clear();
-    nl.Add("");      // so spix = 0 is the empty string
-    nl.Add("!EOF!"); // so EOFSPIX = 1
-    // --- (re)set global data ---
-    curLineStr  = "";
-    curCh       = ' ';
-    curLine     = 0;
-    curCol      = 2;
-    tokenStr    = null;
-    token       = 0;
-    tokenCol    = 0;
-    tokenLine   = 0;
-    tokenStrLen = 0;
-    pendingEOLs = 0;
-    apxLen      = pendingEOLs; // to prevent warning
-  } // InitLex
-
-  private static void EnterKeyword(int token, String keyword) {
-    kwHt.Add(keyword, token);
-  } // EnterKeyword
-
-
-  // *** start of global LEX declarations from ATG ***
-  
-  // *** end of global LEX declarations from ATG ***
-
-
-  public static bool caseSensitive;
-
-  private class LexicalTable {
-    public int   header = 4;
-    public int[] startTab = {
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  4,  5,  0,  0,  0,  0, 17,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 14,  2, 10,  0,
-          0, 16, 16, 16, 16, 16, 13, 16, 13, 16, 13, 13, 16, 16, 16, 16,
-         16, 13, 16, 16, 16, 16, 13, 13, 16, 13, 16,  6,  0,  7,  0,  0,
-          0, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-         13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,  8,  3,  9,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-          0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0
-      };
-    public Sets.Set256 ignoredChars = new Sets.Set256(
-         0x0600, 0x0000, 0x0001
-      );
-    public Sets.Set256 commentStart = new Sets.Set256(
-         0x0000, 0x0000, 0x8000
-      );
-    public Sets.Set256[] cls = {
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x0000, 0xfffe, 0x07ff, 0xfffe, 0x07ff),
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x03ff),
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x0000, 0xf2be, 0x053d),
-        new Sets.Set256( 0x0000, 0x0000, 0x0000, 0x0000, 0x0d40, 0x02c2, 0xfffe, 0x07ff)
-      };
-  } // LexicalTable
-
-  private static LexicalTable lt;
-  private static Hashtable    kwHt;  // hash table for keywords: string -> token 
-  private static Hashtable    nHt;   // hash table for names: string -> null 
-  private static ArrayList    nl;    // name list  for names, index is spix
-
-  private static String curLineStr;  // current source line
-  private static char[] tokenStrArr; // token string in an array
-  private static int    tokenStrLen; // length of token string in tokenStrArr
-  private static int    state;       // current automaton state
-  private static int    apxLen;      // length of appendix in token string
-  private static int    pendingEOLs; // nr of EOLs found in comment
-
-  // --- to save and restore scanner state ---
-  private static char   savedCh;
-  private static int    savedCol, savedLine;
-
-  private static void SaveScannerState() {
-    savedCh      = curCh;
-    savedCol     = curCol;
-    savedLine    = curLine;
-  } // SaveScannerState
-
-  private static void RestoreScannerState() {
-    tokenStrLen -= apxLen;
-    apxLen       = 0;
-    curCh        = savedCh;
-    curCol       = savedCol;
-    curLine      = savedLine;
-  } // RestoreScannerState
-
-
-  public static void NextCh() {
-  //-----------------------------------|----------------------------------------
-    for (;;) {
-      
-      if (curCol < curLineStr.Length) {         // within line
-        curCol++;
-        curCh = curLineStr[curCol - 1];
-        return;
-      } else if (curCol == curLineStr.Length) { // end of line
-        curCol++;
-        curCh = Utils.LF; // to separate lines
-        return;
-      } else { // curCol > curLineStr.Length
-        curLineStr = src.ReadLine();
-        curLine++;
-        curCol = 0;
-        if (curLineStr == null) {               // end of file
-          curLineStr = "";
-          curCh = Utils.EF;
-          return;
-        } // if
-      } // else
-    } // for
-  } // NextCh
-
-
-  private static void CommentErr() {
-    Errors.LexError(curLine, curCol, "end of file in comment");
-  } // CommentErr
-
-  private static bool Comment() {
-    
-    int level = 1;
-    
-    SaveScannerState();
-    // --- from '/' '*' to '*' '/' nested ---
-    NextCh();
-    if (curCh == '*') {
-      NextCh();
-      for (;;)
-        switch (curCh) {
-          case '*':
-            NextCh();
-            if (curCh == '/') {
-              NextCh();
-              level--;
-              if (level == 0) {
-                return true;
-              } // if
-            } // if
-            break;
-          case '/':
-            NextCh();
-            if (curCh == '*') {
-              level++;
-              NextCh();
-            }
-            break;
-          case Utils.EF:
-            CommentErr();
-            return true;
-          default:
-            NextCh();
-            break;
-        } // switch
-    } else
-      RestoreScannerState();
-    return false;
-  } // Comment
-
-  private static void HandleLexErr() {
-    Errors.LexError(curLine, curCol, 
-                    "invalid character '{0}' (hex {1:X})", curCh, (int)curCh);
-    if (apxLen > 0)
-      RestoreScannerState();
-  } // HandleLexErr
-
-
-  public static void GetToken() {
-  //-----------------------------------|----------------------------------------
-    token = -1;
-    tokenStr = null;
-    do {
-      // --- skip ignored chars and comments ---
-      for (;;) {
-        while (Sets.member(curCh, lt.ignoredChars))
-          NextCh();
-        if (!Sets.member(curCh, lt.commentStart))
-          break;
-        if (!Comment())
-          break;
-      } // for
-      // --- scan for next token ---
-      tokenLine   = curLine;
-      tokenCol    = curCol;
-      tokenStrLen = 0;
-      apxLen      = 0;
-      state = (curCh == Utils.EF) ? 1 : lt.startTab[curCh];
-      for (;;) {
-        tokenStrArr[tokenStrLen++]= curCh;
-        NextCh();
-        switch (state) {
-          case 0:
-            Errors.LexError(tokenLine, tokenCol, "invalid token start");
-            break;
-          case 1:
-            token = 0;
-            tokenStrLen = 0;
-            break;                      // EOF recognized
-          case 2:
-            token = 17;
-            break;                      // '=' recognized
-          case 3:
-            token = 18;
-            break;                      // '|' recognized
-          case 4:
-            token = 20;
-            break;                      // '(' recognized
-          case 5:
-            token = 21;
-            break;                      // ')' recognized
-          case 6:
-            token = 22;
-            break;                      // '[' recognized
-          case 7:
-            token = 23;
-            break;                      // ']' recognized
-          case 8:
-            token = 24;
-            break;                      // '{' recognized
-          case 9:
-            token = 25;
-            break;                      // '}' recognized
-          case 10:
-            if (curCh == '>') {
-              state = 11;
-              continue;
-            } // if
-            else {
-              HandleLexErr();
-              break;
-            } // else
-          case 11:
-            token = 26;
-            break;                      // '>>' recognized
-          case 12:
-            token = 27;
-            break;                      // '..' recognized
-          case 13:
-            if (Sets.member(curCh, lt.cls[0])) {
-              state = 13;
-              continue;
-            } // if
-            else if (Sets.member(curCh, lt.cls[1])) {
-              state = 13;
-              continue;
-            } // if
-            else {
-              token = KeywordCheck();
-              if (token >= 0)
-                break;                  // keyword recognized
-              token = 28;
-              break;                    // ident recognized
-            } // else
-          case 14:
-            if (curCh == '<') {
-              state = 15;
-              continue;
-            } // if
-            else {
-              HandleLexErr();
-              break;
-            } // else
-          case 15:
-            token = 29;
-            break;                      // source recognized
-          case 16:
-            if (Sets.member(curCh, lt.cls[1])) {
-              state = 13;
-              continue;
-            } // if
-            else if (Sets.member(curCh, lt.cls[2])) {
-              state = 16;
-              continue;
-            } // if
-            else if (Sets.member(curCh, lt.cls[3])) {
-              state = 13;
-              continue;
-            } // if
-            else {
-              token = KeywordCheck();
-              if (token >= 0)
-                break;                  // keyword recognized
-              token = 28;
-              break;                    // ident recognized
-            } // else
-          case 17:
-            if (curCh == '.') {
-              state = 12;
-              continue;
-            } // if
-            else {
-              token = 19;
-              break;                    // '.' recognized
-            } // else
-        } // switch
-        break;
-      } // for
-    } while (token < 0);
-    if (tokenStr == null)
-      tokenStr = new String(tokenStrArr, 0, tokenStrLen);
-  } // GetToken
-
-  private static int KeywordCheck() {
-    tokenStr = new String(tokenStrArr, 0, tokenStrLen - apxLen);
-    Object token = kwHt[tokenStr];
-    return (token == null) ? -1 : (int)token;
-  } // KeywordCheck
-
-
-  public static int Hash(String s) {
-  //-----------------------------------|----------------------------------------
-    Object spix = nHt[s];
-    if (spix == null) {
-      if (caseSensitive)
-        nl.Add(s);
-      else
-        nl.Add(s.ToUpper());
-      spix   = nl.Count - 1;
-      nHt[s] = spix;
-    } // if
-    return (int)spix;
-  } // Hash
-  
-  
-  public static String HashedStr(int spix) {
-  //-----------------------------------|----------------------------------------
-    return (String)nl[spix];
-  } // HashedStr
-
-
-  public static void GETidentAttr()  {
-  } // GETidentAttr
-  
-  public static void GETsourceAttr()  {
-  } // GETsourceAttr
-
-} // GPDefSyntaxAnalyzerLex
-
-// End of GPDefSyntaxAnalyzerLex.cs
-//=====================================|========================================
Index: anches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzerSem.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzerSem.cs	(revision 9723)
+++ 	(revision )
@@ -1,272 +1,0 @@
-// GPDefSyntaxAnalyzerSem.cs                                              HDO, 2006-08-28
-// -------------
-// Semantic evaluator for table-driven top-down parsing.
-// Generated by Coco-2 (PGT).
-//=====================================|========================================
-
-using System;
-using System.Text;
-using System.Collections;
-using System.Collections.Generic;
-
-using Lex = GPDefSyntaxAnalyzerLex;
-using Syn = GPDefSyntaxAnalyzerSyn;
-
-public class GPDefSyntaxAnalyzerSem {
-
-
-  public const String MODULENAME = "GPDefSyntaxAnalyzerSem";
-
-  public static void GPDefSyntaxAnalyzerSemMethod(Utils.ModuleAction action, out String moduleName) {
-  //-----------------------------------|----------------------------------------
-    moduleName = MODULENAME;
-    switch (action) {
-      case Utils.ModuleAction.getModuleName:
-        return;
-      case Utils.ModuleAction.initModule:
-        break;
-      case Utils.ModuleAction.resetModule:
-        break;
-      case Utils.ModuleAction.cleanupModule:
-        return;
-    } // switch
-  } // GPDefSyntaxAnalyzerSemMethod
-
-
-  // *** start of global SYN and SEM declarations from ATG ***
-  
-
-  // *** end of global SYN and SEM declarations from ATG ***
-
-  
-  private static void P_source() {
-    Lex.GETsourceAttr();
-    for (; ; ) {
-      switch (GPDefSyntaxAnalyzerLex.curCh) {
-        case Utils.EF:
-          Errors.SemError(GPDefSyntaxAnalyzerLex.curLine, GPDefSyntaxAnalyzerLex.curCol, "end of file in source text");
-          return;
-        case '<':
-          GPDefSyntaxAnalyzerLex.NextCh();
-          if (GPDefSyntaxAnalyzerLex.curCh == '<') {
-            Errors.Warning(GPDefSyntaxAnalyzerLex.curLine, GPDefSyntaxAnalyzerLex.curCol, "non closed source text before?");
-            GPDefSyntaxAnalyzerLex.NextCh();
-          }
-          break;
-        case '>':
-          GPDefSyntaxAnalyzerLex.NextCh();
-          if (GPDefSyntaxAnalyzerLex.curCh == '>') {
-            GPDefSyntaxAnalyzerLex.curCh = ' ';          // force GPDefSyntaxAnalyzerLex to get next character
-            return;
-          }
-          break;
-        default:
-          GPDefSyntaxAnalyzerLex.NextCh();
-          break;
-      }
-    }
-  } // P_source
-
-
-  private static void NT_GPDefSyntaxAnalyzer() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr();
-          break;
-        case 2:
-          NT_NonterminalDecl();
-          break;
-        case 3:
-          NT_TerminalDecl();
-          break;
-        case 4:
-          NT_RuleDef();
-          break;
-        case 5:
-          Lex.GETidentAttr();
-          break;
-      } // switch
-    } // for
-  } // NT_GPDefSyntaxAnalyzer
-
-  private static void NT_SemDecl() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-      } // switch
-    } // for
-  } // NT_SemDecl
-
-  private static void NT_SemAction() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-      } // switch
-    } // for
-  } // NT_SemAction
-
-  private static void NT_NonterminalDecl() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr();
-          break;
-      } // switch
-    } // for
-  } // NT_NonterminalDecl
-
-  private static void NT_TerminalDecl() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr();
-          break;
-        case 2:
-          NT_ConstraintDef();
-          break;
-      } // switch
-    } // for
-  } // NT_TerminalDecl
-
-  private static void NT_ConstraintDef() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_ConstraintRule();
-          break;
-      } // switch
-    } // for
-  } // NT_ConstraintDef
-
-  private static void NT_ConstraintRule() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr();
-          break;
-        case 2:
-          NT_SetDefinition();
-          break;
-      } // switch
-    } // for
-  } // NT_ConstraintRule
-
-  private static void NT_SetDefinition() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-      } // switch
-    } // for
-  } // NT_SetDefinition
-
-  private static void NT_RuleDef() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr();
-          break;
-        case 2:
-          NT_SemDecl();
-          break;
-        case 3:
-          NT_SynExpr();
-          break;
-      } // switch
-    } // for
-  } // NT_RuleDef
-
-  private static void NT_SynExpr() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_SynTerm();
-          break;
-        case 2:
-          NT_SynTerm();
-          break;
-      } // switch
-    } // for
-  } // NT_SynExpr
-
-  private static void NT_SynTerm() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_SynFact();
-          break;
-        case 2:
-          NT_SynFact();
-          break;
-      } // switch
-    } // for
-  } // NT_SynTerm
-
-  private static void NT_SynFact() {
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          Lex.GETidentAttr();
-          break;
-        case 2:
-          NT_SynExpr();
-          break;
-        case 3:
-          NT_SynExpr();
-          break;
-        case 4:
-          NT_SynExpr();
-          break;
-        case 5:
-          NT_SemAction();
-          break;
-      } // switch
-    } // for
-  } // NT_SynFact
-
-
-  public delegate void PragmaMethod();
-  public static PragmaMethod[] pragmaMethods = {
-      new PragmaMethod(P_source)
-    };
-
-
-  public static void StartSem() {
-  //-----------------------------------|----------------------------------------
-    for (;;) {
-      switch (Syn.Interpret()) {
-        case 0:
-          return;
-        case 1:
-          NT_GPDefSyntaxAnalyzer();
-          break;
-      } // switch
-    } // for
-  } // StartSem
-
-    
-} // GPDefSyntaxAnalyzerSem
-
-// End of GPDefSyntaxAnalyzerSem.cs
-//=====================================|========================================
Index: anches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzerSyn.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzerSyn.cs	(revision 9723)
+++ 	(revision )
@@ -1,557 +1,0 @@
-// GPDefSyntaxAnalyzerSyn.cs                                              HDO, 2006-08-28
-// -------------
-// Table-driven top-down syntax analyzer (G-code interpreter).
-// Generated by Coco-2 (PGT).
-//=====================================|========================================
-
-// --- call pragma mehts. and exec. sem. acts. after syntax errors? ---
-#define CONTPRAGMAACTS            // !!!must be defined for SG and PGT!!! 
-#undef  CONTSEMACTS               // should not be defined 
-
-using System;
-using System.Text;
-
-using Lex = GPDefSyntaxAnalyzerLex;
-using Sem = GPDefSyntaxAnalyzerSem;
-
-public class GPDefSyntaxAnalyzerSyn {
-                   
-  public static String MODULENAME = "GPDefSyntaxAnalyzerSyn";
-
-  // --- G-code instructions ---
-  public enum Instruction {
-    T, TA, TC, TCA, NT, NTA, ANY, ANYA, EPS, EPSA, JMP, RET
-  } // Instruction
-
-  private const int ROOTPC     =  207;
-  private const int LASTTERM   =   28;
-  private const int LASTPRAGMA =   29;
-
-
-  // --- other constants ---
-  private const int MINERRDIST   =   3;
-  private const int MAXSTACKLEN  = 100;
-  private const int EOFTOK       =   0;
-  private const int FIRSTNONTERM = LASTPRAGMA + 1;
-
-  public class NTData {
-    public int          startPC;
-    public bool         del;
-    public Sets.Set256  firstSet;
-    public NTData(int startPC, bool del, Sets.Set256 firstSet) {
-      this.startPC  = startPC;
-      this.del      = del;
-      this.firstSet = firstSet;
-    } // NTData
-  } // NTData
-  
-  private class GrammarTable {
-    public int[]  header = {
-      212, 28, 29, 41, 3, 0
-    };
-    public byte[] code = {
-         0,   1,   2,  28,   1,   1,  13,  10,   0,   1,  12,  14,   0,   0,
-         5,   5,   3,  24,   0,   2,  10,  16,   0,   0,  10,   5,   8,  34,
-         0,   3,  10,  26,   0,   0,   6,   5,   4,  44,   0,   4,  10,  36,
-         0,   1,   8,  56,   0,   0,   2,   2,  28,   5,   0,  19,  11,   0,
-         9,  10,  48,   0,   0,   4,  11,   0,   7,  11,   2,  28,   1,   0,
-        19,  11,   2,  28,   1,   0,  17,   5,   1,  83,   0,   2,   4,   5,
-         3,   0,  19,  11,   4,   6,   1,   1,  18, 102,   0,   4,   6,   2,
-        10,  92,   0,   8,   1,  11,   4,   7,   1,   5,   7, 116,   0,   2,
-        10, 108,   0,   8,   2,  11,   3,  28, 125,   0,   1,  11,   1,   3,
-       130,   0,  11,   1,  20, 140,   0,   4,   5,   2,   0,  21,  11,   1,
-        22, 150,   0,   4,   5,   3,   0,  23,  11,   1,  24, 160,   0,   4,
-         5,   4,   0,  25,  11,   4,   2,   5,  11,   2,  28,   1,   1,  11,
-       174,   0,   4,   9,   2,   0,  19,  11,   5,  10, 185,   0,   1,  10,
-       177,   0,   8,   3,  11,   2,  28,   1,   0,  14,   4,  11,   2,  11,
-         1,  15, 202,   0,  11,   0,  16,   0,  27,  11,   4,   0,   1,   0,
-         0,  11
-    };
-    public NTData[] nts = {
-      new NTData(   1, false, new Sets.Set256(0x0002)),
-      new NTData(  61, false, new Sets.Set256(0x0010)),
-      new NTData(  64, false, new Sets.Set256(0x0080)),
-      new NTData(  67, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData(  73, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData(  89, false, new Sets.Set256(0x0088, 0x1150)),
-      new NTData( 105, false, new Sets.Set256(0x0088, 0x1150)),
-      new NTData( 119, false, new Sets.Set256(0x0088, 0x1150)),
-      new NTData( 164, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData( 177, true , new Sets.Set256(0x0000, 0x1000)),
-      new NTData( 188, false, new Sets.Set256(0x0000, 0x1000)),
-      new NTData( 197, false, new Sets.Set256(0x8000, 0x0001))
-    };
-    public Sets.Set256[] epsSets = {
-      new Sets.Set256(0x0000, 0x02a8),
-      new Sets.Set256(0x0000, 0x02ac),
-      new Sets.Set256(0x0000, 0x0008)
-    };
-    public Sets.Set256[] anySets = {
-      new Sets.Set256(0x0000)
-    };
-    public String[] names = {
-      "end of file", "PROBLEM", "END", "EPS", "LOCAL", "NONTERMINALS",
-      "RULES", "SEM", "MAXIMIZE", "MINIMIZE", "TERMINALS", "CONSTRAINTS",
-      "INIT", "CODE", "IN", "SET", "RANGE", "=", "|", ".", "(", ")", "[",
-      "]", "{", "}", ">>", "..", "ident", "source", "GPDefSyntaxAnalyzer",
-      "SemDecl", "SemAction", "NonterminalDecl", "RuleDef", "SynExpr",
-      "SynTerm", "SynFact", "TerminalDecl", "ConstraintDef",
-      "ConstraintRule", "SetDefinition"
-    };
-  } // GrammarTable;
-
-  private static GrammarTable gt;
-
-  private static int   pc;             // G-code counter
-  private static int[] stk;            // stack of G-code return adresses
-  private static int   sp;             // stack pointer
-  private static bool  mustRead;       // next Lex.token to read
-  private static int   altRoot;        // root of alternative chain
-  private static bool  leaveOrEnter;   // leaveCnt > 0 OR enterCnt > 0
-  private static int   leaveCnt;       // nr. of sem. proc. to leave
-  private static int   enterCnt;       // nr. of sem. proc. to enter
-  private static int   errDist;        // current error distance
-  private static int[] stkAtErr;       // saved stack at error position
-  private static int[] newSP;          // new stack length
-  private static int[] newPC;          // pc after recovery
-
-
-  public static void GPDefSyntaxAnalyzerSynMethod(Utils.ModuleAction action, out String moduleName) {
-  //-----------------------------------|----------------------------------------
-    moduleName = MODULENAME;
-    switch (action) {
-      case Utils.ModuleAction.getModuleName:
-        return;
-      case Utils.ModuleAction.initModule:
-        Errors.InstallStopParsingMethod(StopParsing);
-        gt       = new GrammarTable();
-        stk      = new int[MAXSTACKLEN];
-        stkAtErr = new int[MAXSTACKLEN];
-        newSP    = new int[LASTTERM + 1];
-        newPC    = new int[LASTTERM + 1];
-        break;
-      case Utils.ModuleAction.resetModule:
-        break;
-      case Utils.ModuleAction.cleanupModule:
-        gt       = null;
-        stk      = null;
-        stkAtErr = null;
-        newSP    = null;
-        newPC    = null;
-        break;
-    } // switch
-  } // GPDefSyntaxAnalyzerSynMethod
-
-  private static void Push(int pc) {
-    if (sp < MAXSTACKLEN)
-      stk[sp++] = pc;
-    else
-      Errors.Restriction(MODULENAME, "Push", "parser stack overflow");
-  } // Push
-
-  private static int Pop() {
-    if (sp > 0)
-      return stk[--sp];
-    else {
-      Errors.CompilerError(MODULENAME, "Pop", "parser stack underflow");
-      return 0;
-    } // else
-  } // Pop
-
-  private static void GetNextToken() {
-    for (;;) {
-      Lex.GetToken(); // updates Lex.token
-      if (Lex.token <= LASTTERM)
-        return;
-  #if !CONTPRAGMAACTS
-      if (NumOfSynErrors() == 0)
-  #endif
-        Sem.pragmaMethods[Lex.token - LASTTERM - 1]();
-    } // for
-  } // GetNextToken
-
-  private static int AdrAt(int pc) {
-    return (gt.code[pc - 1] |
-           (gt.code[pc    ] << 8));
-  } // AdrAt
-
-  private static void AdjustPC(ref int pc) {
-    if (pc == 0)
-      return;
-    for (;;)
-      switch ((Instruction)gt.code[pc - 1]) {
-        case Instruction.T:
-        case Instruction.TA:
-        case Instruction.TC:
-        case Instruction.TCA:
-        case Instruction.NT:
-        case Instruction.NTA:
-        case Instruction.ANY:
-        case Instruction.ANYA:
-        case Instruction.EPS:
-        case Instruction.EPSA:
-          return;
-        case Instruction.JMP:
-          pc = AdrAt(pc + 1);
-          break;
-        case Instruction.RET:
-          pc = 0;
-          return;
-        default:
-          pc++; // syn. or sem. action
-          break;
-      } // switch
-  } // AdjustPC
-
-  private static void GetSymInstr(int pc, 
-                        out int opcode, out int sy, out int nextPC, out int altPC) {
-    opcode = gt.code[pc - 1];
-    nextPC = 0; // dummy init
-    altPC  = 0; // dummy init 
-    switch ((Instruction)opcode) {
-      case Instruction.T:
-      case Instruction.TA:
-      case Instruction.TC:
-      case Instruction.TCA:
-      case Instruction.ANYA:
-      case Instruction.EPS:
-      case Instruction.EPSA:
-        sy = gt.code[pc];
-        break;
-      case Instruction.NT:
-      case Instruction.NTA:
-        sy = gt.code[pc] + FIRSTNONTERM;
-        break;
-      default: // ANY, JMP, RET, SEM, SYN 
-        sy = 0;
-        break;
-    } // switch
-    switch ((Instruction)opcode) {
-      case Instruction.T:
-      case Instruction.EPS:
-        nextPC = pc + 2;
-        altPC = 0;
-        break;
-      case Instruction.TC:
-      case Instruction.NT:
-        nextPC = pc + 3;
-        altPC = 0;
-        break;
-      case Instruction.TA:
-      case Instruction.ANYA:
-      case Instruction.EPSA:
-        nextPC = pc + 4;
-        altPC = AdrAt(pc + 2);
-        break;
-      case Instruction.TCA:
-      case Instruction.NTA:
-        nextPC = pc + 5;
-        altPC = AdrAt(pc + 2);
-        break;
-      case Instruction.ANY:
-        nextPC = pc + 1;
-        altPC = 0;
-        break;
-    } // switch
-    AdjustPC(ref nextPC);
-    AdjustPC(ref altPC);
-  } // GetSymInstr
-
-  private static void Fill(int pc, int sp) {
-    int opcode, sy, nextPC, altPC, i;
-    AdjustPC(ref pc);
-    while (pc > 0) {
-      GetSymInstr(pc, out opcode, out sy, out nextPC, out altPC);
-      switch ((Instruction)opcode) {
-        case Instruction.T:
-        case Instruction.TA:
-        case Instruction.TC:
-        case Instruction.TCA:
-          newPC[sy] = pc;
-          newSP[sy] = sp;
-          break;
-        case Instruction.NT:
-        case Instruction.NTA:
-          for (i = 0; i <= LASTTERM; i++)
-            if (Sets.member((ushort)i, gt.nts[sy - FIRSTNONTERM].firstSet)) {
-              newPC[i] = pc;
-              newSP[i] = sp;
-            }
-          if (gt.nts[sy - FIRSTNONTERM].del)
-            Fill(nextPC, sp);
-          break;
-        case Instruction.EPS:
-        case Instruction.EPSA:
-          Fill(nextPC, sp);
-          break;
-      } // switch
-      pc = altPC;
-    } // while
-  } // Fill
-
-  private static void FillSucc(int pc, int sp) {
-    int opcode, sy, nextPC, altPC;
-    AdjustPC(ref pc);
-    while (pc > 0) {
-      GetSymInstr(pc, out opcode, out sy, out nextPC, out altPC);
-      if (nextPC > 0)
-        Fill(nextPC, sp);
-      pc = altPC;
-    } // while
-  } // FillSucc
-
-  private static void Triple(int altRoot) {
-    for (int i = 0; i <= LASTTERM; i++) { // clear triple list
-      newPC[i] = 0;
-      newSP[i] = 0;
-    } // for
-    for (int i = 1; i <= sp; i++) {       // successors of stacked nt's
-      FillSucc(stk[i - 1], i - 1);
-      Fill(stk[i - 1], i - 1);
-    } // for
-    FillSucc(altRoot, sp);                // successors of alt. chain
-    Fill(altRoot, sp);                    // current alt. chain
-  } // Triple
-
-  private static void HandleSynErr(ref int pc, ref int altRoot) {
-    int     opcode, sy, nextPC, altPC, adjPC, nwSP, eq;
-    bool    nameInMsg;
-    String  name;
-    StringBuilder msg = new StringBuilder();
-    leaveOrEnter = false;
-    if (errDist >= MINERRDIST) { // --- primary error
-      nameInMsg = false;
-      adjPC = altRoot;
-      AdjustPC(ref adjPC);
-      while (adjPC > 0) {
-        GetSymInstr(adjPC, out opcode, out sy, out nextPC, out altPC);
-        if ( (Instruction)opcode >= Instruction.T  && 
-             (Instruction)opcode <= Instruction.NTA  ) {
-          if ( gt.names[sy].IndexOf(' ') >= 0 || 
-               !Char.IsLetter(gt.names[sy][0]) )
-            name = "\"" + gt.names[sy] + "\"";
-          else
-            name = gt.names[sy];
-          if (name.IndexOf('{') > -1) // prevent formatting problems in Errors.SynError
-            name = name.Replace("{", "{{");
-          if (name.IndexOf('}') > -1) // prevent formatting problems in Errors.SynError
-            name = name.Replace("}", "}}");
-          if (msg.Length + name.Length + 2 > 80) {
-            msg.Append(" ...");
-            break;
-          } // if
-          if (!nameInMsg) {
-            nameInMsg = true;
-            msg.Append("expected: " + name);
-          } else {
-            msg.Append(", ");
-            msg.Append(name);
-          } // else
-        } // if
-        adjPC = altPC;
-      } // while
-      if (!nameInMsg)
-        msg.Append("syntax error");
-      Errors.SynError(Lex.tokenLine, Lex.tokenCol, msg.ToString(), "");
-      Triple(altRoot);
-      while (newPC[Lex.token] == 0) {
-        GetNextToken();      // may result in a call to StopParsing
-        if (leaveOrEnter)
-          return;
-      } // while
-      nwSP = newSP[Lex.token];
-      leaveCnt = sp - nwSP;
-      enterCnt = 0;
-      Array.Copy(stk, stkAtErr, stk.Length); // save stack
-    } else {                 // --- spurios error
-      if (errDist == 0) {    // no token used since last error
-        GetNextToken();      // may result in a call to StopParsing
-        if (leaveOrEnter)
-          return;
-      } // if
-      while (newPC[Lex.token] == 0) {
-        GetNextToken();      // may result in a call to StopParsing
-        if (leaveOrEnter) 
-          return;
-      } // while
-      nwSP = newSP[Lex.token];
-      eq = 2;                // compare stkAtErr and stk
-      while (eq <= sp && eq <= nwSP && stkAtErr[eq - 1] == stk[eq - 1])
-        eq++;
-      eq--;                  // stacks are equal up to index eq
-      leaveCnt = sp - eq;
-      if (nwSP < eq) {
-        leaveCnt = sp - nwSP;
-        enterCnt = 0;
-      } else if (nwSP > eq)
-        enterCnt = nwSP - eq;
-      else // nwSP == eq
-        enterCnt = 0;
-      Array.Copy(stkAtErr, stk, stk.Length); // restore stack
-    } // else
-    leaveOrEnter = (leaveCnt + enterCnt) > 0;
-    sp = nwSP;
-    pc = newPC[Lex.token];
-    altRoot = pc;
-    errDist = 0;
-  } // HandleSynErr
-
-  public static int Interpret() {
-  //-----------------------------------|----------------------------------------
-    int actionNr, opcode, currPC;
-    for (;;) {
-      opcode = gt.code[pc - 1];
-      if ( !leaveOrEnter && mustRead && 
-           (Instruction)opcode <= Instruction.EPSA ) {
-        GetNextToken();
-        mustRead = false;
-        errDist++;
-        altRoot = pc;
-      } // if
-      if (leaveOrEnter) {
-        if (leaveCnt > 0) {
-          leaveCnt--;
-          actionNr = 0;
-        } else { // enterCnt > 0
-          enterCnt--;
-          actionNr = gt.code[stkAtErr[sp - enterCnt - 1] - 2];
-        } // else
-        leaveOrEnter = (leaveCnt + enterCnt) > 0;
-        return actionNr;
-      } // if
-      pc++;
-      switch ((Instruction)opcode) {
-        case Instruction.T:
-          if (Lex.token == gt.code[pc - 1])
-            if (Lex.token != EOFTOK) {
-              pc++;
-              mustRead = true;
-            } else {
-              return 0;
-            } // else
-          else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.TA:
-          if (Lex.token == gt.code[pc - 1]) {
-            pc += 3;
-            mustRead = true;
-          } else
-            pc = AdrAt(pc + 1); // try alternative
-          break;
-        case Instruction.TC:
-          if (Lex.token == gt.code[pc - 1]) {
-            pc += 2;
-            mustRead = true;
-            actionNr = gt.code[pc - 2];
-            return actionNr;
-          } else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.TCA:
-          if (Lex.token == gt.code[pc - 1]) {
-            pc += 4;
-            mustRead = true;
-            actionNr = gt.code[pc - 2];
-            return actionNr;
-          } else
-            pc = AdrAt(pc + 1); // try alternative
-          break;
-        case Instruction.NT:
-          currPC = gt.code[pc - 1];
-          if ( gt.nts[currPC].del || 
-               Sets.member((ushort)Lex.token, gt.nts[currPC].firstSet) ) {
-            pc++;
-            actionNr = gt.code[pc - 1];
-            Push(pc + 1);
-            pc = gt.nts[currPC].startPC;
-            altRoot = pc;
-            return actionNr;
-          } else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.NTA:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.nts[currPC].firstSet)) {
-            pc += 3;
-            actionNr = gt.code[pc - 1];
-            Push(pc + 1);
-            pc = gt.nts[currPC].startPC;
-            altRoot = pc;
-            return actionNr;
-          } else
-            pc = AdrAt(pc + 1);
-          break;
-        case Instruction.ANY:
-          mustRead = true;
-          break;
-        case Instruction.ANYA:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.anySets[currPC - 1])) {
-            pc += 3;
-            mustRead = true;
-          } else
-            pc = AdrAt(pc + 1);
-          break;
-        case Instruction.EPS:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.epsSets[currPC - 1]))
-            pc++;
-          else
-            HandleSynErr(ref pc, ref altRoot);
-          break;
-        case Instruction.EPSA:
-          currPC = gt.code[pc - 1];
-          if (Sets.member((ushort)Lex.token, gt.epsSets[currPC - 1]))
-            pc += 3;
-          else
-            pc = AdrAt(pc + 1);
-          break;
-        case Instruction.JMP:
-          pc = AdrAt(pc);
-          break;
-        case Instruction.RET:
-          pc = Pop();
-          altRoot = pc;
-          return 0;
-        default:
-          if (opcode <= 128) {
-  #if !CONTSEMACTS
-          if (Errors.NumOfSynErrors() == 0)
-  #endif
-            return opcode - 12;
-          } else // opcode > 128
-            return opcode - 128;
-          break;
-      } // switch
-    } // for
-  } // Interpret
-
-
-  public static bool Parse() {
-  //-----------------------------------|----------------------------------------
-    Lex.InitLex();
-    sp           = 0;
-    pc           = ROOTPC;
-    altRoot      = pc;
-    mustRead     = true;
-    errDist      = MINERRDIST + 1;
-    leaveOrEnter = false;
-    leaveCnt     = 0;
-    enterCnt     = 0;
-    Sem.StartSem();
-    return Errors.NumOfSynErrors() == 0;
-  } // Parse
-
-
-  public static void StopParsing() {
-  //-----------------------------------|----------------------------------------
-    leaveCnt     = sp + 1;
-    enterCnt     = 0;
-    leaveOrEnter = true;
-  } // StopParsing
-
-} // GPDefSyntaxAnalyzerSyn
- 
-// End of GPDefSyntaxAnalyzerSyn.cs
-//=====================================|========================================
Index: /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/Parser.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/Parser.cs	(revision 9724)
+++ /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/Parser.cs	(revision 9724)
@@ -0,0 +1,370 @@
+
+using System;
+
+namespace SyntaxAnalyzer {
+
+
+
+public class Parser {
+	public const int _EOF = 0;
+	public const int _ident = 1;
+	public const int maxT = 30;
+
+	const bool T = true;
+	const bool x = false;
+	const int minErrDist = 2;
+	
+	public Scanner scanner;
+	public Errors  errors;
+
+	public Token t;    // last recognized token
+	public Token la;   // lookahead token
+	int errDist = minErrDist;
+
+
+
+	public Parser(Scanner scanner) {
+		this.scanner = scanner;
+		errors = new Errors();
+	}
+
+	void SynErr (int n) {
+		if (errDist >= minErrDist) errors.SynErr(la.line, la.col, n);
+		errDist = 0;
+	}
+
+	public void SemErr (string msg) {
+		if (errDist >= minErrDist) errors.SemErr(t.line, t.col, msg);
+		errDist = 0;
+	}
+	
+	void Get () {
+		for (;;) {
+			t = la;
+			la = scanner.Scan();
+			if (la.kind <= maxT) { ++errDist; break; }
+
+			la = t;
+		}
+	}
+	
+	void Expect (int n) {
+		if (la.kind==n) Get(); else { SynErr(n); }
+	}
+	
+	bool StartOf (int s) {
+		return set[s, la.kind];
+	}
+	
+	void ExpectWeak (int n, int follow) {
+		if (la.kind == n) Get();
+		else {
+			SynErr(n);
+			while (!StartOf(follow)) Get();
+		}
+	}
+
+
+	bool WeakSeparator(int n, int syFol, int repFol) {
+		int kind = la.kind;
+		if (kind == n) {Get(); return true;}
+		else if (StartOf(repFol)) {return false;}
+		else {
+			SynErr(n);
+			while (!(set[syFol, kind] || set[repFol, kind] || set[0, kind])) {
+				Get();
+				kind = la.kind;
+			}
+			return StartOf(syFol);
+		}
+	}
+
+	
+	void GPDefSyntaxAnalyzer() {
+		Expect(2);
+		Expect(1);
+		if (la.kind == 3) {
+			Get();
+			Expect(4);
+			while (StartOf(1)) {
+				Get();
+			}
+			Expect(5);
+		}
+		if (la.kind == 6) {
+			Get();
+			Expect(4);
+			while (StartOf(1)) {
+				Get();
+			}
+			Expect(5);
+		}
+		Expect(7);
+		while (la.kind == 1) {
+			NonterminalDecl();
+		}
+		Expect(8);
+		while (la.kind == 1) {
+			TerminalDecl();
+		}
+		Expect(9);
+		while (la.kind == 1) {
+			RuleDef();
+		}
+		if (la.kind == 10) {
+			Get();
+		} else if (la.kind == 11) {
+			Get();
+		} else SynErr(31);
+		Expect(4);
+		while (StartOf(1)) {
+			Get();
+		}
+		Expect(5);
+		Expect(12);
+		Expect(1);
+		Expect(13);
+	}
+
+	void NonterminalDecl() {
+		Expect(1);
+		Expect(4);
+		while (StartOf(1)) {
+			Get();
+		}
+		Expect(5);
+		Expect(13);
+	}
+
+	void TerminalDecl() {
+		Expect(1);
+		Expect(4);
+		while (StartOf(1)) {
+			Get();
+		}
+		Expect(5);
+		if (la.kind == 16) {
+			Get();
+			ConstraintDef();
+		}
+		Expect(13);
+	}
+
+	void RuleDef() {
+		Expect(1);
+		Expect(4);
+		while (StartOf(1)) {
+			Get();
+		}
+		Expect(5);
+		Expect(21);
+		if (la.kind == 14) {
+			SemDecl();
+		}
+		SynExpr();
+		Expect(13);
+	}
+
+	void SemDecl() {
+		Expect(14);
+		Expect(4);
+		while (StartOf(1)) {
+			Get();
+		}
+		Expect(5);
+	}
+
+	void SemAction() {
+		Expect(15);
+		Expect(4);
+		while (StartOf(1)) {
+			Get();
+		}
+		Expect(5);
+	}
+
+	void ConstraintDef() {
+		while (la.kind == 1) {
+			ConstraintRule();
+		}
+	}
+
+	void ConstraintRule() {
+		Expect(1);
+		Expect(17);
+		SetDefinition();
+	}
+
+	void SetDefinition() {
+		if (la.kind == 18) {
+			Get();
+			Expect(4);
+			while (StartOf(1)) {
+				Get();
+			}
+			Expect(5);
+		} else if (la.kind == 19) {
+			Get();
+			Expect(4);
+			while (StartOf(1)) {
+				Get();
+			}
+			Expect(5);
+			Expect(20);
+			Expect(4);
+			while (StartOf(1)) {
+				Get();
+			}
+			Expect(5);
+		} else SynErr(32);
+	}
+
+	void SynExpr() {
+		SynTerm();
+		while (la.kind == 22) {
+			Get();
+			SynTerm();
+		}
+	}
+
+	void SynTerm() {
+		SynFact();
+		while (StartOf(2)) {
+			SynFact();
+		}
+	}
+
+	void SynFact() {
+		switch (la.kind) {
+		case 1: {
+			Get();
+			Expect(4);
+			while (StartOf(1)) {
+				Get();
+			}
+			Expect(5);
+			break;
+		}
+		case 23: {
+			Get();
+			break;
+		}
+		case 24: {
+			Get();
+			SynExpr();
+			Expect(25);
+			break;
+		}
+		case 26: {
+			Get();
+			SynExpr();
+			Expect(27);
+			break;
+		}
+		case 28: {
+			Get();
+			SynExpr();
+			Expect(29);
+			break;
+		}
+		case 15: {
+			SemAction();
+			break;
+		}
+		default: SynErr(33); break;
+		}
+	}
+
+
+
+	public void Parse() {
+		la = new Token();
+		la.val = "";		
+		Get();
+		GPDefSyntaxAnalyzer();
+		Expect(0);
+
+	}
+	
+	static readonly bool[,] set = {
+		{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x},
+		{x,T,T,T, T,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x},
+		{x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,T, T,x,T,x, T,x,x,x}
+
+	};
+} // end Parser
+
+
+public class Errors {
+	public int count = 0;                                    // number of errors detected
+	public System.IO.TextWriter errorStream = Console.Out;   // error messages go to this stream
+	public string errMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text
+
+	public virtual void SynErr (int line, int col, int n) {
+		string s;
+		switch (n) {
+			case 0: s = "EOF expected"; break;
+			case 1: s = "ident expected"; break;
+			case 2: s = "\"PROBLEM\" expected"; break;
+			case 3: s = "\"CODE\" expected"; break;
+			case 4: s = "\"<<\" expected"; break;
+			case 5: s = "\">>\" expected"; break;
+			case 6: s = "\"INIT\" expected"; break;
+			case 7: s = "\"NONTERMINALS\" expected"; break;
+			case 8: s = "\"TERMINALS\" expected"; break;
+			case 9: s = "\"RULES\" expected"; break;
+			case 10: s = "\"MAXIMIZE\" expected"; break;
+			case 11: s = "\"MINIMIZE\" expected"; break;
+			case 12: s = "\"END\" expected"; break;
+			case 13: s = "\".\" expected"; break;
+			case 14: s = "\"LOCAL\" expected"; break;
+			case 15: s = "\"SEM\" expected"; break;
+			case 16: s = "\"CONSTRAINTS\" expected"; break;
+			case 17: s = "\"IN\" expected"; break;
+			case 18: s = "\"SET\" expected"; break;
+			case 19: s = "\"RANGE\" expected"; break;
+			case 20: s = "\"..\" expected"; break;
+			case 21: s = "\"=\" expected"; break;
+			case 22: s = "\"|\" expected"; break;
+			case 23: s = "\"EPS\" expected"; break;
+			case 24: s = "\"(\" expected"; break;
+			case 25: s = "\")\" expected"; break;
+			case 26: s = "\"[\" expected"; break;
+			case 27: s = "\"]\" expected"; break;
+			case 28: s = "\"{\" expected"; break;
+			case 29: s = "\"}\" expected"; break;
+			case 30: s = "??? expected"; break;
+			case 31: s = "invalid GPDefSyntaxAnalyzer"; break;
+			case 32: s = "invalid SetDefinition"; break;
+			case 33: s = "invalid SynFact"; break;
+
+			default: s = "error " + n; break;
+		}
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+		count++;
+	}
+
+	public virtual void SemErr (int line, int col, string s) {
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+		count++;
+	}
+	
+	public virtual void SemErr (string s) {
+		errorStream.WriteLine(s);
+		count++;
+	}
+	
+	public virtual void Warning (int line, int col, string s) {
+		errorStream.WriteLine(errMsgFormat, line, col, s);
+	}
+	
+	public virtual void Warning(string s) {
+		errorStream.WriteLine(s);
+	}
+} // Errors
+
+
+public class FatalError: Exception {
+	public FatalError(string m): base(m) {}
+}
+}
Index: /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/Scanner.cs
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/Scanner.cs	(revision 9724)
+++ /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/Scanner.cs	(revision 9724)
@@ -0,0 +1,453 @@
+
+using System;
+using System.IO;
+using System.Collections;
+
+namespace SyntaxAnalyzer {
+
+public class Token {
+	public int kind;    // token kind
+	public int pos;     // token position in bytes in the source text (starting at 0)
+	public int charPos;  // token position in characters in the source text (starting at 0)
+	public int col;     // token column (starting at 1)
+	public int line;    // token line (starting at 1)
+	public string val;  // token value
+	public Token next;  // ML 2005-03-11 Tokens are kept in linked list
+}
+
+//-----------------------------------------------------------------------------------
+// Buffer
+//-----------------------------------------------------------------------------------
+public class Buffer {
+	// This Buffer supports the following cases:
+	// 1) seekable stream (file)
+	//    a) whole stream in buffer
+	//    b) part of stream in buffer
+	// 2) non seekable stream (network, console)
+
+	public const int EOF = char.MaxValue + 1;
+	const int MIN_BUFFER_LENGTH = 1024; // 1KB
+	const int MAX_BUFFER_LENGTH = MIN_BUFFER_LENGTH * 64; // 64KB
+	byte[] buf;         // input buffer
+	int bufStart;       // position of first byte in buffer relative to input stream
+	int bufLen;         // length of buffer
+	int fileLen;        // length of input stream (may change if the stream is no file)
+	int bufPos;         // current position in buffer
+	Stream stream;      // input stream (seekable)
+	bool isUserStream;  // was the stream opened by the user?
+	
+	public Buffer (Stream s, bool isUserStream) {
+		stream = s; this.isUserStream = isUserStream;
+		
+		if (stream.CanSeek) {
+			fileLen = (int) stream.Length;
+			bufLen = Math.Min(fileLen, MAX_BUFFER_LENGTH);
+			bufStart = Int32.MaxValue; // nothing in the buffer so far
+		} else {
+			fileLen = bufLen = bufStart = 0;
+		}
+
+		buf = new byte[(bufLen>0) ? bufLen : MIN_BUFFER_LENGTH];
+		if (fileLen > 0) Pos = 0; // setup buffer to position 0 (start)
+		else bufPos = 0; // index 0 is already after the file, thus Pos = 0 is invalid
+		if (bufLen == fileLen && stream.CanSeek) Close();
+	}
+	
+	protected Buffer(Buffer b) { // called in UTF8Buffer constructor
+		buf = b.buf;
+		bufStart = b.bufStart;
+		bufLen = b.bufLen;
+		fileLen = b.fileLen;
+		bufPos = b.bufPos;
+		stream = b.stream;
+		// keep destructor from closing the stream
+		b.stream = null;
+		isUserStream = b.isUserStream;
+	}
+
+	~Buffer() { Close(); }
+	
+	protected void Close() {
+		if (!isUserStream && stream != null) {
+			stream.Close();
+			stream = null;
+		}
+	}
+	
+	public virtual int Read () {
+		if (bufPos < bufLen) {
+			return buf[bufPos++];
+		} else if (Pos < fileLen) {
+			Pos = Pos; // shift buffer start to Pos
+			return buf[bufPos++];
+		} else if (stream != null && !stream.CanSeek && ReadNextStreamChunk() > 0) {
+			return buf[bufPos++];
+		} else {
+			return EOF;
+		}
+	}
+
+	public int Peek () {
+		int curPos = Pos;
+		int ch = Read();
+		Pos = curPos;
+		return ch;
+	}
+	
+	// beg .. begin, zero-based, inclusive, in byte
+	// end .. end, zero-based, exclusive, in byte
+	public string GetString (int beg, int end) {
+		int len = 0;
+		char[] buf = new char[end - beg];
+		int oldPos = Pos;
+		Pos = beg;
+		while (Pos < end) buf[len++] = (char) Read();
+		Pos = oldPos;
+		return new String(buf, 0, len);
+	}
+
+	public int Pos {
+		get { return bufPos + bufStart; }
+		set {
+			if (value >= fileLen && stream != null && !stream.CanSeek) {
+				// Wanted position is after buffer and the stream
+				// is not seek-able e.g. network or console,
+				// thus we have to read the stream manually till
+				// the wanted position is in sight.
+				while (value >= fileLen && ReadNextStreamChunk() > 0);
+			}
+
+			if (value < 0 || value > fileLen) {
+				throw new FatalError("buffer out of bounds access, position: " + value);
+			}
+
+			if (value >= bufStart && value < bufStart + bufLen) { // already in buffer
+				bufPos = value - bufStart;
+			} else if (stream != null) { // must be swapped in
+				stream.Seek(value, SeekOrigin.Begin);
+				bufLen = stream.Read(buf, 0, buf.Length);
+				bufStart = value; bufPos = 0;
+			} else {
+				// set the position to the end of the file, Pos will return fileLen.
+				bufPos = fileLen - bufStart;
+			}
+		}
+	}
+	
+	// Read the next chunk of bytes from the stream, increases the buffer
+	// if needed and updates the fields fileLen and bufLen.
+	// Returns the number of bytes read.
+	private int ReadNextStreamChunk() {
+		int free = buf.Length - bufLen;
+		if (free == 0) {
+			// in the case of a growing input stream
+			// we can neither seek in the stream, nor can we
+			// foresee the maximum length, thus we must adapt
+			// the buffer size on demand.
+			byte[] newBuf = new byte[bufLen * 2];
+			Array.Copy(buf, newBuf, bufLen);
+			buf = newBuf;
+			free = bufLen;
+		}
+		int read = stream.Read(buf, bufLen, free);
+		if (read > 0) {
+			fileLen = bufLen = (bufLen + read);
+			return read;
+		}
+		// end of stream reached
+		return 0;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+// UTF8Buffer
+//-----------------------------------------------------------------------------------
+public class UTF8Buffer: Buffer {
+	public UTF8Buffer(Buffer b): base(b) {}
+
+	public override int Read() {
+		int ch;
+		do {
+			ch = base.Read();
+			// until we find a utf8 start (0xxxxxxx or 11xxxxxx)
+		} while ((ch >= 128) && ((ch & 0xC0) != 0xC0) && (ch != EOF));
+		if (ch < 128 || ch == EOF) {
+			// nothing to do, first 127 chars are the same in ascii and utf8
+			// 0xxxxxxx or end of file character
+		} else if ((ch & 0xF0) == 0xF0) {
+			// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+			int c1 = ch & 0x07; ch = base.Read();
+			int c2 = ch & 0x3F; ch = base.Read();
+			int c3 = ch & 0x3F; ch = base.Read();
+			int c4 = ch & 0x3F;
+			ch = (((((c1 << 6) | c2) << 6) | c3) << 6) | c4;
+		} else if ((ch & 0xE0) == 0xE0) {
+			// 1110xxxx 10xxxxxx 10xxxxxx
+			int c1 = ch & 0x0F; ch = base.Read();
+			int c2 = ch & 0x3F; ch = base.Read();
+			int c3 = ch & 0x3F;
+			ch = (((c1 << 6) | c2) << 6) | c3;
+		} else if ((ch & 0xC0) == 0xC0) {
+			// 110xxxxx 10xxxxxx
+			int c1 = ch & 0x1F; ch = base.Read();
+			int c2 = ch & 0x3F;
+			ch = (c1 << 6) | c2;
+		}
+		return ch;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+// Scanner
+//-----------------------------------------------------------------------------------
+public class Scanner {
+	const char EOL = '\n';
+	const int eofSym = 0; /* pdt */
+	const int maxT = 30;
+	const int noSym = 30;
+
+
+	public Buffer buffer; // scanner buffer
+	
+	Token t;          // current token
+	int ch;           // current input character
+	int pos;          // byte position of current character
+	int charPos;      // position by unicode characters starting with 0
+	int col;          // column number of current character
+	int line;         // line number of current character
+	int oldEols;      // EOLs that appeared in a comment;
+	static readonly Hashtable start; // maps first token character to start state
+
+	Token tokens;     // list of tokens already peeked (first token is a dummy)
+	Token pt;         // current peek token
+	
+	char[] tval = new char[128]; // text of current token
+	int tlen;         // length of current token
+	
+	static Scanner() {
+		start = new Hashtable(128);
+		for (int i = 65; i <= 90; ++i) start[i] = 1;
+		for (int i = 97; i <= 122; ++i) start[i] = 1;
+		start[60] = 2; 
+		start[62] = 4; 
+		start[46] = 15; 
+		start[61] = 7; 
+		start[124] = 8; 
+		start[40] = 9; 
+		start[41] = 10; 
+		start[91] = 11; 
+		start[93] = 12; 
+		start[123] = 13; 
+		start[125] = 14; 
+		start[Buffer.EOF] = -1;
+
+	}
+	
+	public Scanner (string fileName) {
+		try {
+			Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
+			buffer = new Buffer(stream, false);
+			Init();
+		} catch (IOException) {
+			throw new FatalError("Cannot open file " + fileName);
+		}
+	}
+	
+	public Scanner (Stream s) {
+		buffer = new Buffer(s, true);
+		Init();
+	}
+	
+	void Init() {
+		pos = -1; line = 1; col = 0; charPos = -1;
+		oldEols = 0;
+		NextCh();
+		if (ch == 0xEF) { // check optional byte order mark for UTF-8
+			NextCh(); int ch1 = ch;
+			NextCh(); int ch2 = ch;
+			if (ch1 != 0xBB || ch2 != 0xBF) {
+				throw new FatalError(String.Format("illegal byte order mark: EF {0,2:X} {1,2:X}", ch1, ch2));
+			}
+			buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
+			NextCh();
+		}
+		pt = tokens = new Token();  // first token is a dummy
+	}
+	
+	void NextCh() {
+		if (oldEols > 0) { ch = EOL; oldEols--; } 
+		else {
+			pos = buffer.Pos;
+			// buffer reads unicode chars, if UTF8 has been detected
+			ch = buffer.Read(); col++; charPos++;
+			// replace isolated '\r' by '\n' in order to make
+			// eol handling uniform across Windows, Unix and Mac
+			if (ch == '\r' && buffer.Peek() != '\n') ch = EOL;
+			if (ch == EOL) { line++; col = 0; }
+		}
+
+	}
+
+	void AddCh() {
+		if (tlen >= tval.Length) {
+			char[] newBuf = new char[2 * tval.Length];
+			Array.Copy(tval, 0, newBuf, 0, tval.Length);
+			tval = newBuf;
+		}
+		if (ch != Buffer.EOF) {
+			tval[tlen++] = (char) ch;
+			NextCh();
+		}
+	}
+
+
+
+	bool Comment0() {
+		int level = 1, pos0 = pos, line0 = line, col0 = col, charPos0 = charPos;
+		NextCh();
+		if (ch == '*') {
+			NextCh();
+			for(;;) {
+				if (ch == '*') {
+					NextCh();
+					if (ch == '/') {
+						level--;
+						if (level == 0) { oldEols = line - line0; NextCh(); return true; }
+						NextCh();
+					}
+				} else if (ch == '/') {
+					NextCh();
+					if (ch == '*') {
+						level++; NextCh();
+					}
+				} else if (ch == Buffer.EOF) return false;
+				else NextCh();
+			}
+		} else {
+			buffer.Pos = pos0; NextCh(); line = line0; col = col0; charPos = charPos0;
+		}
+		return false;
+	}
+
+
+	void CheckLiteral() {
+		switch (t.val) {
+			case "PROBLEM": t.kind = 2; break;
+			case "CODE": t.kind = 3; break;
+			case "INIT": t.kind = 6; break;
+			case "NONTERMINALS": t.kind = 7; break;
+			case "TERMINALS": t.kind = 8; break;
+			case "RULES": t.kind = 9; break;
+			case "MAXIMIZE": t.kind = 10; break;
+			case "MINIMIZE": t.kind = 11; break;
+			case "END": t.kind = 12; break;
+			case "LOCAL": t.kind = 14; break;
+			case "SEM": t.kind = 15; break;
+			case "CONSTRAINTS": t.kind = 16; break;
+			case "IN": t.kind = 17; break;
+			case "SET": t.kind = 18; break;
+			case "RANGE": t.kind = 19; break;
+			case "EPS": t.kind = 23; break;
+			default: break;
+		}
+	}
+
+	Token NextToken() {
+		while (ch == ' ' ||
+			ch >= 9 && ch <= 10 || ch == 13
+		) NextCh();
+		if (ch == '/' && Comment0()) return NextToken();
+		int recKind = noSym;
+		int recEnd = pos;
+		t = new Token();
+		t.pos = pos; t.col = col; t.line = line; t.charPos = charPos;
+		int state;
+		if (start.ContainsKey(ch)) { state = (int) start[ch]; }
+		else { state = 0; }
+		tlen = 0; AddCh();
+		
+		switch (state) {
+			case -1: { t.kind = eofSym; break; } // NextCh already done
+			case 0: {
+				if (recKind != noSym) {
+					tlen = recEnd - t.pos;
+					SetScannerBehindT();
+				}
+				t.kind = recKind; break;
+			} // NextCh already done
+			case 1:
+				recEnd = pos; recKind = 1;
+				if (ch >= '0' && ch <= '9' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') {AddCh(); goto case 1;}
+				else {t.kind = 1; t.val = new String(tval, 0, tlen); CheckLiteral(); return t;}
+			case 2:
+				if (ch == '<') {AddCh(); goto case 3;}
+				else {goto case 0;}
+			case 3:
+				{t.kind = 4; break;}
+			case 4:
+				if (ch == '>') {AddCh(); goto case 5;}
+				else {goto case 0;}
+			case 5:
+				{t.kind = 5; break;}
+			case 6:
+				{t.kind = 20; break;}
+			case 7:
+				{t.kind = 21; break;}
+			case 8:
+				{t.kind = 22; break;}
+			case 9:
+				{t.kind = 24; break;}
+			case 10:
+				{t.kind = 25; break;}
+			case 11:
+				{t.kind = 26; break;}
+			case 12:
+				{t.kind = 27; break;}
+			case 13:
+				{t.kind = 28; break;}
+			case 14:
+				{t.kind = 29; break;}
+			case 15:
+				recEnd = pos; recKind = 13;
+				if (ch == '.') {AddCh(); goto case 6;}
+				else {t.kind = 13; break;}
+
+		}
+		t.val = new String(tval, 0, tlen);
+		return t;
+	}
+	
+	private void SetScannerBehindT() {
+		buffer.Pos = t.pos;
+		NextCh();
+		line = t.line; col = t.col; charPos = t.charPos;
+		for (int i = 0; i < tlen; i++) NextCh();
+	}
+	
+	// get the next token (possibly a token already seen during peeking)
+	public Token Scan () {
+		if (tokens.next == null) {
+			return NextToken();
+		} else {
+			pt = tokens = tokens.next;
+			return tokens;
+		}
+	}
+
+	// peek for the next token, ignore pragmas
+	public Token Peek () {
+		do {
+			if (pt.next == null) {
+				pt.next = NextToken();
+			}
+			pt = pt.next;
+		} while (pt.kind > maxT); // skip pragmas
+	
+		return pt;
+	}
+
+	// make sure that peeking starts at the current scan position
+	public void ResetPeek () { pt = tokens; }
+
+} // end Scanner
+}
Index: /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/SyntaxAnalyzer.csproj
===================================================================
--- /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/SyntaxAnalyzer.csproj	(revision 9723)
+++ /branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/SyntaxAnalyzer.csproj	(revision 9724)
@@ -42,14 +42,8 @@
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Coco-2\Errors.cs" />
-    <Compile Include="Coco-2\Sets.cs" />
-    <Compile Include="Coco-2\Utils.cs" />
-    <Compile Include="GPDefSyntaxAnalyzer.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Include="GPDefSyntaxAnalyzerLex.cs" />
-    <Compile Include="GPDefSyntaxAnalyzerSem.cs" />
-    <Compile Include="GPDefSyntaxAnalyzerSyn.cs" />
+    <Compile Include="GPDefSyntaxAnalyzer.cs" />
+    <Compile Include="Parser.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Scanner.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -57,6 +51,5 @@
   </ItemGroup>
   <ItemGroup>
-    <Content Include="GPDef.pgt.lst" />
-    <Content Include="GPDef.sg.lst" />
+    <Folder Include="Coco-2\" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
