"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tlperl/lib/Pod/Simple/PullParserStartToken.pm" (8 Mar 2018, 4146 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 
    2 require 5;
    3 package Pod::Simple::PullParserStartToken;
    4 use Pod::Simple::PullParserToken ();
    5 use strict;
    6 use vars qw(@ISA $VERSION);
    7 @ISA = ('Pod::Simple::PullParserToken');
    8 $VERSION = '3.35';
    9 
   10 sub new {  # Class->new(tagname, optional_attrhash);
   11   my $class = shift;
   12   return bless ['start', @_], ref($class) || $class;
   13 }
   14 
   15 # Purely accessors:
   16 
   17 sub tagname   { (@_ == 2) ? ($_[0][1] = $_[1]) : $_[0][1] }
   18 sub tag { shift->tagname(@_) }
   19 
   20 sub is_tagname { $_[0][1] eq $_[1] }
   21 sub is_tag { shift->is_tagname(@_) }
   22 
   23 
   24 sub attr_hash { $_[0][2] ||= {} }
   25 
   26 sub attr      {
   27   if(@_ == 2) {      # Reading: $token->attr('attrname')
   28     ${$_[0][2] || return undef}{ $_[1] };
   29   } elsif(@_ > 2) {  # Writing: $token->attr('attrname', 'newval')
   30     ${$_[0][2] ||= {}}{ $_[1] } = $_[2];
   31   } else {
   32     require Carp;
   33     Carp::croak(
   34       'usage: $object->attr("val") or $object->attr("key", "newval")');
   35     return undef;
   36   }
   37 }
   38 
   39 1;
   40 
   41 
   42 __END__
   43 
   44 =head1 NAME
   45 
   46 Pod::Simple::PullParserStartToken -- start-tokens from Pod::Simple::PullParser
   47 
   48 =head1 SYNOPSIS
   49 
   50 (See L<Pod::Simple::PullParser>)
   51 
   52 =head1 DESCRIPTION
   53 
   54 When you do $parser->get_token on a L<Pod::Simple::PullParser> object, you might
   55 get an object of this class.
   56 
   57 This is a subclass of L<Pod::Simple::PullParserToken> and inherits all its methods,
   58 and adds these methods:
   59 
   60 =over
   61 
   62 =item $token->tagname
   63 
   64 This returns the tagname for this start-token object.
   65 For example, parsing a "=head1 ..." line will give you
   66 a start-token with the tagname of "head1", token(s) for its
   67 content, and then an end-token with the tagname of "head1".
   68 
   69 =item $token->tagname(I<somestring>)
   70 
   71 This changes the tagname for this start-token object.
   72 You probably won't need
   73 to do this.
   74 
   75 =item $token->tag(...)
   76 
   77 A shortcut for $token->tagname(...)
   78 
   79 =item $token->is_tag(I<somestring>) or $token->is_tagname(I<somestring>)
   80 
   81 These are shortcuts for C<< $token->tag() eq I<somestring> >>
   82 
   83 =item $token->attr(I<attrname>)
   84 
   85 This returns the value of the I<attrname> attribute for this start-token
   86 object, or undef.
   87 
   88 For example, parsing a LZ<><Foo/"Bar"> link will produce a start-token
   89 with a "to" attribute with the value "Foo", a "type" attribute with the
   90 value "pod", and a "section" attribute with the value "Bar".
   91 
   92 =item $token->attr(I<attrname>, I<newvalue>)
   93 
   94 This sets the I<attrname> attribute for this start-token object to
   95 I<newvalue>.  You probably won't need to do this.
   96 
   97 =item $token->attr_hash
   98 
   99 This returns the hashref that is the attribute set for this start-token.
  100 This is useful if (for example) you want to ask what all the attributes
  101 are -- you can just do C<< keys %{$token->attr_hash} >>
  102 
  103 =back
  104 
  105 
  106 You're unlikely to ever need to construct an object of this class for
  107 yourself, but if you want to, call
  108 C<<
  109 Pod::Simple::PullParserStartToken->new( I<tagname>, I<attrhash> )
  110 >>
  111 
  112 =head1 SEE ALSO
  113 
  114 L<Pod::Simple::PullParserToken>, L<Pod::Simple>, L<Pod::Simple::Subclassing>
  115 
  116 =head1 SEE ALSO
  117 
  118 L<Pod::Simple::PullParserToken>, L<Pod::Simple>, L<Pod::Simple::Subclassing>
  119 
  120 =head1 SUPPORT
  121 
  122 Questions or discussion about POD and Pod::Simple should be sent to the
  123 pod-people@perl.org mail list. Send an empty email to
  124 pod-people-subscribe@perl.org to subscribe.
  125 
  126 This module is managed in an open GitHub repository,
  127 L<https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or
  128 to clone L<git://github.com/perl-pod/pod-simple.git> and send patches!
  129 
  130 Patches against Pod::Simple are welcome. Please send bug reports to
  131 <bug-pod-simple@rt.cpan.org>.
  132 
  133 =head1 COPYRIGHT AND DISCLAIMERS
  134 
  135 Copyright (c) 2002 Sean M. Burke.
  136 
  137 This library is free software; you can redistribute it and/or modify it
  138 under the same terms as Perl itself.
  139 
  140 This program is distributed in the hope that it will be useful, but
  141 without any warranty; without even the implied warranty of
  142 merchantability or fitness for a particular purpose.
  143 
  144 =head1 AUTHOR
  145 
  146 Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.
  147 But don't bother him, he's retired.
  148 
  149 Pod::Simple is maintained by:
  150 
  151 =over
  152 
  153 =item * Allison Randal C<allison@perl.org>
  154 
  155 =item * Hans Dieter Pearcey C<hdp@cpan.org>
  156 
  157 =item * David E. Wheeler C<dwheeler@cpan.org>
  158 
  159 =back
  160 
  161 =cut