Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 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
 
15
use Parser;
16
 
17
use vars qw(@ISA);
18
@ISA = qw(Parser);
19
 
20
# ************************************************************
21
# Subroutine Section
22
# ************************************************************
23
 
24
sub new {
25
  my($class)    = shift;
26
  my($features) = shift;
27
  my(@files)    = @_;
28
  my($self)     = $class->SUPER::new();
29
 
30
  ## Set the values associative array
31
  $self->{'values'} = {};
32
 
33
  ## Process each feature file
34
  foreach my $f (@files) {
35
    if (defined $f) {
36
      my($status, $warn) = $self->cached_file_read($f);
37
      if (!$status) {
38
        ## We only want to warn the user about problems
39
        ## with the feature file.
40
        my($lnumber) = $self->get_line_number();
217 bj 41
        $self->warning($self->mpc_basename($f) . ": line $lnumber: $warn");
107 bj 42
      }
43
    }
44
  }
45
 
46
  ## Process each feature definition
47
  foreach my $feature (@$features) {
48
    my($status, $warn) = $self->parse_line(undef, $feature);
49
    if (!$status) {
50
      ## We only want to warn the user about problems
51
      ## with the -feature option.
52
      $self->warning("-features parameter: $warn");
53
    }
54
  }
55
 
56
  return $self;
57
}
58
 
59
 
60
sub parse_line {
61
  my($self)   = shift;
62
  my($if)     = shift;
63
  my($line)   = shift;
64
  my($status) = 1;
65
  my($error)  = undef;
66
 
67
  if ($line eq '') {
68
  }
69
  elsif ($line =~ /^(\w+)\s*=\s*(\d+)$/) {
217 bj 70
    $self->{'values'}->{lc($1)} = $2;
107 bj 71
  }
72
  else {
73
    $status = 0;
74
    $error  = "Unrecognized line: $line";
75
  }
76
 
77
  return $status, $error;
78
}
79
 
80
 
217 bj 81
sub get_names {
82
  my($self)  = shift;
83
  my(@names) = keys %{$self->{'values'}};
84
  return \@names;
85
}
86
 
87
 
107 bj 88
sub get_value {
89
  my($self) = shift;
90
  my($tag)  = shift;
217 bj 91
  return $self->{'values'}->{lc($tag)};
107 bj 92
}
93
 
94
 
95
1;