Ejemplo n.º 1
0
        public virtual LexemVariable Calculate(LexemFunction function)
        {
            if (this.OnFunctionCalculation != null)
                return this.OnFunctionCalculation(function);

            return null;
        }
Ejemplo n.º 2
0
        public static new LexemFunction Parse(ref string text)
        {
            if (String.IsNullOrWhiteSpace(text))
                return null;

            text = text.Trim();

            Match match = Regex.Match(text, $"^(?<name>{FunctionNamePattern})\\s*\\(");
            if (!match.Success)
                return null;

            var functionName = match.Groups["name"].Value;
            if (String.IsNullOrEmpty(functionName))
                return null;

            int closeBracketIndex = text.Find(new char[] { ')' }, match.Value.Length, LexemBracket.Brackets);
            if (closeBracketIndex < 0)
                return null;

            try
            {
                var result = new LexemFunction(text.Substring(0, closeBracketIndex + 1));

                text = text.Crop(closeBracketIndex + 1);

                return result;
            }
            catch
            {
                return null;
            }
        }