Function serializeParsedExprAST

  • Serialize a parsed expression into its string representation.

    Parameters

    • parsedExpr: ExprAST

      The parsed expression in a JSON format.

    • needsParens: boolean = false

      Whether the expression needs to be wrapped in parentheses.

    Returns string

    The string representation of the parsed expression.

    Note

    Could be clever and remove unnecessary parentheses, for example: (A + B) + C -> A + B + C

    Example

    serializeParsedExprAST(
    { '+': [{ variable: "A" }, { constant: { type: "number", nodeValue: "10" } }] },
    true
    )
    // "(A + 10)"

Generated using TypeDoc