Index: branches/HeuristicLab.Problems.GPDL/HeuristicLab.Grammars/3.3/AttributedGrammar.cs
===================================================================
--- branches/HeuristicLab.Problems.GPDL/HeuristicLab.Grammars/3.3/AttributedGrammar.cs	(revision 10067)
+++ branches/HeuristicLab.Problems.GPDL/HeuristicLab.Grammars/3.3/AttributedGrammar.cs	(revision 10086)
@@ -27,19 +27,18 @@
 namespace HeuristicLab.Grammars {
   public class AttributedGrammar : Grammar {
-    private Dictionary<ISymbol, string> localDefinitions = new Dictionary<ISymbol, string>();
-    private Dictionary<ISymbol, IList<Sequence>> alternatives = new Dictionary<ISymbol, IList<Sequence>>();
+    private readonly Dictionary<ISymbol, string> localDefinitions;
+    private readonly Dictionary<ISymbol, List<Sequence>> alternatives;
 
-    public AttributedGrammar(ISymbol startSymbol)
-      : base(startSymbol) {
-      Debug.Assert(!startSymbol.Equals(EmptySymbol));
+    public AttributedGrammar(ISymbol startSymbol, IEnumerable<ISymbol> nonTerminals, IEnumerable<ISymbol> terminals)
+      : base(startSymbol, nonTerminals, terminals) {
       this.StartSymbol = startSymbol;
+      localDefinitions = nonTerminals.ToDictionary(nt => nt, nt => string.Empty);
+      alternatives = nonTerminals.ToDictionary(nt => nt, nt => new List<Sequence>());
     }
 
     public IEnumerable<Sequence> GetAlternativesWithSemanticActions(ISymbol ntSymbol) {
-      Debug.Assert(!ntSymbol.Equals(EmptySymbol));
       return alternatives[ntSymbol];
     }
     public Sequence GetAlternativeWithSemanticActions(ISymbol ntSymbol, int index) {
-      Debug.Assert(!ntSymbol.Equals(EmptySymbol));
       return alternatives[ntSymbol][index];
     }
@@ -48,9 +47,6 @@
       base.AddProductionRule(ntSymbol, new Sequence(production.Where(symb => !(symb is SemanticSymbol)).ToList()));
 
-      IList<Sequence> list;
-      if (!alternatives.TryGetValue(ntSymbol, out list)) {
-        list = new List<Sequence>();
-        alternatives.Add(ntSymbol, list);
-      }
+      IList<Sequence> list = alternatives[ntSymbol];
+
       // make sure that there is not equivalent production registered already
       Debug.Assert(!list.Any(s => s.SequenceEqual(production)));
@@ -61,40 +57,10 @@
     public void AddLocalDefinitions(ISymbol ntSymbol, string localDefCode) {
       Debug.Assert(!ntSymbol.Equals(EmptySymbol));
-      Debug.Assert(!localDefinitions.ContainsKey(ntSymbol));
 
-      localDefinitions.Add(ntSymbol, localDefCode);
+      localDefinitions[ntSymbol] = localDefCode;
     }
     public string GetLocalDefinitions(ISymbol ntSymbol) {
-      string code;
-      if (localDefinitions.TryGetValue(ntSymbol, out code)) return code;
-      else return string.Empty;
+      return localDefinitions[ntSymbol];
     }
-
-
-
-    //private static Regex ruleExpr = new Regex(@"\s*(?<ntSymbol>\w+)\s*(?<formPar>\<\w+\>)+\s*->\s*(?<alternative>\w+\s*(?<actPar>\<\w+\>)+(?:\s+\w+\s*(?<actPar>\<\w+\>)+)*)(?:\s*\|\s*(?<alternative>\w+\s*(?<formPar>\<\w+\>)+(?:\s+\w+\s*(?<formPar>\<\w+\>)+)*))*");
-    //private static Regex empty = new Regex(@"^\s*$");
-    //public static Grammar FromString(string gStr) {
-    //  var lines = gStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
-    //  lines = lines.Where(l => !empty.IsMatch(l)).ToArray(); // remove empty lines
-
-    //  // first line is the rule for the start-symbol
-    //  var m = ruleExpr.Match(lines.First());
-    //  var startSymbol = new Symbol(m.Groups["ntSymbol"].Value);
-
-    //  var g = new Grammar(startSymbol);
-    //  foreach (var alt in m.Groups["alternative"].Captures) {
-    //    g.AddProductionRule(startSymbol, new Sequence(alt.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(n => new Symbol(n))));
-    //  }
-    //  foreach (var line in lines.Skip(1)) {
-    //    m = ruleExpr.Match(line);
-    //    var ntSymbol = new Symbol(m.Groups["ntSymbol"].Value);
-    //    foreach (var alt in m.Groups["alternative"].Captures) {
-    //      g.AddProductionRule(ntSymbol, new Sequence(alt.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(n => new Symbol(n))));
-    //    }
-    //  }
-
-    //  return g;
-    //}
   }
 }
