Skip to content

Instantly share code, notes, and snippets.

@rns
Last active August 29, 2015 13:56
Show Gist options
  • Save rns/9097111 to your computer and use it in GitHub Desktop.
Save rns/9097111 to your computer and use it in GitHub Desktop.
use strict;
use diagnostics;
use Marpa::R2;
use Test::More;
my $g = Marpa::R2::Scanless::G->new({ source => \(<<'END_OF_SOURCE') });
lexeme default = inaccessible => discard
start1 ::= X
start2 ::= Y
X ~ 'X'
Y ~ 'Y'
END_OF_SOURCE
my @starts = qw/start1 start2/;
for (my $i = 0; $i < @starts; $i++){
my $start = $starts[$i];
my $input = 'X Y';
$g->set( { ':start' => $start } );
my $r = Marpa::R2::Scanless::R->new( { grammar => $g } );
$r->read( \$input );
my $v = ${ $r->value() };
is $v->[0], $input, "with :start ::= $start and input $input";
}
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment