1Perl::Tags::Naive(3)  User Contributed Perl Documentation Perl::Tags::Naive(3)
2
3
4

"Perl::Tags::Naive"

6       A naive implementation.  That is to say, it's based on the classic
7       "pltags.pl" script distributed with Perl, which is by and large a
8       better bet than the results produced by "ctags".  But a "better"
9       approach may be to integrate this with PPI.
10
11   Subclassing
12       See TodoTagger in the "t/" directory of the distribution for a fully
13       working example (tested in <t/02_subclass.t>).  You may want to reuse
14       parsers in the ::Naive package, or use all of the existing parsers and
15       add your own.
16
17           package My::Tagger;
18           use Perl::Tags;
19           use parent 'Perl::Tags::Naive';
20
21           sub get_parsers {
22               my $self = shift;
23               return (
24                   $self->can('todo_line'),     # a new parser
25                   $self->SUPER::get_parsers(), # all ::Naive's parsers
26                   # or maybe...
27                   $self->can('variable'),      # one of ::Naive's parsers
28               );
29           }
30
31           sub todo_line {
32               # your new parser code here!
33           }
34           sub package_line {
35               # override one of ::Naive's parsers
36           }
37
38       Because ::Naive uses "can('parser')" instead of "\&parser", you can
39       just override a particular parser by redefining in the subclass.
40
41   "get_tags_for_file"
42       ::Naive uses a simple line-by-line analysis of Perl code, comparing
43       each line against an array of parsers returned by the get_parsers
44       method.
45
46       The first of these parsers that matches (if any) will return the
47       tag/control to be registred by the tagger.
48
49   "get_parsers"
50       The following parsers are defined by this module.
51
52       "trim"
53           A filter rather than a parser, removes whitespace and comments.
54
55       "variable"
56           Tags definitions of "my", "our", and "local" variables.
57
58           Returns a Perl::Tags::Tag::Var if found
59
60       "package_line"
61           Parse a package declaration, returning a Perl::Tags::Tag::Package
62           if found.
63
64       "sub_line"
65           Parse the declaration of a subroutine, returning a
66           Perl::Tags::Tag::Sub if found.
67
68       "use_constant"
69           Parse a use constant directive
70
71       "use_line"
72           Parse a use, require, and also a use_ok line (from Test::More).
73           Uses a dummy tag (Perl::Tags::Tag::Recurse to do so).
74
75       "label_line"
76           Parse label declaration
77
78
79
80perl v5.30.1                      2020-01-30              Perl::Tags::Naive(3)
Impressum