substituteInParsedExpr
API / @publicodes/tools / index / substituteInParsedExpr
function substituteInParsedExpr(
parsedExpr,
variableName,
constValue): ExprAST
Defined in: commons.ts:229
Replace all occurences [variableName] node with the corresponding [constValue] node.
Parameters
Parameter | Type | Description |
---|---|---|
parsedExpr | ExprAST | The parsed expression in a JSON format. |
variableName | string | The name of the variable to replace. |
constValue | string | The value to replace the variable with. |
Returns
ExprAST
The parsed expression with all occurences of [VariableNode] with the corresponding [ConstantNode].
Example
substituteIn(
{ variable: "A" },
"A",
"10",
"ruleA"
)
// { constant: { type: "number", nodeValue: "10" } }