XLParser  1.7.2
XLParser.ExcelFormulaParser Class Reference

Excel formula parser
Contains parser and utilities that operate directly on the parse tree, or makes working with the parse tree easier. More...

Static Public Member Functions

static ParseTreeNode Parse (string input)
 Parse a formula, return the the tree's root node More...
 
static ParseTree ParseToTree (string input)
 Parse a formula, return the the tree More...
 
static IEnumerable< ParseTreeNode > AllNodesConditional (this ParseTreeNode root, Predicate< ParseTreeNode > stopAt=null)
 Non-terminal nodes in depth-first pre-order, with a conditional stop More...
 
static IEnumerable< ParseTreeNode > AllNodes (this ParseTreeNode root)
 All non-terminal nodes in depth-first pre-order More...
 
static IEnumerable< ParseTreeNode > AllNodes (this ParseTreeNode root, string type)
 All non-terminal nodes of a certain type in depth-first pre-order More...
 
static ParseTreeNode Parent (this ParseTreeNode child, ParseTreeNode treeRoot)
 Get the parent node of a node More...
 
static string Type (this ParseTreeNode node)
 The node type/name More...
 
static bool Is (this ParseTreeNode pt, string type)
 Check if a node is of a particular type More...
 
static Boolean IsFunction (this ParseTreeNode input)
 Checks whether this node is a function More...
 
static bool IsParentheses (this ParseTreeNode input)
 Whether or not this node represents parentheses "(_)" More...
 
static bool IsBinaryOperation (this ParseTreeNode input)
 
static bool IsBinaryNonReferenceOperation (this ParseTreeNode input)
 
static bool IsBinaryReferenceOperation (this ParseTreeNode input)
 
static bool IsUnaryOperation (this ParseTreeNode input)
 
static bool IsUnaryPrefixOperation (this ParseTreeNode input)
 
static bool IsUnaryPostfixOperation (this ParseTreeNode input)
 
static string GetFunction (this ParseTreeNode input)
 Get the function or operator name of this function call More...
 
static bool MatchFunction (this ParseTreeNode input, string functionName)
 Check if this node is a specific function More...
 
static IEnumerable< ParseTreeNode > GetFunctionArguments (this ParseTreeNode input)
 Get all the arguments of a function or operation More...
 
static bool IsBuiltinFunction (this ParseTreeNode node)
 Checks whether this node is a built-in excel function More...
 
static bool IsIntersection (this ParseTreeNode input)
 Whether or not this node represents an intersection More...
 
static bool IsUnion (this ParseTreeNode input)
 Whether or not this node represents an union More...
 
static bool IsNamedFunction (this ParseTreeNode input)
 Checks whether this node is a function call with name, and not just a unary or binary operation More...
 
static bool IsOperation (this ParseTreeNode input)
 
static bool IsExternalUDFunction (this ParseTreeNode input)
 
static bool IsNumberWithSign (this ParseTreeNode input)
 True if this node presents a number constant with a sign More...
 
static PrefixInfo GetPrefixInfo (this ParseTreeNode prefix)
 Extract all of the information from a Prefix non-terminal More...
 
static ParseTreeNode SkipFormula (this ParseTreeNode input)
 Go to the first non-formula child node More...
 
static IEnumerable< ParseTreeNode > GetReferenceNodes (this ParseTreeNode input)
 Get all child nodes that are references and aren't part of another reference expression More...
 
static IEnumerable< ParserReferenceGetParserReferences (this ParseTreeNode node)
 Gets the ParserReferences from the input parse tree node and its children More...
 
static bool IsRange (this ParseTreeNode input)
 Whether or not this node represents a range More...
 
static ParseTreeNode SkipToRelevant (this ParseTreeNode input, bool skipReferencesWithoutPrefix=false)
 Go to the first "relevant" child node, i.e. skips wrapper nodes More...
 
static string Print (this ParseTreeNode input)
 Pretty-print a parse tree to a string More...
 

Detailed Description

Excel formula parser
Contains parser and utilities that operate directly on the parse tree, or makes working with the parse tree easier.

Member Function Documentation

◆ AllNodes() [1/2]

static IEnumerable<ParseTreeNode> XLParser.ExcelFormulaParser.AllNodes ( this ParseTreeNode  root)
static

All non-terminal nodes in depth-first pre-order

◆ AllNodes() [2/2]

static IEnumerable<ParseTreeNode> XLParser.ExcelFormulaParser.AllNodes ( this ParseTreeNode  root,
string  type 
)
static

All non-terminal nodes of a certain type in depth-first pre-order

◆ AllNodesConditional()

static IEnumerable<ParseTreeNode> XLParser.ExcelFormulaParser.AllNodesConditional ( this ParseTreeNode  root,
Predicate< ParseTreeNode >  stopAt = null 
)
static

Non-terminal nodes in depth-first pre-order, with a conditional stop

Parameters
rootThe root node
stopAtDon't process the children of a node matching this predicate

◆ GetFunction()

static string XLParser.ExcelFormulaParser.GetFunction ( this ParseTreeNode  input)
static

Get the function or operator name of this function call

◆ GetFunctionArguments()

static IEnumerable<ParseTreeNode> XLParser.ExcelFormulaParser.GetFunctionArguments ( this ParseTreeNode  input)
static

Get all the arguments of a function or operation

◆ GetParserReferences()

static IEnumerable<ParserReference> XLParser.ExcelFormulaParser.GetParserReferences ( this ParseTreeNode  node)
static

Gets the ParserReferences from the input parse tree node and its children

5 cases:

  1. ReferenceItem node: convert to ParserReference
  2. Reference node (Prefix ReferenceItem): convert to ParserReference, recursive call on the nodes returned from GetReferenceNodes(node) (to include the references in the arguments of external UDFs)
  3. Range node (Cell:Cell): recursive call to retrieve the 2 limits, create ParserReference of type CellRange
  4. Range node with complex limits: recursive call to retrieve limits as 2 ParserReferences
  5. Other cases (RefFunctionCall, Union, Arguments):recursive call on the nodes returned from GetReferenceNodes(node)

◆ GetPrefixInfo()

static PrefixInfo XLParser.ExcelFormulaParser.GetPrefixInfo ( this ParseTreeNode  prefix)
static

Extract all of the information from a Prefix non-terminal

◆ GetReferenceNodes()

static IEnumerable<ParseTreeNode> XLParser.ExcelFormulaParser.GetReferenceNodes ( this ParseTreeNode  input)
static

Get all child nodes that are references and aren't part of another reference expression

◆ Is()

static bool XLParser.ExcelFormulaParser.Is ( this ParseTreeNode  pt,
string  type 
)
static

Check if a node is of a particular type

◆ IsBuiltinFunction()

static bool XLParser.ExcelFormulaParser.IsBuiltinFunction ( this ParseTreeNode  node)
static

Checks whether this node is a built-in excel function

◆ IsFunction()

static Boolean XLParser.ExcelFormulaParser.IsFunction ( this ParseTreeNode  input)
static

Checks whether this node is a function

◆ IsIntersection()

static bool XLParser.ExcelFormulaParser.IsIntersection ( this ParseTreeNode  input)
static

Whether or not this node represents an intersection

◆ IsNamedFunction()

static bool XLParser.ExcelFormulaParser.IsNamedFunction ( this ParseTreeNode  input)
static

Checks whether this node is a function call with name, and not just a unary or binary operation

◆ IsNumberWithSign()

static bool XLParser.ExcelFormulaParser.IsNumberWithSign ( this ParseTreeNode  input)
static

True if this node presents a number constant with a sign

◆ IsParentheses()

static bool XLParser.ExcelFormulaParser.IsParentheses ( this ParseTreeNode  input)
static

Whether or not this node represents parentheses "(_)"

◆ IsRange()

static bool XLParser.ExcelFormulaParser.IsRange ( this ParseTreeNode  input)
static

Whether or not this node represents a range

◆ IsUnion()

static bool XLParser.ExcelFormulaParser.IsUnion ( this ParseTreeNode  input)
static

Whether or not this node represents an union

◆ MatchFunction()

static bool XLParser.ExcelFormulaParser.MatchFunction ( this ParseTreeNode  input,
string  functionName 
)
static

Check if this node is a specific function

◆ Parent()

static ParseTreeNode XLParser.ExcelFormulaParser.Parent ( this ParseTreeNode  child,
ParseTreeNode  treeRoot 
)
static

Get the parent node of a node

This is an expensive operation, as the whole tree will be searched through

◆ Parse()

static ParseTreeNode XLParser.ExcelFormulaParser.Parse ( string  input)
static

Parse a formula, return the the tree's root node

Parameters
inputThe formula to be parsed.
Exceptions
ArgumentExceptionIf formula could not be parsed
Returns
Parse tree root node

◆ ParseToTree()

static ParseTree XLParser.ExcelFormulaParser.ParseToTree ( string  input)
static

Parse a formula, return the the tree

Parameters
inputThe formula to be parsed.
Exceptions
ArgumentExceptionIf formula could not be parsed
Returns
Parse tree

◆ Print()

static string XLParser.ExcelFormulaParser.Print ( this ParseTreeNode  input)
static

Pretty-print a parse tree to a string

◆ SkipFormula()

static ParseTreeNode XLParser.ExcelFormulaParser.SkipFormula ( this ParseTreeNode  input)
static

Go to the first non-formula child node

◆ SkipToRelevant()

static ParseTreeNode XLParser.ExcelFormulaParser.SkipToRelevant ( this ParseTreeNode  input,
bool  skipReferencesWithoutPrefix = false 
)
static

Go to the first "relevant" child node, i.e. skips wrapper nodes

Parameters
inputThe input parse tree node
skipReferencesWithoutPrefixIf true, skip all reference nodes without a prefix instead of only parentheses

Skips:

  • FormulaWithEq and ArrayFormula nodes
  • Formula nodes
  • Parentheses
  • Reference nodes which are just wrappers

◆ Type()

static string XLParser.ExcelFormulaParser.Type ( this ParseTreeNode  node)
static

The node type/name


The documentation for this class was generated from the following file: