Constructor
new Formula(formula)
Creates a math formula object.
Parameters:
Name | Type | Description |
---|---|---|
formula |
string | A mathematical formula to parse.y |
- Source:
Members
(static) operatorMapping :object.<string, string>
List of supported operators.
All operators must have the parameters be name x and y.
The key is the mathematical operator, the value is the process identifier.
Type:
- object.<string, string>
- Source:
(nullable) builder :Builder
Type:
- Source:
tree :object.<string, *>
Type:
- object.<string, *>
- Source:
Methods
addOperatorProcess(operator, left, right) → {BuilderNode}
Adds a process node for an operator like +, -, *, / etc.
Parameters:
Name | Type | Description |
---|---|---|
operator |
string | The operator. |
left |
number | object.<string, *> | The left part for the operator. |
right |
number | object.<string, *> | The right part for the operator. |
- Source:
Throws:
Returns:
- Type
- BuilderNode
generate(setResultNode) → {BuilderNode}
Generates the processes for the formula specified in the constructor.
Returns the last node that computes the result.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
setResultNode |
boolean | true | Set the |
- Source:
Throws:
Returns:
- Type
- BuilderNode
(protected) getRef(value) → {*}
Gets the reference for a value, e.g. from_node or from_parameter.
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
- Source:
Returns:
- Type
- *
(protected) parseTree(tree) → {object.<string, *>}
Walks through the tree generated by the TapDigit parser and generates process nodes.
Parameters:
Name | Type | Description |
---|---|---|
tree |
object.<string, *> |
- Source:
Throws:
Returns:
- Type
- object.<string, *>
setBuilder(builder)
The builder instance to use.
Parameters:
Name | Type | Description |
---|---|---|
builder |
Builder | The builder instance to add the formula to. |
- Source: