pod::parser.3

来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· 3 代码 · 共 1,066 行 · 第 1/3 页

3
1,066
字号
.\" 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::Parser 3".TH Pod::Parser 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::Parser \- base class for creating POD filters and translators.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\&    use Pod::Parser;\&\&    package MyParser;\&    @ISA = qw(Pod::Parser);\&\&    sub command { \&        my ($parser, $command, $paragraph, $line_num) = @_;\&        ## Interpret the command and its text; sample actions might be:\&        if ($command eq \*(Aqhead1\*(Aq) { ... }\&        elsif ($command eq \*(Aqhead2\*(Aq) { ... }\&        ## ... other commands and their actions\&        my $out_fh = $parser\->output_handle();\&        my $expansion = $parser\->interpolate($paragraph, $line_num);\&        print $out_fh $expansion;\&    }\&\&    sub verbatim { \&        my ($parser, $paragraph, $line_num) = @_;\&        ## Format verbatim paragraph; sample actions might be:\&        my $out_fh = $parser\->output_handle();\&        print $out_fh $paragraph;\&    }\&\&    sub textblock { \&        my ($parser, $paragraph, $line_num) = @_;\&        ## Translate/Format this block of text; sample actions might be:\&        my $out_fh = $parser\->output_handle();\&        my $expansion = $parser\->interpolate($paragraph, $line_num);\&        print $out_fh $expansion;\&    }\&\&    sub interior_sequence { \&        my ($parser, $seq_command, $seq_argument) = @_;\&        ## Expand an interior sequence; sample actions might be:\&        return "*$seq_argument*"     if ($seq_command eq \*(AqB\*(Aq);\&        return "\`$seq_argument\*(Aq"     if ($seq_command eq \*(AqC\*(Aq);\&        return "_${seq_argument}_\*(Aq"  if ($seq_command eq \*(AqI\*(Aq);\&        ## ... other sequence commands and their resulting text\&    }\&\&    package main;\&\&    ## Create a parser object and have it parse file whose name was\&    ## given on the command\-line (use STDIN if no files were given).\&    $parser = new MyParser();\&    $parser\->parse_from_filehandle(\e*STDIN)  if (@ARGV == 0);\&    for (@ARGV) { $parser\->parse_from_file($_); }.Ve.SH "REQUIRES".IX Header "REQUIRES"perl5.005, Pod::InputObjects, Exporter, Symbol, Carp.SH "EXPORTS".IX Header "EXPORTS"Nothing..SH "DESCRIPTION".IX Header "DESCRIPTION"\&\fBPod::Parser\fR is a base class for creating \s-1POD\s0 filters and translators.It handles most of the effort involved with parsing the \s-1POD\s0 sectionsfrom an input stream, leaving subclasses free to be concerned only withperforming the actual translation of text..PP\&\fBPod::Parser\fR parses PODs, and makes method calls to handle the variouscomponents of the \s-1POD\s0. Subclasses of \fBPod::Parser\fR override these methodsto translate the \s-1POD\s0 into whatever output format they desire..SH "QUICK OVERVIEW".IX Header "QUICK OVERVIEW"To create a \s-1POD\s0 filter for translating \s-1POD\s0 documentation into some otherformat, you create a subclass of \fBPod::Parser\fR which typically overridesjust the base class implementation for the following methods:.IP "\(bu" 2\&\fB\f(BIcommand()\fB\fR.IP "\(bu" 2\&\fB\f(BIverbatim()\fB\fR.IP "\(bu" 2\&\fB\f(BItextblock()\fB\fR.IP "\(bu" 2\&\fB\f(BIinterior_sequence()\fB\fR.PPYou may also want to override the \fB\f(BIbegin_input()\fB\fR and \fB\f(BIend_input()\fB\fRmethods for your subclass (to perform any needed per-file and/orper-document initialization or cleanup)..PPIf you need to perform any preprocesssing of input before it is parsedyou may want to override one or more of \fB\f(BIpreprocess_line()\fB\fR and/or\&\fB\f(BIpreprocess_paragraph()\fB\fR..PPSometimes it may be necessary to make more than one pass over the inputfiles. If this is the case you have several options. You can make thefirst pass using \fBPod::Parser\fR and override your methods to store theintermediate results in memory somewhere for the \fB\f(BIend_pod()\fB\fR method toprocess. You could use \fBPod::Parser\fR for several passes with anappropriate state variable to control the operation for each pass. Ifyour input source can't be reset to start at the beginning, you canstore it in some other structure as a string or an array and have thatstructure implement a \fB\f(BIgetline()\fB\fR method (which is all that\&\fB\f(BIparse_from_filehandle()\fB\fR uses to read input)..PPFeel free to add any member data fields you need to keep track of thingslike current font, indentation, horizontal or vertical position, orwhatever else you like. Be sure to read \*(L"\s-1PRIVATE\s0 \s-1METHODS\s0 \s-1AND\s0 \s-1DATA\s0\*(R"to avoid name collisions..PPFor the most part, the \fBPod::Parser\fR base class should be able todo most of the input parsing for you and leave you free to worry abouthow to interpret the commands and translate the result..PPNote that all we have described here in this quick overview is thesimplest most straightforward use of \fBPod::Parser\fR to do stream-basedparsing. It is also possible to use the \fBPod::Parser::parse_text\fR functionto do more sophisticated tree-based parsing. See \*(L"TREE-BASED \s-1PARSING\s0\*(R"..SH "PARSING OPTIONS".IX Header "PARSING OPTIONS"A \fIparse-option\fR is simply a named option of \fBPod::Parser\fR with avalue that corresponds to a certain specified behavior. These variousbehaviors of \fBPod::Parser\fR may be enabled/disabled by settingor unsetting one or more \fIparse-options\fR using the \fB\f(BIparseopts()\fB\fR method.The set of currently accepted parse-options is as follows:.IP "\fB\-want_nonPODs\fR (default: unset)" 3.IX Item "-want_nonPODs (default: unset)"Normally (by default) \fBPod::Parser\fR will only provide access tothe \s-1POD\s0 sections of the input. Input paragraphs that are not partof the POD-format documentation are not made available to the caller(not even using \fB\f(BIpreprocess_paragraph()\fB\fR). Setting this option to anon-empty, non-zero value will allow \fB\f(BIpreprocess_paragraph()\fB\fR to seenon-POD sections of the input as well as \s-1POD\s0 sections. The \fB\f(BIcutting()\fB\fRmethod can be used to determine if the corresponding paragraph is a \s-1POD\s0paragraph, or some other input paragraph..IP "\fB\-process_cut_cmd\fR (default: unset)" 3.IX Item "-process_cut_cmd (default: unset)"Normally (by default) \fBPod::Parser\fR handles the \f(CW\*(C`=cut\*(C'\fR \s-1POD\s0 directiveby itself and does not pass it on to the caller for processing. Settingthis option to a non-empty, non-zero value will cause \fBPod::Parser\fR topass the \f(CW\*(C`=cut\*(C'\fR directive to the caller just like any other \s-1POD\s0 command(and hence it may be processed by the \fB\f(BIcommand()\fB\fR method)..Sp\&\fBPod::Parser\fR will still interpret the \f(CW\*(C`=cut\*(C'\fR directive to mean that\&\*(L"cutting mode\*(R" has been (re)entered, but the caller will get a chanceto capture the actual \f(CW\*(C`=cut\*(C'\fR paragraph itself for whatever purposeit desires..IP "\fB\-warnings\fR (default: unset)" 3.IX Item "-warnings (default: unset)"Normally (by default) \fBPod::Parser\fR recognizes a bare minimum ofpod syntax errors and warnings and issues diagnostic messagesfor errors, but not for warnings. (Use \fBPod::Checker\fR to do morethorough checking of \s-1POD\s0 syntax.) Setting this option to a non-empty,non-zero value will cause \fBPod::Parser\fR to issue diagnostics forthe few warnings it recognizes as well as the errors..PPPlease see \*(L"\fIparseopts()\fR\*(R" for a complete description of the interfacefor the setting and unsetting of parse-options..SH "RECOMMENDED SUBROUTINE/METHOD OVERRIDES".IX Header "RECOMMENDED SUBROUTINE/METHOD OVERRIDES"\&\fBPod::Parser\fR provides several methods which most subclasses will probablywant to override. These methods are as follows:.SH "\fB\fP\f(BIcommand()\fP\fB\fP".IX Header "command()".Vb 1\&            $parser\->command($cmd,$text,$line_num,$pod_para);.Ve.PPThis method should be overridden by subclasses to take the appropriateaction when a \s-1POD\s0 command paragraph (denoted by a line beginning with\&\*(L"=\*(R") is encountered. When such a \s-1POD\s0 directive is seen in the input,this method is called and is passed:.ie n .IP "$cmd" 3.el .IP "\f(CW$cmd\fR" 3.IX Item "$cmd"the name of the command for this \s-1POD\s0 paragraph.ie n .IP "$text" 3.el .IP "\f(CW$text\fR" 3.IX Item "$text"the paragraph text for the given \s-1POD\s0 paragraph command..ie n .IP "$line_num" 3.el .IP "\f(CW$line_num\fR" 3.IX Item "$line_num"the line-number of the beginning of the paragraph.ie n .IP "$pod_para" 3.el .IP "\f(CW$pod_para\fR" 3.IX Item "$pod_para"a reference to a \f(CW\*(C`Pod::Paragraph\*(C'\fR object which contains furtherinformation about the paragraph command (see Pod::InputObjectsfor details)..PP\&\fBNote\fR that this method \fIis\fR called for \f(CW\*(C`=pod\*(C'\fR paragraphs..PPThe base class implementation of this method simply treats the raw \s-1POD\s0command as normal block of paragraph text (invoking the \fB\f(BItextblock()\fB\fRmethod with the command paragraph)..SH "\fB\fP\f(BIverbatim()\fP\fB\fP".IX Header "verbatim()".Vb 1\&            $parser\->verbatim($text,$line_num,$pod_para);.Ve.PPThis method may be overridden by subclasses to take the appropriateaction when a block of verbatim text is encountered. It is passed thefollowing parameters:.ie n .IP "$text" 3.el .IP "\f(CW$text\fR" 3.IX Item "$text"the block of text for the verbatim paragraph.ie n .IP "$line_num" 3.el .IP "\f(CW$line_num\fR" 3.IX Item "$line_num"the line-number of the beginning of the paragraph.ie n .IP "$pod_para" 3.el .IP "\f(CW$pod_para\fR" 3.IX Item "$pod_para"a reference to a \f(CW\*(C`Pod::Paragraph\*(C'\fR object which contains furtherinformation about the paragraph (see Pod::InputObjectsfor details)..PP

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?