line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hyper::Developer::Generator::Control::ContainerFlow; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1936
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
5
|
use version; our $VERSION = qv('0.01'); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
89
|
use base qw(Hyper::Developer::Generator::Control); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
153
|
|
8
|
|
|
|
|
|
|
use Class::Std; |
9
|
|
|
|
|
|
|
use Parse::RecDescent; |
10
|
|
|
|
|
|
|
use Hyper::Error; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _get_data_ref_of_steps { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
my $step_ref = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
return { |
17
|
|
|
|
|
|
|
map { |
18
|
|
|
|
|
|
|
my $name = $_; |
19
|
|
|
|
|
|
|
$name =~ s{[^\w]}{_}xmsg; |
20
|
|
|
|
|
|
|
$name => { |
21
|
|
|
|
|
|
|
control => $step_ref->{$_}->get_controls(), |
22
|
|
|
|
|
|
|
action => $self->_create_action_code($step_ref->{$_}->get_action()), |
23
|
|
|
|
|
|
|
transitions => [ |
24
|
|
|
|
|
|
|
map { |
25
|
|
|
|
|
|
|
my $destination = $_->get_destination(); |
26
|
|
|
|
|
|
|
$destination =~ s{[^\w]}{_}xmsg; |
27
|
|
|
|
|
|
|
$destination => $self->_create_condition_code($_->get_condition()); |
28
|
|
|
|
|
|
|
} @{$step_ref->{$_}->get_transitions()} |
29
|
|
|
|
|
|
|
], |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} keys %{$step_ref} |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _get_default_parser :PRIVATE { |
36
|
|
|
|
|
|
|
return Parse::RecDescent->new(q{ |
37
|
|
|
|
|
|
|
line : expr |
38
|
|
|
|
|
|
|
| { die '__ERROR__'; } |
39
|
|
|
|
|
|
|
expr : { die '__REPLACE_ME__'; } |
40
|
|
|
|
|
|
|
mixed : method |
41
|
|
|
|
|
|
|
| ident |
42
|
|
|
|
|
|
|
| { die '__ERROR__' } |
43
|
|
|
|
|
|
|
method : variables '()' |
44
|
|
|
|
|
|
|
{ if ( $item[1]->[0] eq 'this') { |
45
|
|
|
|
|
|
|
shift @{$item[1]}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
my $method = pop @{$item[1]}; |
48
|
|
|
|
|
|
|
'$self' |
49
|
|
|
|
|
|
|
. ( |
50
|
|
|
|
|
|
|
@{$item[1]} |
51
|
|
|
|
|
|
|
? '->get_value_recursive([qw(' |
52
|
|
|
|
|
|
|
. ( join q{ }, @{$item[1]} ) . ')])' |
53
|
|
|
|
|
|
|
: q{} |
54
|
|
|
|
|
|
|
) . "->$method()"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
constant : m{[-]?\d[\d_]*(?: \.(?: \d[\d_])*)?}xms |
57
|
|
|
|
|
|
|
| m{'(?: \\\\' | [^'] )* '}xms |
58
|
|
|
|
|
|
|
| m{"(?: \\\\" | [^"] )* "}xms |
59
|
|
|
|
|
|
|
variable : m{[a-z_][a-z0-9_]*}xmsi |
60
|
|
|
|
|
|
|
variables : variable(s /\./) |
61
|
|
|
|
|
|
|
ident : constant |
62
|
|
|
|
|
|
|
| variables |
63
|
|
|
|
|
|
|
{ if ( $item[1]->[0] eq 'this') { |
64
|
|
|
|
|
|
|
shift @{$item[1]}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
'$self' |
67
|
|
|
|
|
|
|
. ( |
68
|
|
|
|
|
|
|
@{$item[1]} |
69
|
|
|
|
|
|
|
? '->get_value_recursive([qw(' |
70
|
|
|
|
|
|
|
. ( join q{ }, @{$item[1]} ) . ')])' |
71
|
|
|
|
|
|
|
: q{} |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
}); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _create_action_code :RESTRICTED { |
78
|
|
|
|
|
|
|
my $self = shift; |
79
|
|
|
|
|
|
|
my $param = shift; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return q{} if ! defined $param; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $parser = $self->_get_default_parser(); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$parser->Extend(q{ |
86
|
|
|
|
|
|
|
terminator : m{ \s* ;* \s* (\#.*)? \z }xms |
87
|
|
|
|
|
|
|
{ return q{} } |
88
|
|
|
|
|
|
|
}); |
89
|
|
|
|
|
|
|
$parser->Replace(q{ |
90
|
|
|
|
|
|
|
expr : variables '=' mixed terminator |
91
|
|
|
|
|
|
|
{ chomp $item{mixed}; |
92
|
|
|
|
|
|
|
$item{mixed} =~ s{\s*\;$}{}; |
93
|
|
|
|
|
|
|
"\$self->set_value_recursive(" |
94
|
|
|
|
|
|
|
. '[qw(' |
95
|
|
|
|
|
|
|
. ( join q{ }, @{$item{variables}} ) |
96
|
|
|
|
|
|
|
. ")], $item{mixed});" |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
| method |
99
|
|
|
|
|
|
|
{ "$item{method};" } |
100
|
|
|
|
|
|
|
}); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# return input converted to grammar |
103
|
|
|
|
|
|
|
my $result = eval { |
104
|
|
|
|
|
|
|
join "\n", map { $parser->line($_) } split m{\n}, $param; |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
throw("$@ Error generating action code near\n$param") if $@; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return $result; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub _create_condition_code :RESTRICTED { |
113
|
|
|
|
|
|
|
my $self = shift; |
114
|
|
|
|
|
|
|
my $param = shift; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
return q{} if ! defined $param; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $parser = $self->_get_default_parser(); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
$parser->Extend(q{ |
121
|
|
|
|
|
|
|
logop : 'eq' | 'ne' | '==' | '!=' | '||' | '&&' | 'or' | 'and' |
122
|
|
|
|
|
|
|
}); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$parser->Replace(q{ |
125
|
|
|
|
|
|
|
expr : mixed logop expr |
126
|
|
|
|
|
|
|
{ join q{ }, @item[1..3] } |
127
|
|
|
|
|
|
|
| mixed |
128
|
|
|
|
|
|
|
}); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# return input converted to grammar |
131
|
|
|
|
|
|
|
my $result = eval { |
132
|
|
|
|
|
|
|
join "\n", map { $parser->line($_); } split m{\n}, $param; |
133
|
|
|
|
|
|
|
}; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
throw("$@ Error generating condition code near\n $param") if $@; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
return $result; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |
141
|
|
|
|
|
|
|
__END__ |