5 |
|
# |
6 |
|
# Description |
7 |
|
# ----------- |
8 |
< |
# Simple multi parsing functionality |
8 |
> |
# Simple multi parsing functionality and group manipulation |
9 |
|
# |
10 |
|
# Interface |
11 |
|
# --------- |
13 |
|
# filetoparse([filename]) : Set/Return the filename of document |
14 |
|
# newparse(parselabel) : Create a new parse type |
15 |
|
# parse(parselabel) : Parse the document file for the given parse level |
16 |
< |
# addtag(parselabel,tagname,start,obj,text,obj,end,obj) : |
16 |
> |
# addtag(parselabel,tagname,start,obj,[text,obj,end,obj]) : |
17 |
|
# Add tags to the parse given by label |
18 |
+ |
# grouptag(tagname, parselabel) : Allow a tag to switch context |
19 |
+ |
# - if not you can never turn a context off! |
20 |
|
# checktag(tagname, hashref, param) : check for existence of param in |
21 |
|
# hashref from a tag call |
22 |
|
# includeparse(local_parsename, objparsename, activedoc) : copy the parse from |
26 |
|
# |
27 |
|
# addignoretags(parsename) : add <ignore> </igonore> tags funtionality to the |
28 |
|
# specified parse |
29 |
+ |
# opengroup(name) : declare a group to be open |
30 |
+ |
# closegroup(name) : declare a group to be closed |
31 |
+ |
# allowgroup(name,parse) : allow a group so named |
32 |
+ |
# disallowgroup(name,parse) : disallow the named group |
33 |
+ |
# restoregroup(name,parse) : restore group access setting (that before last change) |
34 |
|
# --------------- Error handling routines --------------- |
35 |
|
# verbose(string) : Print string in verbosity mode |
36 |
|
# verbosity(0|1) : verbosity off|on |
77 |
|
$parselabel=shift; |
78 |
|
|
79 |
|
my $file=$self->filetoparse(); |
80 |
< |
if ( $file ) { |
80 |
> |
if ( -f $file ) { |
81 |
|
if ( exists $self->{parsers}{$parselabel} ) { |
82 |
|
$self->verbose("Parsing $parselabel in file $file"); |
83 |
|
$self->{currentparsename}=$parselabel; |
89 |
|
} |
90 |
|
} |
91 |
|
else { |
92 |
< |
$self->error("Cannot parse $parselabel - file not known"); |
92 |
> |
$self->error("Cannot parse \"$parselabel\" - file $file not known"); |
93 |
|
} |
94 |
|
} |
95 |
|
|
149 |
|
sub addtag { |
150 |
|
my $self=shift; |
151 |
|
my $parselabel=shift; |
152 |
< |
if ( $#_ != 6 ) { |
152 |
> |
if ( ( $#_ != 6 ) && ( $#_ != 2) ) { |
153 |
|
$self->error("Incorrect addtags specification\n". |
154 |
|
"called with :\n@_ \n"); |
155 |
|
} |
164 |
|
} |
165 |
|
return $self->{filename}; |
166 |
|
} |
167 |
+ |
# --------- Group services |
168 |
+ |
sub grouptag { |
169 |
+ |
my $self=shift; |
170 |
+ |
my $name=shift; |
171 |
+ |
my $parselabel=shift; |
172 |
+ |
|
173 |
+ |
$self->{parsers}{$parselabel}->contexttag($name); |
174 |
+ |
} |
175 |
+ |
|
176 |
+ |
sub opengroup { |
177 |
+ |
my $self=shift; |
178 |
+ |
my $name=shift; |
179 |
+ |
|
180 |
+ |
if ( defined $self->currentparser ) { |
181 |
+ |
$self->currentparser()->opencontext($name); |
182 |
+ |
} |
183 |
+ |
else { |
184 |
+ |
$self->error("Cannot Call opengroup outside of a parse (". |
185 |
+ |
caller().")"); |
186 |
+ |
} |
187 |
+ |
} |
188 |
+ |
|
189 |
+ |
sub closegroup { |
190 |
+ |
my $self=shift; |
191 |
+ |
my $name=shift; |
192 |
+ |
|
193 |
+ |
if ( defined $self->currentparser ) { |
194 |
+ |
$self->currentparser()->closecontext($name); |
195 |
+ |
} |
196 |
+ |
else { |
197 |
+ |
$self->error("Cannot Call closegroup outside of a parse (". |
198 |
+ |
caller().")"); |
199 |
+ |
} |
200 |
+ |
} |
201 |
+ |
|
202 |
+ |
sub allowgroup { |
203 |
+ |
my $self=shift; |
204 |
+ |
my $name=shift; |
205 |
+ |
my $parselabel=shift; |
206 |
+ |
|
207 |
+ |
$self->{parsers}{$parselabel}->includecontext($name); |
208 |
+ |
} |
209 |
+ |
|
210 |
+ |
sub disallowgroup { |
211 |
+ |
my $self=shift; |
212 |
+ |
my $name=shift; |
213 |
+ |
my $parselabel=shift; |
214 |
+ |
|
215 |
+ |
$self->{parsers}{$parselabel}->excludecontext($name); |
216 |
+ |
} |
217 |
|
|
218 |
|
# -------- Error Handling and Error services -------------- |
219 |
|
|