Subversion Repositories gelsvn

Rev

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

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