@ikasoba000/daizu

0.3.0 • Public • Published

٩(๑òωó๑)۶

@ikasoba000/daizu

daizu is simple parser combinator library.

installation

pnpm i @ikasoba000/daizu

Hello, world!

import * as D from "@ikasoba000/daizu";

const parser = D.string("Hello, world!");

D.parse(parser, "Hello, world!"); // "Hello, world!"

const parser = D.regexp(/Hello, \w+!/);

D.parse(parser, "Hello, daizu!"); // "Hello, daizu!"

const parser = D.regexp(/Hello, (\w+)!/);

D.parse(parser, "Hello, daizu!"); // "daizu"

daizu/helper

import D from "@ikasoba000/daizu/helper";

D.string("a").many1(); // Matches aaaaaaaaaaaaaa...

const parser =
  D.choice(
    D.regexp(/[a-zA-Z]/).map(x => x.toLowerCase()),
    D.regexp(/\s*/).ignore()
  )
  .many0();

parser.parse("a b \n c    d e\n f") // "a", "b", "c", "d", "e", "f"

Package Sidebar

Install

npm i @ikasoba000/daizu

Weekly Downloads

2

Version

0.3.0

License

MIT

Unpacked Size

12.2 kB

Total Files

21

Last publish

Collaborators

  • ikasoba000