1 package ANTLR::Runtime::UnwantedTokenException; 2 3 use Moose; 4 5 use overload 6 '""' => \&to_string; 7 8 extends 'ANTLR::Runtime::MismatchedTokenException'; 9 10 sub get_unexpected_token { 11 my ($self) = @_; 12 return $self->token; 13 } 14 15 sub to_string { 16 my ($self) = @_; 17 18 my $exp; 19 if ($self->expecting == ANTLR::Runtime::Token->INVALID_TOKEN_TYPE) { 20 $exp = ''; 21 } 22 else { 23 $exp = ", expected " . $self->expecting; 24 } 25 26 if (defined $self->token) { 27 return "UnwantedTokenException(found=" . $self->token->get_text() . "$exp)"; 28 } 29 else { 30 return "UnwantedTokenException(found=undef$exp)"; 31 } 32 } 33 34 no Moose; 35 __PACKAGE__->meta->make_immutable(); 36 1; 37 __END__ 38