Skip to content

Instantly share code, notes, and snippets.

@jeffreykegler
Created January 8, 2014 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreykegler/8312534 to your computer and use it in GitHub Desktop.
Save jeffreykegler/8312534 to your computer and use it in GitHub Desktop.
Ruslan Zakirov's example, redone using a forgiving token
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Marpa::R2 2.079_007;
use Data::Dumper;
my $source = <<'END';
:default ::= action => ::array
:start ::= content
content ::= name ':' value
name ~ [A-Za-z0-9-]+
value ~ [A-Za-z0-9:-]+
:lexeme ~ value forgiving => 1
END
my $g = Marpa::R2::Scanless::G->new({
source => \$source
});
my $input = 'UID:urn:uuid:4fbe8971-0bc3-424c-9c26-36c3e1eff6b1';
my $slr =
Marpa::R2::Scanless::R->new( { grammar => $g,
# trace_terminals => 1
} );
$slr->read( \$input );
print Dumper([ ${$slr->value} ]);
# vim: set expandtab shiftwidth=4:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment