I have a parser that can be defined as int = a:/[0-9]+/ {parseInt(a)}. It is supposed to match an int and convert it into a number. There can also be a parser like sum = a:int b:int {a+b}As you can see, it is a series of tokens, which means that they must be parsed as an array of tokens. When we start such an array, I allocate a scope for the variables. The trouble however is that the chain includes the semantic action. Parsing 1 2 with int int would produce [1,2] and semantic action a+b, which is also a parser, replaces that with [3], three in the array, because sum is a chain of parsers and its result must be an array. But, normal user wants pure result 3. How do I solve the problem?
Semantic action in parser combinators
semantics;parser combinator