/// <summary> /// Initializes a new instance of the <see cref="AnalysisValueIntermediateResultWithFormula"/> class. /// </summary> /// <param name="functionFormula">Function formula</param> /// <param name="arguments">Arguments</param> /// <param name="rowContext">Row context</param> /// <param name="valueContext">Value context</param> public AnalysisValueIntermediateResultWithFormula(AnalysisFunctionFormula functionFormula, List <object> arguments, AnalysisProcessingQueryResultRowExecutionContext rowContext, AnalysisProcessingValueExecutionContext valueContext) : base(functionFormula.FormulaFunction) { this.Arguments = arguments; this.Formula = functionFormula; this.RowContext = rowContext; this.ValueContext = valueContext; this.Complete = false; }
private AnalysisFunctionFormulaParseResult Parse(AnalysisParserString parserString) { List <object> argumentArray; int nextArgumentIndex; string javascriptFormula; if (parserString.CurrentString?.StartsWith("$") ?? false) { AnalysisFunctionFormulaParseResult result = this.ParseVariable(parserString); if (result.Result == null || parserString.Complete || parserString.NextCharacter() == ')') { return(result); } argumentArray = new List <object> { result.Result }; javascriptFormula = "v[0]"; nextArgumentIndex = 1; } else { javascriptFormula = string.Empty; nextArgumentIndex = 0; argumentArray = new List <object>(); } int bracketCount = 0; string copyString; int copyPos = parserString.CurrentPos; AnalysisFunctionFormulaParseResult parseResult; var builder = new StringBuilder(); builder.Append(javascriptFormula); while (!parserString.Complete) { switch (parserString.NextCharacter()) { case '(': bracketCount++; parserString.SkipChar(); break; case ')': if (bracketCount == 0) { copyString = parserString.StringFromPos(copyPos); if (copyString?.Length > 0) { builder.Append(copyString); } var function = new AnalysisFunctionFormula(javascriptFormula, argumentArray, this.Analysis); if (function != null) { return(new AnalysisFunctionFormulaParseResult(function)); } return(new AnalysisFunctionFormulaParseResult("function not supported")); } else { parserString.SkipChar(); } bracketCount--; break; case '$': copyString = parserString.StringFromPos(copyPos); if (copyString?.Length > 0) { builder.Append(copyString); } parseResult = this.ParseVariable(parserString); if (parseResult.Error != null) { return(parseResult); } builder.Append($"v[{nextArgumentIndex++}]"); argumentArray.Add(parseResult.Result); copyPos = parserString.CurrentPos; break; default: parserString.SkipChar(); break; } } javascriptFormula = builder.ToString(); if (bracketCount > 0) { return(new AnalysisFunctionFormulaParseResult("missing closing bracket")); } copyString = parserString.StringFromPos(copyPos); if (copyString?.Length > 0) { builder.Append(copyString); } AnalysisFunctionFormula function1 = new AnalysisFunctionFormula(javascriptFormula, argumentArray, this.Analysis); if (function1 != null) { return(new AnalysisFunctionFormulaParseResult(function1)); } return(new AnalysisFunctionFormulaParseResult("function not supported")); }