summaryrefslogtreecommitdiff
path: root/lib/sbin/ScheduleParser.pl
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2008-04-09 03:37:21 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2008-04-09 03:37:21 +0000
commita780159bccfd17395ac08e394b1464d7e57fc249 (patch)
tree6fd9ed0b23e9fa4e48d17ca8a65d35ad4b7a3fb7 /lib/sbin/ScheduleParser.pl
parenta9833d5a888148fde04946252e997b4642eb7c47 (diff)
Add IF clauses to schedule items
Schedule items in Cactus can already have WHILE clauses, which means that they are executed while a certain condition are true. This patch adds IF clauses, which means that they are executed only if a certain condition is true. The syntax is equivalent to WHILE clauses. These if clauses is different from the existing C-syntax if statements, which are only evaluated at startup and determine how the schedule is constructed. These if clauses are evaluated every time the schedule is traversed, and can skip certain schedule items. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4478 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/ScheduleParser.pl')
-rw-r--r--lib/sbin/ScheduleParser.pl30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/sbin/ScheduleParser.pl b/lib/sbin/ScheduleParser.pl
index aae105f8..dff3b0d9 100644
--- a/lib/sbin/ScheduleParser.pl
+++ b/lib/sbin/ScheduleParser.pl
@@ -112,7 +112,7 @@ sub parse_schedule_ccl
my($n_statements);
my($name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options, $before_list, $after_list, $while_list);
+ $options, $before_list, $after_list, $while_list, $if_list);
my($groups);
$buffer = "";
@@ -126,7 +126,8 @@ sub parse_schedule_ccl
($line_number,
$name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options,$before_list, $after_list, $while_list) = &ParseScheduleBlock($thorn,$line_number, @data);
+ $options,$before_list, $after_list, $while_list, $if_list)
+ = &ParseScheduleBlock($thorn,$line_number, @data);
$schedule_db{"\U$thorn\E BLOCK_$n_blocks NAME"} = $name;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks AS"} = $as;
@@ -142,6 +143,7 @@ sub parse_schedule_ccl
$schedule_db{"\U$thorn\E BLOCK_$n_blocks BEFORE"} = $before_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks AFTER"} = $after_list;
$schedule_db{"\U$thorn\E BLOCK_$n_blocks WHILE"} = $while_list;
+ $schedule_db{"\U$thorn\E BLOCK_$n_blocks IF"} = $if_list;
$buffer .= "\@BLOCK\@$n_blocks\n";
$n_blocks++;
@@ -193,12 +195,13 @@ sub ParseScheduleBlock
my($thorn,$line_number, @data) = @_;
my($name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options, $before_list, $after_list, $while_list);
+ $options, $before_list, $after_list, $while_list, $if_list);
my(@fields);
my($field);
my(@before_list) = ();
my(@after_list) = ();
my(@while_list) = ();
+ my(@if_list) = ();
my(@mem_groups) = ();
my(@comm_groups) = ();
my(@trigger_groups) = ();
@@ -330,6 +333,16 @@ sub ParseScheduleBlock
$keyword = "WHILE";
$field++;
}
+ elsif($fields[$field] =~ m:^IF$:i)
+ {
+ if($keyword ne "")
+ {
+ &CST_error(0,"Error parsing schedule block line '$data[$line_number]'",
+ "",__LINE__,__FILE__);
+ }
+ $keyword = "IF";
+ $field++;
+ }
elsif($keyword ne "" && $fields[$field] =~ m:\s*\(\s*:)
{
# Parse a clause of the form BEFORE(a,b,c)
@@ -363,6 +376,10 @@ sub ParseScheduleBlock
{
push(@while_list, @current_sched_list);
}
+ elsif($keyword eq "IF")
+ {
+ push(@if_list, @current_sched_list);
+ }
# Reset keyword to empty for next time.
$keyword = "";
@@ -381,6 +398,10 @@ sub ParseScheduleBlock
{
push(@while_list, $fields[$field]);
}
+ elsif($keyword eq "IF")
+ {
+ push(@if_list, $fields[$field]);
+ }
$field++;
$keyword = "";
}
@@ -499,12 +520,13 @@ sub ParseScheduleBlock
$before_list = join(",", @before_list);
$after_list = join(",", @after_list);
$while_list = join(",", @while_list);
+ $if_list = join(",", @if_list);
return ($line_number,
$name, $as, $type, $description, $where, $language,
$mem_groups, $comm_groups, $trigger_groups, $sync_groups,
- $options,$before_list, $after_list, $while_list);
+ $options,$before_list, $after_list, $while_list, $if_list);
}