ESCalc - v0.0.1-beta.2
    Preparing search index...

    Function parse

    • Parse an NCalc expression string into an Abstract Syntax Tree (AST).

      The returned LogicalExpression can be inspected, passed to execute, format, or parameters.

      Parameters

      • expression: string

        The NCalc expression string to parse.

      • OptionalparserOptions: { stopOnFirstError?: boolean }

        Optional parse settings.

      Returns LogicalExpression

      The root node of the parsed AST.

      ParserError If the expression contains syntax errors. The error includes an errors array of individual ParseIssue items, and an incompleteExpression field with a partial AST when stopOnFirstError is false.

      import { parse } from 'escalc';

      const ast = parse('1 + [x] * 2');
      // ast.type === 'binary', ast.operator === 'addition'