-
Notifications
You must be signed in to change notification settings - Fork 0
/
ce-sym
executable file
·54 lines (39 loc) · 1.34 KB
/
ce-sym
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
use warnings;
use strict;
use v5.10;
use FindBin;
use lib $FindBin::Bin;
use compeval::Task;
sub print_workflow {
my ($workflow, $indent, $firstinput) = @_;
if ($workflow->kind eq 'input') {
print "INPUT('".$workflow->value."')";
} elsif ($workflow->kind eq 'literal') {
print "FILE('".$workflow->value."')";
} elsif ($workflow->kind eq 'computation') {
my $compname = $workflow->value;
# String with LISP-y function call
my $callstr = "($compname ";
# Space indentation aligning with callstr - callstr converted to spaces
my $callstrspaces = ' ' x length $callstr;
my $indent2 = $indent . $callstrspaces;
# Print function call
print "$callstr";
# Recursively print arguments
my $inputcount = 0;
for my $input ($workflow->inputs) {
# Start a new line (and indent) unless we are the first input
$inputcount == 0 or print "\n$indent2";
print_workflow($workflow->input($input), $indent2, $inputcount == 0 ? 'firstinput' : undef);
$inputcount++;
}
# Close the call on next line if we had more than one argument
$inputcount < 2 or print "\n$indent ";
print ")[".join(', ', $workflow->outputs_slice)."]";
}
}
my $task = compeval::Task->new('.');
say "Inputs: " . join(', ', map { "'$_'" } $task->inputnames());
print_workflow($task->workflow(), '', 'firstinput');
print "\n"; # terminate with newline