49 |
my $parser = new WebPAC::Parser( |
my $parser = new WebPAC::Parser( |
50 |
config => new WebPAC::Config(), |
config => new WebPAC::Config(), |
51 |
base_path => '/optional/path/to/conf', |
base_path => '/optional/path/to/conf', |
52 |
|
only_database => $only |
53 |
); |
); |
54 |
|
|
55 |
=cut |
=cut |
241 |
|
|
242 |
my $lookup_src_cache; |
my $lookup_src_cache; |
243 |
|
|
244 |
|
my $only_database = $self->{only_database}; |
245 |
|
my $only_input = $self->{only_input}; |
246 |
|
|
247 |
$self->{config}->iterate_inputs( sub { |
$self->{config}->iterate_inputs( sub { |
248 |
my ($input, $database) = @_; |
my ($input, $database) = @_; |
249 |
|
|
250 |
|
return if ( $only_database && $database !~ m/$only_database/i ); |
251 |
|
return if ( $only_input && $input->{name} !~ m/$only_input/i ); |
252 |
|
|
253 |
$log->debug("database: $database input = ", dump($input)); |
$log->debug("database: $database input = ", dump($input)); |
254 |
|
|
255 |
foreach my $normalize (@{ $input->{normalize} }) { |
foreach my $normalize (@{ $input->{normalize} }) { |
269 |
$self->{valid_inputs}->{$database}->{$input_name}++; |
$self->{valid_inputs}->{$database}->{$input_name}++; |
270 |
|
|
271 |
push @sources, sub { |
push @sources, sub { |
272 |
warn "### $database $input_name, $full ###\n"; |
#warn "### $database $input_name, $full ###\n"; |
273 |
$self->_parse_source( $database, $input_name, $full, $s ); |
$self->_parse_source( $database, $input_name, $full, $s ); |
274 |
}; |
}; |
275 |
|
|
312 |
|
|
313 |
my $Document = PPI::Document->new( \$source ) || $log->logdie("can't parse source:\n", $self->{source}); |
my $Document = PPI::Document->new( \$source ) || $log->logdie("can't parse source:\n", $self->{source}); |
314 |
|
|
315 |
$Document->prune('PPI::Token::Whitespace'); |
#$Document->prune('PPI::Token::Whitespace'); |
316 |
$Document->prune('PPI::Token::Comment'); |
$Document->prune('PPI::Token::Comment'); |
317 |
#$Document->prune('PPI::Token::Operator'); |
#$Document->prune('PPI::Token::Operator'); |
318 |
|
|
332 |
my ($Document,$Element) = @_; |
my ($Document,$Element) = @_; |
333 |
|
|
334 |
$Element->isa('PPI::Token::Word') or return ''; |
$Element->isa('PPI::Token::Word') or return ''; |
335 |
|
|
336 |
|
if ( $Element->content eq 'sub' ) { |
337 |
|
# repair demage done by prune of whitespace |
338 |
|
$Element->insert_after( PPI::Token::Whitespace->new(' ') ); |
339 |
|
return ''; |
340 |
|
} |
341 |
|
|
342 |
$Element->content eq 'lookup' or return ''; |
$Element->content eq 'lookup' or return ''; |
343 |
|
|
344 |
$log->debug("expansion: ", $Element->snext_sibling); |
$log->debug("expansion: ", $Element->snext_sibling); |
413 |
} |
} |
414 |
|
|
415 |
$e[7]->remove; |
$e[7]->remove; |
416 |
$e[8]->insert_before( new PPI::Token::Quote::Single( "'$key'" ) ); |
$e[8]->insert_before( PPI::Token::Quote::Single->new( "'$key'" ) ); |
417 |
$e[8]->remove; |
$e[8]->remove; |
418 |
|
|
419 |
|
|