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

https://github.com/zachary822/parser-combinator

Javascript Parser Combinator
https://github.com/zachary822/parser-combinator

deno parser typescript

Last synced: about 1 month ago
JSON representation

Javascript Parser Combinator

Awesome Lists containing this project

README

          

# Parser Combinator

Parser combinator implemented in church encoded types.

## Example

The library uses a custom `List` type to represent arrays, strings used by the
parser are lists of characters (`List`). Use `strToList` to convert
string to `List`.

```typescript
const input = strToList("abc");

const parser = stringP(strToList("ab"));

// result contained in a Maybe type
const result = parser(input)(
// default return value if parser doesn't match input
null,
// tuple of remaing input and parse result as javascript strings
(r) => [listToStr(fst(r)), listToStr(snd(r))];
```