Use CommentMap

master
Futago-za Ryuu 6 years ago
parent 11bc94f4c3
commit 8e9be9afea

@ -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)). * `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 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 in the grammar and return them on the `comments` property (as an object map)
`grammar` AST node (the AST directly returned by the parser). Each comment on the `grammar` AST node (the AST directly returned by the parser). Each
object within the array has the following structure: comment property has it's offset as the property key, while the property value
has the following structure:
```js ```js
{ {

@ -51,14 +51,14 @@ declare namespace peg {
private readonly _alwaysConsumesOnSuccess: any; private readonly _alwaysConsumesOnSuccess: any;
type: "grammar"; type: "grammar";
comments?: Comment; comments?: CommentMap;
initializer?: Initializer; initializer?: Initializer;
rules: Rule[]; rules: Rule[];
constructor( constructor(
initializer: void | Initializer, initializer: void | Initializer,
rules: Rule[], rules: Rule[],
comments: void | Comment, comments: void | CommentMap,
location: SourceLocation, location: SourceLocation,
); );
@ -79,7 +79,7 @@ declare namespace peg {
} }
interface Comment { interface CommentMap {
[ offset: number ]: { [ offset: number ]: {

Loading…
Cancel
Save