[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] subs, pod, package & sectioning



Hi all,

I'm reworking the pop-up index functionality of Alpha's Perl mode and need
to know some things about the normal format of code this feature will see.

Two pop-up's indexes are provided, one I'm using to present an alphabetical
indext into any subroutine in the current file, the other provides a list
of subroutines "in order of apperance" plus other info.

For the later case, I'm scanning each line with a regex that hits on all
the instances I'm concerned with, then useing a case statement. Here is the
regex:
^(package|BEGIN|END|sub|=head1|=pod|__END__|__DATA__)([ \t]+[^\s;\{])*|(^ *###)

By pieces, this part helps me eliminate sections of text that shouls not be
scanned for any indexing:
=head1|=pod|__END__|__DATA__)

[Q] Can I count on these starting in the first column? (same for "=cut").

I need to know if I'm in a package so:
package

for this an index is created that notes the name and the fact that it is a
package. Now any subsequent subroutine will be considered a part of the
package and will appear indented and prefixed with '::'.

[Q] Can I count on this starting in the first column?
[Q] Other than another package, is there some way of 'unpackaging' that I
      need to be aware of?

Once in a package, BEGIN and END act as special subroutines, so I create
indexes for them:
BEGIN|END

[Q] Can I count on these starting in the first column?
[Q] Are there other such?

Wether or not any of the above occurs, we always want to form index entries
for subroutines. The above will only catch a sub if the keyword 'sub'
starts in column 1.

[Q] Is this reasonable?

I've seen code where a sub defines a sub inside its code, if I allow
whitespace before 'sub', I'll index these also, Such indexes don't reflect
that they are defined in a sub, and are confusing. So I want to leave them
out.

[Q] Will this cause trouble?

Are their any other keyword/constructs that would be useful to index?

Here is an example of how a file might index:

 SDF_USER *pkg
*Constants
*Variables
*Initalization
  ::InitMacros
*Support Routines
  ::_PageNF
... etc.

The indexes that start with a '*', are sectioning enteries, they are formed
from comments with this format:
#### Constant ####

(actually, three sharp's on each side is enough to trigger this)

[Q] Is this going to cause any problems with the way people do comments?

Tom




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch