ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/Switcher.pm
(Generate patch)

Comparing COMP/SCRAM/src/ActiveDoc/Switcher.pm (file contents):
Revision 1.15 by williamc, Mon Aug 28 07:43:21 2000 UTC vs.
Revision 1.17 by sashby, Wed Mar 27 17:35:48 2002 UTC

# Line 6 | Line 6
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;
# Line 48 | Line 52 | sub streamexclude {
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;
# Line 90 | Line 95 | sub parse {
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;
103          # The buffering seems all messed up - best not to use it
# Line 149 | Line 157 | sub _checkchar {
157  
158          # ---- In a tag
159          if ( $self->{tagcontext}=~/tag/ ) {
160 +           $self->{tagbuff}=$self->{tagbuff}.$char;
161             if ( ! $self->_quotetest($char) ) {
162              if ( ! $self->_labeltest($char) ) {
163               if ( $char eq ">") { $self->_closetag(); }
# Line 171 | Line 180 | sub _nextchar() {
180          my $self=shift;
181          my $char;
182          $char=substr($self->{currentline},$self->{stringpos}++,1);
174        #print "Debug : Fetching character $char\n";
183  
184          # Keep a record for any stream processes
185          $self->{streamstore}=$self->{streamstore}.$char;
# Line 195 | Line 203 | sub _opentag {
203  
204          # Do we have an opening or closing tag?
205          if ( ($char=$self->_nextchar()) eq "/" ) { #we have a closing tag
206 +          $self->{tagbuff}="<".$char;
207            $self->{tagcontext}="endtag";
208          }
209          else { # an opening tag
210 +          $self->{tagbuff}="<";
211            $self->{tagcontext}="starttag";
212            $self->_checkchar($char);
213          }
214 <        #print "\nDebug : Opening $self->{tagcontext}\n";
214 > #       print "\nDebug : Opening $self->{tagcontext}\n";
215   }
216  
217   #
# Line 395 | Line 405 | sub _closelabel {
405              ($self->{tagname}=$self->_getstore())=~tr/A-Z/a-z/;
406           }
407           else {
408 <            die ">Tag syntax error in $self->{tagname} on line ".
409 <                $self->line()." of file \n$self->{filename}";
408 >            # do not die anymore - breaks non tag documents
409 >            #die ">Tag syntax error in $self->{tagname} on line ".
410 >            #   $self->line()." of file \n$self->{filename}";
411 >            # -- assume that this is plain text
412 >            $self->{tagcontext}="text";
413 >            $self->_resetstore();
414 >            $self->_unshiftstore($self->{tagbuff});
415 >            $self->{tagbuff}="";
416 >            return;
417           }
418          }
419          $self->_resetstore();
# Line 412 | Line 429 | sub _putstore() {
429          $self->{stringbuff}=$self->{stringbuff}.$char;
430   }
431  
432 + sub _unshiftstore() {
433 +        my $self=shift;
434 +        my $char=shift;
435 +
436 +        $self->{stringbuff}=$char.$self->{stringbuff};
437 + }
438 +
439   sub _getstore() {
440          my $self=shift;
441  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines