# rexparse

> The easy parser with regular expressions

Latest version **1.0.0** (published 2020-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install rexparse
pnpm add rexparse
yarn add rexparse
bun add rexparse
```

## 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.0 |
| Published | 2020-09-03 |
| First published | 2020-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | YEBISUYA Sugoroku |
| Maintainers | sugoroku-y |

## Links

- npm: https://www.npmjs.com/package/rexparse
- npm.io page: https://npm.io/package/rexparse

## Dependencies (1)

- [rexscan](https://npm.io/package/rexscan.md) ^1.0.2

## Recent versions

- 1.0.0 (latest) — 2020-09-03

## README

# rexparse

正規表現を使った簡易パーザークラスです。

[![Build Status](https://travis-ci.org/sugoroku-y/rexparse.svg?branch=master)](https://travis-ci.org/sugoroku-y/rexparse)
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)

```ts
const jsonParser = new Parser<JsonContext>([
  // null
  [/null/, (_, context) => context.add(null)],
  // 真偽値
  [/true/, (_, context) => context.add(true)],
  [/false/, (_, context) => context.add(false)],
  // 数値
  [
    /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?/g,
    (matched, context) => context.add(+matched),
  ],
  // 文字列
  [
    /"[^"\\]*(?:\\.[^"\\]*)*"/g,
    (matched, context, index) => context.add(dequote(matched, index)),
  ],
  // `[`が来たらコンテキストを配列用に切り替え
  [/\[/, (_, context, index) => new ArrayContext(context, index)],
  // `{`が来たらコンテキストをオブジェクト用に切り替え
  [/\{/, (_, context, index) => new ObjectContext(context, index)],
  // 配列、オブジェクトの終了
  [/\]/, (_, context) => context.closeSquareBracket()],
  [/\}/, (_, context) => context.closeCurlyBracket()],
  // 値の区切り
  [/,/, (_, context) => context.comma()],
  // プロパティ名と値の区切り
  [/:/, (_, context) => context.colon()],
  // 空白文字は無視
  [/\s+/, (_, context) => context],
]);

function JSON_parse(s: string): JSONVALUE {
  return jsonParser.parse(s, new RootContext()).final();
}
```

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