From 27687615e581a561ab8b9dbe3a02638657ae66ae Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Mon, 15 Oct 2018 07:20:33 +0100 Subject: [PATCH] Document filename option for generated parsers --- docs/guides/using-the-parser.md | 5 +++-- packages/pegjs/typings/generated-parser.d.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/guides/using-the-parser.md b/docs/guides/using-the-parser.md index b564d0c..465fc50 100644 --- a/docs/guides/using-the-parser.md +++ b/docs/guides/using-the-parser.md @@ -12,7 +12,8 @@ parser.parse("abcd"); // throws an exception You can tweak parser behavior by passing a second parameter with an `options` object to the `parse` method. The following options are supported: - * `startRule` — name of the rule to start parsing from (depends on the rules the grammar supports as starting rules) - * `tracer` — tracer to use (only if the parser was generated with `"trace": true` option passed to the compiler) +* `filename` — the name of the source passed to the generated parser; will be used by the `location()` helper +* `startRule` — name of the rule to start parsing from (depends on the rules the grammar supports as starting rules) +* `tracer` — tracer to use (only if the parser was generated with `"trace": true` option passed to the compiler) Parsers can also support their own custom options on the `options` object passed to them. diff --git a/packages/pegjs/typings/generated-parser.d.ts b/packages/pegjs/typings/generated-parser.d.ts index 8e8840c..581aec3 100644 --- a/packages/pegjs/typings/generated-parser.d.ts +++ b/packages/pegjs/typings/generated-parser.d.ts @@ -18,6 +18,7 @@ declare namespace generatedparser { */ interface SourceLocation { + filename?: string; start: SourcePosition; end: SourcePosition;