6 |
|
# processed. |
7 |
|
# Interface |
8 |
|
# --------- |
9 |
+ |
# |
10 |
|
# new(file,objectref) : A new object - filename of file to parse |
11 |
< |
# objectref->of the methods |
11 |
> |
# objectref->of the methods |
12 |
|
# usetags(tagobjref) : Specify a tagcontainer set to direct to |
13 |
|
# to the desired routines |
14 |
|
# usegroupchecker(groupchecker) : Set a groupchecker |
15 |
|
# parse() : Parse the file |
16 |
< |
# line() : return the current line number of the parse |
17 |
< |
# tagstartline() : return the line number on which the current |
18 |
< |
# tag was opened |
19 |
< |
# stream(filehandle) : stream output to the filehandle if not handled |
20 |
< |
# in any other way |
16 |
> |
# line() : return the current line number of the parse |
17 |
> |
# tagstartline() : return the line number on which the current |
18 |
> |
# tag was opened |
19 |
> |
# stream(filehandle) : stream output to the filehandle if not handled |
20 |
> |
# in any other way |
21 |
|
package ActiveDoc::Switcher; |
22 |
+ |
use Utilities::Verbose; |
23 |
|
require 5.001; |
24 |
|
use Carp; |
25 |
|
|
26 |
+ |
@ISA=qw(Utilities::Verbose); |
27 |
+ |
|
28 |
|
sub new { |
29 |
|
my $class=shift; |
30 |
|
my $file=shift; |
52 |
|
$self->{streamexclude}{$tag}=1; |
53 |
|
} |
54 |
|
|
55 |
< |
sub _initialise (hash1) { |
56 |
< |
my $self=shift; |
57 |
< |
$self->{filename}=shift; |
58 |
< |
|
59 |
< |
# add a default groupchecker |
60 |
< |
use ActiveDoc::GroupChecker; |
61 |
< |
$self->{groupchecker}=GroupChecker->new(); |
62 |
< |
$self->{groupchecker}->include("all"); |
63 |
< |
|
64 |
< |
# Add a default TagContainer |
65 |
< |
use ActiveDoc::TagContainer; |
66 |
< |
$self->{tagcontainer}=ActiveDoc::TagContainer->new(); |
67 |
< |
|
68 |
< |
} |
55 |
> |
sub _initialise (hash1) |
56 |
> |
{ |
57 |
> |
my $self=shift; |
58 |
> |
$self->{filename}=shift; |
59 |
> |
$self->verbose(">> New ActiveDoc::Switcher created."); |
60 |
> |
# add a default groupchecker |
61 |
> |
use ActiveDoc::GroupChecker; |
62 |
> |
$self->{groupchecker}=GroupChecker->new(); |
63 |
> |
$self->{groupchecker}->include("all"); |
64 |
> |
|
65 |
> |
# Add a default TagContainer |
66 |
> |
use ActiveDoc::TagContainer; |
67 |
> |
$self->{tagcontainer}=ActiveDoc::TagContainer->new(); |
68 |
> |
|
69 |
> |
} |
70 |
|
|
71 |
|
sub usetags { |
72 |
|
my $self=shift; |
95 |
|
use FileHandle; |
96 |
|
local $filehandle; |
97 |
|
$filehandle=FileHandle->new(); |
98 |
+ |
|
99 |
+ |
$self->verbose(">> Reading file: ".$self->{filename}." "); |
100 |
+ |
|
101 |
|
$filehandle->open("<".$self->{filename}) |
102 |
|
or return 1; |
95 |
– |
# The buffering seems all messed up - best not to use it |
96 |
– |
$filehandle->setvbuf($buf, _IONBF, 3000); |
103 |
|
|
104 |
|
# Start file processing |
105 |
|
while ( ($_=<$filehandle>) ) { |
106 |
|
$self->{linecount}++; |
107 |
+ |
# Skip lines that start with a hash. A better way |
108 |
+ |
# of adding comments than ignore tags: |
109 |
+ |
next if (/^#/); |
110 |
|
$self->{currentline}=$_; |
111 |
|
$self->{stringpos}=0; |
112 |
|
while ( ($char=$self->_nextchar()) ne "" ) { |
117 |
|
# make sure we close the last buffer |
118 |
|
$self->_calltag($self->{textcontext}, $self->{textcontext}, |
119 |
|
$self->_getstore()); |
111 |
– |
#$self->_printstream(); |
120 |
|
} |
121 |
+ |
|
122 |
+ |
sub parsefilelist |
123 |
+ |
{ |
124 |
+ |
my $self=shift; |
125 |
+ |
my ($char,$buf); |
126 |
+ |
|
127 |
+ |
$self->{linecount}=0; |
128 |
+ |
$self->_resetvars(); |
129 |
+ |
$self->{streamstore}=""; |
130 |
+ |
$self->{streamtmp}=""; |
131 |
+ |
|
132 |
+ |
foreach my $buildfile (@{$self->{filename}}) |
133 |
+ |
{ |
134 |
+ |
if ( -f $buildfile) |
135 |
+ |
{ |
136 |
+ |
# Open the file |
137 |
+ |
use FileHandle; |
138 |
+ |
local $filehandle; |
139 |
+ |
$filehandle=FileHandle->new(); |
140 |
+ |
$self->verbose(">> Reading file: ".$buildfile." "); |
141 |
+ |
$filehandle->open("<".$buildfile) or return 1; |
142 |
+ |
|
143 |
+ |
# Start file processing |
144 |
+ |
while ( ($_=<$filehandle>) ) |
145 |
+ |
{ |
146 |
+ |
$self->{linecount}++; |
147 |
+ |
# Skip lines that start with a hash. A better way |
148 |
+ |
# of adding comments than ignore tags: |
149 |
+ |
next if (/^#/); |
150 |
+ |
$self->{currentline}=$_; |
151 |
+ |
$self->{stringpos}=0; |
152 |
+ |
while ( ($char=$self->_nextchar()) ne "" ) |
153 |
+ |
{ |
154 |
+ |
$self->_checkchar($char); |
155 |
+ |
} # end char while |
156 |
+ |
} # End String while loop |
157 |
+ |
undef $filehandle; |
158 |
+ |
# Make sure we close the last buffer: |
159 |
+ |
$self->_calltag($self->{textcontext}, $self->{textcontext}, |
160 |
+ |
$self->_getstore()); |
161 |
+ |
} |
162 |
+ |
} |
163 |
+ |
} |
164 |
|
|
165 |
|
# |
166 |
|
# return the current line number |
223 |
|
my $self=shift; |
224 |
|
my $char; |
225 |
|
$char=substr($self->{currentline},$self->{stringpos}++,1); |
175 |
– |
#print "Debug : Fetching character $char\n"; |
226 |
|
|
227 |
|
# Keep a record for any stream processes |
228 |
|
$self->{streamstore}=$self->{streamstore}.$char; |
254 |
|
$self->{tagcontext}="starttag"; |
255 |
|
$self->_checkchar($char); |
256 |
|
} |
207 |
– |
#print "\nDebug : Opening $self->{tagcontext}\n"; |
257 |
|
} |
258 |
|
|
259 |
|
# |
271 |
|
$tagroutine=$self->{tagname}."_".$self->{tagcontext}; |
272 |
|
$self->_calltag($tagroutine, $self->{tagname}, |
273 |
|
$self->{tagvar}); |
225 |
– |
#print "\nDebug : Closing Tag $tagroutine\n"; |
274 |
|
|
275 |
|
# -- Now make sure the text context is set for calling routines to |
276 |
|
# -- deal with text portions outside of tags |
313 |
|
my $rt; |
314 |
|
my $found=0; |
315 |
|
|
316 |
+ |
# print "TAGROUTINE: ",$tagroutine,"\n"; |
317 |
+ |
|
318 |
|
if ( $self->{groupchecker}->status() || |
319 |
|
( $self->{tagcontainer}->inquiregroup($tagroutine)) ) { |
320 |
|
($rt,$obj)=$self->{tagcontainer}->getroutine($tagroutine); |
365 |
|
my $this; |
366 |
|
|
367 |
|
undef @tempstack; |
318 |
– |
#print "In ----".$#{$stack}; |
368 |
|
# Keep popping until we find our string |
369 |
|
while ( ($this=(pop @{$stack})) ne "$name") { |
370 |
|
push @tempstack, $this; |
375 |
|
$this=pop @tempstack; |
376 |
|
push @{$stack}, $this; |
377 |
|
} |
329 |
– |
#print " Out ----".$#{$stack}; |
378 |
|
} |
379 |
|
|
380 |
|
# |