summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1998-11-17 18:16:09 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1998-11-17 18:16:09 +0000
commit2392b1c9fd68a7ba0970b272442240ac71855b8f (patch)
treeacfbbcb6a895fbbd8dee0936ee5627e2bd712516 /lib
parent689767cfe9f92076db1cd321ddf2904add830a3a (diff)
Now can create the parameter structure for c.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@22 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib')
-rw-r--r--lib/sbin/config_parser.pl124
-rw-r--r--lib/sbin/interface_parser.pl10
2 files changed, 130 insertions, 4 deletions
diff --git a/lib/sbin/config_parser.pl b/lib/sbin/config_parser.pl
index 3a5d9ef7..bc4ffc6e 100644
--- a/lib/sbin/config_parser.pl
+++ b/lib/sbin/config_parser.pl
@@ -1,2 +1,126 @@
#! /usr/bin/perl
+$in = shift(@ARGV);
+$tmphome = shift(@ARGV);
+
+if (!$in || !$tmphome)
+{
+ printf "Usage: xxx indir tmpdir";
+}
+
+# Set up the CCTK home directory
+$cachome = $ENV{'CCTK_HOME'} || "$ENV{HOME}/CCTK";
+$cachome =~ s:/$::g;
+
+#
+#if (!-e "$cachome/lib/perl/thorn_utils.pl" ) {
+# print <<EOE;
+#
+#ERROR: Cannot find the cactus perl libraries!
+#---------------------------------------------
+#This error usually means that either CACTUS_HOME is
+#set incorrectly, or that your distribution is not
+#in ~/cactus. Remeber that CACTUS_HOME has
+#to point to the directory above cactus.
+#
+#I was looking in
+#
+# $cachome/lib/perl
+#
+#when I failed.
+#
+#
+#EOE
+# exit;
+#}
+
+
+require "lib/sbin/parameter_parser.pl";
+require "lib/sbin/interface_parser.pl";
+
+%thorns = &create_thorn_list;
+
+%interface_database = create_interface_database(%thorns);
+
+%parameter_database = create_parameter_database(%thorns);
+
+
+@parameter_structure = &create_parameter_structure(%parameter_database);
+
+
+foreach $line (@parameter_structure)
+{
+ print "$line\n";
+}
+
+@parameter_declarations = &create_parameter_declarations(%parameter_database);
+
+
+#&print_parameter_database(%parameter_database);
+
+#&print_interface_database(%interface_database);
+
+sub create_parameter_declarations
+{
+ local(@paramater_database) = @_;
+
+ foreach $entry (@parameter_database)
+ {
+ }
+
+}
+
+sub create_parameter_structure
+{
+ local(%parameter_database) = @_;
+ local(@structure);
+ local($line, $entry, $thorn, $parameter, $type);
+
+ $line = "struct CCTK_PARAMS {";
+
+ push(@structure, $line);
+
+ foreach $entry ( keys %parameter_database )
+ {
+ if($entry =~ m:([^ ]*) ([^ ]*) type:)
+ {
+ $thorn = $1;
+ $parameter = "\L$2\E";
+ if($parameter_database{$entry} eq "KEYWORD" ||
+ $parameter_database{$entry} eq "STRING" ||
+ $parameter_database{$entry} eq "SENTENCE")
+ {
+ $type = "char *";
+ }
+ elsif($parameter_database{$entry} eq "LOGICAL" ||
+ $parameter_database{$entry} eq "INTEGER")
+ {
+ $type = "int ";
+ }
+ elsif($parameter_database{$entry} eq "REAL")
+ {
+ $type = "Double ";
+ }
+ else
+ {
+ die("Unknown parameter type '$parameter_database{$entry}'");
+ }
+
+ $line = " ". $type . $thorn . "_". $parameter .";";
+
+ push(@structure, $line);
+ }
+ }
+
+ $line = "};";
+ push(@structure, $line);
+
+ return @structure;
+}
+
+sub create_thorn_list
+{
+ return ("flesh", "toolkits/test/flesh",
+ "test1", "toolkits/test/test1",
+ "test2", "toolkits/test/test2");
+}
diff --git a/lib/sbin/interface_parser.pl b/lib/sbin/interface_parser.pl
index 97c7cd77..61b87ad6 100644
--- a/lib/sbin/interface_parser.pl
+++ b/lib/sbin/interface_parser.pl
@@ -1,13 +1,13 @@
#! /usr/bin/perl
-require "parameter_parser.pl";
+#require "parameter_parser.pl";
-%implementations = ("flesh", "flesh", "test1", "test1", "test2", "test2");
+#%implementations = ("flesh", "flesh", "test1", "test1", "test2", "test2");
-%interface_database = create_interface_database(%implementations);
+#%interface_database = create_interface_database(%implementations);
-&print_interface_database(%interface_database);
+#&print_interface_database(%interface_database);
#/*@@
# @routine create_interface_database
@@ -162,3 +162,5 @@ sub print_interface_database
print "$field has value $database{$field}\n";
}
}
+
+1;