Changeset 18100 for branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer
- Timestamp:
- 12/01/21 13:40:55 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs
r18093 r18100 82 82 knownSymbols = new BidirectionalLookup<string, ISymbol>(StringComparer.InvariantCulture, new SymbolComparer()); 83 83 84 private Num num = new Num();85 private RealConstant realConstant = new RealConstant();84 private Number number = new Number(); 85 private Constant constant = new Constant(); 86 86 private Variable variable = new Variable(); 87 87 private BinaryFactorVariable binaryFactorVar = new BinaryFactorVariable(); … … 181 181 && str[pos] != ']' 182 182 && str[pos] != '}' 183 && str[pos] != ',') { 183 && str[pos] != ',' 184 && str[pos] != '>') { 184 185 sb.Append(str[pos]); 185 186 pos++; … … 333 334 foreach (var negTerm in negTerms) sumNeg.AddSubtree(negTerm); 334 335 335 var constNode = (Num TreeNode)num.CreateTreeNode();336 var constNode = (NumberTreeNode)number.CreateTreeNode(); 336 337 constNode.Value = -1.0; 337 338 var prod = GetSymbol("*").CreateTreeNode(); … … 532 533 } 533 534 } else if (next.TokenType == TokenType.LeftAngleBracket) { 535 Token numberTok = null; 534 536 var leftAngleBracket = tokens.Dequeue(); 535 537 if (leftAngleBracket.TokenType != TokenType.LeftAngleBracket) … … 539 541 if (idTok.TokenType != TokenType.Identifier || idTok.strVal.ToLower() != "num") 540 542 throw new ArgumentException("string 'num' expected"); 543 544 if (tokens.Peek().TokenType == TokenType.Eq) { 545 var equalTok = tokens.Dequeue(); 546 if (tokens.Peek().TokenType != TokenType.Number) 547 throw new ArgumentException("No value for number specified."); 548 549 numberTok = tokens.Dequeue(); 550 } 551 541 552 var rightAngleBracket = tokens.Dequeue(); 542 553 if (rightAngleBracket.TokenType != TokenType.RightAngleBracket) 543 554 throw new ArgumentException("closing bracket > expected"); 544 var numNode = (NumTreeNode)num.CreateTreeNode(); 555 var numNode = (NumberTreeNode)number.CreateTreeNode(); 556 if (numberTok != null) numNode.Value = numberTok.doubleVal; 545 557 return numNode; 546 558 } else if (next.TokenType == TokenType.Number) { 547 559 var numTok = tokens.Dequeue(); 548 var constNode = ( RealConstantTreeNode)realConstant.CreateTreeNode();560 var constNode = (ConstantTreeNode)constant.CreateTreeNode(); 549 561 constNode.Value = numTok.doubleVal; 550 562 return constNode;
Note: See TracChangeset
for help on using the changeset viewer.