1#!/usr/bin/perl 2 3use blib; 4 5use English qw( -no_match_vars ); 6use ANTLR::Runtime::ANTLRStringStream; 7use TLexer; 8 9use strict; 10use warnings; 11 12my $input = ANTLR::Runtime::ANTLRStringStream->new({ '01X0' }); 13my $lexer = TLexer->new($input); 14 15while (1) { 16 my $token = eval { $lexer->next_token(); }; 17 if ($EVAL_ERROR) { 18 my $exception = $EVAL_ERROR; 19 print $exception; 20 next; 21 } 22 last if $token->get_type() == $TLexer::EOF; 23 24 print "type: ", $token->get_type(), "\n"; 25 print "text: ", $token->get_text(), "\n"; 26 print "\n"; 27} 28