This time with attachment :/

On Wednesday, August 8, 2018 at 12:20:39 AM UTC-5, Michael Spertus wrote:
>
> Thanks for helping me to get to a (surprising) answer to my previous 
> question. I was hoping you could help me with another. I want the following 
> grammar to parse 'xy' as a single statement
>
> statements ::= statement+
>> statement ::= xy | x | y
>> x ::= 'x'
>> y ::= 'y'
>> xy ::= 'x' 'y'
>>
>>
> Unfortunately, it always parses as two statements, even if I use the 
> attached "high_rule_only" code and rank the statement alternatives as 
>
>  statement ::= xy rank => 1 | x | y
>
>
> I still get two statements. Is there a way I can do this with ordering, or 
> do I need to do something like traverse the ASF? Note that I need to do 
> this at the ::= level rather than with lexemes because in the actual 
> grammar I care about x and y are complicated rules themselves.
>
> Thanks, 
> Mike
>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
use Marpa::R2;
use Data::Dumper;

my $dsl = <<'END_OF_DSL';
:default ::= action => [name,values]
lexeme default = latm => 1

:start ::= statements

statements ::= statement+
statement ::= xy rank => 1 | x | y
x ::= 'x'
y ::= 'y'
xy ::= 'x' 'y'

END_OF_DSL



my $grammar = Marpa::R2::Scanless::G->new( { source => \$dsl } );
my $recce = Marpa::R2::Scanless::R->new(
    { grammar => $grammar, semantics_package => 'CodeProcess' , ranking_method => 'high_rule_only' } );

my $input = 'xy';
my $length_read = $recce->read( \$input );

my $value_ref = $recce->value;

print Dumper($value_ref);

Reply via email to