Skip to content

Commit eb2d121

Browse files
committed
Failed flags support
1 parent 462f053 commit eb2d121

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
"prefer-numeric-literals": "error",
231231
"prefer-reflect": "off",
232232
"prefer-rest-params": "off",
233-
"prefer-spread": "error",
233+
"prefer-spread": "off",
234234
"prefer-template": "off",
235235
"quote-props": "off",
236236
"quotes": "off",

src/speg_visitor.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,24 @@ SPEG_actions.prototype.parsing_ordered_choice = function(node) {
6161
};
6262

6363
SPEG_actions.prototype.parsing_sub_expression = function(node) {
64-
return function() {
65-
var result = node.children[1].children[0].apply(this, arguments);
64+
return function(state) {
65+
var result = node.children[1].children[0].call(this, state);
66+
var tags = node.children[0].children.map(function(tag_node){
67+
return tag_node.children[0].match;
68+
});
6669
if (result) {
67-
var tags = node.children[0].children.map(function(tag_node){
68-
return tag_node.children[0].match;
69-
});
7070
if (tags.length > 0) {
7171
if (result.tags) {
7272
result.tags = tags.concat(result.tags);
7373
} else {
7474
result.tags = tags;
7575
}
7676
}
77+
} else {
78+
if (!state.failedTags) {
79+
state.failedTags = [];
80+
}
81+
state.failedTags.push.apply(state.failedTags, tags);
7782
}
7883
return result;
7984
}

0 commit comments

Comments
 (0)