Function substituteInParsedExpr

  • Replace all occurences [variableName] node with the corresponding [constValue] node.

    Parameters

    • 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" } }

Generated using TypeDoc