From bc1743cd4b654b9cbfa27a36d8cc285fefde1785 Mon Sep 17 00:00:00 2001 From: chaosmail Date: Sun, 19 Nov 2017 12:26:41 +0100 Subject: [PATCH 1/2] add createLanguage, Parser.trim and Parser.thru --- types/parsimmon/index.d.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/types/parsimmon/index.d.ts b/types/parsimmon/index.d.ts index dfbae05e23..b7928c5182 100644 --- a/types/parsimmon/index.d.ts +++ b/types/parsimmon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Parsimmon 1.3 +// Type definitions for Parsimmon 1.6.2 // Project: https://github.com/jneen/parsimmon // Definitions by: Bart van der Schoor // Mizunashi Mana @@ -73,6 +73,14 @@ declare namespace Parsimmon { expected: string[]; index: Index; } + + interface Rule { + [key: string]: (r?: Language) => Parser; + } + + interface Language { + [key: string]: Parser; + } interface Parser { /** @@ -106,6 +114,15 @@ declare namespace Parsimmon { */ // tslint:disable-next-line:unified-signatures then(anotherParser: Parser): Parser; + /** + * returns wrapper(this) from the parser. Useful for custom functions used + * to wrap your parsers, while keeping with Parsimmon chaining style. + */ + thru(call: (wrapper: Parser) => Parser): Parser; + /** + * expects anotherParser before and after parser, yielding the result of parser + */ + trim(anotherParser: Parser): Parser; /** * transforms the output of parser with the given function. */ @@ -171,6 +188,11 @@ declare namespace Parsimmon { */ function Parser(fn: (input: string, i: number) => Parsimmon.Reply): Parser; + /** + * Starting point for building a language parser in Parsimmon + */ + function createLanguage(rules: Rule): Language; + /** * To be used inside of Parsimmon(fn). Generates an object describing how * far the successful parse went (index), and what value it created doing From b60a11e605ed64db115a613ce6ada528b3ba173c Mon Sep 17 00:00:00 2001 From: Christoph Koerner Date: Sun, 19 Nov 2017 12:55:00 +0100 Subject: [PATCH 2/2] fix lint errors --- types/parsimmon/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/parsimmon/index.d.ts b/types/parsimmon/index.d.ts index b7928c5182..26ed383daf 100644 --- a/types/parsimmon/index.d.ts +++ b/types/parsimmon/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Parsimmon 1.6.2 +// Type definitions for Parsimmon 1.6 // Project: https://github.com/jneen/parsimmon // Definitions by: Bart van der Schoor // Mizunashi Mana @@ -73,7 +73,7 @@ declare namespace Parsimmon { expected: string[]; index: Index; } - + interface Rule { [key: string]: (r?: Language) => Parser; } @@ -115,7 +115,7 @@ declare namespace Parsimmon { // tslint:disable-next-line:unified-signatures then(anotherParser: Parser): Parser; /** - * returns wrapper(this) from the parser. Useful for custom functions used + * returns wrapper(this) from the parser. Useful for custom functions used * to wrap your parsers, while keeping with Parsimmon chaining style. */ thru(call: (wrapper: Parser) => Parser): Parser; @@ -192,7 +192,7 @@ declare namespace Parsimmon { * Starting point for building a language parser in Parsimmon */ function createLanguage(rules: Rule): Language; - + /** * To be used inside of Parsimmon(fn). Generates an object describing how * far the successful parse went (index), and what value it created doing