The docs for Marpa::R2::Scanless:R say, for ambiguous(), "This method should be called after the read() method." I think that should be somehow clarified. Consider this code (BTW the parse is ambiguous):
for
(
my $pos = $self -> recce -> read(\$string);
$pos < $length;
$pos = $self -> recce -> resume($pos)
)
{
# if ($self -> recce -> ambiguity_metric > 1)
# {
# $self -> log(notice => 'Ambiguous parse');
# }
# if ($ambiguous_status = $self -> recce -> ambiguous)
# {
# $self -> log(notice => "Parse is ambiguous: $ambiguous_status");
# }
@event = @{$self -> recce -> events};
#$self -> log(debug => 'Event count: ' . ($#event + 1) . ': ' . join(', ', map{${$_}[0]} @event) . '.');
$event_name = ${$event[0]}[0];
($start, $span) = $self -> recce -> pause_span;
$lexeme_name = $self -> recce -> pause_lexeme;
$lexeme = $self -> recce -> literal($start, $span);
etc down to
}
read() is called, but if I uncomment either of those ifs /inside the loop/ $self -> recce -> value returns undef.
Inside the loop, the first if prints nothing, but affects value().
Inside the loop, the 2nd prints 'No parse' each time thru the loop, and affects value().
Now comment those both out, so the next discussion is only about calls after the loop.
If I have the 1st if after the loop, it says:
Ambiguous parse.
If I have the 2nd if after the loop, it says:
Parse is ambiguous: Ambiguous symch at Glade=9, Symbol=<edge_statement>:
The ambiguity is from line 1, column 1 to line 1, column 2
Text is: ->
There are 2 symches
Symch 0 is a rule: edge_statement ::= edge_name attribute_definition
Symch 1 is a rule: edge_statement ::= edge_name
Parse failed. Error: value() called when recognizer is not in tree mode
The current mode is "forest"
Marpa::R2 exception at lib/MarpaX/Demo/StringParser.pm line 485.