Your grammar as written is ambiguous and therefore Marpa gives you all
parses in an unspecified order – to see them, iterate over the value
like
while (my $ref = $recce->value) {
print Dumper $$ref;
}
Marpa's ranks are a bit unintuitive, I previously ran into very
similar problems. This lead to the Marpa::R2::Semantics::Rank
document[1] being written (Thanks Jeffrey!). That document shows a
related example. The solution seems to be to spell out the sequence
rule explicitly:
statements ::= xy rank => 1
statements ::= x
statements ::= y
statements ::= statements xy rank => 1
statements ::= statements x
statements ::= statements y
The docs emphasize: “The rank of a parse choice is the rank of the
rule of its cause”, which suggests the problem is the intermediate
statement rule. If I understand correctly, the "statements ::=
statement+" sequence rule has no choices because it always gets a
statement at each position (not a choice between x and xy). And the
rank within statement does not matter because … I still don't
understand this 100%.
[1]:
https://metacpan.org/pod/release/JKEGL/Marpa-R2-5.043_043/pod/Semantics/Rank.pod
> --
> You received this message because you are subscribed to the Google Groups "marpa parser" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
marpa-parser...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.