Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9842


Ignore:
Timestamp:
08/02/13 18:11:26 (11 years ago)
Author:
gkronber
Message:

#2026 added rudimentary error checking to GPDL parser ATG. Added GPL license headers to all files. Created a first set of unit tests.

Location:
branches/HeuristicLab.Problems.GPDL
Files:
8 added
25 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GPDL

    • Property svn:ignore
      •  

        old new  
        11_ReSharper.HeuristicLab.Problems.GPDL
        22*.suo
         3bin
         4*.user
  • branches/HeuristicLab.Problems.GPDL/GpdlCompiler/Program.cs

    r9724 r9842  
    1 // GpdlCompiler.cs                                                        HDO, 2006-08-28
    2 // -----
    3 // Main program for compiler generated from GpdlCompiler.atg with Coco-2.
    4 //=====================================|========================================
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
    521
    622using System;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/CodeEditor.xaml.cs

    r9724 r9842  
    1 using System.Collections.Generic;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Collections.Generic;
    223using System.IO;
    324using System.Windows.Controls;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/ColorizeErrors.cs

    r9674 r9842  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    523using System.Windows;
    624using System.Windows.Media;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/CreateProblemMenuItem.cs

    r9528 r9842  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlCompletionData.cs

    r9674 r9842  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using ICSharpCode.AvalonEdit.CodeCompletion;
    324using ICSharpCode.AvalonEdit.Document;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.Designer.cs

    r9674 r9842  
    1 using System.Windows.Forms;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Windows.Forms;
    223using HeuristicLab.MainForm.WindowsForms;
    324
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs

    r9725 r9842  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.IO;
    324using System.Linq;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlExampleDataDescriptor.cs

    r9519 r9842  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    522using HeuristicLab.Problems.Instances;
    623
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlExampleProvider.cs

    r9519 r9842  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using HeuristicLab.Problems.GPDL.Views.Properties;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlProblemInstanceConsumerView.cs

    r9528 r9842  
    1 using HeuristicLab.Problems.Instances.Views;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Problems.Instances.Views;
    223
    324namespace HeuristicLab.Problems.GPDL.Views {
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Plugin.cs.frame

    r9674 r9842  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2522using HeuristicLab.PluginInfrastructure;
    2623
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.sln

    r9696 r9842  
    2929Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GpdlCompiler", "GpdlCompiler\GpdlCompiler.csproj", "{C3A2E1C9-9677-4992-A1B7-7B38CDB82FEF}"
    3030EndProject
     31Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{94073310-27AB-4C93-8FDD-3D35824AE3F7}"
     32EndProject
    3133Global
    3234  GlobalSection(SolutionConfigurationPlatforms) = preSolution
     
    5153    {C3A2E1C9-9677-4992-A1B7-7B38CDB82FEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
    5254    {C3A2E1C9-9677-4992-A1B7-7B38CDB82FEF}.Release|Any CPU.Build.0 = Release|Any CPU
     55    {94073310-27AB-4C93-8FDD-3D35824AE3F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     56    {94073310-27AB-4C93-8FDD-3D35824AE3F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
     57    {94073310-27AB-4C93-8FDD-3D35824AE3F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
     58    {94073310-27AB-4C93-8FDD-3D35824AE3F7}.Release|Any CPU.Build.0 = Release|Any CPU
    5359  EndGlobalSection
    5460  GlobalSection(SolutionProperties) = preSolution
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/AST.cs

    r9430 r9842  
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    122using System.Collections.Generic;
    2 using System;
     23using System.Linq;
    324using System.Text;
    425
     
    1839    this.ClassCodeNode = new CodeNode();
    1940    this.InitCodeNode = new CodeNode();
     41  }
     42
     43  public bool IsSymbolDefined(SymbolNode n) {
     44    return NonTerminals.Any(s => s.Ident == n.Ident) ||
     45           Terminals.Any(s => s.Ident == n.Ident);
     46  }
     47  public bool IsNonTerminalDefined(string ntIdent) {
     48    return NonTerminals.Any(s => s.Ident == ntIdent);
     49  }
     50  public bool IsRuleDefined(RuleNode n) {
     51    return IsRuleDefined(n.NtSymbol);
     52  }
     53  public bool IsRuleDefined(string ntSymbol) {
     54    return Rules.Any(r => r.NtSymbol == ntSymbol);
     55  }
     56  public string UndefinedNonTerminals() {
     57    var sb = new StringBuilder();
     58    foreach (var nt in NonTerminals) {
     59      if (!IsRuleDefined(nt.Ident)) {
     60        sb.AppendFormat("{0} ", nt.Ident);
     61      }
     62    }
     63    return sb.ToString();
    2064  }
    2165}
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDef.atg

    r9727 r9842  
     1/* HeuristicLab
     2 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 *
     4 * This file is part of HeuristicLab.
     5 *
     6 * HeuristicLab is free software: you can redistribute it and/or modify
     7 * it under the terms of the GNU General Public License as published by
     8 * the Free Software Foundation, either version 3 of the License, or
     9 * (at your option) any later version.
     10 *
     11 * HeuristicLab is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 * GNU General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU General Public License
     17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     18 */
     19
     20// Coco/R grammar for the GPDL compiler
     21
    122$namespace=HeuristicLab.Problems.GPDL
    223
    324using System.Text;
    425using System.Collections.Generic;
     26using System.Linq;
    527using IEnumerableConstraintNode = System.Collections.Generic.IEnumerable<ConstraintNode>;
    628
     
    4466    ]
    4567
    46     "NONTERMINALS" { NonterminalDecl<out ntNode>                                  (. gpDef.NonTerminals.Add(ntNode); .)
    47     }
    48     "TERMINALS" { TerminalDecl<out tNode>                                         (. gpDef.Terminals.Add(tNode); .)
    49     }
    50     "RULES" { RuleDef<out ruleNode>                                               (. gpDef.Rules.Add(ruleNode); .)
    51     }
     68    "NONTERMINALS" { NonterminalDecl<out ntNode>                                  (. if(gpDef.IsSymbolDefined(ntNode)) {
     69                                                                                       SemErr("Duplicate non-terminal symbol: " + ntNode.Ident);
     70                                                                                     } else {
     71                                                                                       gpDef.NonTerminals.Add(ntNode);
     72                                                                                     }
     73                                                                                  .)
     74    }                                                                             (. if(!gpDef.NonTerminals.Any())
     75                                                                                       SemErr("No non-terminal symbols defined.");
     76                                                                                  .)
     77    "TERMINALS" { TerminalDecl<out tNode>                                         (. if(gpDef.IsSymbolDefined(tNode)) {
     78                                                                                       SemErr("Duplicate terminal symbol: " + tNode.Ident);
     79                                                                                     } else {
     80                                                                                       gpDef.Terminals.Add(tNode);
     81                                                                                     }
     82                                                                                  .)
     83    }                                                                             (. if(!gpDef.Terminals.Any())
     84                                                                                       SemErr("No terminal symbols defined.");
     85                                                                                  .)
     86    "RULES" { RuleDef<out ruleNode>                                               (.
     87                                                                                     if(!gpDef.IsNonTerminalDefined(ruleNode.NtSymbol)) {
     88                                                                                       SemErr("Non-terminal symbol " + ruleNode.NtSymbol + " is not defined in the NONTERMINALS section.");
     89                                                                                     } else if(gpDef.IsRuleDefined(ruleNode)) {
     90                                                                                       SemErr("Duplicate rule definition for non-terminal symbol " + ruleNode.NtSymbol);
     91                                                                                     } else {
     92                                                                                       gpDef.Rules.Add(ruleNode);
     93                                                                                     }
     94                                                                                   .)
     95    }                                                                             (.
     96                                                                                     var undefinedNT = gpDef.UndefinedNonTerminals();
     97                                                                                     if(!string.IsNullOrEmpty(undefinedNT)) {
     98                                                                                       SemErr("Rules missing in the RULES section for: " + undefinedNT);
     99                                                                                     }
     100                                                                                  .)
    52101                                                                                  (. fitnessFunNode = new FitnessFunctionNode();
    53                                                                                          gpDef.FitnessFunctionNode = fitnessFunNode;
     102                                                                                     gpDef.FitnessFunctionNode = fitnessFunNode;
    54103                                                                                  .)
    55104    ("MAXIMIZE"                                                                   (. fitnessFunNode.Maximization = true; .)
     
    57106    )
    58107     SourceCode<out src>                                                          (. fitnessFunNode.SrcCode = src; .)
     108                                                                                  (. if(errors.count > 0) throw new FatalError("Syntactic or semantic errors found."); .)
    59109    "END" ident                                                                   (.
    60                                                                                     // SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
    61110                                                                                    var gen = new ProblemGenerator();
    62111                                                                                    problem = gen.GenerateFromAst(gpDef);
     
    125174                                                                                  .)
    126175    ident                                                                         (. constraint = new ConstraintNode(t.val); .)
    127     "IN" SetDefinition<constraint>                                                // (. SourceReader.Handle(GPDefSem.srcText.ToString()); .) // flush the source reader
     176    "IN" SetDefinition<constraint>                                               
    128177  .
    129178
     
    135184     "RANGE"                                                                      (. constraint.Type = ConstraintNodeType.Range; .)
    136185     SourceCode<out src>                                                          (. constraint.RangeMinExpression = src; .)
    137      ".." SourceCode<out src>                                                     (. // SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader
    138                                                                                     constraint.RangeMaxExpression = src; .)
     186     ".." SourceCode<out src>                                                     (. constraint.RangeMaxExpression = src; .)
    139187    )
    140188  .
     
    142190  /******************************************************/
    143191  RuleDef<out RuleNode rule> =                                                    (.
    144                                                                                     RuleExprNode expr = null;
    145                                                                                     string identStr = null;
    146                                                                                     RuleNode myRule = null;
    147                                                                                     rule = null;
    148                                                                                    string src = "";
     192                                                                                     RuleExprNode expr = null;
     193                                                                                     string identStr = null;
     194                                                                                     RuleNode myRule = null;
     195                                                                                     rule = null;
     196                                                                                     string src = "";
    149197                                                                                  .)
    150198  ident                                                                           (. identStr = t.val; .)
    151199  [ SourceCode<out src> ] '='                                                     (.
    152                                                                                       myRule = new RuleNode();
    153                                                                                       rule = myRule;
    154                                                                                       myRule.NtSymbol = identStr;
     200                                                                                     myRule = new RuleNode();
     201                                                                                     rule = myRule;
     202                                                                                     myRule.NtSymbol = identStr;
    155203                                                                                  .)
    156204  ["LOCAL" SourceCode<out src>                                                    (.
    157                                                                                     myRule.LocalCode = src;
     205                                                                                     myRule.LocalCode = src;
    158206                                                                                  .)
    159207  ]
     
    205253// not implemented   | '[' SynExpr<ref rules, mBuilder> ']'
    206254// not implemented   | '{' SynExpr<ref rules, mBuilder> '}'
    207      | SemAction<out action>                                                      (. expr = action; .)
     255     | SemAction<out action>                                                     (. expr = action; .)
    208256    )
    209257  .
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Grammar.cs

    r9430 r9842  
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    122using System;
    223using System.Collections.Generic;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/InterpreterBuilder.cs

    r9430 r9842  
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    122using System.Collections.Generic;
    223using System;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/MethodBuilder.cs

    r9430 r9842  
    1 using System.Collections.Generic;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222using System;
    323using System.Text;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Parser.cs

    r9727 r9842  
    11using System.Text;
    22using System.Collections.Generic;
     3using System.Linq;
    34using IEnumerableConstraintNode = System.Collections.Generic.IEnumerable<ConstraintNode>;
    45
     
    125126    while (la.kind == 1) {
    126127      NonterminalDecl(out ntNode);
    127       gpDef.NonTerminals.Add(ntNode);
    128     }
     128      if(gpDef.IsSymbolDefined(ntNode)) {
     129       SemErr("Duplicate non-terminal symbol: " + ntNode.Ident);
     130      } else {
     131       gpDef.NonTerminals.Add(ntNode);
     132      }
     133     
     134    }
     135    if(!gpDef.NonTerminals.Any())
     136     SemErr("No non-terminal symbols defined.");
     137   
    129138    Expect(8);
    130139    while (la.kind == 1) {
    131140      TerminalDecl(out tNode);
    132       gpDef.Terminals.Add(tNode);
    133     }
     141      if(gpDef.IsSymbolDefined(tNode)) {
     142       SemErr("Duplicate terminal symbol: " + tNode.Ident);
     143      } else {
     144       gpDef.Terminals.Add(tNode);
     145      }
     146     
     147    }
     148    if(!gpDef.Terminals.Any())
     149     SemErr("No terminal symbols defined.");
     150   
    134151    Expect(9);
    135152    while (la.kind == 1) {
    136153      RuleDef(out ruleNode);
    137       gpDef.Rules.Add(ruleNode);
    138     }
     154      if(!gpDef.IsNonTerminalDefined(ruleNode.NtSymbol)) {
     155       SemErr("Non-terminal symbol " + ruleNode.NtSymbol + " is not defined in the NONTERMINALS section.");
     156      } else if(gpDef.IsRuleDefined(ruleNode)) {
     157       SemErr("Duplicate rule definition for non-terminal symbol " + ruleNode.NtSymbol);
     158      } else {
     159       gpDef.Rules.Add(ruleNode);
     160      }
     161     
     162    }
     163    var undefinedNT = gpDef.UndefinedNonTerminals();
     164    if(!string.IsNullOrEmpty(undefinedNT)) {
     165     SemErr("Rules missing in the RULES section for: " + undefinedNT);
     166    }
     167   
    139168    fitnessFunNode = new FitnessFunctionNode();
    140        gpDef.FitnessFunctionNode = fitnessFunNode;
     169    gpDef.FitnessFunctionNode = fitnessFunNode;
    141170   
    142171    if (la.kind == 10) {
     
    149178    SourceCode(out src);
    150179    fitnessFunNode.SrcCode = src;
     180    if(errors.count > 0) throw new FatalError("Syntactic or semantic errors found.");
    151181    Expect(12);
    152182    Expect(1);
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Plugin.cs.frame

    r9430 r9842  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Text;
    2522using HeuristicLab.PluginInfrastructure;
    2623
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/ProblemGenerator.cs

    r9528 r9842  
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    122using System;
    223using System.CodeDom.Compiler;
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/SourceReader.cs

    r9726 r9842  
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    122using System.Collections.Generic;
    223using System.Linq;
     
    1334      yield return new TerminalNode.FieldDefinition(m.Groups["refOrOut"].Value, m.Groups["type"].Value, m.Groups["id"].Value);
    1435    }
    15     //var nParameters = match.Groups["id"].Captures.Count;
    16     //for (int i = 0; i < nParameters; i++) {
    17     //  yield return new TerminalNode.FieldDefinition(match.Groups["refOrOut"].Captures[i].Value, match.Groups["type"].Captures[i].Value, match.Groups["id"].Captures[i].Value);
    18     //}
    1936  }
    2037}
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/SymbolBuilder.cs

    r9430 r9842  
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    122using System.Collections.Generic;
    223using System;
  • branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDef.atg

    r9727 r9842  
     1/* HeuristicLab
     2 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 *
     4 * This file is part of HeuristicLab.
     5 *
     6 * HeuristicLab is free software: you can redistribute it and/or modify
     7 * it under the terms of the GNU General Public License as published by
     8 * the Free Software Foundation, either version 3 of the License, or
     9 * (at your option) any later version.
     10 *
     11 * HeuristicLab is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 * GNU General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU General Public License
     17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     18 */
     19
    120$namespace=SyntaxAnalyzer
    221
     
    1534IGNORE '\t' + '\r' + '\n'
    1635
     36// grammar production rules in EBNF syntax
    1737PRODUCTIONS
    1838  GPDefSyntaxAnalyzer =
  • branches/HeuristicLab.Problems.GPDL/SyntaxAnalyzer/GPDefSyntaxAnalyzer.cs

    r9725 r9842  
    1 // GPDefSyntaxAnalyzer.cs                                       GKR, 2013
    2 // -----
    3 // Main program for compiler generated from GPDef.atg with Coco/R.
    4 //=====================================|========================================
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    522
    623using System;
Note: See TracChangeset for help on using the changeset viewer.