From 27b384591d461999ad218247f562c9b7bb3c303f Mon Sep 17 00:00:00 2001 From: marihachi Date: Mon, 18 Jul 2022 12:07:14 +0900 Subject: [PATCH 1/2] update json example --- examples/json/package.json | 2 +- examples/json/src/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/json/package.json b/examples/json/package.json index 0a3f7d5..c87ce37 100644 --- a/examples/json/package.json +++ b/examples/json/package.json @@ -12,6 +12,6 @@ "typescript": "4.7.4" }, "dependencies": { - "terrario": "0.2.0" + "terrario": "0.3.0" } } diff --git a/examples/json/src/index.ts b/examples/json/src/index.ts index 6f66207..c633b07 100644 --- a/examples/json/src/index.ts +++ b/examples/json/src/index.ts @@ -55,7 +55,7 @@ const lang = P.createLanguage({ return P.seq([ P.str('{'), spaces, - P.option(entry.sep1(separator)), + entry.sep(separator, 1).option(), spaces, P.str('}'), ], 2).map((value: { key: string, value: unknown }[] | null) => { @@ -79,7 +79,7 @@ const lang = P.createLanguage({ return P.seq([ P.str('['), spaces, - P.option(r.value.sep1(separator)), + r.value.sep(separator, 1).option(), spaces, P.str(']'), ], 2).map((value: unknown[] | null) => { From e56bdfb428d43bdb708ad45649724ad2b871ad78 Mon Sep 17 00:00:00 2001 From: marihachi Date: Mon, 18 Jul 2022 12:12:26 +0900 Subject: [PATCH 2/2] docs --- docs/api.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 0d3b392..089e1e3 100644 --- a/docs/api.md +++ b/docs/api.md @@ -10,9 +10,6 @@ Generates a new parser that consumes the input string using the specified regula ## P.alt(parsers: Parser[]): Parser -## P.option(parser: Parser): Parser -Generates a new parser that returns null even if the match fails. - ## P.notMatch(parser: Parser): Parser Generates a new parser to continue if the match fails. The generated parser does not consume input. @@ -26,6 +23,8 @@ The generated parser does not consume input. ## P.lf +## P.newline + # Parser APIs @@ -35,7 +34,10 @@ The generated parser does not consume input. ## parser.many(min: number): Parser -## parser.sep1(separator: Parser): Parser +## parser.sep(separator: Parser, min: number): Parser + +## parser.option(): Parser +Generates a new parser that returns null even if the match fails. # Other APIs