Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ikasoba/daizu.ts

daizu.ts is simple parser combinator.
https://github.com/ikasoba/daizu.ts

Last synced: 6 days ago
JSON representation

daizu.ts is simple parser combinator.

Awesome Lists containing this project

README

        



٩(๑òωó๑)۶



@ikasoba000/daizu












daizu is simple parser combinator library.

# installation

```
pnpm i @ikasoba000/daizu
```

# Hello, world!

```ts
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

```ts
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"
```