Last active
August 29, 2015 13:56
-
-
Save rns/9299823 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
$VAR1 = [ | |
'S', | |
'pair', | |
[ | |
'S', | |
'bracketed', | |
'<', | |
[ | |
${\$VAR1->[0]}, | |
${\$VAR1->[1]}, | |
[ | |
${\$VAR1->[0]}, | |
${\$VAR1->[1]}, | |
[ | |
'S', | |
'non-bracketed', | |
[ | |
'non_parens', | |
'non_parens', | |
' words in ' | |
] | |
], | |
[ | |
${\$VAR1->[2][0]}, | |
${\$VAR1->[2][1]}, | |
'<', | |
[ | |
${\$VAR1->[2][3][2][2][0]}, | |
${\$VAR1->[2][3][2][2][1]}, | |
[ | |
${\$VAR1->[2][3][2][2][2][0]}, | |
${\$VAR1->[2][3][2][2][2][1]}, | |
'nested angle' | |
] | |
], | |
'>' | |
] | |
], | |
[ | |
${\$VAR1->[2][3][2][2][0]}, | |
${\$VAR1->[2][3][2][2][1]}, | |
[ | |
${\$VAR1->[2][3][2][2][2][0]}, | |
${\$VAR1->[2][3][2][2][2][1]}, | |
' brackets ' | |
] | |
] | |
], | |
'>' | |
], | |
[ | |
${\$VAR1->[2][3][2][2][0]}, | |
${\$VAR1->[2][3][2][2][1]}, | |
[ | |
${\$VAR1->[2][3][2][2][2][0]}, | |
${\$VAR1->[2][3][2][2][2][1]}, | |
' | |
' | |
] | |
] | |
]; |
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( { | |
bless_package => 'main', | |
source => \(<<'END_OF_SOURCE'), | |
:default ::= action => [symbol, name, values] | |
lexeme default = action => [symbol, name, values] latm => 1 | |
S ::= S S name => 'pair' | | |
'<' S '>' name => 'bracketed' | | |
'<' '>' name => 'empty bracketed' | | |
non_parens name => 'non-bracketed' | |
non_parens ~ non_paren* | |
non_paren ~ [^<>] | |
END_OF_SOURCE | |
} ); | |
my $input = <<EOI; | |
< words in <nested angle> brackets > | |
EOI | |
my $r = Marpa::R2::Scanless::R->new( { grammar => $g } ); | |
$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