> For the complete documentation index, see [llms.txt](https://www.bendscript.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.bendscript.com/syntax-library.md).

# SYNTAX LIBRARY

BendScript is to be coded with a node package manager library imported and surrounded by redaction marks at the top of each script in order to use the advanced parts of the language syntax such as bend and fold.\
\
Links to resources:

* <https://www.npmjs.com/package/bendscript>
* <https://www.bendscript.com/language-syntax>
* <https://www.bendscript.com/language-syntax/redact>

Using the syntax library:

{% code title="terminal:" %}

```bash
# start project
npm init -y

# get syntax library
npm install bendscript
```

{% endcode %}

{% code title="touch ./example-syntax-in.bs" %}

```typescript
/*{*/
  import { type, recursive } from 'bendscript';
/*}*/

// a binary tree
type.loop(`MyTree`)
  .branch(`Node`, [
      'val', 
      recursive('left'),
      recursive('right'),
  ])
  .branch(`Leaf`, [])
```

{% endcode %}

{% code title="terminal:" %}

```bash
# run transpiler
telebend -i ./example-syntax-in.bs -o ./example-syntax-out.bend
```

{% endcode %}

{% code title="cat ./example-syntax-out.bs" %}

```python
# a binary tree
type MyTree:
  Node { val, ~left, ~right }
  Leaf
```

{% endcode %}
