Subversion Repositories gelsvn

Rev

Rev 198 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 198 Rev 217
1
package Creator;
1
package Creator;
2
 
2
 
3
# ************************************************************
3
# ************************************************************
4
# Description   : Base class for workspace and project creators
4
# Description   : Base class for workspace and project creators
5
# Author        : Chad Elliott
5
# Author        : Chad Elliott
6
# Create Date   : 5/13/2002
6
# Create Date   : 5/13/2002
7
# ************************************************************
7
# ************************************************************
8
 
8
 
9
# ************************************************************
9
# ************************************************************
10
# Pragmas
10
# Pragmas
11
# ************************************************************
11
# ************************************************************
12
 
12
 
13
use strict;
13
use strict;
14
use FileHandle;
14
use FileHandle;
15
use File::Basename;
-
 
16
 
15
 
17
use Parser;
16
use Parser;
18
 
17
 
19
use vars qw(@ISA);
18
use vars qw(@ISA);
20
@ISA = qw(Parser);
19
@ISA = qw(Parser);
21
 
20
 
22
# ************************************************************
21
# ************************************************************
23
# Data Section
22
# Data Section
24
# ************************************************************
23
# ************************************************************
25
 
24
 
-
 
25
my($assign_key)  = 'assign';
-
 
26
my($gassign_key) = 'global_assign';
-
 
27
 
26
my(@statekeys) = ('global', 'include', 'template', 'ti',
28
my(@statekeys) = ('global', 'include', 'template', 'ti',
27
                  'dynamic', 'static', 'relative', 'addtemp',
29
                  'dynamic', 'static', 'relative', 'addtemp',
28
                  'addproj', 'progress', 'toplevel', 'baseprojs',
30
                  'addproj', 'progress', 'toplevel', 'baseprojs',
29
                  'feature_file', 'features', 'hierarchy',
31
                  'feature_file', 'features', 'hierarchy',
30
                  'name_modifier', 'apply_project', 'into', 'use_env',
32
                  'name_modifier', 'apply_project', 'into', 'use_env',
31
                  'expand_vars',
33
                  'expand_vars', 'language',
32
                 );
34
                 );
33
 
35
 
34
my(%all_written) = ();
36
my(%all_written) = ();
-
 
37
my($onVMS) = ($^O eq 'VMS');
35
 
38
 
36
# ************************************************************
39
# ************************************************************
37
# Subroutine Section
40
# Subroutine Section
38
# ************************************************************
41
# ************************************************************
39
 
42
 
40
sub new {
43
sub new {
41
  my($class)      = shift;
44
  my($class)      = shift;
42
  my($global)     = shift;
45
  my($global)     = shift;
43
  my($inc)        = shift;
46
  my($inc)        = shift;
44
  my($template)   = shift;
47
  my($template)   = shift;
45
  my($ti)         = shift;
48
  my($ti)         = shift;
46
  my($dynamic)    = shift;
49
  my($dynamic)    = shift;
47
  my($static)     = shift;
50
  my($static)     = shift;
48
  my($relative)   = shift;
51
  my($relative)   = shift;
49
  my($addtemp)    = shift;
52
  my($addtemp)    = shift;
50
  my($addproj)    = shift;
53
  my($addproj)    = shift;
51
  my($progress)   = shift;
54
  my($progress)   = shift;
52
  my($toplevel)   = shift;
55
  my($toplevel)   = shift;
53
  my($baseprojs)  = shift;
56
  my($baseprojs)  = shift;
54
  my($feature)    = shift;
57
  my($feature)    = shift;
55
  my($features)   = shift;
58
  my($features)   = shift;
56
  my($hierarchy)  = shift;
59
  my($hierarchy)  = shift;
57
  my($nmodifier)  = shift;
60
  my($nmodifier)  = shift;
58
  my($applypj)    = shift;
61
  my($applypj)    = shift;
59
  my($into)       = shift;
62
  my($into)       = shift;
60
  my($language)   = shift;
63
  my($language)   = shift;
61
  my($use_env)    = shift;
64
  my($use_env)    = shift;
62
  my($expandvars) = shift;
65
  my($expandvars) = shift;
63
  my($type)       = shift;
66
  my($type)       = shift;
64
  my($self)       = Parser::new($class, $inc);
67
  my($self)       = Parser::new($class, $inc);
65
 
68
 
66
  $self->{'relative'}        = $relative;
69
  $self->{'relative'}        = $relative;
67
  $self->{'template'}        = $template;
70
  $self->{'template'}        = $template;
68
  $self->{'ti'}              = $ti;
71
  $self->{'ti'}              = $ti;
69
  $self->{'global'}          = $global;
72
  $self->{'global'}          = $global;
70
  $self->{'grammar_type'}    = $type;
73
  $self->{'grammar_type'}    = $type;
71
  $self->{'type_check'}      = $type . '_defined';
74
  $self->{'type_check'}      = $type . '_defined';
72
  $self->{'global_read'}     = 0;
75
  $self->{'global_read'}     = 0;
73
  $self->{'current_input'}   = '';
76
  $self->{'current_input'}   = '';
74
  $self->{'progress'}        = $progress;
77
  $self->{'progress'}        = $progress;
75
  $self->{'addtemp'}         = $addtemp;
78
  $self->{'addtemp'}         = $addtemp;
76
  $self->{'addproj'}         = $addproj;
79
  $self->{'addproj'}         = $addproj;
77
  $self->{'toplevel'}        = $toplevel;
80
  $self->{'toplevel'}        = $toplevel;
78
  $self->{'files_written'}   = {};
81
  $self->{'files_written'}   = {};
79
  $self->{'real_fwritten'}   = [];
82
  $self->{'real_fwritten'}   = [];
80
  $self->{'reading_global'}  = 0;
83
  $self->{'reading_global'}  = 0;
81
  $self->{'global_assign'}   = {};
84
  $self->{$gassign_key}      = {};
82
  $self->{'assign'}          = {};
85
  $self->{$assign_key}       = {};
83
  $self->{'baseprojs'}       = $baseprojs;
86
  $self->{'baseprojs'}       = $baseprojs;
84
  $self->{'dynamic'}         = $dynamic;
87
  $self->{'dynamic'}         = $dynamic;
85
  $self->{'static'}          = $static;
88
  $self->{'static'}          = $static;
86
  $self->{'feature_file'}    = $feature;
89
  $self->{'feature_file'}    = $feature;
87
  $self->{'features'}        = $features;
90
  $self->{'features'}        = $features;
88
  $self->{'hierarchy'}       = $hierarchy;
91
  $self->{'hierarchy'}       = $hierarchy;
89
  $self->{'name_modifier'}   = $nmodifier;
92
  $self->{'name_modifier'}   = $nmodifier;
90
  $self->{'apply_project'}   = $applypj;
93
  $self->{'apply_project'}   = $applypj;
91
  $self->{'into'}            = $into;
94
  $self->{'into'}            = $into;
92
  $self->{'language'}        = $language;
95
  $self->{'language'}        = $language;
93
  $self->{'use_env'}         = $use_env;
96
  $self->{'use_env'}         = $use_env;
94
  $self->{'expand_vars'}     = $expandvars;
97
  $self->{'expand_vars'}     = $expandvars;
95
  $self->{'convert_slashes'} = $self->convert_slashes();
98
  $self->{'convert_slashes'} = $self->convert_slashes();
-
 
99
  $self->{'case_tolerant'}   = $self->case_insensitive();
96
 
100
 
97
  return $self;
101
  return $self;
98
}
102
}
99
 
103
 
100
 
104
 
101
sub preprocess_line {
105
sub preprocess_line {
102
  my($self) = shift;
106
  my($self) = shift;
103
  my($fh)   = shift;
107
  my($fh)   = shift;
104
  my($line) = shift;
108
  my($line) = shift;
105
 
109
 
106
  $line = $self->strip_line($line);
110
  $line = $self->strip_line($line);
107
  while ($line =~ /\\$/) {
111
  while ($line =~ /\\$/) {
108
    $line =~ s/\s*\\$/ /;
112
    $line =~ s/\s*\\$/ /;
109
    my($next) = $fh->getline();
113
    my($next) = $fh->getline();
110
    if (defined $next) {
114
    if (defined $next) {
111
      $line .= $self->strip_line($next);
115
      $line .= $self->strip_line($next);
112
    }
116
    }
113
  }
117
  }
114
  return $line;
118
  return $line;
115
}
119
}
116
 
120
 
117
 
121
 
118
sub generate_default_input {
122
sub generate_default_input {
119
  my($self)  = shift;
123
  my($self)  = shift;
120
  my($status,
124
  my($status,
121
     $error) = $self->parse_line(undef, "$self->{'grammar_type'} {");
125
     $error) = $self->parse_line(undef, "$self->{'grammar_type'} {");
122
 
126
 
123
  if ($status) {
127
  if ($status) {
124
    ($status, $error) = $self->parse_line(undef, '}');
128
    ($status, $error) = $self->parse_line(undef, '}');
125
  }
129
  }
126
 
130
 
127
  if (!$status) {
131
  if (!$status) {
128
    $self->error($error);
132
    $self->error($error);
129
  }
133
  }
130
 
134
 
131
  return $status;
135
  return $status;
132
}
136
}
133
 
137
 
134
 
138
 
135
sub parse_file {
139
sub parse_file {
136
  my($self)  = shift;
140
  my($self)  = shift;
137
  my($input) = shift;
141
  my($input) = shift;
138
  my($oline) = $self->get_line_number();
142
  my($oline) = $self->get_line_number();
139
 
143
 
140
  ## Read the input file and get the last line number
144
  ## Read the input file and get the last line number
141
  my($status, $errorString) = $self->read_file($input);
145
  my($status, $errorString) = $self->read_file($input);
142
 
146
 
143
  if (!$status) {
147
  if (!$status) {
144
    $self->error($errorString,
148
    $self->error($errorString,
145
                 "$input: line " . $self->get_line_number() . ':');
149
                 "$input: line " . $self->get_line_number() . ':');
146
  }
150
  }
147
  elsif ($status && $self->{$self->{'type_check'}}) {
151
  elsif ($status && $self->{$self->{'type_check'}}) {
148
    ## If we are at the end of the file and the type we are looking at
152
    ## If we are at the end of the file and the type we are looking at
149
    ## is still defined, then we have an error
153
    ## is still defined, then we have an error
150
    $self->error("Did not " .
154
    $self->error("Did not " .
151
                 "find the end of the $self->{'grammar_type'}",
155
                 "find the end of the $self->{'grammar_type'}",
152
                 "$input: line " . $self->get_line_number() . ':');
156
                 "$input: line " . $self->get_line_number() . ':');
153
    $status = 0;
157
    $status = 0;
154
  }
158
  }
155
  $self->set_line_number($oline);
159
  $self->set_line_number($oline);
156
 
160
 
157
  return $status;
161
  return $status;
158
}
162
}
159
 
163
 
160
 
164
 
161
sub generate {
165
sub generate {
162
  my($self)   = shift;
166
  my($self)   = shift;
163
  my($input)  = shift;
167
  my($input)  = shift;
164
  my($status) = 1;
168
  my($status) = 1;
165
 
169
 
166
  ## Reset the files_written hash array between processing each file
170
  ## Reset the files_written hash array between processing each file
167
  $self->{'files_written'} = {};
171
  $self->{'files_written'} = {};
168
  $self->{'real_fwritten'} = [];
172
  $self->{'real_fwritten'} = [];
169
 
173
 
170
  ## Allow subclasses to reset values before
174
  ## Allow subclasses to reset values before
171
  ## each call to generate().
175
  ## each call to generate().
172
  $self->reset_values();
176
  $self->reset_values();
173
 
177
 
174
  ## Read the global configuration file
178
  ## Read the global configuration file
175
  if (!$self->{'global_read'}) {
179
  if (!$self->{'global_read'}) {
176
    $status = $self->read_global_configuration();
180
    $status = $self->read_global_configuration();
177
    $self->{'global_read'} = 1;
181
    $self->{'global_read'} = 1;
178
  }
182
  }
179
 
183
 
180
  if ($status) {
184
  if ($status) {
181
    $self->{'current_input'} = $input;
185
    $self->{'current_input'} = $input;
182
 
186
 
183
    ## An empty input file name says that we
187
    ## An empty input file name says that we
184
    ## should generate a default input file and use that
188
    ## should generate a default input file and use that
185
    if ($input eq '') {
189
    if ($input eq '') {
186
      $status = $self->generate_default_input();
190
      $status = $self->generate_default_input();
187
    }
191
    }
188
    else {
192
    else {
189
      $status = $self->parse_file($input);
193
      $status = $self->parse_file($input);
190
    }
194
    }
191
  }
195
  }
192
 
196
 
193
  return $status;
197
  return $status;
194
}
198
}
195
 
199
 
196
 
200
 
197
sub parse_assignment {
201
sub parse_assignment {
198
  my($self)   = shift;
202
  my($self)   = shift;
199
  my($line)   = shift;
203
  my($line)   = shift;
200
  my($values) = shift;
204
  my($values) = shift;
201
 
205
 
202
  if ($line =~ /^(\w+(::\w+)*)\s*\+=\s*(.*)?/) {
206
  if ($line =~ /^(\w+(::\w+)*)\s*([\-+]?=)\s*(.*)?/) {
203
    my($name)  = lc($1);
-
 
204
    my($value) = $3;
-
 
205
    push(@$values, 'assign_add', $name, $value);
-
 
206
    return 1;
-
 
207
  }
-
 
208
  elsif ($line =~ /^(\w+(::\w+)*)\s*=\s*(.*)?/) {
-
 
209
    my($name)  = lc($1);
-
 
210
    my($value) = $3;
-
 
211
    push(@$values, 'assignment', $name, $value);
207
    push(@$values, $3, lc($1), $4);
212
    return 1;
-
 
213
  }
-
 
214
  elsif ($line =~ /^(\w+(::\w+)*)\s*\-=\s*(.*)?/) {
-
 
215
    my($name)  = lc($1);
-
 
216
    my($value) = $3;
-
 
217
    push(@$values, 'assign_sub', $name, $value);
-
 
218
    return 1;
208
    return 1;
219
  }
209
  }
220
 
210
 
221
  return 0;
211
  return 0;
222
}
212
}
223
 
213
 
224
 
214
 
225
sub parse_known {
215
sub parse_known {
226
  my($self)        = shift;
216
  my($self)        = shift;
227
  my($line)        = shift;
217
  my($line)        = shift;
228
  my($status)      = 1;
218
  my($status)      = 1;
229
  my($errorString) = undef;
219
  my($errorString) = undef;
230
  my($type)        = $self->{'grammar_type'};
220
  my($type)        = $self->{'grammar_type'};
231
  my(@values)      = ();
221
  my(@values)      = ();
232
 
222
 
233
  ##
223
  ##
234
  ## Each regexp that looks for the '{' looks for it at the
224
  ## Each regexp that looks for the '{' looks for it at the
235
  ## end of the line.  It is purposely this way to decrease
225
  ## end of the line.  It is purposely this way to decrease
236
  ## the amount of extra lines in each file.  This
226
  ## the amount of extra lines in each file.  This
237
  ## allows for the most compact file as human readably
227
  ## allows for the most compact file as human readably
238
  ## possible.
228
  ## possible.
239
  ##
229
  ##
240
  if ($line eq '') {
230
  if ($line eq '') {
241
  }
231
  }
242
  elsif ($line =~ /^$type\s*(\([^\)]+\))?\s*(:.*)?\s*{$/) {
232
  elsif ($line =~ /^$type\s*(\([^\)]+\))?\s*(:.*)?\s*{$/) {
243
    my($name)    = $1;
233
    my($name)    = $1;
244
    my($parents) = $2;
234
    my($parents) = $2;
245
    if ($self->{$self->{'type_check'}}) {
235
    if ($self->{$self->{'type_check'}}) {
246
      $errorString = "Did not find the end of the $type";
236
      $errorString = "Did not find the end of the $type";
247
      $status = 0;
237
      $status = 0;
248
    }
238
    }
249
    else {
239
    else {
250
      if (defined $parents) {
240
      if (defined $parents) {
251
        my(@parents) = ();
-
 
252
        $parents =~ s/^://;
241
        $parents =~ s/^:\s*//;
253
        foreach my $parent (split(',', $parents)) {
-
 
254
          $parent =~ s/^\s+//;
-
 
255
          $parent =~ s/\s+$//;
242
        $parents =~ s/\s+$//;
256
          if ($parent ne '') {
-
 
257
            push(@parents, $parent);
243
        my(@parents) = split(/\s*,\s*/, $parents);
258
          }
-
 
259
        }
-
 
260
        if (!defined $parents[0]) {
244
        if (!defined $parents[0]) {
261
          ## The : was used, but no parents followed.  This
245
          ## The : was used, but no parents followed.  This
262
          ## is an error.
246
          ## is an error.
263
          $errorString = 'No parents listed';
247
          $errorString = 'No parents listed';
264
          $status = 0;
248
          $status = 0;
265
        }
249
        }
266
        $parents = \@parents;
250
        $parents = \@parents;
267
      }
251
      }
268
      push(@values, $type, $name, $parents);
252
      push(@values, $type, $name, $parents);
269
    }
253
    }
270
  }
254
  }
271
  elsif ($line =~ /^}$/) {
255
  elsif ($line =~ /^}$/) {
272
    if ($self->{$self->{'type_check'}}) {
256
    if ($self->{$self->{'type_check'}}) {
273
      push(@values, $type, $line);
257
      push(@values, $type, $line);
274
    }
258
    }
275
    else {
259
    else {
276
      $errorString = "Did not find the beginning of the $type";
260
      $errorString = "Did not find the beginning of the $type";
277
      $status = 0;
261
      $status = 0;
278
    }
262
    }
279
  }
263
  }
280
  elsif ($line =~ /^(feature)\s*\(([^\)]+)\)\s*(:.*)?\s*{$/) {
264
  elsif ($line =~ /^(feature)\s*\(([^\)]+)\)\s*(:.*)?\s*{$/) {
281
    my($type)    = $1;
265
    my($type)    = $1;
282
    my($name)    = $2;
266
    my($name)    = $2;
283
    my($parents) = $3;
267
    my($parents) = $3;
284
    my(@names)   = split(/\s*,\s*/, $name);
268
    my(@names)   = split(/\s*,\s*/, $name);
285
 
269
 
286
    if (defined $parents) {
270
    if (defined $parents) {
287
      my(@parents) = ();
-
 
288
      $parents =~ s/^://;
271
      $parents =~ s/^:\s*//;
289
      foreach my $parent (split(',', $parents)) {
-
 
290
        $parent =~ s/^\s+//;
-
 
291
        $parent =~ s/\s+$//;
272
      $parents =~ s/\s+$//;
292
        if ($parent ne '') {
-
 
293
          push(@parents, $parent);
273
      my(@parents) = split(/\s*,\s*/, $parents);
294
        }
-
 
295
      }
-
 
296
      if (!defined $parents[0]) {
274
      if (!defined $parents[0]) {
297
        ## The : was used, but no parents followed.  This
275
        ## The : was used, but no parents followed.  This
298
        ## is an error.
276
        ## is an error.
299
        $errorString = 'No parents listed';
277
        $errorString = 'No parents listed';
300
        $status = 0;
278
        $status = 0;
301
      }
279
      }
302
      $parents = \@parents;
280
      $parents = \@parents;
303
    }
281
    }
304
    push(@values, $type, \@names, $parents);
282
    push(@values, $type, \@names, $parents);
305
  }
283
  }
306
  elsif (!$self->{$self->{'type_check'}}) {
284
  elsif (!$self->{$self->{'type_check'}}) {
307
    $errorString = "No $type was defined";
285
    $errorString = "No $type was defined";
308
    $status = 0;
286
    $status = 0;
309
  }
287
  }
310
  elsif ($self->parse_assignment($line, \@values)) {
288
  elsif ($self->parse_assignment($line, \@values)) {
311
    ## If this returns true, then we've found an assignment
289
    ## If this returns true, then we've found an assignment
312
  }
290
  }
313
  elsif ($line =~ /^(\w+)\s*(\([^\)]+\))?\s*{$/) {
291
  elsif ($line =~ /^(\w+)\s*(\([^\)]+\))?\s*{$/) {
314
    my($comp) = lc($1);
292
    my($comp) = lc($1);
315
    my($name) = $2;
293
    my($name) = $2;
316
 
294
 
317
    if (defined $name) {
295
    if (defined $name) {
318
      $name =~ s/^\(\s*//;
296
      $name =~ s/^\(\s*//;
319
      $name =~ s/\s*\)$//;
297
      $name =~ s/\s*\)$//;
320
    }
298
    }
321
    else {
299
    else {
322
      $name = $self->get_default_component_name();
300
      $name = $self->get_default_component_name();
323
    }
301
    }
324
    push(@values, 'component', $comp, $name);
302
    push(@values, 'component', $comp, $name);
325
  }
303
  }
326
  else {
304
  else {
327
    $errorString = "Unrecognized line: $line";
305
    $errorString = "Unrecognized line: $line";
328
    $status = -1;
306
    $status = -1;
329
  }
307
  }
330
 
308
 
331
  return $status, $errorString, @values;
309
  return $status, $errorString, @values;
332
}
310
}
333
 
311
 
334
 
312
 
335
sub parse_scope {
313
sub parse_scope {
336
  my($self)        = shift;
314
  my($self)        = shift;
337
  my($fh)          = shift;
315
  my($fh)          = shift;
338
  my($name)        = shift;
316
  my($name)        = shift;
339
  my($type)        = shift;
317
  my($type)        = shift;
340
  my($validNames)  = shift;
318
  my($validNames)  = shift;
341
  my($flags)       = shift;
319
  my($flags)       = shift;
342
  my($elseflags)   = shift;
320
  my($elseflags)   = shift;
343
  my($status)      = 0;
321
  my($status)      = 0;
344
  my($errorString) = "Unable to process $name";
322
  my($errorString) = "Unable to process $name";
345
 
323
 
346
  if (!defined $flags) {
324
  if (!defined $flags) {
347
    $flags = {};
325
    $flags = {};
348
  }
326
  }
349
 
327
 
350
  while(<$fh>) {
328
  while(<$fh>) {
351
    my($line) = $self->preprocess_line($fh, $_);
329
    my($line) = $self->preprocess_line($fh, $_);
352
 
330
 
353
    if ($line eq '') {
331
    if ($line eq '') {
354
    }
332
    }
355
    elsif ($line =~ /^}$/) {
333
    elsif ($line =~ /^}$/) {
356
      ($status, $errorString) = $self->handle_scoped_end($type, $flags);
334
      ($status, $errorString) = $self->handle_scoped_end($type, $flags);
357
      last;
335
      last;
358
    }
336
    }
359
    elsif ($line =~ /^}\s*else\s*{$/) {
337
    elsif ($line =~ /^}\s*else\s*{$/) {
360
      if (defined $elseflags) {
338
      if (defined $elseflags) {
361
        ## From here on out anything after this goes into the $elseflags
339
        ## From here on out anything after this goes into the $elseflags
362
        $flags = $elseflags;
340
        $flags = $elseflags;
363
        $elseflags = undef;
341
        $elseflags = undef;
364
 
342
 
365
        ## We need to adjust the type also.  If there was a type
343
        ## We need to adjust the type also.  If there was a type
366
        ## then the first part of the clause was used.  If there was
344
        ## then the first part of the clause was used.  If there was
367
        ## no type, then the first part was ignored and the second
345
        ## no type, then the first part was ignored and the second
368
        ## part will be used.
346
        ## part will be used.
369
        if (defined $type) {
347
        if (defined $type) {
370
          $type = undef;
348
          $type = undef;
371
        }
349
        }
372
        else {
350
        else {
373
          $type = $self->get_default_component_name();
351
          $type = $self->get_default_component_name();
374
        }
352
        }
375
      }
353
      }
376
      else {
354
      else {
377
        $status = 0;
355
        $status = 0;
378
        $errorString = 'An else is not allowed in this context';
356
        $errorString = 'An else is not allowed in this context';
379
        last;
357
        last;
380
      }
358
      }
381
    }
359
    }
382
    else {
360
    else {
383
      my(@values) = ();
361
      my(@values) = ();
384
      if (defined $validNames && $self->parse_assignment($line, \@values)) {
362
      if (defined $validNames && $self->parse_assignment($line, \@values)) {
385
        if (defined $$validNames{$values[1]}) {
363
        if (defined $$validNames{$values[1]}) {
386
          if ($values[0] eq 'assignment') {
364
          if ($values[0] eq '=') {
387
            $self->process_assignment($values[1], $values[2], $flags);
365
            $self->process_assignment($values[1], $values[2], $flags);
388
          }
366
          }
389
          elsif ($values[0] eq 'assign_add') {
367
          elsif ($values[0] eq '+=') {
390
            $self->process_assignment_add($values[1], $values[2], $flags);
368
            $self->process_assignment_add($values[1], $values[2], $flags);
391
          }
369
          }
392
          elsif ($values[0] eq 'assign_sub') {
370
          elsif ($values[0] eq '-=') {
393
            $self->process_assignment_sub($values[1], $values[2], $flags);
371
            $self->process_assignment_sub($values[1], $values[2], $flags);
394
          }
372
          }
395
        }
373
        }
396
        else {
374
        else {
397
          ($status,
375
          ($status,
398
           $errorString) = $self->handle_unknown_assignment($type,
376
           $errorString) = $self->handle_unknown_assignment($type,
399
                                                            @values);
377
                                                            @values);
400
          if (!$status) {
378
          if (!$status) {
401
            last;
379
            last;
402
          }
380
          }
403
        }
381
        }
404
      }
382
      }
405
      else {
383
      else {
406
        ($status, $errorString) = $self->handle_scoped_unknown($fh,
384
        ($status, $errorString) = $self->handle_scoped_unknown($fh,
407
                                                               $type,
385
                                                               $type,
408
                                                               $flags,
386
                                                               $flags,
409
                                                               $line);
387
                                                               $line);
410
        if (!$status) {
388
        if (!$status) {
411
          last;
389
          last;
412
        }
390
        }
413
      }
391
      }
414
    }
392
    }
415
  }
393
  }
416
  return $status, $errorString;
394
  return $status, $errorString;
417
}
395
}
418
 
396
 
419
 
397
 
420
sub base_directory {
398
sub base_directory {
421
  my($self) = shift;
399
  my($self) = shift;
422
  return basename($self->getcwd());
400
  return $self->mpc_basename($self->getcwd());
423
}
401
}
424
 
402
 
425
 
403
 
426
sub generate_default_file_list {
404
sub generate_default_file_list {
427
  my($self)    = shift;
405
  my($self)    = shift;
428
  my($dir)     = shift;
406
  my($dir)     = shift;
429
  my($exclude) = shift;
407
  my($exclude) = shift;
-
 
408
  my($fileexc) = shift;
430
  my($recurse) = shift;
409
  my($recurse) = shift;
431
  my($dh)      = new FileHandle();
410
  my($dh)      = new FileHandle();
432
  my(@files)   = ();
411
  my(@files)   = ();
433
 
412
 
434
  if (opendir($dh, $dir)) {
413
  if (opendir($dh, $dir)) {
435
    my($need_dir) = ($dir ne '.');
414
    my($need_dir) = ($dir ne '.');
436
    my($skip)     = 0;
415
    my($skip)     = 0;
437
    foreach my $file (grep(!/^\.\.?$/, readdir($dh))) {
416
    foreach my $file (grep(!/^\.\.?$/, readdir($dh))) {
438
      $file =~ s/\.dir$// if ($^O eq 'VMS');
417
      $file =~ s/\.dir$// if ($onVMS);
439
 
418
 
440
      ## Prefix each file name with the directory only if it's not '.'
419
      ## Prefix each file name with the directory only if it's not '.'
441
      my($full) = ($need_dir ? "$dir/" : '') . $file;
420
      my($full) = ($need_dir ? "$dir/" : '') . $file;
442
 
421
 
443
      if (defined $$exclude[0]) {
422
      if (defined $$exclude[0]) {
444
        foreach my $exc (@$exclude) {
423
        foreach my $exc (@$exclude) {
445
          if ($full eq $exc) {
424
          if ($full eq $exc) {
446
            $skip = 1;
425
            $skip = 1;
447
            last;
426
            last;
448
          }
427
          }
449
        }
428
        }
450
      }
429
      }
451
 
430
 
452
      if ($skip) {
431
      if ($skip) {
453
        $skip = 0;
432
        $skip = 0;
-
 
433
        $$fileexc = 1 if (defined $fileexc);
454
      }
434
      }
455
      else {
435
      else {
456
        if ($recurse && -d $full) {
436
        if ($recurse && -d $full) {
457
          push(@files,
437
          push(@files,
458
               $self->generate_default_file_list($full, $exclude, $recurse));
438
               $self->generate_default_file_list($full, $exclude,
-
 
439
                                                 $fileexc, $recurse));
459
        }
440
        }
460
        else {
441
        else {
461
          push(@files, $full);
442
          push(@files, $full);
462
        }
443
        }
463
      }
444
      }
464
    }
445
    }
465
 
446
 
466
    if ($self->sort_files()) {
447
    if ($self->sort_files()) {
467
      @files = sort { $self->file_sorter($a, $b) } @files;
448
      @files = sort { $self->file_sorter($a, $b) } @files;
468
    }
449
    }
469
 
450
 
470
    closedir($dh);
451
    closedir($dh);
471
  }
452
  }
472
  return @files;
453
  return @files;
473
}
454
}
474
 
455
 
475
 
456
 
476
sub transform_file_name {
457
sub transform_file_name {
477
  my($self) = shift;
458
  my($self) = shift;
478
  my($name) = shift;
459
  my($name) = shift;
479
 
460
 
480
  $name =~ s/[\s\-]/_/g;
461
  $name =~ s/[\s\-]/_/g;
481
  return $name;
462
  return $name;
482
}
463
}
483
 
464
 
484
 
465
 
485
sub file_written {
466
sub file_written {
486
  my($self) = shift;
467
  my($self) = shift;
487
  my($file) = shift;
468
  my($file) = shift;
488
  return (defined $all_written{$self->getcwd() . '/' . $file});
469
  return (defined $all_written{$self->getcwd() . '/' . $file});
489
}
470
}
490
 
471
 
491
 
472
 
492
sub add_file_written {
473
sub add_file_written {
493
  my($self) = shift;
474
  my($self) = shift;
494
  my($file) = shift;
475
  my($file) = shift;
495
  my($key)  = lc($file);
476
  my($key)  = lc($file);
496
 
477
 
497
  if (defined $self->{'files_written'}->{$key}) {
478
  if (defined $self->{'files_written'}->{$key}) {
498
    $self->warning("$self->{'grammar_type'} $file has " .
479
    $self->warning("$self->{'grammar_type'} $file " .
-
 
480
                   ($self->{'case_tolerant'} ?
499
                   "possibly been overwritten.");
481
                           "has been overwritten." :
-
 
482
                           "of differing case has been processed."));
500
  }
483
  }
501
  else {
484
  else {
502
    $self->{'files_written'}->{$key} = $file;
485
    $self->{'files_written'}->{$key} = $file;
503
    push(@{$self->{'real_fwritten'}}, $file);
486
    push(@{$self->{'real_fwritten'}}, $file);
504
  }
487
  }
505
 
488
 
506
  $all_written{$self->getcwd() . '/' . $file} = 1;
489
  $all_written{$self->getcwd() . '/' . $file} = 1;
507
}
490
}
508
 
491
 
509
 
492
 
510
sub extension_recursive_input_list {
493
sub extension_recursive_input_list {
511
  my($self)    = shift;
494
  my($self)    = shift;
512
  my($dir)     = shift;
495
  my($dir)     = shift;
513
  my($exclude) = shift;
496
  my($exclude) = shift;
514
  my($ext)     = shift;
497
  my($ext)     = shift;
515
  my($fh)      = new FileHandle();
498
  my($fh)      = new FileHandle();
516
  my(@files)   = ();
499
  my(@files)   = ();
517
 
500
 
518
  if (opendir($fh, $dir)) {
501
  if (opendir($fh, $dir)) {
519
    foreach my $file (grep(!/^\.\.?$/, readdir($fh))) {
502
    foreach my $file (grep(!/^\.\.?$/, readdir($fh))) {
520
      $file =~ s/\.dir$// if ($^O eq 'VMS');
503
      $file =~ s/\.dir$// if ($onVMS);
521
 
504
 
522
      my($skip) = 0;
505
      my($skip) = 0;
523
      my($full) = ($dir ne '.' ? "$dir/" : '') . $file;
506
      my($full) = ($dir ne '.' ? "$dir/" : '') . $file;
524
 
507
 
525
      ## Check for command line exclusions
508
      ## Check for command line exclusions
526
      if (defined $$exclude[0]) {
509
      if (defined $$exclude[0]) {
527
        foreach my $exc (@$exclude) {
510
        foreach my $exc (@$exclude) {
528
          if ($full eq $exc) {
511
          if ($full eq $exc) {
529
            $skip = 1;
512
            $skip = 1;
530
            last;
513
            last;
531
          }
514
          }
532
        }
515
        }
533
      }
516
      }
534
 
517
 
535
      ## If we are not skipping this directory or file, then check it out
518
      ## If we are not skipping this directory or file, then check it out
536
      if (!$skip) {
519
      if (!$skip) {
537
        if (-d $full) {
520
        if (-d $full) {
538
          push(@files, $self->extension_recursive_input_list($full,
521
          push(@files, $self->extension_recursive_input_list($full,
539
                                                             $exclude,
522
                                                             $exclude,
540
                                                             $ext));
523
                                                             $ext));
541
        }
524
        }
542
        elsif ($full =~ /$ext$/) {
525
        elsif ($full =~ /$ext$/) {
543
          push(@files, $full);
526
          push(@files, $full);
544
        }
527
        }
545
      }
528
      }
546
    }
529
    }
547
    closedir($fh);
530
    closedir($fh);
548
  }
531
  }
549
 
532
 
550
  return @files;
533
  return @files;
551
}
534
}
552
 
535
 
553
 
536
 
554
sub modify_assignment_value {
537
sub modify_assignment_value {
555
  my($self)  = shift;
538
  my($self)  = shift;
556
  my($name)  = shift;
539
  my($name)  = shift;
557
  my($value) = shift;
540
  my($value) = shift;
558
 
541
 
559
  if ($self->{'convert_slashes'} && $name !~ /flags/) {
542
  if ($self->{'convert_slashes'} && index($name, 'flags') == -1) {
560
    $value = $self->slash_to_backslash($value);
543
    $value =~ s/\//\\/g;
561
  }
544
  }
562
  return $value;
545
  return $value;
563
}
546
}
564
 
547
 
565
 
548
 
566
sub get_assignment_hash {
549
sub get_assignment_hash {
567
  ## NOTE: If anything in this block changes, then you must make the
550
  ## NOTE: If anything in this block changes, then you must make the
568
  ## same change in process_assignment.
551
  ## same change in process_assignment.
569
  my($self)   = shift;
552
  my($self) = shift;
570
  my($tag)    = ($self->{'reading_global'} ? 'global_assign' : 'assign');
553
  return $self->{$self->{'reading_global'} ? $gassign_key : $assign_key};
571
  my($assign) = $self->{$tag};
-
 
572
 
-
 
573
  ## If we haven't yet defined the hash table in this project
-
 
574
  if (!defined $assign) {
-
 
575
    $assign = {};
-
 
576
    $self->{$tag} = $assign;
-
 
577
  }
-
 
578
 
-
 
579
  return $assign;
-
 
580
}
554
}
581
 
555
 
582
 
556
 
583
sub process_assignment {
557
sub process_assignment {
584
  my($self)   = shift;
558
  my($self)   = shift;
585
  my($name)   = shift;
559
  my($name)   = shift;
586
  my($value)  = shift;
560
  my($value)  = shift;
587
  my($assign) = shift;
561
  my($assign) = shift;
588
 
562
 
589
  ## If no hash table was passed in
563
  ## If no hash table was passed in
590
  if (!defined $assign) {
564
  if (!defined $assign) {
591
    ## NOTE: If anything in this block changes, then you must make the
565
    ## NOTE: If anything in this block changes, then you must make the
592
    ## same change in get_assignment_hash.
566
    ## same change in get_assignment_hash.
593
    my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign');
-
 
594
    $assign  = $self->{$tag};
567
    $assign  = $self->{$self->{'reading_global'} ?
595
 
-
 
596
    ## If we haven't yet defined the hash table in this project
568
                               $gassign_key : $assign_key};
597
    if (!defined $assign) {
-
 
598
      $assign = {};
-
 
599
      $self->{$tag} = $assign;
-
 
600
    }
-
 
601
  }
569
  }
602
 
570
 
603
  if (defined $value) {
571
  if (defined $value) {
604
    $value =~ s/^\s+//;
572
    $value =~ s/^\s+//;
605
    $value =~ s/\s+$//;
573
    $value =~ s/\s+$//;
606
 
574
 
607
    ## Modify the assignment value before saving it
575
    ## Modify the assignment value before saving it
608
    $$assign{$name} = $self->modify_assignment_value($name, $value);
576
    $$assign{$name} = $self->modify_assignment_value($name, $value);
609
  }
577
  }
610
  else {
578
  else {
611
    $$assign{$name} = undef;
579
    $$assign{$name} = undef;
612
  }
580
  }
613
}
581
}
614
 
582
 
615
 
583
 
616
sub process_assignment_add {
584
sub process_assignment_add {
617
  my($self)   = shift;
585
  my($self)   = shift;
618
  my($name)   = shift;
586
  my($name)   = shift;
619
  my($value)  = shift;
587
  my($value)  = shift;
620
  my($assign) = shift;
588
  my($assign) = shift;
621
  my($nval)   = $self->get_assignment_for_modification($name, $assign);
589
  my($nval)   = $self->get_assignment_for_modification($name, $assign);
622
 
590
 
623
  ## Remove all duplicate parts from the value to be added.
591
  ## Remove all duplicate parts from the value to be added.
624
  ## Whether anything gets removed or not is up to the implementation
592
  ## Whether anything gets removed or not is up to the implementation
625
  ## of the sub classes.
593
  ## of the sub classes.
626
  $value = $self->remove_duplicate_addition($name, $value, $nval);
594
  $value = $self->remove_duplicate_addition($name, $value, $nval);
627
 
595
 
628
  ## If there is anything to add, then do so
596
  ## If there is anything to add, then do so
629
  if ($value ne '') {
597
  if ($value ne '') {
630
    if (defined $nval) {
598
    if (defined $nval) {
631
      if ($self->preserve_assignment_order($name)) {
599
      if ($self->preserve_assignment_order($name)) {
632
        $nval .= " $value";
600
        $nval .= " $value";
633
      }
601
      }
634
      else {
602
      else {
635
        $nval = "$value $nval";
603
        $nval = "$value $nval";
636
      }
604
      }
637
    }
605
    }
638
    else {
606
    else {
639
      $nval = $value;
607
      $nval = $value;
640
    }
608
    }
641
    $self->process_assignment($name, $nval, $assign);
609
    $self->process_assignment($name, $nval, $assign);
642
  }
610
  }
643
}
611
}
644
 
612
 
645
 
613
 
646
sub process_assignment_sub {
614
sub process_assignment_sub {
647
  my($self)   = shift;
615
  my($self)   = shift;
648
  my($name)   = shift;
616
  my($name)   = shift;
649
  my($value)  = shift;
617
  my($value)  = shift;
650
  my($assign) = shift;
618
  my($assign) = shift;
651
  my($nval)   = $self->get_assignment_for_modification($name, $assign, 1);
619
  my($nval)   = $self->get_assignment_for_modification($name, $assign);
652
 
620
 
653
  if (defined $nval) {
621
  if (defined $nval) {
654
    ## Remove double quotes if there are any
622
    ## Remove double quotes if there are any
655
    $value =~ s/^\"(.*)\"$/$1/;
623
    $value =~ s/^\"(.*)\"$/$1/;
656
 
624
 
657
    ## Escape any regular expression special characters
625
    ## Escape any regular expression special characters
658
    $value = $self->escape_regex_special($value);
626
    $value = $self->escape_regex_special($value);
659
 
627
 
-
 
628
    my($last)  = 1;
-
 
629
    my($found) = undef;
660
    ## Due to the way process_assignment() works, we only need to
630
    for(my $i = 0; $i <= $last; $i++) {
-
 
631
      if ($i == $last) {
661
    ## attempt to remove a value that is either followed by a space
632
        ## If we did not find the string to subtract in the original
662
    ## or at the end of the line (single values are always at the end
633
        ## value, try again after expanding template variables for
663
    ## of the line).
634
        ## subtraction.
664
    if ($nval =~ s/$value\s+// || $nval =~ s/$value$//) {
-
 
665
      $self->process_assignment($name, $nval, $assign);
635
        $nval = $self->get_assignment_for_modification($name, $assign, 1);
666
    }
636
      }
667
    else {
637
      for(my $j = 0; $j <= $last; $j++) {
668
      ## Try the same thing only with double quotes around the value.
638
        ## If we didn't find it the first time, try again with quotes
-
 
639
        my($re) = ($j == $last ? '"' . $value . '"' : $value);
-
 
640
 
-
 
641
        ## Due to the way process_assignment() works, we only need to
669
      ## Double quotes will be preserved in the value when the value
642
        ## attempt to remove a value that is either followed by a space
670
      ## contains spaces.
643
        ## or at the end of the line (single values are always at the end
671
      $value = '"' . $value . '"';
644
        ## of the line).
672
      if ($nval =~ s/$value\s+// || $nval =~ s/$value$//) {
645
        if ($nval =~ s/$re\s+// || $nval =~ s/$re$//) {
673
        $self->process_assignment($name, $nval, $assign);
646
          $self->process_assignment($name, $nval, $assign);
-
 
647
          $found = 1;
-
 
648
          last;
-
 
649
        }
674
      }
650
      }
-
 
651
      last if ($found);
675
    }
652
    }
676
  }
653
  }
677
}
654
}
678
 
655
 
679
 
656
 
680
sub fill_type_name {
657
sub fill_type_name {
681
  my($self)  = shift;
658
  my($self)  = shift;
682
  my($names) = shift;
659
  my($names) = shift;
683
  my($def)   = shift;
660
  my($def)   = shift;
684
  my($array) = ($names =~ /\s/ ? $self->create_array($names) : [$names]);
661
  my($array) = ($names =~ /\s/ ? $self->create_array($names) : [$names]);
685
 
662
 
686
  $names = '';
663
  $names = '';
687
  foreach my $name (@$array) {
664
  foreach my $name (@$array) {
688
    if ($name =~ /\*/) {
665
    if ($name =~ /\*/) {
689
      my($pre)  = $def . '_';
666
      my($pre)  = $def . '_';
690
      my($mid)  = '_' . $def . '_';
667
      my($mid)  = '_' . $def . '_';
691
      my($post) = '_' . $def;
668
      my($post) = '_' . $def;
692
 
669
 
693
      ## Replace the beginning and end first then the middle
670
      ## Replace the beginning and end first then the middle
694
      $name =~ s/^\*/$pre/;
671
      $name =~ s/^\*/$pre/;
695
      $name =~ s/\*$/$post/;
672
      $name =~ s/\*$/$post/;
696
      $name =~ s/\*/$mid/g;
673
      $name =~ s/\*/$mid/g;
697
 
674
 
698
      ## Remove any trailing underscore or any underscore that is followed
675
      ## Remove any trailing underscore or any underscore that is followed
699
      ## by a space.  This value could be a space separated list.
676
      ## by a space.  This value could be a space separated list.
700
      $name =~ s/_$//;
677
      $name =~ s/_$//;
701
      $name =~ s/_\s/ /g;
678
      $name =~ s/_\s/ /g;
702
      $name =~ s/\s_/ /g;
679
      $name =~ s/\s_/ /g;
703
 
680
 
704
      ## If any one word is capitalized then capitalize each word
681
      ## If any one word is capitalized then capitalize each word
705
      if ($name =~ /[A-Z][0-9a-z_]+/) {
682
      if ($name =~ /[A-Z][0-9a-z_]+/) {
706
        ## Do the first word
683
        ## Do the first word
707
        if ($name =~ /^([a-z])([^_]+)/) {
684
        if ($name =~ /^([a-z])([^_]+)/) {
708
          my($first) = uc($1);
685
          my($first) = uc($1);
709
          my($rest)  = $2;
686
          my($rest)  = $2;
710
          $name =~ s/^[a-z][^_]+/$first$rest/;
687
          $name =~ s/^[a-z][^_]+/$first$rest/;
711
        }
688
        }
712
        ## Do subsequent words
689
        ## Do subsequent words
713
        while($name =~ /(_[a-z])([^_]+)/) {
690
        while($name =~ /(_[a-z])([^_]+)/) {
714
          my($first) = uc($1);
691
          my($first) = uc($1);
715
          my($rest)  = $2;
692
          my($rest)  = $2;
716
          $name =~ s/_[a-z][^_]+/$first$rest/;
693
          $name =~ s/_[a-z][^_]+/$first$rest/;
717
        }
694
        }
718
      }
695
      }
719
    }
696
    }
720
 
697
 
721
    $names .= $name . ' ';
698
    $names .= $name . ' ';
722
  }
699
  }
723
  $names =~ s/\s+$//;
700
  $names =~ s/\s+$//;
724
 
701
 
725
  return $names;
702
  return $names;
726
}
703
}
727
 
704
 
728
 
705
 
729
sub save_state {
706
sub save_state {
730
  my($self)     = shift;
707
  my($self)     = shift;
731
  my($selected) = shift;
708
  my($selected) = shift;
732
  my(%state)    = ();
709
  my(%state)    = ();
733
 
710
 
734
  ## Make a deep copy of each state value.  That way our array
711
  ## Make a deep copy of each state value.  That way our array
735
  ## references and hash references do not get accidentally modified.
712
  ## references and hash references do not get accidentally modified.
736
  foreach my $skey (defined $selected ? $selected : @statekeys) {
713
  foreach my $skey (defined $selected ? $selected : @statekeys) {
737
    if (defined $self->{$skey}) {
714
    if (defined $self->{$skey}) {
738
      if (UNIVERSAL::isa($self->{$skey}, 'ARRAY')) {
715
      if (UNIVERSAL::isa($self->{$skey}, 'ARRAY')) {
739
        $state{$skey} = [];
716
        $state{$skey} = [];
740
        foreach my $element (@{$self->{$skey}}) {
717
        foreach my $element (@{$self->{$skey}}) {
741
          push(@{$state{$skey}}, $element);
718
          push(@{$state{$skey}}, $element);
742
        }
719
        }
743
      }
720
      }
744
      elsif (UNIVERSAL::isa($self->{$skey}, 'HASH')) {
721
      elsif (UNIVERSAL::isa($self->{$skey}, 'HASH')) {
745
        $state{$skey} = {};
722
        $state{$skey} = {};
746
        foreach my $key (keys %{$self->{$skey}}) {
723
        foreach my $key (keys %{$self->{$skey}}) {
747
          $state{$skey}->{$key} = $self->{$skey}->{$key};
724
          $state{$skey}->{$key} = $self->{$skey}->{$key};
748
        }
725
        }
749
      }
726
      }
750
      else {
727
      else {
751
        $state{$skey} = $self->{$skey};
728
        $state{$skey} = $self->{$skey};
752
      }
729
      }
753
    }
730
    }
754
  }
731
  }
755
 
732
 
756
  return %state;
733
  return %state;
757
}
734
}
758
 
735
 
759
 
736
 
760
sub restore_state {
737
sub restore_state {
761
  my($self)     = shift;
738
  my($self)     = shift;
762
  my($state)    = shift;
739
  my($state)    = shift;
763
  my($selected) = shift;
740
  my($selected) = shift;
764
 
741
 
765
  ## Make a deep copy of each state value.  That way our array
742
  ## Make a deep copy of each state value.  That way our array
766
  ## references and hash references do not get accidentally modified.
743
  ## references and hash references do not get accidentally modified.
767
  foreach my $skey (defined $selected ? $selected : @statekeys) {
744
  foreach my $skey (defined $selected ? $selected : @statekeys) {
768
    if (defined $state->{$skey}) {
745
    if (defined $state->{$skey}) {
769
      if (UNIVERSAL::isa($state->{$skey}, 'ARRAY')) {
746
      if (UNIVERSAL::isa($state->{$skey}, 'ARRAY')) {
770
        my(@arr) = @{$state->{$skey}};
747
        my(@arr) = @{$state->{$skey}};
771
        $self->{$skey} = \@arr;
748
        $self->{$skey} = \@arr;
772
      }
749
      }
773
      elsif (UNIVERSAL::isa($state->{$skey}, 'HASH')) {
750
      elsif (UNIVERSAL::isa($state->{$skey}, 'HASH')) {
774
        my(%hash) = %{$state->{$skey}};
751
        my(%hash) = %{$state->{$skey}};
775
        $self->{$skey} = \%hash;
752
        $self->{$skey} = \%hash;
776
      }
753
      }
777
      else {
754
      else {
778
        $self->{$skey} = $state->{$skey};
755
        $self->{$skey} = $state->{$skey};
779
      }
756
      }
780
    }
757
    }
781
  }
758
  }
782
}
759
}
783
 
760
 
784
 
761
 
785
sub get_global_cfg {
762
sub get_global_cfg {
786
  my($self) = shift;
763
  my($self) = shift;
787
  return $self->{'global'};
764
  return $self->{'global'};
788
}
765
}
789
 
766
 
790
 
767
 
791
sub get_template_override {
768
sub get_template_override {
792
  my($self) = shift;
769
  my($self) = shift;
793
  return $self->{'template'};
770
  return $self->{'template'};
794
}
771
}
795
 
772
 
796
 
773
 
797
sub get_ti_override {
774
sub get_ti_override {
798
  my($self) = shift;
775
  my($self) = shift;
799
  return $self->{'ti'};
776
  return $self->{'ti'};
800
}
777
}
801
 
778
 
802
 
779
 
803
sub get_relative {
780
sub get_relative {
804
  my($self) = shift;
781
  my($self) = shift;
805
  return $self->{'relative'};
782
  return $self->{'relative'};
806
}
783
}
807
 
784
 
808
 
785
 
809
sub get_progress_callback {
786
sub get_progress_callback {
810
  my($self) = shift;
787
  my($self) = shift;
811
  return $self->{'progress'};
788
  return $self->{'progress'};
812
}
789
}
813
 
790
 
814
 
791
 
815
sub get_addtemp {
792
sub get_addtemp {
816
  my($self) = shift;
793
  my($self) = shift;
817
  return $self->{'addtemp'};
794
  return $self->{'addtemp'};
818
}
795
}
819
 
796
 
820
 
797
 
821
sub get_addproj {
798
sub get_addproj {
822
  my($self) = shift;
799
  my($self) = shift;
823
  return $self->{'addproj'};
800
  return $self->{'addproj'};
824
}
801
}
825
 
802
 
826
 
803
 
827
sub get_toplevel {
804
sub get_toplevel {
828
  my($self) = shift;
805
  my($self) = shift;
829
  return $self->{'toplevel'};
806
  return $self->{'toplevel'};
830
}
807
}
831
 
808
 
832
 
809
 
833
sub get_into {
810
sub get_into {
834
  my($self) = shift;
811
  my($self) = shift;
835
  return $self->{'into'};
812
  return $self->{'into'};
836
}
813
}
837
 
814
 
838
 
815
 
839
sub get_use_env {
816
sub get_use_env {
840
  my($self) = shift;
817
  my($self) = shift;
841
  return $self->{'use_env'};
818
  return $self->{'use_env'};
842
}
819
}
843
 
820
 
844
 
821
 
845
sub get_expand_vars {
822
sub get_expand_vars {
846
  my($self) = shift;
823
  my($self) = shift;
847
  return $self->{'expand_vars'};
824
  return $self->{'expand_vars'};
848
}
825
}
849
 
826
 
850
 
827
 
851
sub get_files_written {
828
sub get_files_written {
852
  my($self)  = shift;
829
  my($self)  = shift;
853
  return $self->{'real_fwritten'};
830
  return $self->{'real_fwritten'};
854
}
831
}
855
 
832
 
856
 
833
 
857
sub get_assignment {
834
sub get_assignment {
858
  my($self)   = shift;
835
  my($self)   = shift;
859
  my($name)   = shift;
836
  my($name)   = shift;
860
  my($assign) = shift;
837
  my($assign) = shift;
861
 
838
 
862
  ## If no hash table was passed in
839
  ## If no hash table was passed in
863
  if (!defined $assign) {
840
  if (!defined $assign) {
864
    my($tag) = ($self->{'reading_global'} ? 'global_assign' : 'assign');
841
    $assign = $self->{$self->{'reading_global'} ?
865
    $assign = $self->{$tag};
842
                              $gassign_key : $assign_key};
866
  }
843
  }
867
 
844
 
868
  return $$assign{$name};
845
  return $$assign{$name};
869
}
846
}
870
 
847
 
871
 
848
 
872
sub get_assignment_for_modification {
849
sub get_assignment_for_modification {
873
  my($self)        = shift;
850
  my($self)        = shift;
874
  my($name)        = shift;
851
  my($name)        = shift;
875
  my($assign)      = shift;
852
  my($assign)      = shift;
876
  my($subtraction) = shift;
853
  my($subtraction) = shift;
877
  return $self->get_assignment($name, $assign);
854
  return $self->get_assignment($name, $assign);
878
}
855
}
879
 
856
 
880
 
857
 
881
sub get_baseprojs {
858
sub get_baseprojs {
882
  my($self) = shift;
859
  my($self) = shift;
883
  return $self->{'baseprojs'};
860
  return $self->{'baseprojs'};
884
}
861
}
885
 
862
 
886
 
863
 
887
sub get_dynamic {
864
sub get_dynamic {
888
  my($self) = shift;
865
  my($self) = shift;
889
  return $self->{'dynamic'};
866
  return $self->{'dynamic'};
890
}
867
}
891
 
868
 
892
 
869
 
893
sub get_static {
870
sub get_static {
894
  my($self) = shift;
871
  my($self) = shift;
895
  return $self->{'static'};
872
  return $self->{'static'};
896
}
873
}
897
 
874
 
898
 
875
 
899
sub get_default_component_name {
876
sub get_default_component_name {
900
  #my($self) = shift;
877
  #my($self) = shift;
901
  return 'default';
878
  return 'default';
902
}
879
}
903
 
880
 
904
 
881
 
905
sub get_hierarchy {
882
sub get_hierarchy {
906
  my($self) = shift;
883
  my($self) = shift;
907
  return $self->{'hierarchy'};
884
  return $self->{'hierarchy'};
908
}
885
}
909
 
886
 
910
 
887
 
911
sub get_name_modifier {
888
sub get_name_modifier {
912
  my($self) = shift;
889
  my($self) = shift;
913
  return $self->{'name_modifier'};
890
  return $self->{'name_modifier'};
914
}
891
}
915
 
892
 
916
 
893
 
917
sub get_apply_project {
894
sub get_apply_project {
918
  my($self) = shift;
895
  my($self) = shift;
919
  return $self->{'apply_project'};
896
  return $self->{'apply_project'};
920
}
897
}
921
 
898
 
922
 
899
 
923
sub get_language {
900
sub get_language {
924
  my($self) = shift;
901
  my($self) = shift;
925
  return $self->{'language'};
902
  return $self->{'language'};
926
}
903
}
927
 
904
 
-
 
905
 
928
sub get_outdir {
906
sub get_outdir {
929
  my($self) = shift;
907
  my($self) = shift;
930
  if (defined $self->{'into'}) {
908
  if (defined $self->{'into'}) {
931
    my($outdir) = $self->getcwd();
909
    my($outdir) = $self->getcwd();
932
    my($re)     = $self->escape_regex_special($self->getstartdir());
910
    my($re)     = $self->escape_regex_special($self->getstartdir());
933
 
911
 
934
    $outdir =~ s/^$re//;
912
    $outdir =~ s/^$re//;
935
    return $self->{'into'} . $outdir;
913
    return $self->{'into'} . $outdir;
936
  }
914
  }
937
  else {
915
  else {
938
    return '.';
916
    return '.';
939
  }
917
  }
940
}
918
}
941
 
919
 
942
# ************************************************************
920
# ************************************************************
943
# Virtual Methods To Be Overridden
921
# Virtual Methods To Be Overridden
944
# ************************************************************
922
# ************************************************************
945
 
923
 
946
sub preserve_assignment_order {
924
sub preserve_assignment_order {
947
  #my($self) = shift;
925
  #my($self) = shift;
948
  #my($name) = shift;
926
  #my($name) = shift;
949
  return 1;
927
  return 1;
950
}
928
}
951
 
929
 
952
 
930
 
953
sub compare_output {
931
sub compare_output {
954
  #my($self) = shift;
932
  #my($self) = shift;
955
  return 0;
933
  return 0;
956
}
934
}
957
 
935
 
958
 
936
 
959
sub handle_scoped_end {
937
sub handle_scoped_end {
960
  #my($self)  = shift;
938
  #my($self)  = shift;
961
  #my($type)  = shift;
939
  #my($type)  = shift;
962
  #my($flags) = shift;
940
  #my($flags) = shift;
963
  return 1, undef;
941
  return 1, undef;
964
}
942
}
965
 
943
 
966
 
944
 
967
sub handle_unknown_assignment {
945
sub handle_unknown_assignment {
968
  my($self)   = shift;
946
  my($self)   = shift;
969
  my($type)   = shift;
947
  my($type)   = shift;
970
  my(@values) = @_;
948
  my(@values) = @_;
971
  return 0, "Invalid assignment name: $values[1]";
949
  return 0, "Invalid assignment name: $values[1]";
972
}
950
}
973
 
951
 
974
 
952
 
975
sub handle_scoped_unknown {
953
sub handle_scoped_unknown {
976
  my($self)  = shift;
954
  my($self)  = shift;
977
  my($fh)    = shift;
955
  my($fh)    = shift;
978
  my($type)  = shift;
956
  my($type)  = shift;
979
  my($flags) = shift;
957
  my($flags) = shift;
980
  my($line)  = shift;
958
  my($line)  = shift;
981
  return 0, "Unrecognized line: $line";
959
  return 0, "Unrecognized line: $line";
982
}
960
}
983
 
961
 
984
 
962
 
985
sub remove_duplicate_addition {
963
sub remove_duplicate_addition {
986
  my($self)    = shift;
964
  my($self)    = shift;
987
  my($name)    = shift;
965
  my($name)    = shift;
988
  my($value)   = shift;
966
  my($value)   = shift;
989
  my($current) = shift;
967
  my($current) = shift;
990
  return $value;
968
  return $value;
991
}
969
}
992
 
970
 
993
 
971
 
994
sub generate_recursive_input_list {
972
sub generate_recursive_input_list {
995
  #my($self)    = shift;
973
  #my($self)    = shift;
996
  #my($dir)     = shift;
974
  #my($dir)     = shift;
997
  #my($exclude) = shift;
975
  #my($exclude) = shift;
998
  return ();
976
  return ();
999
}
977
}
1000
 
978
 
1001
 
979
 
1002
sub reset_values {
980
sub reset_values {
1003
  #my($self) = shift;
981
  #my($self) = shift;
1004
}
982
}
1005
 
983
 
1006
 
984
 
1007
sub sort_files {
985
sub sort_files {
1008
  #my($self) = shift;
986
  #my($self) = shift;
1009
  return 1;
987
  return 1;
1010
}
988
}
1011
 
989
 
1012
 
990
 
1013
sub file_sorter {
991
sub file_sorter {
1014
  my($self)  = shift;
992
  #my($self)  = shift;
1015
  my($left)  = shift;
993
  #my($left)  = shift;
1016
  my($right) = shift;
994
  #my($right) = shift;
1017
  return $left cmp $right;
995
  return $_[1] cmp $_[2];
1018
}
996
}
1019
 
997
 
1020
 
998
 
1021
sub read_global_configuration {
999
sub read_global_configuration {
1022
  #my($self)  = shift;
1000
  #my($self)  = shift;
1023
  #my($input) = shift;
1001
  #my($input) = shift;
1024
  return 1;
1002
  return 1;
1025
}
1003
}
1026
 
1004
 
1027
 
1005
 
1028
1;
1006
1;
1029
 
1007