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.3 by williamc, Fri Jan 14 18:48:46 2000 UTC vs.
Revision 1.8 by sashby, Mon Sep 11 14:50:21 2006 UTC

# Line 9 | Line 9
9   #
10   # Interface
11   # ---------
12 < # new()         : A new Parse object
12 > # new()                 : A new Parse object
13   # addtag(name,start,text,end,$object)   : Add a new tag
14 < # addgrouptags()  : add <Group> tag functionality
15 < # addignoretags() : add <ignore> tag functionality
14 > # addgrouptags()        : add <Group> tag functionality
15 > # addignoretags()       : add <ignore> tag functionality
16   # parse(filename,[streamhandle], [streamexcludetag]) :
17   #                               parse the given file - turn on the stream
18   #                                  function of the switcher if a filehandle
19   #                                  supplied as a second argument
20 < # line()        : return the current linenumber in the file
20 > # line()                : return the current linenumber in the file
21   # tagstartline()        : return the linenumber of the last tag opening
22 < # includeparse(Parse) : include the settings from another parse object
22 > # includeparse(Parse)   : include the settings from another parse object
23   # tags()                : return list of defined tags
24   # cleartags()           : clear of all tags
25 + # opencontext(name)     : open a parse context
26 + # closecontext(name)    : close a parse context
27 + # includecontext(name)  : Process when in a given context
28 + # excludecontext(name)  : No Processing when given context
29 + # contexttag(tagname)   : Register the tagname as one able to change context
30 + #                         if not registerd - the close tag will be ignored
31 + #                         too if outside of the specified context!
32  
33  
34   package ActiveDoc::Parse;
# Line 30 | Line 37 | use ActiveDoc::Switcher;
37   use ActiveDoc::TagContainer;
38   use ActiveDoc::GroupChecker;
39  
40 < sub new {
41 <        my $class=shift;
42 <        $self={};
43 <        bless $self, $class;
44 <        $self->init();
45 <        return $self;
46 < }
47 <
48 < sub init {
49 <        my $self=shift;
50 <        $self->{gc}=GroupChecker->new();
51 <        $self->{gc}->include("all");
52 <        $self->{tags}=ActiveDoc::TagContainer->new();
53 < }
54 <
55 < sub parse {
56 <        my $self=shift;
57 <        my $file=shift;
58 <        
59 <        # basic setup of switcher
60 <        $self->{switch}=ActiveDoc::Switcher->new($file);
61 <        $self->{switch}->usegroupchecker($self->{gc});
62 <        $self->{switch}->usetags($self->{tags});
63 <
64 <        # do we need to switch on the streamer?
65 <        if ( @_ ) {
66 <           $fh=shift;
67 <           $self->{switch}->stream($fh);
68 <           foreach $tag ( @_ ) {
69 <                $self->{switch}->streamexclude($tag);
70 <           }
71 <        }
72 <
73 <        # parse
74 <        $self->{switch}->parse();
75 <        undef $self->{switch};
76 < }
77 <
78 < sub line {
79 <        my $self=shift;
80 <        if ( defined $self->{switch} ) {
81 <          return $self->{switch}->line();
82 <        }
83 <        return undef;
84 < }
85 <
86 < sub tagstartline {
87 <        my $self=shift;
88 <        if ( defined $self->{switch} ) {
89 <          return $self->{switch}->tagstartline();
90 <        }
91 <        return undef;
92 < }
93 <
94 < sub includeparse {
95 <        my $self=shift;
96 <        my $obj=shift;
97 <
98 <        my $tag;
99 <        # copy the tags from  the remote parse object
100 <        foreach $tag ( $obj->tags() ) {
101 <          $self->addtag($tag,$obj->{tags}->tagsettings($tag));
102 <        }
103 <        # now the group settings
104 < }
105 <
106 < sub addtag {
107 <        my $self=shift;
108 <        $self->{tags}->addtag(@_);
109 < }
110 <
111 < sub addgrouptags {
112 <        my $self=shift;
113 <        $self->{tags}->addtag("Group", \&Group_Start,$self,
114 <                                "", $self, \&Group_End, $self);
115 <        $self->{tags}->setgrouptag("Group");
116 < }
117 <
118 < sub addignoretags {
119 <        my $self=shift;
120 <        $self->{gc}->exclude("ignore");
121 <        $self->{tags}->addtag("Ignore", \&Ignore_Start, $self,
122 <                        "",$self, \&Ignore_End,$self);
123 < }
124 <
125 < sub cleartags {
126 <        my $self=shift;
127 <        $self->{tags}->cleartags();
128 < }
40 > sub new
41 >   {
42 >   my $class=shift;
43 >   $self={};
44 >   bless $self, $class;
45 >   $self->init();
46 >   return $self;
47 >   }
48 >
49 > sub init
50 >   {
51 >   my $self=shift;
52 >   $self->{gc}=GroupChecker->new();
53 >   $self->{gc}->include("all");
54 >   $self->{tags}=ActiveDoc::TagContainer->new();
55 >   }
56 >
57 > sub parse
58 >   {
59 >   my $self=shift;
60 >   my $file=shift;
61 >  
62 >   # 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};
81 >   }
82 >
83 > sub parsefilelist()
84 >   {
85 >   my $self=shift;
86 >   my ($files)=@_;
87 >   # basic setup of switcher
88 >   $self->{switch}=ActiveDoc::Switcher->new($files);  
89 >   $self->{switch}->usegroupchecker($self->{gc});
90 >   $self->{switch}->usetags($self->{tags});
91 >
92 >   # -- parse
93 >   $self->{switch}->parsefilelist();
94 >   undef $self->{switch};
95 >   }
96 >
97 > sub line
98 >   {
99 >   my $self=shift;
100 >  
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;
117 >   }
118 >
119 > sub includeparse
120 >   {
121 >   my $self=shift;
122 >   my $obj=shift;
123 >   my $tag;
124 >  
125 >   # copy the tags from  the remote parse object
126 >   foreach $tag ( $obj->tags() )
127 >      {
128 >      $self->addtag($tag,$obj->{tags}->tagsettings($tag));
129 >      }
130 >   # now the group settings
131 >   }
132 >
133 > sub addtag
134 >   {
135 >   my $self=shift;
136 >   $self->{tags}->addtag(@_);
137 >   }
138 >
139 > 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;
# Line 127 | Line 203 | sub tags {
203  
204   # ---------  Basic Group Related Tags ---------------------------------
205  
206 < sub Group_Start {
207 <        my $self=shift;
208 <        my $name=shift;
209 <        my $vars=shift;
210 <        my $lastgp;
211 <
212 <        $lastgp="group::".$$vars{name};
213 <        $self->{switch}->checkparam($name, 'name');
214 <        $self->{gc}->opencontext("group::".$$vars{name});
215 <
216 < }
217 <
218 < sub Group_End {
219 <        my $self=shift;
220 <        my $name=shift;
221 <        my $lastgp;
222 <
223 <        $self->{gc}->closelastcontext("group");
224 < }
225 <
226 < sub Ignore_Start {
227 <        my $self=shift;
228 <        my $name=shift;
229 <
230 <        $self->{gc}->opencontext("ignore");
231 < }
232 <
233 < sub Ignore_End {
234 <        my $self=shift;
235 <        $self->{gc}->closecontext("ignore");
160 < }
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines