Why do many
and at_least_one
return void while consume
, subrule
, or
, and option
return values?
#1933
Unanswered
thejohnfreeman
asked this question in
Q&A
Replies: 1 comment
-
Hello @thejohnfreeman History for that decision can be found here: I think you may be able implement this yourself: class MyParser extends EmbeddedActionsParser {
// you could decide to always pass a subRule rather than a general grammar action and that would guarantee
// something would be returned on each iteration
myMany(idx, iterationAction) {
const resultArr = []
this.many(idx, () => {
const iterItem = iterationAction() // may need to bind to the parser's `this` when invoking...
resultArr.push(iterItem)
})
return resultArr
}
}
`` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Shouldn't they return arrays?
I'll note the example embedded actions parser manipulates a captured result value in the body of the function passed to
MANY
, instead of using a value returned fromMANY
. Plus it is impossible to pass arguments to the function called byMANY
. Together, this makes it impossible to construct the rule bottom-up, as I'm trying to do.Beta Was this translation helpful? Give feedback.
All reactions