Home | History | Annotate | Download | only in id
      1 #!/usr/bin/perl
      2 
      3 use blib;
      4 
      5 use English qw( -no_match_vars );
      6 use ANTLR::Runtime::ANTLRStringStream;
      7 use IDLexer;
      8 
      9 use strict;
     10 use warnings;
     11 
     12 my $input = ANTLR::Runtime::ANTLRStringStream->new({ input => "Hello World!\n42\n" });
     13 my $lexer = IDLexer->new({ input => $input });
     14 
     15 while (1) {
     16     my $token = $lexer->next_token();
     17     last if $token->get_type() == IDLexer->EOF;
     18 
     19     print "text: ", $token->get_text(), "\n";
     20     print "type: ", $token->get_type(), "\n";
     21     print "pos: ", $token->get_line(), ':', $token->get_char_position_in_line(), "\n";
     22     print "channel: ", $token->get_channel(), "\n";
     23     print "token index: ", $token->get_token_index(), "\n";
     24     print "\n";
     25 }
     26