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

Comparing COMP/SCRAM/src/ActiveDoc/Parse.pm (file contents):
Revision 1.8 by sashby, Mon Sep 11 14:50:21 2006 UTC vs.
Revision 1.9 by sashby, Tue Feb 27 11:59:42 2007 UTC

# Line 30 | Line 30
30   #                         if not registerd - the close tag will be ignored
31   #                         too if outside of the specified context!
32  
33
33   package ActiveDoc::Parse;
34   require 5.004;
35 < use ActiveDoc::Switcher;
37 < use ActiveDoc::TagContainer;
38 < use ActiveDoc::GroupChecker;
35 > use XML::Parser;
36  
37 < sub new
37 > sub new()
38     {
39     my $class=shift;
40     $self={};
41     bless $self, $class;
42 <   $self->init();
42 >   my ($dataclass, $parse_style)=@_;
43 >
44 >   $self->{xmlparser} = new XML::Parser (
45 >                                         Style => $parse_style,
46 >                                         ParseParamEnt => 1,
47 >                                         ErrorContext => 3,
48 >                                         Pkg   => $dataclass);  
49     return $self;
50     }
51  
52 < sub init
52 > sub parsefilelist()
53     {
54     my $self=shift;
55 <   $self->{gc}=GroupChecker->new();
56 <   $self->{gc}->include("all");
54 <   $self->{tags}=ActiveDoc::TagContainer->new();
55 >   my ($files)=@_;
56 >   print __PACKAGE__."::parsefilelist(): Not used?\n";
57     }
58  
59 < sub parse
59 > sub parse()
60     {
61     my $self=shift;
62 <   my $file=shift;
63 <  
64 <   # basic setup of switcher
63 <   $self->{switch}=ActiveDoc::Switcher->new($file);
64 <   $self->{switch}->usegroupchecker($self->{gc});
65 <   $self->{switch}->usetags($self->{tags});
66 <
67 <   # do we need to switch on the streamer?
68 <   if ( @_ )
69 <      {
70 <      $fh=shift;
71 <      $self->{switch}->stream($fh);
72 <      foreach $tag ( @_ )
73 <         {
74 <         $self->{switch}->streamexclude($tag);
75 <         }
76 <      }
77 <
78 <   # -- parse
79 <   $self->{switch}->parse();
80 <   undef $self->{switch};
62 >   my ($file)=@_;
63 >   $self->{data} = $self->{xmlparser}->parse($self->getfilestring_($file));
64 >   return $self;
65     }
66  
67 < sub parsefilelist()
67 > sub getfilestring_()
68     {
69     my $self=shift;
70 <   my ($files)=@_;
71 <   # basic setup of switcher
72 <   $self->{switch}=ActiveDoc::Switcher->new($files);  
73 <   $self->{switch}->usegroupchecker($self->{gc});
74 <   $self->{switch}->usetags($self->{tags});
75 <
76 <   # -- parse
77 <   $self->{switch}->parsefilelist();
78 <   undef $self->{switch};
70 >   my ($file)=@_;
71 >   open (IN, "< $file") or die __PACKAGE__.": Cannot read file $file: $!\n";
72 >   my $filestring = join("", <IN>);
73 >   close (IN) or die __PACKAGE__.": Cannot read file $file: $!\n";
74 >   # Strip spaces at the beginning and end of the line:
75 >   $filestring =~ s/^\s+//g;
76 >   $filestring =~ s/\s+$//g;
77 >   # Finally strip the newlines:
78 >   $filestring =~ s/\n//g;
79 >   # Strip out spaces in between tags:
80 >   $filestring =~ s/>\s+</></g;
81 >   $self->{filestring}=$filestring;
82 >   return $filestring;
83     }
84  
85 < sub line
85 > sub data()
86     {
87     my $self=shift;
88 <  
101 <   if ( defined $self->{switch} )
102 <      {
103 <      return $self->{switch}->line();
104 <      }
105 <   return undef;
106 <   }
107 <
108 < sub tagstartline
109 <   {
110 <   my $self=shift;
111 <
112 <   if ( defined $self->{switch} )
113 <      {
114 <      return $self->{switch}->tagstartline();
115 <      }
116 <   return undef;
88 >   return $self->{data}->[0];
89     }
90  
91   sub includeparse
# Line 127 | Line 99 | sub includeparse
99        {
100        $self->addtag($tag,$obj->{tags}->tagsettings($tag));
101        }
130   # now the group settings
102     }
103  
104   sub addtag
# Line 136 | Line 107 | sub addtag
107     $self->{tags}->addtag(@_);
108     }
109  
110 < sub addgrouptags
140 <   {
141 <   my $self=shift;
142 <   $self->{tags}->addtag("Group", \&Group_Start,$self,
143 <                         "", $self, \&Group_End, $self);
144 <   $self->{tags}->setgrouptag("Group");
145 <   }
146 <
147 < sub addignoretags
148 <   {
149 <   my $self=shift;
150 <   $self->{gc}->exclude("ignore");
151 <   $self->{tags}->addtag("Ignore", \&Ignore_Start, $self,
152 <                         "",$self, \&Ignore_End,$self);
153 <   $self->{tags}->setgrouptag("Ignore");
154 <   }
155 <
156 < sub contexttag
157 <   {
158 <   my $self=shift;
159 <   my $name=shift;
160 <   $self->{tags}->setgrouptag($name);
161 <   }
162 <
163 < sub opencontext
164 <   {
165 <   my $self=shift;
166 <   my $name=shift;
167 <   $self->{gc}->opencontext($name);
168 <   }
169 <
170 < sub closecontext
171 <   {
172 <   my $self=shift;
173 <   my $name=shift;
174 <   $self->{gc}->closecontext($name);
175 <   }
176 <
177 < sub includecontext
178 <   {
179 <   my $self=shift;
180 <   my $name=shift;
181 <   $self->{gc}->unexclude($name);
182 <   $self->{gc}->include($name);
183 <   }
184 <
185 < sub excludecontext
186 <   {
187 <   my $self=shift;
188 <   my $name=shift;
189 <   $self->{gc}->exclude($name);
190 <   $self->{gc}->uninclude($name);
191 <   }
192 <
193 < sub cleartags
194 <   {
195 <   my $self=shift;
196 <   $self->{tags}->cleartags();
197 <   }
198 <
199 < sub tags {
200 <         my $self=shift;
201 <         return $self->{tags}->tags();
202 < }
203 <
204 < # ---------  Basic Group Related Tags ---------------------------------
205 <
206 < sub Group_Start
207 <   {
208 <   my $self=shift;
209 <   my $name=shift;
210 <   my $vars=shift;
211 <   my $lastgp;
212 <   $lastgp="group::".$$vars{name};
213 <   $self->{switch}->checkparam($name, 'name');
214 <   $self->{gc}->opencontext("group::".$$vars{name});  
215 <   }
216 <
217 < sub Group_End
218 <   {
219 <   my $self=shift;
220 <   my $name=shift;
221 <   $self->{gc}->closelastcontext("group");
222 <   }
223 <
224 < sub Ignore_Start
225 <   {
226 <   my $self=shift;
227 <   my $name=shift;
228 <   $self->{gc}->opencontext("ignore");
229 <   }
230 <
231 < sub Ignore_End
232 <   {
233 <   my $self=shift;
234 <   $self->{gc}->closecontext("ignore");
235 <   }
236 <
110 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines