Esempio n. 1
0
        private int OperatorDepth(ParseTreeNode node, ISet <string> operators = null)
        {
            // Get the maximum depth of the childnodes
            int depth = node.ChildNodes.Count == 0 ? 0 : node.ChildNodes.Max(n => OperatorDepth(n, operators));

            // If this is one of the target functions, increase depth by 1
            if (node.IsFunction() &&
                (operators == null || operators.Contains(node.GetFunction())))
            {
                depth++;
            }

            return(depth);
        }
Esempio n. 2
0
 /// <summary>
 /// Checks whether this node is a built-in excel function
 /// </summary>
 public static bool IsBuiltinFunction(this ParseTreeNode node)
 {
     return(node.IsFunction() &&
            (node.ChildNodes[0].Is(GrammarNames.FunctionName) || node.ChildNodes[0].Is(GrammarNames.RefFunctionName)));
 }
Esempio n. 3
0
 public static bool IsUnaryPostfixOperation(this ParseTreeNode input)
 {
     return(input.IsFunction() &&
            input.ChildNodes.Count == 2 &&
            input.ChildNodes[1].Term.Flags.HasFlag(TermFlags.IsOperator));
 }
Esempio n. 4
0
        private int OperatorDepth(ParseTreeNode node, ISet<string> operators = null)
        {
            // Get the maximum depth of the childnodes
            int depth = node.ChildNodes.Count == 0 ? 0 : node.ChildNodes.Max(n => OperatorDepth(n, operators));

            // If this is one of the target functions, increase depth by 1
            if(node.IsFunction()
               && (operators == null || operators.Contains(node.GetFunction())))
            {
                depth++;
            }

            return depth;
        }
Esempio n. 5
0
 /// <summary>
 /// Checks whether this node is a built-in excel function
 /// </summary>
 public static bool IsBuiltinFunction(this ParseTreeNode node)
 {
     return(node.IsFunction() && (node.Is(GrammarNames.ExcelFunction) || node.Is(GrammarNames.ReferenceFunction)));
 }