The rewrite approach seems to work great for recursive rules, but it
doesn't do anything for non-recursive rules. Running the following gives
me an ambiguous parse. Since opt1a is a higher priority, I expect to see
two productions of opt1a with no ambiguity. Am I expecting too much here?
Thanks for your help!
use strict;
use Marpa::R2;
use Data::Dumper;
my $grammar = "
options ::= option*
option ::= opt1a || opt2a
opt1a ::= 'a'
opt2a ::= 'a' 'a'
:discard ~ whitespace
whitespace ~ [\\s]+
";
my $grammar = Marpa::R2::Scanless::G->new( { source => \$grammar } );
my $input = 'a a';
my $value_ref = $grammar->parse( \$input );
my $value = ${$value_ref};
print "Output:\n".Dumper($value);
On Wednesday, August 31, 2016 at 8:55:21 PM UTC-6, Jeffrey Kegler wrote:
>
> I've remembered a major reason for preferring the rewrite approach. If
> you parse then rank, you're using ambiguous parsing -- Marpa is cool with
> that, but it is not necessarily as fast as an unambiguous parse. If the
> expression is of size X the parse could be as bad as O(X^3) and that can
> make a difference if you have a lot of long expressions.
>
> <snip>
>
>
--
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.