From 5e7310f944e83149b4ab68a3cd966feaf24914a0 Mon Sep 17 00:00:00 2001 From: BryceCicada Date: Tue, 22 May 2018 22:27:36 +0100 Subject: [PATCH] [pegjs] Added support for parser options --- types/pegjs/index.d.ts | 5 +++-- types/pegjs/pegjs-tests.ts | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/types/pegjs/index.d.ts b/types/pegjs/index.d.ts index 722153038b..c5cdb533ec 100644 --- a/types/pegjs/index.d.ts +++ b/types/pegjs/index.d.ts @@ -51,8 +51,9 @@ export type GrammarError = PegjsError; export var GrammarError: any; export interface ParserOptions { - startRule: string; - tracer: any; + startRule?: string; + tracer?: any; + [key: string]: any; } export interface Parser { diff --git a/types/pegjs/pegjs-tests.ts b/types/pegjs/pegjs-tests.ts index 267a64b060..f2a3d543ed 100644 --- a/types/pegjs/pegjs-tests.ts +++ b/types/pegjs/pegjs-tests.ts @@ -26,6 +26,11 @@ import * as pegjs from 'pegjs'; }) } +{ + let parser: pegjs.Parser = pegjs.generate('start = "a" { return options; }'); + let parsed: any = parser.parse("a", {a: 42}); +} + try { let source: string = pegjs.generate("A = 'test'", {output: "source"}); } catch (error) { @@ -44,4 +49,4 @@ try { console.log(e.location.end.line); console.log(e.message); console.log(e.name); -} \ No newline at end of file +}