Coding 2022-01-12
I'm going to try to diversify what I work on and blog about, but not today.
All right, let's plan out some of the stuff I was talking about last time. Iterating over parses. Because any found sub-tree is guaranteed to produce at least one valid sub-parse, I think I want to work by iterating over all possible top-level divisions of sub-trees (to look for the values that work), and then take the product of the parses of those sub-trees.
So this looks like:
- "I have a generator that yields valid parse trees of the given type, with the given start and end indices"
- "What's it look like inside?"
- "Well, it iterates over all items where the rule's LHS matches the type..."
- "Uh-huh"
- "For each matching rule, it passes that item to a generator that finds all valid divisions of the item's range..."
- "Uh-huh"
- "Then, it takes the product of the parse iterators over the items in the divisions."
- "So..."
- "So, there's a top-level parses function that iterates over all successful items in the last set. It then delegates to a parses_for_item function that takes an item and an end index and generates all parses satisfying those constraints. This function relies on a divisions_for_item function to get the information. Ultimately, parses_for_item is recursive, because it needs to slot successful parses into the divisions.
I'm not sure whether I'd rather accomplish that by making a bunch of these have the same return types, or by confining the recursion to the parses_for_item function. I was originally thinking the former, but I'd like to try the latter. Later.
It's late and I'm tired.
Good night.