ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/Parse.pm
Revision: 1.3
Committed: Fri Jan 14 18:48:46 2000 UTC (25 years, 3 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.2: +11 -4 lines
Log Message:
added new interfaces

File Contents

# User Rev Content
1 williamc 1.1 #
2     # Parse.pm
3     #
4     # Originally Written by Christopher Williams
5     #
6     # Description
7     # -----------
8     # maintain parse configurations
9     #
10     # Interface
11     # ---------
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
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
21     # tagstartline() : return the linenumber of the last tag opening
22 williamc 1.2 # includeparse(Parse) : include the settings from another parse object
23     # tags() : return list of defined tags
24 williamc 1.3 # cleartags() : clear of all tags
25 williamc 1.1
26    
27     package ActiveDoc::Parse;
28     require 5.004;
29     use ActiveDoc::Switcher;
30     use ActiveDoc::TagContainer;
31     use ActiveDoc::GroupChecker;
32    
33     sub new {
34     my $class=shift;
35     $self={};
36     bless $self, $class;
37     $self->init();
38     return $self;
39     }
40    
41     sub init {
42     my $self=shift;
43     $self->{gc}=GroupChecker->new();
44     $self->{gc}->include("all");
45     $self->{tags}=ActiveDoc::TagContainer->new();
46     }
47    
48     sub parse {
49     my $self=shift;
50     my $file=shift;
51    
52     # basic setup of switcher
53     $self->{switch}=ActiveDoc::Switcher->new($file);
54     $self->{switch}->usegroupchecker($self->{gc});
55     $self->{switch}->usetags($self->{tags});
56    
57     # do we need to switch on the streamer?
58     if ( @_ ) {
59     $fh=shift;
60     $self->{switch}->stream($fh);
61     foreach $tag ( @_ ) {
62     $self->{switch}->streamexclude($tag);
63     }
64     }
65    
66     # parse
67     $self->{switch}->parse();
68     undef $self->{switch};
69     }
70    
71     sub line {
72     my $self=shift;
73     if ( defined $self->{switch} ) {
74     return $self->{switch}->line();
75     }
76     return undef;
77     }
78    
79     sub tagstartline {
80     my $self=shift;
81     if ( defined $self->{switch} ) {
82     return $self->{switch}->tagstartline();
83     }
84     return undef;
85     }
86 williamc 1.2
87     sub includeparse {
88     my $self=shift;
89     my $obj=shift;
90    
91     my $tag;
92     # copy the tags from the remote parse object
93     foreach $tag ( $obj->tags() ) {
94     $self->addtag($tag,$obj->{tags}->tagsettings($tag));
95     }
96     # now the group settings
97     }
98    
99 williamc 1.1 sub addtag {
100     my $self=shift;
101     $self->{tags}->addtag(@_);
102     }
103    
104     sub addgrouptags {
105     my $self=shift;
106     $self->{tags}->addtag("Group", \&Group_Start,$self,
107     "", $self, \&Group_End, $self);
108     $self->{tags}->setgrouptag("Group");
109     }
110    
111     sub addignoretags {
112     my $self=shift;
113     $self->{gc}->exclude("ignore");
114     $self->{tags}->addtag("Ignore", \&Ignore_Start, $self,
115     "",$self, \&Ignore_End,$self);
116     }
117    
118 williamc 1.3 sub cleartags {
119     my $self=shift;
120     $self->{tags}->cleartags();
121     }
122    
123     sub tags {
124     my $self=shift;
125     return $self->{tags}->tags();
126     }
127    
128 williamc 1.1 # --------- Basic Group Related Tags ---------------------------------
129    
130     sub Group_Start {
131     my $self=shift;
132     my $name=shift;
133     my $vars=shift;
134     my $lastgp;
135    
136     $lastgp="group::".$$vars{name};
137     $self->{switch}->checkparam($name, 'name');
138     $self->{gc}->opencontext("group::".$$vars{name});
139    
140     }
141    
142     sub Group_End {
143     my $self=shift;
144     my $name=shift;
145     my $lastgp;
146    
147     $self->{gc}->closelastcontext("group");
148     }
149    
150     sub Ignore_Start {
151     my $self=shift;
152     my $name=shift;
153    
154     $self->{gc}->opencontext("ignore");
155     }
156    
157     sub Ignore_End {
158     my $self=shift;
159     $self->{gc}->closecontext("ignore");
160     }
161