Last active
August 29, 2015 14:06
-
-
Save rns/fb6abf62a5fa779957ba 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 => [name, value] | |
lexeme default = action => [name, value] | |
All ::= Syllable+ | |
Syllable ::= | |
Syllable_CVC | | |
Syllable_CV | | |
Syllable_C_or_Abbrev | |
Syllable_CVC ~ C V C | |
Syllable_CV ~ C V | |
Syllable_C_or_Abbrev ~ C | |
C ~ [bcdfghjklmnpqrstvwxyz] | |
V ~ [aeiou] | |
:discard ~ whitespace | |
whitespace ~ [\s]+ | |
END_OF_SOURCE | |
} ); | |
my $input = <<EOI; | |
mat | |
m | |
EOI | |
my $r = Marpa::R2::Scanless::R->new( { grammar => $g } ); | |
eval {$r->read(\$input)} || die "Parse failure, progress report is:\n" . $r->show_progress; | |
while (my $v = $r->value){ | |
say Dumper $v; | |
} |
Author
rns
commented
Sep 3, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment