Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Feb 17, 2024
1 parent aed8d51 commit a348eaf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,32 @@ fn = compile(tree)
fn({ a: {b: 1}, c: 2 }) // 3
```

## Syntax Tree
### Syntax Tree

AST has simplified lispy tree structure (inspired by [frisk](https://ghub.io/frisk) / [nisp](https://github.com/ysmood/nisp)), opposed to [ESTree](https://github.com/estree/estree):

* not limited to particular language (JS), can be compiled to different targets;
* reflects execution sequence, rather than code layout;
* has minimal overhead, directly maps to operators;
* simplifies manual evaluation and debugging;
* has conventional form and one-line docs:
* has conventional form and one-liner docs:

```js
import { compile } from 'subscript.js'

const fn = compile(['+', ['*', 'min', [,60]], [,'sec']])

fn({min: 5}) // min*60 + "sec" == "300sec"
```

### Node kinds:

* `['∘', a]` - unary prefix or postfix operator
* `['∘', a, b]` - binary operator
* `['∘', a, b, c]` n-ary operator
* `[, a]` - literal value
* `a` - variable (from scope)


## Extending

_Subscript_ provides pluggable language [features](./features) and API to customize syntax:
Expand Down

0 comments on commit a348eaf

Please sign in to comment.