The PARSE of PROGRESS

So it occurs to me that the name is kind of wrong, here.

In parser combinator systems, a parser is typically a function that takes input and returns a result (and possibly the remaining unconsumed input), while a combinator is a higher-order function that assembles or modifies parsers.

What's being produced here is a generator-like function, pre-bound to an input, that yields values extracted by applying rules (parser expressions) passed in per call. Once the input is consumed or the stream is otherwise closed, it reports completion.

That flips the traditional model: instead of fixing the rules and varying the input, it fixes the input and varies the rules.

Asking AIs they don't seem to be aware of this pattern having a name. Might have to make one up. "Parse Pump"? I don't know if pump [...rule...] looks great. Maybe call the variable "PROCESS", or "GRAB"?

>> grab: make-parse-pump [a 1020]

>> grab word!
== a

>> done? grab []
== ~null~  ; anti

>> grab [one]
== 1020

>> done? grab []
== ~okay~  ; anti

:thinking:

Naming is hard.

2 Likes