Last active
August 29, 2015 14:05
-
-
Save rns/df918056abc656eb0d01 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( { | |
bless_package => 'main', | |
source => \(<<'END_OF_SOURCE'), | |
:default ::= action => [name, values] | |
lexeme default = action => [name, value] | |
Numbers ::= Number+ | |
Number ::= '0b' BinDigits | '0x' HexDigits | |
HexDigits ::= [\dA-Fa-f]+ | |
BinDigits ::= [01]+ | |
:discard ~ whitespace | |
whitespace ~ [\s]+ | |
END_OF_SOURCE | |
} ); | |
my $input = <<EOI; | |
0b0101 | |
0x0f01 | |
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
Output: