📄 pod::simple::pullparser.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "Pod::Simple::PullParser 3".TH Pod::Simple::PullParser 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"Pod::Simple::PullParser \-\- a pull\-parser interface to parsing Pod.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 3\& my $parser = SomePodProcessor\->new;\& $parser\->set_source( "whatever.pod" );\& $parser\->run;.Ve.PPOr:.PP.Vb 3\& my $parser = SomePodProcessor\->new;\& $parser\->set_source( $some_filehandle_object );\& $parser\->run;.Ve.PPOr:.PP.Vb 3\& my $parser = SomePodProcessor\->new;\& $parser\->set_source( \e$document_source );\& $parser\->run;.Ve.PPOr:.PP.Vb 3\& my $parser = SomePodProcessor\->new;\& $parser\->set_source( \e@document_lines );\& $parser\->run;.Ve.PPAnd elsewhere:.PP.Vb 4\& 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...\& }\& }.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"This class is for using Pod::Simple to build a Pod processor \*(-- butone that uses an interface based on a stream of token objects,instead of based on events..PPThis is a subclass of Pod::Simple and inherits all its methods..PPA subclass of Pod::Simple::PullParser should define a \f(CW\*(C`run\*(C'\fR methodthat calls \f(CW\*(C`$token = $parser\->get_token\*(C'\fR to pull tokens..PPSee the source for Pod::Simple::RTF for an example of a formatterthat uses Pod::Simple::PullParser..SH "METHODS".IX Header "METHODS".ie n .IP "my $token\fR = \f(CW$parser\->get_token" 4.el .IP "my \f(CW$token\fR = \f(CW$parser\fR\->get_token" 4.IX Item "my $token = $parser->get_token"This returns the next token object (which will be of a subclass ofPod::Simple::PullParserToken), or undef if the parser-stream has hitthe end of the document..ie n .IP "$parser\fR\->unget_token( \f(CW$token )" 4.el .IP "\f(CW$parser\fR\->unget_token( \f(CW$token\fR )" 4.IX Item "$parser->unget_token( $token )".PD 0.ie n .IP "$parser\fR\->unget_token( \f(CW$token1\fR, \f(CW$token2, ... )" 4.el .IP "\f(CW$parser\fR\->unget_token( \f(CW$token1\fR, \f(CW$token2\fR, ... )" 4.IX Item "$parser->unget_token( $token1, $token2, ... )".PDThis restores the token object(s) to the front of the parser stream..PPThe source has to be set before you can parse anything. The lowest-levelway is to call \f(CW\*(C`set_source\*(C'\fR:.ie n .IP "$parser\fR\->set_source( \f(CW$filename )" 4.el .IP "\f(CW$parser\fR\->set_source( \f(CW$filename\fR )" 4.IX Item "$parser->set_source( $filename )".PD 0.ie n .IP "$parser\fR\->set_source( \f(CW$filehandle_object )" 4.el .IP "\f(CW$parser\fR\->set_source( \f(CW$filehandle_object\fR )" 4.IX Item "$parser->set_source( $filehandle_object )".ie n .IP "$parser\->set_source( \e$document_source )" 4.el .IP "\f(CW$parser\fR\->set_source( \e$document_source )" 4.IX Item "$parser->set_source( $document_source )".ie n .IP "$parser\->set_source( \e@document_lines )" 4.el .IP "\f(CW$parser\fR\->set_source( \e@document_lines )" 4.IX Item "$parser->set_source( @document_lines )".PD.PPOr you can call these methods, which Pod::Simple::PullParser has definedto work just like Pod::Simple's same-named methods:.ie n .IP "$parser\->parse_file(...)" 4.el .IP "\f(CW$parser\fR\->parse_file(...)" 4.IX Item "$parser->parse_file(...)".PD 0.ie n .IP "$parser\->parse_string_document(...)" 4.el .IP "\f(CW$parser\fR\->parse_string_document(...)" 4.IX Item "$parser->parse_string_document(...)".ie n .IP "$parser\->filter(...)" 4.el .IP "\f(CW$parser\fR\->filter(...)" 4.IX Item "$parser->filter(...)".ie n .IP "$parser\->parse_from_file(...)" 4.el .IP "\f(CW$parser\fR\->parse_from_file(...)" 4.IX Item "$parser->parse_from_file(...)".PD.PPFor those to work, the Pod-processing subclass ofPod::Simple::PullParser has to have defined a \f(CW$parser\fR\->run method \*(--so it is advised that all Pod::Simple::PullParser subclasses do so.See the Synopsis above, or the source for Pod::Simple::RTF..PPAuthors of formatter subclasses might find these methods useful tocall on a parser object that you haven't started pulling tokensfrom yet:.ie n .IP "my $title_string\fR = \f(CW$parser\->get_title" 4.el .IP "my \f(CW$title_string\fR = \f(CW$parser\fR\->get_title" 4.IX Item "my $title_string = $parser->get_title"This tries to get the title string out of \f(CW$parser\fR, by getting some tokens,and scanning them for the title, and then ungetting them so that you canprocess the token-stream from the beginning..SpFor example, suppose you have a document that starts out:.Sp.Vb 1\& =head1 NAME\& \& Hoo::Boy::Wowza \-\- Stuff B<wow> yeah!.Ve.Sp\&\f(CW$parser\fR\->get_title on that document will return \*(L"Hoo::Boy::Wowza \*(--Stuff wow yeah!\*(R"..SpIn cases where get_title can't find the title, it will return empty-string("")..ie n .IP "my $title_string\fR = \f(CW$parser\->get_short_title" 4.el .IP "my \f(CW$title_string\fR = \f(CW$parser\fR\->get_short_title" 4.IX Item "my $title_string = $parser->get_short_title"This is just like get_title, except that it returns just the modulename, ifthe title seems to be of the form \*(L"SomeModuleName \*(-- description\*(R"..SpFor example, suppose you have a document that starts out:.Sp.Vb 1\& =head1 NAME\& \& Hoo::Boy::Wowza \-\- Stuff B<wow> yeah!.Ve.Spthen \f(CW$parser\fR\->get_short_title on that document will return\&\*(L"Hoo::Boy::Wowza\*(R"..SpBut if the document starts out:.Sp.Vb 1\& =head1 NAME\& \& Hooboy, stuff B<wow> yeah!.Ve.Spthen \f(CW$parser\fR\->get_short_title on that document will return \*(L"Hooboy,stuff wow yeah!\*(R"..SpIf the title can't be found, then get_short_title returns empty-string("")..ie n .IP "$author_name\fR = \f(CW$parser\->get_author" 4.el .IP "\f(CW$author_name\fR = \f(CW$parser\fR\->get_author" 4.IX Item "$author_name = $parser->get_author"This works like get_title except that it returns the contents of the\&\*(L"=head1 AUTHOR\en\enParagraph...\en\*(R" section, assuming that that sectionisn't terribly long..Sp(This method tolerates \*(L"\s-1AUTHORS\s0\*(R" instead of \*(L"\s-1AUTHOR\s0\*(R" too.).ie n .IP "$description_name\fR = \f(CW$parser\->get_description" 4.el .IP "\f(CW$description_name\fR = \f(CW$parser\fR\->get_description" 4.IX Item "$description_name = $parser->get_description"This works like get_title except that it returns the contents of the\&\*(L"=head1 PARAGRAPH\en\enParagraph...\en\*(R" section, assuming that that sectionisn't terribly long..ie n .IP "$version_block\fR = \f(CW$parser\->get_version" 4.el .IP "\f(CW$version_block\fR = \f(CW$parser\fR\->get_version" 4.IX Item "$version_block = $parser->get_version"This works like get_title except that it returns the contents ofthe \*(L"=head1 VERSION\en\en[\s-1BIG\s0 \s-1BLOCK\s0]\en\*(R" block. Note that this does \s-1NOT\s0return the module's \f(CW$VERSION\fR!!.SH "NOTE".IX Header "NOTE"You don't actually \fIhave\fR to define a \f(CW\*(C`run\*(C'\fR method. If you'rewriting a Pod-formatter class, you should define a \f(CW\*(C`run\*(C'\fR just sothat users can call \f(CW\*(C`parse_file\*(C'\fR etc, but you don't \fIhave\fR to..PPAnd if you're not writing a formatter class, but are instead justwriting a program that does something simple with a Pod::PullParserobject (and not an object of a subclass), then there's no reason tobother subclassing to add a \f(CW\*(C`run\*(C'\fR method..SH "SEE ALSO".IX Header "SEE ALSO"Pod::Simple.PPPod::Simple::PullParserToken \*(-- and its subclassesPod::Simple::PullParserStartToken,Pod::Simple::PullParserTextToken, andPod::Simple::PullParserEndToken..PPHTML::TokeParser, which inspired this..SH "COPYRIGHT AND DISCLAIMERS".IX Header "COPYRIGHT AND DISCLAIMERS"Copyright (c) 2002 Sean M. Burke. All rights reserved..PPThis library is free software; you can redistribute it and/or modify itunder the same terms as Perl itself..PPThis program is distributed in the hope that it will be useful, butwithout any warranty; without even the implied warranty ofmerchantability or fitness for a particular purpose..SH "AUTHOR".IX Header "AUTHOR"Sean M. Burke \f(CW\*(C`sburke@cpan.org\*(C'\fR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -