Subversion Repositories gelsvn

Rev

Rev 68 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 bj 1
package FeatureParser;
2
 
3
# ************************************************************
4
# Description   : Reads the feature files and store the values
5
# Author        : Chad Elliott
6
# Create Date   : 5/21/2003
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
use File::Basename;
15
 
16
use Parser;
17
 
18
use vars qw(@ISA);
19
@ISA = qw(Parser);
20
 
21
# ************************************************************
22
# Subroutine Section
23
# ************************************************************
24
 
25
sub new {
71 bj 26
  my($class)    = shift;
27
  my($features) = shift;
28
  my(@files)    = @_;
29
  my($self)     = $class->SUPER::new();
68 bj 30
 
31
  ## Set the values associative array
32
  $self->{'values'} = {};
33
 
34
  ## Process each feature file
71 bj 35
  foreach my $f (@files) {
68 bj 36
    if (defined $f) {
37
      my($status, $warn) = $self->cached_file_read($f);
38
      if (!$status) {
39
        ## We only want to warn the user about problems
40
        ## with the feature file.
41
        my($lnumber) = $self->get_line_number();
42
        $self->warning(basename($f) . ": line $lnumber: $warn");
43
      }
44
    }
45
  }
46
 
47
  ## Process each feature definition
48
  foreach my $feature (@$features) {
49
    my($status, $warn) = $self->parse_line(undef, $feature);
50
    if (!$status) {
51
      ## We only want to warn the user about problems
52
      ## with the -feature option.
53
      $self->warning("-features parameter: $warn");
54
    }
55
  }
56
 
57
  return $self;
58
}
59
 
60
 
61
sub parse_line {
62
  my($self)   = shift;
63
  my($if)     = shift;
64
  my($line)   = shift;
65
  my($status) = 1;
66
  my($error)  = undef;
67
 
68
  if ($line eq '') {
69
  }
70
  elsif ($line =~ /^(\w+)\s*=\s*(\d+)$/) {
71
    $self->{'values'}->{$1} = $2;
72
  }
73
  else {
74
    $status = 0;
75
    $error  = "Unrecognized line: $line";
76
  }
77
 
78
  return $status, $error;
79
}
80
 
81
 
82
sub get_value {
83
  my($self) = shift;
84
  my($tag)  = shift;
85
  return $self->{'values'}->{$tag};
86
}
87
 
88
 
89
1;