From 038ac01d5cf6f1d751448a8693fdb5caf5acd460 Mon Sep 17 00:00:00 2001 From: fcrozatier Date: Wed, 18 Jun 2025 15:38:10 +0200 Subject: [PATCH 1/3] fix docs --- README.md | 10 ++++++---- mod.ts | 19 ++++++++++++++++++- src/combinators/alternation/alt.ts | 2 +- src/combinators/recursion/mod.ts | 6 ++++++ src/core/types.ts | 2 -- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 51670e6..c47cfb4 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,18 @@ # Monarch -Monarch is a full-featured type-safe parser combinator library with: +Monarch is a clean, composable parser combinator library that makes building parsers feel natural and expressive: -- Precise error messages reports with position +- Clean & readable API +- Type-safe parsing +- Precise error reports with position +- Support for custom error messages - Support for ambiguous grammars - Support for context-sensitive grammars - Support for left-recursive grammars with [fold](#foldl-and-foldr) and [lazy evaluation](#lazy-evaluation) -- Full type-safety -Easily build an error-reporting parser by combining, extending and customizing +Easily build error-reporting parsers by combining, extending and customizing the provided base parsers and their error messages. ## Table of content diff --git a/mod.ts b/mod.ts index abe3606..054e6d0 100644 --- a/mod.ts +++ b/mod.ts @@ -1,5 +1,20 @@ /** - * Build parsers by composing structural combinators and chaining semantic refinements + * ## Features + * + * - Clean & readable API + * - Type-safe parsing + * - Precise error reports with position + * - Support for custom error messages + * - Support for ambiguous grammars + * - Support for context-sensitive grammars + * - Support for left-recursive grammars with fold and lazy evaluation + * + * Easily build error-reporting parsers by combining, extending and customizing +the provided base parsers and their error messages. + * + * ## Structural Combinators & Semantic Refinements + * + * To build parsers with Monarch you compose structural combinators and chain semantic refinements. * * Combinators describe your grammar with function composition: * @@ -16,6 +31,8 @@ * - [mapping](https://jsr.io/@fcrozatier/monarch/doc/~/Parser.prototype.map) * - [skipping](https://jsr.io/@fcrozatier/monarch/doc/~/Parser.prototype.skipTrailing) * + * ## Guide + * * For a introductory walkthrough of the various combinators, see the following [guide](https://github.com/fcrozatier/monarch?tab=readme-ov-file#getting-started-guide) * * @module diff --git a/src/combinators/alternation/alt.ts b/src/combinators/alternation/alt.ts index 6dfe19b..9a7a421 100644 --- a/src/combinators/alternation/alt.ts +++ b/src/combinators/alternation/alt.ts @@ -7,7 +7,7 @@ import { sortPosition } from "../../utils.ts"; * @example Signed integers * * ```ts - * import { integer, literal, natural } from "@fcrozatier/monarch/common"; + * import { literal, natural } from "@fcrozatier/monarch/common"; * * const integer = alt( * literal("-").chain(() => natural).map((x) => -x), diff --git a/src/combinators/recursion/mod.ts b/src/combinators/recursion/mod.ts index 8d907fe..70c4aa4 100644 --- a/src/combinators/recursion/mod.ts +++ b/src/combinators/recursion/mod.ts @@ -1,2 +1,8 @@ +/** + * Reduction combinators + * + * @module + */ + export { lazy } from "./lazy.ts"; export { memoize } from "./memoize.ts"; diff --git a/src/core/types.ts b/src/core/types.ts index 45d3676..08935fb 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -1,7 +1,5 @@ /** * The current position in the source - * - * @internal */ export type Position = { line: number; From 30680615b8705e1ca6d01a7d6111c0111bd874b3 Mon Sep 17 00:00:00 2001 From: fcrozatier Date: Wed, 18 Jun 2025 15:38:24 +0200 Subject: [PATCH 2/3] expose types --- src/core/mod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/mod.ts b/src/core/mod.ts index 54e840c..e7c1fc8 100644 --- a/src/core/mod.ts +++ b/src/core/mod.ts @@ -6,5 +6,5 @@ export { createParser, Parser } from "./parser.ts"; export { result } from "./result.ts"; -export type { ParseFail, ParseResult, ParseSuccess } from "./types.ts"; +export * from "./types.ts"; export { fail } from "./fail.ts"; From 3a3c58764db5076814c97f99155d399a4b22a110 Mon Sep 17 00:00:00 2001 From: fcrozatier Date: Wed, 18 Jun 2025 15:40:47 +0200 Subject: [PATCH 3/3] format --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c47cfb4..6c46c7f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ # Monarch -Monarch is a clean, composable parser combinator library that makes building parsers feel natural and expressive: +Monarch is a clean, composable parser combinator library that makes building +parsers feel natural and expressive: - Clean & readable API - Type-safe parsing @@ -15,8 +16,8 @@ Monarch is a clean, composable parser combinator library that makes building par - Support for left-recursive grammars with [fold](#foldl-and-foldr) and [lazy evaluation](#lazy-evaluation) -Easily build error-reporting parsers by combining, extending and customizing -the provided base parsers and their error messages. +Easily build error-reporting parsers by combining, extending and customizing the +provided base parsers and their error messages. ## Table of content