From 8e9be9afea75b07490f6d2a5107e5d93abee6b69 Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Tue, 30 Jan 2018 01:02:39 +0000 Subject: [PATCH] Use CommentMap --- README.md | 7 ++++--- lib/typings/api.d.ts | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e6d7000..0fea2e9 100644 --- a/README.md +++ b/README.md @@ -185,9 +185,10 @@ The following option's are used by the PEG.js parser: * `reservedWords` - An array of words that the parser wont allow as labels for rules (default: [ES5](http://es5.github.io/#x7.6.1)). When `extractComments` is set to `true`, the parser will collect all comments -in the grammar and return them on the `comments` property (as an array) in the -`grammar` AST node (the AST directly returned by the parser). Each comment -object within the array has the following structure: +in the grammar and return them on the `comments` property (as an object map) +on the `grammar` AST node (the AST directly returned by the parser). Each +comment property has it's offset as the property key, while the property value +has the following structure: ```js { diff --git a/lib/typings/api.d.ts b/lib/typings/api.d.ts index fde5e2e..3371663 100644 --- a/lib/typings/api.d.ts +++ b/lib/typings/api.d.ts @@ -51,14 +51,14 @@ declare namespace peg { private readonly _alwaysConsumesOnSuccess: any; type: "grammar"; - comments?: Comment; + comments?: CommentMap; initializer?: Initializer; rules: Rule[]; constructor( initializer: void | Initializer, rules: Rule[], - comments: void | Comment, + comments: void | CommentMap, location: SourceLocation, ); @@ -79,7 +79,7 @@ declare namespace peg { } - interface Comment { + interface CommentMap { [ offset: number ]: {