Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mcluck90/parsnip-ts

Parser combinators built in, and for, TypeScript
https://github.com/mcluck90/parsnip-ts

parser-combinators parsing typescript

Last synced: 4 days ago
JSON representation

Parser combinators built in, and for, TypeScript

Awesome Lists containing this project

README

        

# 🌱 Parsnip-ts

Parser combinators written in and for TypeScript.

## Getting Started

### Installation

```sh
npm install parsnip-ts
```

### Example

```ts
import { list, text } from 'parsnip-ts'
import { integer } from 'parsnip-ts/numbers'
import { ws } from 'parsnip-ts/whitespace'

const array = text('[')
.and(list(integer, ws.and(text(',').and(ws)))
.bind(integers =>
text(']').map(() => integers)
)

array.parseToEnd('[1, 2, 3]') // [1, 2, 3]
```

For a more thorough example, check out the [examples folder.](https://github.com/MCluck90/parsnip-ts/tree/main/examples)