- Timestamp:
- 08/02/13 18:11:26 (11 years ago)
- Location:
- branches/HeuristicLab.Problems.GPDL
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GPDL
- Property svn:ignore
-
old new 1 1 _ReSharper.HeuristicLab.Problems.GPDL 2 2 *.suo 3 bin 4 *.user
-
- Property svn:ignore
-
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 1 22 $namespace=HeuristicLab.Problems.GPDL 2 23 3 24 using System.Text; 4 25 using System.Collections.Generic; 26 using System.Linq; 5 27 using IEnumerableConstraintNode = System.Collections.Generic.IEnumerable<ConstraintNode>; 6 28 … … 44 66 ] 45 67 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 .) 52 101 (. fitnessFunNode = new FitnessFunctionNode(); 53 102 gpDef.FitnessFunctionNode = fitnessFunNode; 54 103 .) 55 104 ("MAXIMIZE" (. fitnessFunNode.Maximization = true; .) … … 57 106 ) 58 107 SourceCode<out src> (. fitnessFunNode.SrcCode = src; .) 108 (. if(errors.count > 0) throw new FatalError("Syntactic or semantic errors found."); .) 59 109 "END" ident (. 60 // SourceReader.Handle(GPDefSem.srcText.ToString()); // flush the source reader61 110 var gen = new ProblemGenerator(); 62 111 problem = gen.GenerateFromAst(gpDef); … … 125 174 .) 126 175 ident (. constraint = new ConstraintNode(t.val); .) 127 "IN" SetDefinition<constraint> // (. SourceReader.Handle(GPDefSem.srcText.ToString()); .) // flush the source reader176 "IN" SetDefinition<constraint> 128 177 . 129 178 … … 135 184 "RANGE" (. constraint.Type = ConstraintNodeType.Range; .) 136 185 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; .) 139 187 ) 140 188 . … … 142 190 /******************************************************/ 143 191 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 = ""; 149 197 .) 150 198 ident (. identStr = t.val; .) 151 199 [ SourceCode<out src> ] '=' (. 152 153 154 200 myRule = new RuleNode(); 201 rule = myRule; 202 myRule.NtSymbol = identStr; 155 203 .) 156 204 ["LOCAL" SourceCode<out src> (. 157 myRule.LocalCode = src;205 myRule.LocalCode = src; 158 206 .) 159 207 ] … … 205 253 // not implemented | '[' SynExpr<ref rules, mBuilder> ']' 206 254 // not implemented | '{' SynExpr<ref rules, mBuilder> '}' 207 | SemAction<out action> 255 | SemAction<out action> (. expr = action; .) 208 256 ) 209 257 .
Note: See TracChangeset
for help on using the changeset viewer.