#!/usr/bin/perl

use Parse::Lex;

@token = qw(
             OP       [-+*/]
             LEFTP    [\(]
             RIGHTP   [\)]
             INTEGER  [1-9][0-9]*
             NEWLINE  \n
          );
$lexer = Parse::Lex->new( @token );
$lexer->from( \*DATA ); # The input starts after __END__.

TOKEN:
while ( 1 ) {
    $token = $lexer->next;
    if ( not $lexer->eoi ) {
        print "Type: ", $token->name, "\t";
        print "Content:->", $token->text, "<-\n";
    } else {
        last TOKEN;
    }
}
__END__
12+34*(567-89)
