# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.bendscript.com/syntax-library.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
