summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2002-11-08 18:59:24 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2002-11-08 18:59:24 +0000
commit72fcb6e19fb0929f107ab215a1cb5190a7d1ba38 (patch)
treefad9b7e12011f90a67d8e42d2e7224b171969428
parentd5089ca1cd350409fd5f4a2d5943630a74e7ee04 (diff)
downloadMPC-72fcb6e19fb0929f107ab215a1cb5190a7d1ba38.tar.gz
ChangeLogTag: Fri Nov 8 12:57:57 2002 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/ProjectCreator.pm85
-rw-r--r--modules/TemplateParser.pm18
2 files changed, 96 insertions, 7 deletions
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index e460e578..fe13bb5e 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -104,6 +104,9 @@ sub new {
$self->{'want_static_projects'} = $static;
$self->{'flag_overrides'} = {};
+ ## Set up the verbatim constructs
+ $self->{'verbatim'} = {};
+
## Valid component names within a project along with the valid file extensions
my(%vc) = ('source_files' => [ "\\.cpp", "\\.cxx", "\\.cc", "\\.c", "\\.C", ],
'template_files' => [ "_T\\.cpp", "_T\\.cxx", "_T\\.cc", "_T\\.c", "_T\\.C", ],
@@ -205,7 +208,8 @@ sub parse_line {
foreach my $key (keys %{$self->{'valid_components'}}) {
delete $self->{$key};
}
- $self->{'assign'} = {};
+ $self->{'assign'} = {};
+ $self->{'verbatim'} = {};
}
}
$self->{$typecheck} = 0;
@@ -228,10 +232,9 @@ sub parse_line {
}
if (defined $file) {
- my($rp) = $self->{'reading_parent'};
- push(@$rp, 1);
+ push(@{$self->{'reading_parent'}}, 1);
$status = $self->parse_file($file);
- pop(@$rp);
+ pop(@{$self->{'reading_parent'}});
if (!$status) {
$errorString = "ERROR: Invalid parent: $parent";
@@ -314,8 +317,17 @@ sub parse_line {
}
}
else {
- $errorString = "ERROR: Invalid component name: $comp";
- $status = 0;
+ if ($comp eq 'verbatim') {
+ my($type, $loc) = split(/\s*,\s*/, $name);
+ if (!$self->parse_verbatim($ih, $comp, $type, $loc)) {
+ $errorString = "ERROR: Unable to process $comp";
+ $status = 0;
+ }
+ }
+ else {
+ $errorString = "ERROR: Invalid component name: $comp";
+ $status = 0;
+ }
}
}
else {
@@ -438,6 +450,41 @@ sub parse_components {
}
+sub parse_verbatim {
+ my($self) = shift;
+ my($fh) = shift;
+ my($tag) = shift;
+ my($type) = shift;
+ my($loc) = shift;
+
+ ## All types are lowercase
+ $type = lc($type);
+
+ if (!defined $self->{'verbatim'}->{$type}) {
+ $self->{'verbatim'}->{$type} = {};
+ }
+ $self->{'verbatim'}->{$type}->{$loc} = [];
+ my($array) = $self->{'verbatim'}->{$type}->{$loc};
+
+ while(<$fh>) {
+ my($line) = $self->strip_line($_);
+
+ if ($line eq "") {
+ }
+ elsif ($line =~ /^}/) {
+ ## This is not an error,
+ ## this is the end of the components
+ last;
+ }
+ else {
+ push(@$array, $line);
+ }
+ }
+
+ return 1;
+}
+
+
sub process_assignment {
my($self) = shift;
my($name) = shift;
@@ -1384,6 +1431,32 @@ sub update_project_info {
}
+sub get_verbatim {
+ my($self) = shift;
+ my($marker) = shift;
+ my($type) = lc(substr("$self", 0, 3)); ## This number corresponds to
+ ## signif in Driver.pm
+ my($str) = undef;
+ my($thash) = $self->{'verbatim'}->{$type};
+
+ if (defined $thash) {
+ if (defined $thash->{$marker}) {
+ my($crlf) = $self->crlf();
+ foreach my $line (@{$thash->{$marker}}) {
+ if (!defined $str) {
+ $str = "";
+ }
+ $str .= $self->process_special($line) . $crlf;
+ }
+ if (defined $str) {
+ $str .= $crlf;
+ }
+ }
+ }
+ return $str;
+}
+
+
# ************************************************************
# Virtual Methods To Be Overridden
# ************************************************************
diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm
index 03e01a36..ce76cde0 100644
--- a/modules/TemplateParser.pm
+++ b/modules/TemplateParser.pm
@@ -26,7 +26,7 @@ my(@keywords) = ('if', 'else', 'endif',
'noextension', 'dirname', 'basename', 'basenoextension',
'foreach', 'forfirst', 'fornotfirst',
'fornotlast', 'forlast', 'endfor',
- 'comment', 'flag_overrides',
+ 'comment', 'flag_overrides', 'marker',
);
# ************************************************************
@@ -666,6 +666,19 @@ sub handle_flag_overrides {
}
+sub handle_marker {
+ my($self) = shift;
+ my($name) = shift;
+
+ if (!$self->{'if_skip'}) {
+ my($value) = $self->{'prjc'}->get_verbatim($name);
+ if (defined $value) {
+ $self->append_current($value);
+ }
+ }
+}
+
+
## Given a line that starts with an identifier, we split
## then name from the possible value stored inside ()'s and
## we stop looking at the line when we find the %> ending
@@ -744,6 +757,9 @@ sub process_name {
elsif ($name eq 'flag_overrides') {
$self->handle_flag_overrides($val);
}
+ elsif ($name eq 'marker') {
+ $self->handle_marker($val);
+ }
elsif ($name eq 'noextension') {
$self->handle_noextension($val);
}