@thomasfosterau/effect-parse
v0.6.2
Published
Parser combinators for Effect, ported from Rust's nom and winnow: text, bytes, bits and token streams, streaming input, compiled parsers and Schema integration
Maintainers
Readme
effect-parse
Parser combinators for Effect, ported from Rust's nom and winnow: text, bytes, bits and token streams, streaming input, compiled parsers, syntax trees and Schema integration.
[!CAUTION] Experimental and pre-1.0, largely written with Claude Code. The API may change between minor versions.
Install
pnpm add @thomasfosterau/effect-parse effecteffect (^4.0.0) is a peer dependency. Every module is on the root entry as a namespace and on its own subpath (@thomasfosterau/effect-parse/Parser, …).
Example
import { Ascii, Parser, Token } from "@thomasfosterau/effect-parse"
const point = Parser.gen(function* () {
yield* Token.literal("(")
const x = yield* Ascii.decInt
yield* Token.literal(",")
const y = yield* Ascii.decInt
yield* Token.literal(")")
return { x, y }
})
Parser.parse(point, "(1,-2)") // Result.succeed({ x: 1, y: -2 })
Parser.parse(point, "(1;-2)") // Result.fail(ParseError): expected digit or ",", found ";" at line 1, column 3Documentation
- Guide: writing, running and compiling parsers, errors, streaming, schemas, Unicode, syntax trees, coming from nom or winnow.
- Architecture: how parsing, compilation, streaming and syntax trees fit together.
- Examples: JSON, arithmetic, INI, HTTP, jq and a ripgrep clone.
- Contributing, security, changelog.
