comby icon indicating copy to clipboard operation
comby copied to clipboard

Greedy parser for holes

Open RomanSoloweow opened this issue 10 months ago • 2 comments

Good afternoon,

I'm sorry for my question, but how is the greediness of holes in a combi implemented?

Is Lookahead used for the entire pattern following the hole? If so, were there any optimizations added, such as memoization, to avoid parsing the entire following pattern in its entirety?

I wonder how the comby works in such a scenario, for example. Image

RomanSoloweow avatar Apr 03 '25 07:04 RomanSoloweow

@rvantonder ping

RomanSoloweow avatar Apr 14 '25 09:04 RomanSoloweow

@RomanSoloweow It "looks ahead" within the current nesting level (e.g., inside parens). There are no memoization / optimizations added, so it will attempt to parse at each point until it is satisfied or until epsilon. Since this happens within a nesting level, and not the entire input, in practice, for normal programs with delimiters, that are syntax-rich, it tends to perform well enough. Does that help?

rvantonder avatar Apr 21 '25 00:04 rvantonder