Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | 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 {
26
  my($class)       = shift;
27
  my($global_file) = shift;
28
  my($file)        = shift;
29
  my($features)    = shift;
30
  my($self)        = $class->SUPER::new();
31
 
32
  ## Set the values associative array
33
  $self->{'values'} = {};
34
 
35
  ## Process each feature file
36
  foreach my $f ($global_file, $file) {
37
    if (defined $f) {
38
      my($status, $warn) = $self->cached_file_read($f);
39
      if (!$status) {
40
        ## We only want to warn the user about problems
41
        ## with the feature file.
42
        my($lnumber) = $self->get_line_number();
43
        $self->warning(basename($f) . ": line $lnumber: $warn");
44
      }
45
    }
46
  }
47
 
48
  ## Process each feature definition
49
  foreach my $feature (@$features) {
50
    my($status, $warn) = $self->parse_line(undef, $feature);
51
    if (!$status) {
52
      ## We only want to warn the user about problems
53
      ## with the -feature option.
54
      $self->warning("-features parameter: $warn");
55
    }
56
  }
57
 
58
  return $self;
59
}
60
 
61
 
62
sub parse_line {
63
  my($self)   = shift;
64
  my($if)     = shift;
65
  my($line)   = shift;
66
  my($status) = 1;
67
  my($error)  = undef;
68
 
69
  if ($line eq '') {
70
  }
71
  elsif ($line =~ /^(\w+)\s*=\s*(\d+)$/) {
72
    $self->{'values'}->{$1} = $2;
73
  }
74
  else {
75
    $status = 0;
76
    $error  = "Unrecognized line: $line";
77
  }
78
 
79
  return $status, $error;
80
}
81
 
82
 
83
sub get_value {
84
  my($self) = shift;
85
  my($tag)  = shift;
86
  return $self->{'values'}->{$tag};
87
}
88
 
89
 
90
1;