Isn't the whole point of a precedence rule to provide a disambiguition? On Friday, 2 September 2016, Jeffrey Kegler <[email protected]> wrote:
> If you use the rewrite option, it remains possible to write a precedenced > statement that is inherently ambiguous. Rewriting is to prevent the > *implementation* of precedenced rules from *introducing* new ambiguities > not actually in the precedenced rule itself. > > > On Fri, Sep 2, 2016 at 1:30 PM, <[email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote: > >> 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] >> <javascript:_e(%7B%7D,'cvml','marpa-parser%[email protected]');> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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] > <javascript:_e(%7B%7D,'cvml','marpa-parser%[email protected]');> > . > For more options, visit https://groups.google.com/d/optout. > -- 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.
