12 |
|
# to the desired routines |
13 |
|
# usegroupchecker(groupchecker) : Set a groupchecker |
14 |
|
# parse() : Parse the file |
15 |
– |
# checkparam($name,$par) : Exit with an error message if parameter |
16 |
– |
# is undefined in tag $name |
15 |
|
# line() : return the current line number of the parse |
16 |
+ |
# tagstartline() : return the line number on which the current |
17 |
+ |
# tag was opened |
18 |
|
# stream(filehandle) : stream output to the filehandle if not handled |
19 |
|
# in any other way |
20 |
|
package ActiveDoc::Switcher; |
40 |
|
$self->{stream}=shift; |
41 |
|
} |
42 |
|
|
43 |
+ |
sub streamexclude { |
44 |
+ |
my $self=shift; |
45 |
+ |
my $tag=shift; |
46 |
+ |
|
47 |
+ |
$tag=~tr/A-Z/a-z/; |
48 |
+ |
$self->{streamexclude}{$tag}=1; |
49 |
+ |
} |
50 |
+ |
|
51 |
|
sub _initialise (hash1) { |
52 |
|
my $self=shift; |
53 |
|
$self->{filename}=shift; |
84 |
|
$self->{linecount}=0; |
85 |
|
$self->_resetvars(); |
86 |
|
$self->{streamstore}=""; |
87 |
+ |
$self->{streamtmp}=""; |
88 |
|
|
89 |
|
# Open the file |
90 |
|
use FileHandle; |
108 |
|
$self->_printstream(); |
109 |
|
} |
110 |
|
|
102 |
– |
sub checkparam($name, $key) { |
103 |
– |
my $self=shift; |
104 |
– |
my $name=shift; |
105 |
– |
my $key=shift; |
106 |
– |
|
107 |
– |
if ( ! defined $self->{tagvar}{$key} ) { |
108 |
– |
print "Switcher: Badly formed $name tag -". |
109 |
– |
" undefined $key parameter\n"; |
110 |
– |
exit 1; |
111 |
– |
} |
112 |
– |
} |
113 |
– |
|
111 |
|
# |
112 |
|
# return the current line number |
113 |
|
# |
115 |
|
my $self=shift; |
116 |
|
return $self->{linecount}; |
117 |
|
} |
118 |
+ |
|
119 |
+ |
# return the line the current tag was opened |
120 |
+ |
sub tagstartline { |
121 |
+ |
my $self=shift; |
122 |
+ |
$self->{tagstart}; |
123 |
+ |
} |
124 |
|
# --------------- Utility routines ---------------------------- |
125 |
|
|
126 |
|
# |
180 |
|
my $self=shift; |
181 |
|
my $char; |
182 |
|
|
183 |
+ |
# Keep a record of where the tag started |
184 |
+ |
$self->{tagstart}=$self->line(); |
185 |
+ |
|
186 |
|
# Close the last text segment |
187 |
+ |
$self->{streamtmp}=$self->_popstream(); |
188 |
|
$self->_calltag($self->{textcontext}, $self->{textcontext}, |
189 |
|
$self->_getstore()); |
190 |
|
$self->_resetstore(); |
191 |
|
$self->_resetlabels(); |
192 |
|
|
186 |
– |
$self->{scramtmp}=$self->_popstream(); |
193 |
|
# Do we have an opening or closing tag? |
194 |
|
if ( ($char=$self->_nextchar()) eq "/" ) { #we have a closing tag |
195 |
|
$self->{tagcontext}="endtag"; |
264 |
|
} |
265 |
|
} |
266 |
|
|
267 |
< |
if ( ! $found ) { |
267 |
> |
# stream function |
268 |
> |
if ( ! exists $self->{streamexclude}{$tagroutine} ) { |
269 |
|
$self->_printstream(); |
270 |
|
} |
271 |
|
$self->_clearstream(); |
365 |
|
sub _resetlabels { |
366 |
|
my $self=shift; |
367 |
|
undef $self->{tagvar}; |
368 |
+ |
undef $self->{tagname}; |
369 |
|
} |
370 |
|
|
371 |
|
sub _closelabel { |
377 |
|
$self->{lastlabel}=""; |
378 |
|
} |
379 |
|
elsif ( $self->_getstore() ne "") { |
380 |
< |
#Then it must be the tag name |
381 |
< |
($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/; |
380 |
> |
# Then it must be the tag name |
381 |
> |
if ( ! defined $self->{tagname} ) { |
382 |
> |
($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/; |
383 |
> |
} |
384 |
> |
else { |
385 |
> |
die ">Tag syntax error in $self->{tagname} on line ". |
386 |
> |
$self->line()." of file \n$self->{filename}"; |
387 |
> |
} |
388 |
|
} |
389 |
|
$self->_resetstore(); |
390 |
|
} |