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 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) => {