unist-formula-ast
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

unist-formula-ast

version download

Excel formula ast to implement unist specification.


unist-formula-ast is a specification for representing Excel Formula in a syntax tree.

If you want to know how to use unist-formula-ast directly, read Getting Started!

Introduction

This document defines a format for abstract syntax tree. Development of unist-formula-ast started in May 2024. This specification is written in a Web IDL-like TypeScript grammar.

Where this specification fits

Types

If you are using TypeScript, you can use the unist types by installing them with npm:

npm install unist-formula-ast

Nodes(abstract)

BasicNode

interface IBasicNode {
  type: BasicNodeType | BasicCalculationNodeType
  value?: string | number
  position: IBasicNodePosition
  children?: IBasicNode[]
}

Nodes

BasicCalculationNode

type BasicCalculationNodeType =
  | "Addition"
  | "Subtraction"
  | "Multiplication"
  | "Division"

interface IBasicCalculationNode extends IBasicNode {
  type: BasicCalculationNodeType
  children: IBasicNode[]
}

NumberNode

interface INumberNode extends IBasicNode {
  type: "Number"
  value: number
}

VariableNode

interface IVariableNode extends IBasicNode {
  type: "Variable"
  value: string
}

FuntionCallNode

interface IFuntionCallNode extends IBasicNode {
  type: "Function"
  value: string
  children: FuntionCallArgumentType[]
}

Want to know more definitions for unist-formula-ast, see src/types.ts

References

  • Peggy: The parser of unist-formula-ast is generated by this project.
  • unist: The specification of unist-formula-ast is based on this project.

LICENSE

MIT © Herbert He

Package Sidebar

Install

npm i unist-formula-ast

Weekly Downloads

4

Version

1.4.1

License

MIT

Unpacked Size

57.7 kB

Total Files

5

Last publish

Collaborators

  • herberthe