From 55e04a732774625ed5f4ec5d603d31ca5640a9a8 Mon Sep 17 00:00:00 2001 From: Mingun Date: Sat, 24 Apr 2021 02:32:02 +0500 Subject: [PATCH] Add location information to group AST node (#112) --- CHANGELOG.md | 5 +++++ lib/parser.js | 2 +- src/parser.pegjs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe36deff..f2a210dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ Released: TBD data,for example, path to the currently parsed file. [@Mingun](https://github.com/peggyjs/peggy/pull/95) +### Bug fixes + +- [#112](https://github.com/peggyjs/peggy/pull/112): `"group"` node in the AST now have `location` information (back-ported) + + 1.1.0 ----- diff --git a/lib/parser.js b/lib/parser.js index 8a4570de..4aa2f01d 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -290,7 +290,7 @@ function peg$parse(input, options) { // nodes that already isolate label scope themselves. This leaves us with // "labeled" and "sequence". return expression.type === "labeled" || expression.type === "sequence" - ? { type: "group", expression: expression } + ? { type: "group", expression: expression, location: location() } : expression; }; var peg$c40 = function(name) { diff --git a/src/parser.pegjs b/src/parser.pegjs index 76963042..784ec04b 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -201,7 +201,7 @@ PrimaryExpression // nodes that already isolate label scope themselves. This leaves us with // "labeled" and "sequence". return expression.type === "labeled" || expression.type === "sequence" - ? { type: "group", expression: expression } + ? { type: "group", expression: expression, location: location() } : expression; }