IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3454


Ignore:
Timestamp:
Mar 18, 2005, 1:38:05 PM (21 years ago)
Author:
jhoblitt
Message:

move comment_line|blank_line removal into grammar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Metadata-Config/lib/PS/IPP/Metadata/Config.pm

    r3453 r3454  
    11# Copyright (c) 2005  Joshua Hoblitt
    22#
    3 # $Id: Config.pm,v 1.5 2005-03-18 22:12:45 jhoblitt Exp $
     3# $Id: Config.pm,v 1.6 2005-03-18 23:38:05 jhoblitt Exp $
    44
    55package PS::IPP::Metadata::Config;
     
    4343    #print Dumper($tree);
    4444   
    45     # remove comment only lines
    46     $self->_strip_comments( $tree ) or return undef;
    47 
    4845    # handle multi-symbol lines
    4946    $self->_merge_multi_symbols( $tree ) or return undef;
     
    5451
    5552    return $tree;
    56 }
    57 
    58 sub _strip_comments {
    59     my ( $self, $tree ) = @_;
    60 
    61     # Iteratate through the parse tree and remove the hashes that have a
    62     # class key equal to "comment_line".
    63     for (my $i = 0; $i < @{$tree}; $i++) {
    64         my $elem = $tree->[$i];
    65 
    66         # recurse through nested metadata
    67         if ( $elem->{class} eq "metadata" ) {
    68             $self->_strip_comments( $elem->{value} );
    69         }
    70 
    71         # stop if the prevous pass removed the last element and called redo
    72         last unless defined $elem;
    73 
    74         if ( $elem->{class} =~ /comment_line|blank_line/ ) {
    75             # delete element from array
    76             splice @$tree, $i, 1;
    77 
    78             # the list just got shorter by one element so we don't want to
    79             # increment the cursor
    80             redo;
    81         }
    82     }
    83 
    84     return 1;
    8553}
    8654
     
    192160grammar:
    193161    statement(s)
    194         { $item[1] }
     162        {[ grep $_->{class} !~ /(comment_line|blank_line)/, @{$item[1]} ]}
    195163
    196164statement:
Note: See TracChangeset for help on using the changeset viewer.