Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
$ perl t.pl
type: 4
text: 0

type: 5
text: 1

type: 4
text: 0

2007-06-13

+ More interesting tokens like identifier and integers are now recognizedEscaped characters, like '\n', are now handled properly.

+ Added  error handling.

...

Code Block
#!/usr/bin/perl

use ANTLR::Runtime::ANTLRStringStream;
use T2Lexer;

use strict;
use warnings;

my $input = ANTLR::Runtime::ANTLRStringStream->new("Hello World!\n42\n");
my $lexer = T2Lexer->new($input);

while (1) {
       my $token = $lexer->next_token();
       last if $token->get_type() == $T2Lexer::EOF;

       print "type: ", $token->get_type(), "\n";
       print "text: ", $token->get_text(), "\n";
       print "\n";
}
Code Block
type: 4
text: Hello

type: 7
text:

type: 4
text: World

line 1:12 no viable alternative at character '!'
type: 6
text:


type: 5
text: 42

type: 6
text:

...