1package ANTLR::Runtime::UnwantedTokenException; 2 3use Moose; 4 5use overload 6 '""' => \&to_string; 7 8extends 'ANTLR::Runtime::MismatchedTokenException'; 9 10sub get_unexpected_token { 11 my ($self) = @_; 12 return $self->token; 13} 14 15sub 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 34no Moose; 35__PACKAGE__->meta->make_immutable(); 361; 37__END__ 38