- Timestamp:
- 12/01/21 13:40:55 (3 years ago)
- Location:
- branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
r17180 r18100 88 88 StringBuilder builder = new StringBuilder(); 89 89 var varTreeNode = tree as VariableTreeNode; 90 var numTreeNode = tree as NumberTreeNode; 90 91 var constTreeNode = tree as ConstantTreeNode; 91 92 var factorVarTreeNode = tree as FactorVariableTreeNode; … … 97 98 } else if (binFactorVarTreeNode != null) { 98 99 builder.Append("(factor " + binFactorVarTreeNode.VariableName + "=" + binFactorVarTreeNode.VariableValue); 99 } else if ( constTreeNode != null) {100 } else if (numTreeNode != null || constTreeNode != null) { 100 101 builder.Append("(const"); 101 102 } else { -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs
r18093 r18100 58 58 59 59 if (@const!=0.0) { 60 Num TreeNode cNode = (NumTreeNode)new Num().CreateTreeNode();60 NumberTreeNode cNode = (NumberTreeNode)new Number().CreateTreeNode(); 61 61 cNode.Value = @const; 62 62 add.AddSubtree(cNode); … … 99 99 100 100 if (!@const.IsAlmost(0.0)) { 101 Num TreeNode cNode = (NumTreeNode)new Num().CreateTreeNode();101 NumberTreeNode cNode = (NumberTreeNode)new Number().CreateTreeNode(); 102 102 cNode.Value = @const; 103 103 addition.AddSubtree(cNode); … … 130 130 131 131 if (!@const.IsAlmost(0.0)) { 132 Num TreeNode cNode = (NumTreeNode)new Num().CreateTreeNode();132 NumberTreeNode cNode = (NumberTreeNode)new Number().CreateTreeNode(); 133 133 cNode.Value = @const; 134 134 addition.AddSubtree(cNode); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
r18093 r18100 145 145 146 146 private AutoDiff.Term ConvertToAutoDiff(ISymbolicExpressionTreeNode node) { 147 if (node.Symbol is Num ) {148 initialConstants.Add(((Num TreeNode)node).Value);147 if (node.Symbol is Number) { 148 initialConstants.Add(((NumberTreeNode)node).Value); 149 149 var var = new AutoDiff.Variable(); 150 150 variables.Add(var); … … 152 152 } 153 153 154 if (node.Symbol is RealConstant) {155 initialConstants.Add((( RealConstantTreeNode)node).Value);154 if (node.Symbol is Constant) { 155 initialConstants.Add(((ConstantTreeNode)node).Value); 156 156 var var = new AutoDiff.Variable(); 157 157 variables.Add(var); … … 267 267 } 268 268 if (node.Symbol is Power) { 269 var powerNode = node.GetSubtree(1) as Num TreeNode;269 var powerNode = node.GetSubtree(1) as NumberTreeNode; 270 270 if (powerNode == null) 271 271 throw new NotSupportedException("Only integer powers are allowed in parameter optimization. Try to use exp() and log() instead of the power symbol."); … … 337 337 !(n.Symbol is FactorVariable) && 338 338 !(n.Symbol is LaggedVariable) && 339 !(n.Symbol is Num ) &&340 !(n.Symbol is RealConstant) &&339 !(n.Symbol is Number) && 340 !(n.Symbol is Constant) && 341 341 !(n.Symbol is Addition) && 342 342 !(n.Symbol is Subtraction) && -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
r17811 r18100 54 54 55 55 var power = node.GetSubtree(1); 56 if(power is ConstantTreeNode constNode && Math.Truncate(constNode.Value) == constNode.Value) {56 if(power is NumberTreeNode constNode && Math.Truncate(constNode.Value) == constNode.Value) { 57 57 strBuilder.Append(" ").Append(token).Append(" ").Append(constNode.Value.ToString(formatString, numberFormat)); 58 58 } else { … … 141 141 142 142 if (!factorNode.Weight.IsAlmost(1.0)) strBuilder.Append(")"); 143 } else if (node.Symbol is Constant) {144 var constNode = node as ConstantTreeNode;143 } else if (node.Symbol is Number) { 144 var constNode = node as NumberTreeNode; 145 145 if (constants == null && constNode.Value < 0) { 146 146 strBuilder.Append("(").Append(constNode.Value.ToString(formatString, numberFormat)) … … 204 204 /// </summary> 205 205 /// <param name="symbolicExpressionTree">The tree representation of the expression.</param> 206 /// <param name="numberFormat"> Numberformat that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param>206 /// <param name="numberFormat">Constant format that should be used for numeric parameters (e.g. NumberFormatInfo.InvariantInfo (default)).</param> 207 207 /// <param name="formatString">The format string for numeric parameters (e.g. \"G4\" to limit to 4 digits, default is \"G\")</param> 208 208 /// <returns>Infix expression</returns> -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r17648 r18100 162 162 var varNode = node as VariableTreeNode; 163 163 strBuilder.AppendFormat("{0} * {1}", VariableName2Identifier(varNode.VariableName), varNode.Weight.ToString("g17", CultureInfo.InvariantCulture)); 164 } else if (node is ConstantTreeNode) { 165 var constNode = node as ConstantTreeNode; 166 strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 164 } else if (node is INumericTreeNode numNode) { 165 strBuilder.Append(numNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 167 166 } else if (node.Symbol is FactorVariable) { 168 167 var factorNode = node as FactorVariableTreeNode; -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r17180 r18100 134 134 } 135 135 stringBuilder.Append("))"); 136 } else if (symbol is Constant) {137 ConstantTreeNode constantTreeNode = node as ConstantTreeNode;138 stringBuilder.Append( constantTreeNode.Value.ToString(CultureInfo.InvariantCulture));136 } else if (symbol is INumericSymbol numNode) { 137 var numTreeNode = node as INumericTreeNode; 138 stringBuilder.Append(numTreeNode.Value.ToString(CultureInfo.InvariantCulture)); 139 139 } else if (symbol is Cosine) { 140 140 stringBuilder.Append("COS("); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r17826 r18100 189 189 } else if (node.Symbol is IfThenElse) { 190 190 strBuilder.Append(@" \operatorname{if} \left( "); 191 } else if (node.Symbol is Constant) {192 var constName = "c_{" + constIndex + "}";191 } else if (node.Symbol is INumericSymbol numNode) { 192 var numName = "c_{" + constIndex + "}"; 193 193 constIndex++; 194 var constNode = node as ConstantTreeNode;195 if ( constNode.Value.IsAlmost(1.0)) {194 var numericNode = node as INumericTreeNode; 195 if (numericNode.Value.IsAlmost(1.0)) { 196 196 strBuilder.Append("1 "); 197 197 } else { 198 strBuilder.Append(constName); 199 constants.Add(new KeyValuePair<string, double>(constName, constNode.Value)); 200 } 201 198 strBuilder.Append(numName); 199 constants.Add(new KeyValuePair<string, double>(numName, numericNode.Value)); 200 } 202 201 } else if (node.Symbol is FactorVariable) { 203 202 var factorNode = node as FactorVariableTreeNode; … … 471 470 } else if (node.Symbol is IfThenElse) { 472 471 strBuilder.Append(@" \right) "); 472 } else if (node.Symbol is Number) { 473 473 } else if (node.Symbol is Constant) { 474 } 474 }else if (node.Symbol is LaggedVariable) { 475 475 } else if (node.Symbol is Variable) { 476 476 } else if (node.Symbol is FactorVariable) { -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
r17180 r18100 151 151 } 152 152 stringBuilder.Append(")"); 153 } else if (symbol is Constant) {154 ConstantTreeNode constantTreeNode = node as ConstantTreeNode;155 stringBuilder.Append( constantTreeNode.Value.ToString(CultureInfo.InvariantCulture));153 } else if (symbol is INumericSymbol) { 154 var numberTreeNode = node as INumericTreeNode; 155 stringBuilder.Append(numberTreeNode?.Value.ToString(CultureInfo.InvariantCulture)); 156 156 } else if (symbol is Cosine) { 157 157 stringBuilder.Append("cos("); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
r17180 r18100 130 130 var varNode = node as VariableTreeNode; 131 131 strBuilder.AppendFormat("Times[{0}, {1}]", varNode.VariableName, varNode.Weight.ToString("G17", CultureInfo.InvariantCulture)); 132 } else if (node.Symbol is Constant) {133 var constNode = node as ConstantTreeNode;134 strBuilder.Append( constNode.Value.ToString("G17", CultureInfo.InvariantCulture));132 } else if (node.Symbol is INumericSymbol) { 133 var numNode = node as INumericTreeNode; 134 strBuilder.Append(numNode?.Value.ToString("G17", CultureInfo.InvariantCulture)); 135 135 } else if (node.Symbol is FactorVariable) { 136 136 var factorNode = node as FactorVariableTreeNode; -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionPythonFormatter.cs
r17929 r18100 202 202 else if (node is VariableTreeNode) 203 203 FormatVariableTreeNode(node, strBuilder); 204 else if (node is ConstantTreeNode)205 Format ConstantTreeNode(node, strBuilder);204 else if (node is INumericTreeNode) 205 FormatNumericTreeNode(node, strBuilder); 206 206 else 207 207 throw new NotSupportedException("Formatting of symbol: " + symbol + " not supported for Python symbolic expression tree formatter."); … … 227 227 } 228 228 229 private static void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 230 var constNode = node as ConstantTreeNode; 231 strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 229 private static void FormatNumericTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 230 var symbol = node.Symbol; 231 double value = 0.0; 232 if (symbol is INumericSymbol) { 233 var numNode = node as INumericTreeNode; 234 value = numNode.Value; 235 } else { 236 throw new NotSupportedException("Formatting of symbol: " + symbol + " not supported for Python symbolic expression tree formatter."); 237 } 238 239 240 strBuilder.Append(value.ToString("g17", CultureInfo.InvariantCulture)); 232 241 } 233 242 -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs
r17180 r18100 83 83 } 84 84 stringBuilder.Append(")"); 85 } else if (symbol is Constant) {86 ConstantTreeNode constantTreeNode = node as ConstantTreeNode;87 stringBuilder.Append( constantTreeNode.Value.ToString(CultureInfo.InvariantCulture));88 } 85 } else if (symbol is INumericSymbol) { 86 var numberTreeNode = node as INumericTreeNode; 87 stringBuilder.Append(numberTreeNode?.Value.ToString(CultureInfo.InvariantCulture)); 88 }else if (symbol is Cosine) { 89 89 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 90 90 stringBuilder.Append(" cos"); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/TSQLExpressionFormatter.cs
r17180 r18100 164 164 var varNode = node as VariableTreeNode; 165 165 strBuilder.AppendFormat("{0} * {1}", VariableName2Identifier(varNode.VariableName), varNode.Weight.ToString("g17", CultureInfo.InvariantCulture)); 166 } else if (node is ConstantTreeNode) { 167 var constNode = node as ConstantTreeNode; 168 strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 169 } else if (node.Symbol is FactorVariable) { 166 } else if (node is INumericTreeNode numNode) { 167 strBuilder.Append(numNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 168 }else if (node.Symbol is FactorVariable) { 170 169 var factorNode = node as FactorVariableTreeNode; 171 170 FormatFactor(level, factorNode, strBuilder); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/ArithmeticExpressionGrammar.cs
r18093 r18100 49 49 var mul = new Multiplication(); 50 50 var div = new Division(); 51 var constant = new Num(); 52 constant.MinValue = -20; 53 constant.MaxValue = 20; 54 var number = new RealConstant(); 51 var number = new Number(); 55 52 number.MinValue = -20; 56 53 number.MaxValue = 20; 54 var constant = new Constant(); 57 55 var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable(); 58 56 var binFactorVariableSymbol = new BinaryFactorVariable(); 59 57 var factorVariableSymbol = new FactorVariable(); 60 58 61 var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, number, variableSymbol, binFactorVariableSymbol, factorVariableSymbol };59 var allSymbols = new List<Symbol>() { add, sub, mul, div, number, constant, variableSymbol, binFactorVariableSymbol, factorVariableSymbol }; 62 60 var functionSymbols = new List<Symbol>() { add, sub, mul, div }; 63 61 … … 68 66 SetSubtreeCount(funSymb, 1, 3); 69 67 } 68 SetSubtreeCount(number, 0, 0); 70 69 SetSubtreeCount(constant, 0, 0); 71 SetSubtreeCount(number, 0, 0);72 70 SetSubtreeCount(variableSymbol, 0, 0); 73 71 SetSubtreeCount(binFactorVariableSymbol, 0, 0); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r18093 r18100 118 118 variableCondition.InitialFrequency = 0.0; 119 119 120 var constant = new Num();121 constant.MinValue = -20;122 constant.MaxValue = 20;120 var number = new Number(); 121 number.MinValue = -20; 122 number.MaxValue = 20; 123 123 var variableSymbol = new HeuristicLab.Problems.DataAnalysis.Symbolic.Variable(); 124 124 var binFactorVariable = new BinaryFactorVariable(); … … 130 130 autoregressiveVariable.Enabled = false; 131 131 132 var number = new RealConstant(); 133 number.MinValue = -20; 134 number.MaxValue = 20; 132 var constant = new Constant(); 135 133 136 134 var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp, tanh, 137 135 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral, 138 @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, number, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition };136 @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, number, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition }; 139 137 var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, tanh, not, timeLag, integral, derivative, 140 138 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral … … 143 141 var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, aq, variableCondition }; 144 142 var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or, xor }; 145 var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, constant, number, laggedVariable, autoregressiveVariable };143 var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, number, constant, laggedVariable, autoregressiveVariable }; 146 144 147 145 foreach (var symb in allSymbols) -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/LinearScalingGrammar.cs
r18093 r18100 66 66 var abs = new Absolute(); 67 67 var aq = new AnalyticQuotient(); 68 var constant = new Num(); 69 constant.MinValue = -20; 70 constant.MaxValue = 20; 71 var number = new RealConstant(); 68 var number = new Number(); 72 69 number.MinValue = -20; 73 70 number.MaxValue = 20; 71 var constant = new Constant(); 74 72 var variableSymbol = new Variable(); 75 73 … … 81 79 //all other symbols 82 80 var allSymbols = new List<Symbol> { 83 add, sub, mul, div, constant, number, variableSymbol, sin, cos, tan, log, square, sqrt, cube, cbrt, exp,81 add, sub, mul, div, number, constant, variableSymbol, sin, cos, tan, log, square, sqrt, cube, cbrt, exp, 84 82 tanh, aq, abs 85 83 }; … … 89 87 var realValueSymbols = new List<Symbol> { 90 88 add, sub, mul, div, sin, cos, tan, tanh, exp, log, aq, abs, square, cube, sqrt, cbrt, 91 variableSymbol, constant, number89 variableSymbol, number, constant 92 90 }; 93 91 … … 116 114 //Define childs for offset 117 115 AddAllowedChildSymbol(offset, scaling, 0); 118 AddAllowedChildSymbol(offset, constant, 1);116 AddAllowedChildSymbol(offset, number, 1); 119 117 120 118 //Define childs for scaling 121 119 foreach (var symb in allSymbols) AddAllowedChildSymbol(scaling, symb, 0); 122 AddAllowedChildSymbol(scaling, constant, 1);120 AddAllowedChildSymbol(scaling, number, 1); 123 121 124 122 //Define childs for realvalue symbols -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r18093 r18100 105 105 var derivative = new Derivative(); 106 106 107 var constant = new Num(); 108 constant.MinValue = -20; 109 constant.MaxValue = 20; 110 var number = new RealConstant(); 107 var number = new Number(); 111 108 number.MinValue = -20; 112 109 number.MaxValue = 20; 110 var constant = new Constant(); 113 111 var variableSymbol = new Variable(); 114 112 var binFactorVariable = new BinaryFactorVariable(); … … 124 122 var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, 125 123 fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient}); 126 var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, number, variableSymbol, binFactorVariable, factorVariable });124 var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { number, constant, variableSymbol, binFactorVariable, factorVariable }); 127 125 var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols }); 128 126 … … 196 194 AddAllowedChildSymbol(powerSymbols, laggedVariable, 0); 197 195 AddAllowedChildSymbol(powerSymbols, autoregressiveVariable, 0); 198 AddAllowedChildSymbol(powerSymbols, constant, 1);196 AddAllowedChildSymbol(powerSymbols, number, 1); 199 197 200 198 AddAllowedChildSymbol(square, realValuedSymbols, 0); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r18093 r18100 174 174 <Compile Include="Interfaces\IBoundsEstimator.cs" /> 175 175 <Compile Include="Interfaces\IModelBacktransformator.cs" /> 176 <Compile Include="Interfaces\INumericSymbol.cs" /> 177 <Compile Include="Interfaces\INumericTreeNode.cs" /> 176 178 <Compile Include="Interfaces\IVariableTreeNode.cs" /> 177 179 <Compile Include="Interfaces\IVariableSymbol.cs" /> … … 238 240 <Compile Include="Symbols\AutoregressiveVariable.cs" /> 239 241 <Compile Include="Symbols\Average.cs" /> 240 <Compile Include="Symbols\Num .cs" />241 <Compile Include="Symbols\Num TreeNode.cs" />242 <Compile Include="Symbols\Number.cs" /> 243 <Compile Include="Symbols\NumberTreeNode.cs" /> 242 244 <Compile Include="Symbols\AiryA.cs" /> 243 245 <Compile Include="Symbols\AiryB.cs" /> … … 251 253 <Compile Include="Symbols\CubeRoot.cs" /> 252 254 <Compile Include="Symbols\HyperbolicTangent.cs" /> 253 <Compile Include="Symbols\ RealConstant.cs" />254 <Compile Include="Symbols\ RealConstantTreeNode.cs" />255 <Compile Include="Symbols\Constant.cs" /> 256 <Compile Include="Symbols\ConstantTreeNode.cs" /> 255 257 <Compile Include="Symbols\VariableBase.cs" /> 256 258 <Compile Include="Symbols\VariableTreeNodeBase.cs" /> -
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.