Created
January 15, 2014 13:03
-
-
Save rns/8435795 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.010; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Marpa::R2; | |
my $g = Marpa::R2::Scanless::G->new( { | |
source => \(<<'END_OF_SOURCE'), | |
:default ::= action => [values] bless => ::lhs | |
lexeme default = action => [value] bless => ::name | |
lhs ::= rhs1 rhs2 | |
|| rhs1 rhs2 | |
rhs1 ~ 'rhs1' | |
rhs2 ~ 'rhs2' | |
:discard ~ whitespace | |
whitespace ~ [\s]+ | |
END_OF_SOURCE | |
} ); | |
for my $input ('rhs1 rhs2'){ | |
my $r = Marpa::R2::Scanless::R->new( { grammar => $g } ); | |
eval { $r->read(\$input) }; | |
say $@ ? $@ : Dumper $r->value(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment