Created
September 5, 2014 08:52
-
-
Save rns/17faef77b8d3468fb7fe 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.018; | |
use strictures; | |
use Marpa::R2 qw(); | |
my $source = <<'END'; | |
:default ::= | |
action => [values] | |
bless => ::lhs | |
lexeme default = | |
action => [ value ] | |
bless => ::name | |
latm => 1 | |
:start ::= escapedstring | |
escapedstring ::= '"' stringbody '"' | |
stringbody ::= stringbodychar* | |
stringbodychar ~ [^\\"] | escapedquote | |
escapedquote ~ '\"' | |
END | |
my $grammar = Marpa::R2::Scanless::G->new({ | |
bless_package => 'Quot', | |
source => \$source, | |
}); | |
print $grammar->show_rules; | |
print $grammar->show_symbols; | |
my $parser = Marpa::R2::Scanless::R->new({ | |
grammar => $grammar, | |
trace_terminals => 1, | |
trace_values => 1, | |
}); | |
$parser->read(\qq("foo\N{REVERSE SOLIDUS}"bar")); | |
use YAML; say Dump ${$parser->value}; |
Author
rns
commented
Sep 5, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment