You are viewing the version of this documentation from Perl 5.14.4. View the latest version

CONTENTS

NAME

Pod::Simple::PullParser -- a pull-parser interface to parsing Pod

SYNOPSIS

my $parser = SomePodProcessor->new;
$parser->set_source( "whatever.pod" );
$parser->run;

Or:

my $parser = SomePodProcessor->new;
$parser->set_source( $some_filehandle_object );
$parser->run;

Or:

my $parser = SomePodProcessor->new;
$parser->set_source( \$document_source );
$parser->run;

Or:

my $parser = SomePodProcessor->new;
$parser->set_source( \@document_lines );
$parser->run;

And elsewhere:

require 5;
package SomePodProcessor;
use strict;
use base qw(Pod::Simple::PullParser);

sub run {
  my $self = shift;
 Token:
  while(my $token = $self->get_token) {
    ...process each token...
  }
}

DESCRIPTION

This class is for using Pod::Simple to build a Pod processor -- but one that uses an interface based on a stream of token objects, instead of based on events.

This is a subclass of Pod::Simple and inherits all its methods.

A subclass of Pod::Simple::PullParser should define a run method that calls $token = $parser->get_token to pull tokens.

See the source for Pod::Simple::RTF for an example of a formatter that uses Pod::Simple::PullParser.

METHODS

my $token = $parser->get_token

This returns the next token object (which will be of a subclass of Pod::Simple::PullParserToken), or undef if the parser-stream has hit the end of the document.

$parser->unget_token( $token )
$parser->unget_token( $token1, $token2, ... )

This restores the token object(s) to the front of the parser stream.

The source has to be set before you can parse anything. The lowest-level way is to call set_source:

$parser->set_source( $filename )
$parser->set_source( $filehandle_object )