diff --git a/types/parsimmon/index.d.ts b/types/parsimmon/index.d.ts index dfbae05e23..26ed383daf 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 // Project: https://github.com/jneen/parsimmon // Definitions by: Bart van der Schoor // Mizunashi Mana @@ -74,6 +74,14 @@ declare namespace Parsimmon { index: Index; } + interface Rule { + [key: string]: (r?: Language) => Parser; + } + + interface Language { + [key: string]: Parser; + } + interface Parser { /** * parse the string @@ -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