Documentation
¶
Index ¶
- Constants
- Variables
- type AnyClosure
- type BinaryExpressionNode
- type CType
- type CVal
- type Cell
- type CellNode
- type CellRangeNode
- type Context
- type Formula
- type FunctionNode
- type LogicalNode
- type Node
- type NodeJSON
- type NodeType
- type NumberNode
- type Range
- type RawSheet
- type Sheet
- type ShuntingYard
- type TextNode
- type Token
- type TokenStream
- type TokenStreamImpl
- func (ts *TokenStreamImpl) Consume() error
- func (ts *TokenStreamImpl) GetNext() Token
- func (ts *TokenStreamImpl) NextIs(ttype string, tsubtype string) bool
- func (ts *TokenStreamImpl) NextIsBinaryOperator() bool
- func (ts *TokenStreamImpl) NextIsCell() bool
- func (ts *TokenStreamImpl) NextIsEndOfFunctionCall() bool
- func (ts *TokenStreamImpl) NextIsFunctionArgumentSeparator() bool
- func (ts *TokenStreamImpl) NextIsFunctionCall() bool
- func (ts *TokenStreamImpl) NextIsLogical() bool
- func (ts *TokenStreamImpl) NextIsNumber() bool
- func (ts *TokenStreamImpl) NextIsOpenParen() bool
- func (ts *TokenStreamImpl) NextIsPostfixOperator() bool
- func (ts *TokenStreamImpl) NextIsPrefixOperator() bool
- func (ts *TokenStreamImpl) NextIsRange() bool
- func (ts *TokenStreamImpl) NextIsTerminal() bool
- func (ts *TokenStreamImpl) NextIsText() bool
- func (ts *TokenStreamImpl) Position() int
- type UnaryExpressionNode
- type ValueNode
- type Workbook
Constants ¶
const CTBool = xl.CTBool
const CTEmpty = xl.CTEmpty
const CTFormula = xl.CTFormula
const CTNumber = xl.CTNumber
const CTString = xl.CTString
Variables ¶
var IsCommutative = map[string]bool{ " ": true, ",": false, "^": false, "*": true, "/": false, "+": true, "-": false, "&": false, "=": true, "<>": true, "<=": false, ">=": false, ">": false, "<": false, }
IsCommutative is a map of binary operators to whether they are commutative. True if A OP B == B OP A False if A OP B != B OP A
var PrecedenceMap = map[string]int{
" ": 8,
",": 8,
"^": 5,
"*": 4,
"/": 4,
"+": 3,
"-": 3,
"&": 2,
"=": 1,
"<>": 1,
"<=": 1,
">=": 1,
">": 1,
"<": 1,
}
PrecedenceMap is a map of binary operators to their precedence. It lets us know which operators should be evaluated first.
Functions ¶
This section is empty.
Types ¶
type AnyClosure ¶
type AnyClosure func() error
type BinaryExpressionNode ¶
type BinaryExpressionNode struct {
Operator string `json:"operator"`
Left Node `json:"left"`
Right Node `json:"right"`
}
func (BinaryExpressionNode) Children ¶
func (b BinaryExpressionNode) Children() []Node
func (BinaryExpressionNode) IsEq ¶
func (b BinaryExpressionNode) IsEq(node Node) bool
func (BinaryExpressionNode) Type ¶
func (b BinaryExpressionNode) Type() NodeType
type CellRangeNode ¶
type CellRangeNode struct {
// Make sure that start and end are in the same sheet!
Start CellNode `json:"startCell"`
End CellNode `json:"endCell"`
}
func (CellRangeNode) Children ¶
func (c CellRangeNode) Children() []Node
func (CellRangeNode) IsEq ¶
func (c CellRangeNode) IsEq(n Node) bool
func (CellRangeNode) Range ¶
func (c CellRangeNode) Range() Range
func (CellRangeNode) Type ¶
func (c CellRangeNode) Type() NodeType
type Formula ¶
func ShiftFormula
deprecated
Shifts a formula from one cell to another, inside the same sheet.
Deprecated: This is very slow, since we now do it in three steps: 1. Parse the formula into a tree. 2. Shift the tree. 3. Serialize the tree back into a formula. Use Parse/ShiftNode/MoveNode/StringifyNode instead depending on your needs.
func StringifyNode ¶
type FunctionNode ¶
func (FunctionNode) Children ¶
func (c FunctionNode) Children() []Node
func (FunctionNode) IsEq ¶
func (f FunctionNode) IsEq(n Node) bool
func (FunctionNode) Type ¶
func (f FunctionNode) Type() NodeType
type LogicalNode ¶
type LogicalNode struct {
Value bool `json:"value"`
}
func (LogicalNode) Children ¶
func (l LogicalNode) Children() []Node
func (LogicalNode) IsEq ¶
func (l LogicalNode) IsEq(node Node) bool
func (LogicalNode) String ¶
func (l LogicalNode) String() string
func (LogicalNode) Type ¶
func (l LogicalNode) Type() NodeType
type Node ¶
Node is the interface that all nodes in the AST implement. It represent a node such as a SUM function, a cell reference, a + binary expression, etc.
func BuildTree ¶
BuildTree takes a slice of tokens and returns a Node representing the formula root. The context parameter is used to resolve relative cell references, and contains the current sheet name, and other context information necessary.
type NodeJSON ¶
func ToNodeJson ¶
type NumberNode ¶
type NumberNode struct {
Value float64 `json:"value"`
}
func (NumberNode) Children ¶
func (n NumberNode) Children() []Node
func (NumberNode) IsEq ¶
func (n NumberNode) IsEq(node Node) bool
func (NumberNode) String ¶
func (n NumberNode) String() string
func (NumberNode) Type ¶
func (n NumberNode) Type() NodeType
type ShuntingYard ¶
type ShuntingYard = shuntingyard.ShuntingYardState[Node]
type TokenStream ¶
type TokenStream interface {
Consume() error
GetNext() Token
NextIs(ttype string, tsubtype string) bool
NextIsOpenParen() bool
NextIsTerminal() bool
NextIsFunctionCall() bool
NextIsFunctionArgumentSeparator() bool
NextIsEndOfFunctionCall() bool
NextIsBinaryOperator() bool
NextIsPrefixOperator() bool
NextIsPostfixOperator() bool
NextIsRange() bool
NextIsCell() bool
NextIsNumber() bool
NextIsText() bool
NextIsLogical() bool
Position() int
}
func NewTokenStream ¶
func NewTokenStream(tokens []Token) TokenStream
type TokenStreamImpl ¶
type TokenStreamImpl struct {
// contains filtered or unexported fields
}
func (*TokenStreamImpl) Consume ¶
func (ts *TokenStreamImpl) Consume() error
func (*TokenStreamImpl) GetNext ¶
func (ts *TokenStreamImpl) GetNext() Token
func (*TokenStreamImpl) NextIs ¶
func (ts *TokenStreamImpl) NextIs(ttype string, tsubtype string) bool
func (*TokenStreamImpl) NextIsBinaryOperator ¶
func (ts *TokenStreamImpl) NextIsBinaryOperator() bool
func (*TokenStreamImpl) NextIsCell ¶
func (ts *TokenStreamImpl) NextIsCell() bool
func (*TokenStreamImpl) NextIsEndOfFunctionCall ¶
func (ts *TokenStreamImpl) NextIsEndOfFunctionCall() bool
func (*TokenStreamImpl) NextIsFunctionArgumentSeparator ¶
func (ts *TokenStreamImpl) NextIsFunctionArgumentSeparator() bool
func (*TokenStreamImpl) NextIsFunctionCall ¶
func (ts *TokenStreamImpl) NextIsFunctionCall() bool
func (*TokenStreamImpl) NextIsLogical ¶
func (ts *TokenStreamImpl) NextIsLogical() bool
func (*TokenStreamImpl) NextIsNumber ¶
func (ts *TokenStreamImpl) NextIsNumber() bool
func (*TokenStreamImpl) NextIsOpenParen ¶
func (ts *TokenStreamImpl) NextIsOpenParen() bool
func (*TokenStreamImpl) NextIsPostfixOperator ¶
func (ts *TokenStreamImpl) NextIsPostfixOperator() bool
func (*TokenStreamImpl) NextIsPrefixOperator ¶
func (ts *TokenStreamImpl) NextIsPrefixOperator() bool
func (*TokenStreamImpl) NextIsRange ¶
func (ts *TokenStreamImpl) NextIsRange() bool
func (*TokenStreamImpl) NextIsTerminal ¶
func (ts *TokenStreamImpl) NextIsTerminal() bool
func (*TokenStreamImpl) NextIsText ¶
func (ts *TokenStreamImpl) NextIsText() bool
func (*TokenStreamImpl) Position ¶
func (ts *TokenStreamImpl) Position() int
type UnaryExpressionNode ¶
func (UnaryExpressionNode) Children ¶
func (u UnaryExpressionNode) Children() []Node
func (UnaryExpressionNode) IsEq ¶
func (u UnaryExpressionNode) IsEq(node Node) bool
func (UnaryExpressionNode) Type ¶
func (u UnaryExpressionNode) Type() NodeType