Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/herberthe/unist-formula-ast

Excel formula ast to implement unist specification
https://github.com/herberthe/unist-formula-ast

Last synced: about 2 months ago
JSON representation

Excel formula ast to implement unist specification

Awesome Lists containing this project

README

        

# unist-formula-ast

[![version](https://img.shields.io/npm/v/unist-formula-ast.svg)](https://www.npmjs.com/package/unist-formula-ast)
[![download](https://img.shields.io/npm/dm/unist-formula-ast.svg)](https://www.npmjs.com/package/unist-formula-ast)

Excel formula ast to implement unist specification.

****

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

If you want to know how to use *unist-formula-ast* directly, read [Getting Started](./getting-started.md)!

## Introduction

This document defines a format for [abstract syntax tree][unist]. Development of unist-formula-ast started in May 2024. This specification is written in a ~~[Web IDL][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:

```sh
npm install unist-formula-ast
```

## Nodes(abstract)

### `BasicNode`

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

## Nodes

### `BasicCalculationNode`

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

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

### `NumberNode`

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

### `VariableNode`

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

### `FuntionCallNode`

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

Want to know more definitions for *unist-formula-ast*, see [src/types.ts](./src/types.ts)

## References

- [Peggy](https://github.com/peggyjs/peggy): The parser of unist-formula-ast is generated by this project.
- [unist](https://github.com/syntax-tree/unist): The specification of unist-formula-ast is based on this project.

## LICENSE

MIT © Herbert He

[unist]: https://github.com/syntax-tree/unist#syntax-tree

[web-idl]: https://heycam.github.io/webidl/