Created
April 7, 2012 11:22
-
-
Save pstuifzand/2327730 to your computer and use it in GitHub Desktop.
Testcase parser, lexer exhausted
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 Marpa::XS; | |
use MarpaX::Simple::Lexer; | |
use IO::String; | |
my $grammar = Marpa::XS::Grammar->new( { | |
start => 'Parser', | |
rules => [ | |
[ 'Parser' => [ 'X' ] ], | |
], | |
terminals => [qw/X/], | |
}); | |
$grammar->precompute; | |
my $recognizer = Marpa::XS::Recognizer->new( { grammar => $grammar } ); | |
my $lexer = MarpaX::Simple::Lexer->new( | |
recognizer => $recognizer, | |
tokens => { | |
X => qr/X/, | |
}, | |
debug => 1, | |
); | |
my $io = IO::String->new("X"); | |
$lexer->recognize($io); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment