What is the best way to handle a case where the input string will require a
non-greedy match in order to match the grammar? Here's a simple test case.
use strict;
use warnings;
use Marpa::R2;
use Data::Dumper;
# Example 1
{
my $g_str = <<'END_GRAMMAR';
:start ::= data
data ::= many_a 'A'
many_a ~ [A]+
END_GRAMMAR
my $g_obj = Marpa::R2::Scanless::G->new({ source => \$g_str });
my $p_obj = Marpa::R2::Scanless::R->new({
grammar => $g_obj,
trace_values => 1,
trace_terminals => 1
});
my $s = 'AA';
$p_obj->read( \$s );
print "EXAMPLE 1 VALUE:".Dumper($p_obj->value)."\n";
}
Clearly, the input string 'AA' should be able to match here, but since
Marpa does not backtrack, the many_a lexeme eats all the 'A' characters and
doesn't leave any for the 'A' literal.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.