Skip to content

Commit e6666b6

Browse files
authored
Revise syntax format to syntax tree
Updated syntax section to reflect changes in structure and details.
1 parent 6df714b commit e6666b6

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,24 @@ fn({}) // 120
6161
See [docs](./docs.md#presets) for full description.
6262

6363

64-
## Syntax format
64+
## Syntax tree
6565

66-
Expressions parse to a minimal JSON-compatible syntax tree:
66+
Expressions parse to simplified lispy tree structure, opposed to ESTree:
67+
68+
- language-agnostic, can be compiled to different targets
69+
- reflects execution sequence, rather than code layout
70+
- has minimal overhead, directly maps to operators
71+
- simplifies manual evaluation and debugging
72+
- has conventional form and one-liner docs
73+
- JSON-compatible
6774

6875
```js
6976
import { parse } from 'subscript'
7077

7178
parse('a + b * 2')
7279
// ['+', 'a', ['*', 'b', [, 2]]]
73-
```
74-
75-
Three forms:
7680

77-
```js
81+
// node kinds
7882
'x' // identifier — resolve from context
7983
[, value] // literal — return as-is (empty slot = data)
8084
[op, ...args] // operation — apply operator
@@ -83,6 +87,7 @@ Three forms:
8387
See [spec.md](./spec.md).
8488

8589

90+
8691
## Extension
8792

8893
Add operators, literals or custom syntax:

0 commit comments

Comments
 (0)