Home | History | Annotate | Download | only in Runtime
      1 package ANTLR::Runtime::MissingTokenException;
      2 
      3 use Moose;
      4 
      5 use overload
      6     '""' => \&to_string;
      7 
      8 extends 'ANTLR::Runtime::MismatchedTokenException';
      9 
     10 has 'inserted' => (
     11     is  => 'ro',
     12     isa => 'Any',
     13 );
     14 
     15 sub get_missing_type {
     16     my ($self) = @_;
     17     return $self->expecting;
     18 }
     19 
     20 sub to_string {
     21     my ($self) = @_;
     22 
     23     if (defined (my $inserted = $self->inserted) && defined (my $token = $self->token)) {
     24         return "MissingTokenException(inserted $inserted at " . $token->get_text() . ")";
     25     }
     26     if (defined $self->token) {
     27         return "MissingTokenException(at " . $self->token->get_text() . ")";
     28     }
     29 
     30     return "MissingTokenException";
     31 }
     32 
     33 no Moose;
     34 __PACKAGE__->meta->make_immutable();
     35 1;
     36 __END__
     37