Skip to content

Instantly share code, notes, and snippets.

@pstuifzand
Created April 7, 2012 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pstuifzand/2327730 to your computer and use it in GitHub Desktop.
Save pstuifzand/2327730 to your computer and use it in GitHub Desktop.
Testcase parser, lexer exhausted
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