# rena-js

> recursion notation API

Latest version **0.1.0** (published 2020-02-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install rena-js
pnpm add rena-js
yarn add rena-js
bun add rena-js
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-02-29 |
| First published | 2018-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 71 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yuichiro MORIGUCHI |
| Maintainers | ymoriguchi |
| Keywords | rena-js, parser, matcher |

## Links

- npm: https://www.npmjs.com/package/rena-js
- Repository: https://github.com/y-moriguchi/rena-js
- Homepage: https://github.com/y-moriguchi/rena-js#readme
- Issues: https://github.com/y-moriguchi/rena-js/issues
- npm.io page: https://npm.io/package/rena-js

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2020-02-29
- 0.0.1 — 2018-08-14
- 0.0.0 — 2018-03-17

## README

# Rena.js
Rena.js is a library of parsing texts. Rena.js makes parsing text easily.  
Rena.js can treat recursion of pattern, hence Rena.js can parse languages which described top down parsing
like arithmetic expressions and so on.  
Rena.js can also treat synthesized and inherited attributes.  
'Rena' is an acronym of REpetation (or REcursion) Notation API.  

## How to use

### node.js
Install Rena.js:
```
npm install rena-js
```

Use module:
```js
var R = require('rena-js');
```

### Browser
```html
<script src="rena.js"></script>
```

## Examples

### Parsing CSV texts
```js
var csvparser = R.t(
  R.attr([]).maybe(
    R.delimitArray(
      R.delimitArray(R.or(
        R('"').t(/(""|[^"])+/, function(x) { return x.replace('""', '"'); }).t('"'),
        R(/[^",\n\r]+/, R.I)), ","), R.br())))
  .maybe(R.br())
  .isEnd();

// outputs [["a","b","c"],["d","e\n\"f","g"],["h"]]
console.log(csvparser.parse('a,b,c\nd,"e\n""f",g\nh\n').attribute)
```

### Parsing simple arithmetic expressions
```js
var expr = R.Yn(function(t, f, e) {
  return R.t(f).maybe(R.or(
    R.t("+").t(f, function(x, a, b) { return b + a; }),
    R.t("-").t(f, function(x, a, b) { return b - a; })));
  },
function(t, f, e) {
  return R.t(e).maybe(R.or(
    R.t("*").t(e, function(x, a, b) { return b * a; }),
    R.t("/").t(e, function(x, a, b) { return b / a; })));
},
function(t, f, e) {
  return R.or(R.thenInt(/[0-9]+/), R.t("(").t(t).t(")"))
}).isEnd();

// outputs 7
console.log(expr.parse("1+2*3").attribute);

// outputs 1
console.log(ptn1.parse("4-6/2").attribute);
```

## Document
[A document of Rena.js is here.](http://rena.morilib.net)

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