/[webpac2]/trunk/lib/WebPAC/Parser.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Parser.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 707 by dpavlin, Mon Sep 25 15:26:12 2006 UTC revision 724 by dpavlin, Fri Sep 29 18:55:31 2006 UTC
# Line 17  WebPAC::Parser - parse perl normalizatio Line 17  WebPAC::Parser - parse perl normalizatio
17    
18  =head1 VERSION  =head1 VERSION
19    
20  Version 0.05  Version 0.06
21    
22  =cut  =cut
23    
24  our $VERSION = '0.05';  our $VERSION = '0.06';
25    
26  =head1 SYNOPSIS  =head1 SYNOPSIS
27    
# Line 148  sub lookup_create_rules { Line 148  sub lookup_create_rules {
148          return $self->{_lookup_create}->{ _q($database) }->{ _q($input) };          return $self->{_lookup_create}->{ _q($database) }->{ _q($input) };
149  }  }
150    
151    =head2 normalize_rules
152    
153      my $source = $parser->normalize_rules($database, $input);
154    
155    =cut
156    
157    sub normalize_rules {
158            my $self = shift;
159            my ($database,$input) = @_;
160            $input = _input_name($input);
161            return unless (
162                    defined( $self->{_normalize_source}->{ _q($database) } ) &&
163                    defined( $self->{_normalize_source}->{ _q($database) }->{ _q($input) } )
164            );
165            return $self->{_normalize_source}->{ _q($database) }->{ _q($input) };
166    }
167    
168  =head1 PRIVATE  =head1 PRIVATE
169    
170  =head2 _read_sources  =head2 _read_sources
# Line 208  sub _read_sources { Line 225  sub _read_sources {
225    
226    $parser->_parse_lookups($database,$input,$path,$source);    $parser->_parse_lookups($database,$input,$path,$source);
227    
228  Called for each normalize source (rules) in each input by L</read_sources>  Called for each normalize source (rules) in each input by L</_read_sources>
229    
230  It will report invalid databases and inputs in error log after parsing.  It will report invalid databases and inputs in error log after parsing.
231    
# Line 232  sub _parse_lookups { Line 249  sub _parse_lookups {
249          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});
250    
251          $Document->prune('PPI::Token::Whitespace');          $Document->prune('PPI::Token::Whitespace');
252            $Document->prune('PPI::Token::Comment');
253          #$Document->prune('PPI::Token::Operator');          #$Document->prune('PPI::Token::Operator');
254    
255          # Find all the named subroutines          # Find all the named subroutines
# Line 296  sub _parse_lookups { Line 314  sub _parse_lookups {
314    
315                          $log->debug("key = $key");                          $log->debug("key = $key");
316    
                         my $create = "save_into_lookup('$key', $e[7] $e[8] );\n";  
   
                         $log->debug("create: $create");  
   
317                          return $self->_lookup_error("invalid database $e[3] in $path" ) unless $self->valid_database( $e[3] );                          return $self->_lookup_error("invalid database $e[3] in $path" ) unless $self->valid_database( $e[3] );
318                          return $self->_lookup_error("invalid input $e[5] of database $e[3] in $path", ) unless $self->valid_database_input( $e[3], $e[5] );                          return $self->_lookup_error("invalid input $e[5] of database $e[3] in $path", ) unless $self->valid_database_input( $e[3], $e[5] );
319    
320                            my $create = qq{
321                                    save_into_lookup($e[3],$e[5],'$key', $e[7] $e[8] );
322                            };
323    
324                            $log->debug("create: $create");
325    
326                          # save code to create this lookup                          # save code to create this lookup
327                          $self->{_lookup_create}->{ _q($e[3]) }->{ _q($e[5]) } .= $create;                          $self->{_lookup_create}->{ _q($e[3]) }->{ _q($e[5]) } .= $create;
328                          $self->{_lookup_create_key}->{ _q($e[3]) }->{ _q($e[5]) }->{ _q($key) }++;                          $self->{_lookup_create_key}->{ _q($e[3]) }->{ _q($e[5]) }->{ _q($key) }++;
# Line 333  sub _parse_lookups { Line 353  sub _parse_lookups {
353          $log->debug("create: ", dump($self->{_lookup_create}) );          $log->debug("create: ", dump($self->{_lookup_create}) );
354          $log->debug("normalize: $normalize_source");          $log->debug("normalize: $normalize_source");
355    
356          $self->{_normalize_source}->{$database}->{$input} = $normalize_source;          $self->{_normalize_source}->{$database}->{$input} .= $normalize_source;
357    
358          if ($self->{debug}) {          if ($self->{debug}) {
359                  my $Dumper = PPI::Dumper->new( $Document );                  my $Dumper = PPI::Dumper->new( $Document );

Legend:
Removed from v.707  
changed lines
  Added in v.724

  ViewVC Help
Powered by ViewVC 1.1.26