# happy-parser

> Package for easy parsing using a monadic parser combinator

Latest version **1.0.25** (published 2016-12-18) · GPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install happy-parser
pnpm add happy-parser
yarn add happy-parser
bun add happy-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.25 |
| Published | 2016-12-18 |
| First published | 2016-10-29 |
| Weekly downloads | 0 |
| License | GPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | AgustinCB |
| Maintainers | agustincb |
| Keywords | nomads, parser, combinator |

## Links

- npm: https://www.npmjs.com/package/happy-parser
- Repository: https://github.com/AgustinCB/happy-parser
- Homepage: https://github.com/AgustinCB/happy-parser#readme
- Issues: https://github.com/AgustinCB/happy-parser/issues
- npm.io page: https://npm.io/package/happy-parser

## Recent versions

- 1.0.25 (latest) — 2016-12-18
- 1.0.23 — 2016-12-18
- 1.0.22 — 2016-12-18
- 1.0.21 — 2016-12-18
- 1.0.20 — 2016-12-17
- 1.0.19 — 2016-12-17
- 1.0.16 — 2016-12-15
- 1.0.15 — 2016-12-14
- 1.0.14 — 2016-12-09
- 1.0.13 — 2016-11-11
- 1.0.12 — 2016-11-09
- 1.0.11 — 2016-11-07
- 1.0.10 — 2016-11-07
- 1.0.9 — 2016-11-07
- 1.0.8 — 2016-11-05
- … 8 more at https://npm.io/package/happy-parser/versions

## README

# Node parser combinator
[![travis-ci](https://api.travis-ci.org/AgustinCB/happy-parser.png?branch=master)](https://travis-ci.org/AgustinCB/docker-api)

Immutable monadic parser combinator for node javascript.

## Example

```javascript
const parsec = require('happy-parser');

const sum = (x, y) => x + y, 
      rest = (x, y) => x - y

const
  termOperations = parsec.Parser.operations([ parsec.char('+'), sum ], [ parsec.char('-'), rest ]).trim(),
  factorOperations = parsec.Parser.operations([ parsec.char('^'), Math.pow.bind() ]).trim()

const factor = parsec.lazy(() => 
            parsec.int.or(expr.between(parsec.char('('), parsec.char(')'))).trim()
          ),
      term = parsec.lazy(() => factor.chainRight(factorOperations)),
      expr = term.chain(termOperations).trim()

console.log(expr.parse(' 3^2 + (4 - 7) '))
```

Check also the [documentation](https://github.com/AgustinCB/happy-parser/tree/master/docs) and [tests](https://github.com/AgustinCB/happy-parser/tree/master/test)

---
_Source: https://npm.io/package/happy-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
