Say I have a nice ambiguous Marpa grammar and a nice ambiguous input string.
I can parse the string with Marpa and end up with a parse forest. I can even iterate through each parse tree in the forest.
But how can I iterate "along" the parse forest?
To describe what I mean:
A parse forest is a kind of graph which can have nodes where alternatives split off, and nodes where alternatives join back together into a "main stream".
Say these are the alternative parse trees of one parse forest:
A B1 C
A B2 C
A B3 B4 C
There is a main stream A
... C
but an ambiguous B
section.
Of course in real world parses there can be many levels of branching upon branching and there may be streams that do not rejoin a single main stream. But in general there will be a lot of parts common to two or many interpretations.
What approaches can be used to iterate along the chain of unambiguous and ambiguous nodes?
In fact can I output the entire graph?