MCluck90 / parsnip-ts

Parser combinators built in, and for, TypeScript

Home Page:http://mcluck.tech/parsnip-ts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🌱 Parsnip-ts

Parser combinators written in and for TypeScript.

Getting Started

Installation

npm install parsnip-ts

Example

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.

About

Parser combinators built in, and for, TypeScript

http://mcluck.tech/parsnip-ts/

License:MIT License


Languages

Language:TypeScript 87.8%Language:Handlebars 9.9%Language:JavaScript 1.3%Language:CSS 1.0%