Skip to content
This repository has been archived by the owner on Aug 21, 2019. It is now read-only.

Fix nested groups #4

Merged
merged 1 commit into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export default function parse(str) {
// The grouping node should be detached to properly handle
// out-of-bounds `^` operator. Node will be attached right on group end
const node = new Node();
const groupCtx = groupStack.length ? last(groupStack)[0] : ctx;
groupStack.push([node, groupCtx, stream.pos]);
groupStack.push([node, ctx, stream.pos]);
ctx = node;
stream.next();
continue;
Expand Down
1 change: 1 addition & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Parser', () => {
assert.equal(parse('a>((b>c)(d>e))f'), '<a><b><c></c></b><d><e></e></d><f></f></a>');
assert.equal(parse('a>((((b>c))))+d'), '<a><b><c></c></b><d></d></a>');
assert.equal(parse('a>(((b>c))*4)+d'), '<a>(<b><c></c></b>)*4<d></d></a>');
assert.equal(parse('(div>dl>(dt+dd)*2)'), '<div><dl>(<dt></dt><dd></dd>)*2</dl></div>');
});
});

Expand Down