pione 0.5.0.alpha.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/History.txt +2 -1
- data/example/DeferredChoiceWithPage/DeferredChoiceWithPage.pione +2 -5
- data/example/DeferredChoiceWithPage/{DefferredChoiceWithPage.pnml → DeferredChoiceWithPage.pnml} +0 -0
- data/example/DeferredChoiceWithPage/pione-package.json +2 -1
- data/example/FeatureExample/FeatureExample.pione +1 -1
- data/example/FeatureExample/pione-package.json +2 -2
- data/example/Fib/Fib.pione +9 -54
- data/example/Fib/FibN.pione +49 -0
- data/example/Interaction/Interaction.pione +6 -8
- data/example/Interaction/pione-package.json +6 -5
- data/example/LoopByTouch/LoopByTouch.pione +1 -3
- data/example/LoopByTouch/LoopByTouch.pnml +23 -6
- data/example/MakePair/scenario/case1/pione-scenario.json +28 -28
- data/example/MakePair/scenario/case2/pione-scenario.json +10 -10
- data/example/MakePair/scenario/case3/pione-scenario.json +26 -26
- data/example/OddSelector/OddSelector.pione +0 -1
- data/example/OddSelector/pione-package.json +2 -2
- data/example/OddSelector/scenario/pione-scenario.json +9 -9
- data/example/PegasusWMS/Merge/PegasusWMSMerge.pione +0 -1
- data/example/PegasusWMS/Merge/PegasusWMSMerge.pnml +2 -2
- data/example/PegasusWMS/Pipeline/PegasusWMSPipeline.pione +0 -1
- data/example/PegasusWMS/Split/PegasusWMSSplit.pione +0 -1
- data/example/ScoreAggregation/pione-package.json +3 -3
- data/example/ScoreAggregation/scenario/case1/pione-scenario.json +19 -19
- data/example/SelectRuleByParam/SelectRuleByParam.pione +5 -15
- data/example/SelectRuleByParam/pione-package.json +4 -0
- data/example/SequentialParameter/SequentialParameter.pione +0 -1
- data/example/SerialProcessing/A.pione +0 -1
- data/example/SerialProcessing/B.pione +0 -1
- data/example/SerialProcessing/SerialProcessing.pione +0 -1
- data/example/SerialProcessing/pione-package.json +2 -2
- data/example/SieveOfEratosthenes/CreateUndeterminedNumbers.pione +11 -0
- data/example/SingleParticlesWithRef/Create3dinfo.pione +36 -0
- data/example/SingleParticlesWithRef/Create3dinfo.pnml +5 -5
- data/example/SingleParticlesWithRef/Package.pione +3 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +8 -91
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pnml +6 -6
- data/example/SingleParticlesWithRef/misc/{SingleParticlesWithRef.Display2.pione → SingleParticlesWithRef.Display2.pione.bak} +0 -0
- data/example/SingleParticlesWithRef/misc/{SingleParticlesWithRefFull.pione → SingleParticlesWithRefFull.pione.bak} +0 -0
- data/example/SingleParticlesWithRef/pione-package.json +20 -0
- data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/StructuredSynchronizingMerge.pione +20 -46
- data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/pione-package.json +19 -0
- data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/MultipleInstancesWithoutSynchronization.pione +0 -1
- data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/MultipleInstancesWithDesignTimeKnowledge.pione +0 -1
- data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/MultipleInstancesWithRunTimeKnowledge.pione +0 -1
- data/example/WorkflowPatterns/33_GeneralizedANDJoin/GeneralizedANDJoin.pione +0 -1
- data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/GeneralSynchronizingMerge.pione +28 -68
- data/example/WorkflowPatterns/41_ThreadMerge/A.pione +24 -0
- data/example/WorkflowPatterns/41_ThreadMerge/A1.pione +14 -0
- data/example/WorkflowPatterns/41_ThreadMerge/ThreadMerge.pione +8 -31
- data/example/WorkflowPatterns/41_ThreadMerge/pione-package.json +21 -0
- data/example/WorkflowPatterns/42_ThreadSplit/ThreadSplit.pione +7 -7
- data/example/WorkflowPatterns/42_ThreadSplit/pione-package.json +19 -0
- data/lib/pione/command/pione-package-build.rb +2 -1
- data/lib/pione/lang/expr-parser.rb +1 -1
- data/lib/pione/lang/expr-transformer.rb +2 -0
- data/lib/pione/lang/type.rb +2 -2
- data/lib/pione/lang/variable.rb +8 -0
- data/lib/pione/pnml/compiler.rb +42 -23
- data/lib/pione/pnml/declaration-extractor.rb +16 -6
- data/lib/pione/pnml/pione-model.rb +18 -6
- data/lib/pione/pnml/ticket-instantiation.rb +2 -2
- data/lib/pione/version.rb +1 -1
- metadata +16 -7
@@ -0,0 +1,24 @@
|
|
1
|
+
Rule A
|
2
|
+
input '0.count'
|
3
|
+
input 'cont'
|
4
|
+
output 'o1'
|
5
|
+
Flow
|
6
|
+
rule __A_A1_0__
|
7
|
+
rule A2
|
8
|
+
End
|
9
|
+
|
10
|
+
Rule __A_A1_0__
|
11
|
+
input '*.count'.all
|
12
|
+
input 'cont'
|
13
|
+
output '{$*.length}.count'
|
14
|
+
Flow
|
15
|
+
rule A1
|
16
|
+
End
|
17
|
+
|
18
|
+
Rule A2
|
19
|
+
input 'cont'
|
20
|
+
input '*.count'.all
|
21
|
+
output 'o1'
|
22
|
+
output 'cont'.remove
|
23
|
+
constraint $*.length > 5
|
24
|
+
End
|
@@ -1,43 +1,20 @@
|
|
1
|
-
Rule
|
2
|
-
output 'o1'
|
1
|
+
Rule ThreadMerge
|
3
2
|
Flow
|
3
|
+
rule __ThreadMerge_A_0__
|
4
4
|
rule Init
|
5
|
-
rule A
|
6
5
|
End
|
7
6
|
|
8
|
-
Rule
|
9
|
-
output 'i1'.touch
|
10
|
-
output 'cont'.touch
|
11
|
-
output '0.count'.touch
|
12
|
-
End
|
13
|
-
|
14
|
-
Rule A
|
7
|
+
Rule __ThreadMerge_A_0__
|
15
8
|
input 'i1'
|
16
9
|
input 'cont'
|
17
10
|
input '0.count'
|
18
11
|
output 'o1'
|
19
12
|
Flow
|
20
|
-
rule
|
21
|
-
rule A2
|
22
|
-
End
|
23
|
-
|
24
|
-
Rule A1
|
25
|
-
input '*.count'.all or null
|
26
|
-
input 'cont'
|
27
|
-
output '{$*.length}.count'
|
28
|
-
Flow
|
29
|
-
rule A1Count {N: $*.length}
|
30
|
-
End
|
31
|
-
|
32
|
-
Rule A1Count
|
33
|
-
output '{$N}.count'.touch
|
34
|
-
param $N
|
13
|
+
rule A
|
35
14
|
End
|
36
15
|
|
37
|
-
Rule
|
38
|
-
|
39
|
-
|
40
|
-
output '
|
41
|
-
output 'cont'.remove
|
42
|
-
constraint $*.length > 5
|
16
|
+
Rule Init
|
17
|
+
output 'i1'
|
18
|
+
output 'cont'
|
19
|
+
output '0.count'
|
43
20
|
End
|
@@ -1,16 +1,16 @@
|
|
1
|
-
Rule
|
1
|
+
Rule ThreadSplit
|
2
2
|
output 'o1-*'.all
|
3
3
|
Flow
|
4
|
-
rule Init
|
5
4
|
rule A
|
6
|
-
|
7
|
-
|
8
|
-
Rule Init
|
9
|
-
output 'p1'.touch
|
5
|
+
rule Init
|
10
6
|
End
|
11
7
|
|
12
8
|
Rule A
|
13
9
|
input 'p1'
|
14
|
-
output 'o1-{$N}'
|
10
|
+
output 'o1-{$N}'
|
15
11
|
param $N := 1.upto(5)
|
16
12
|
End
|
13
|
+
|
14
|
+
Rule Init
|
15
|
+
output 'p1'
|
16
|
+
End
|
@@ -131,7 +131,7 @@ module Pione
|
|
131
131
|
location.entries.each_with_object(Hash.new) do |entry, actions|
|
132
132
|
if entry.basename.end_with?(".action.md")
|
133
133
|
begin
|
134
|
-
actions.merge!(LiterateAction::
|
134
|
+
actions.merge!(LiterateAction::MarkdownParser.parse(entry.read))
|
135
135
|
rescue
|
136
136
|
Log::SystemLog.fatal("Error has occured when parsing the action document %s." % entry.address)
|
137
137
|
raise
|
@@ -156,6 +156,7 @@ module Pione
|
|
156
156
|
option = {
|
157
157
|
:flow_rule_name => flow_name,
|
158
158
|
:literate_actions => actions,
|
159
|
+
:package_pione => location + "Package.pione"
|
159
160
|
}
|
160
161
|
content = PNML::Compiler.new(net, option).compile
|
161
162
|
file = entry.dirname + (flow_name + ".pione")
|
@@ -18,6 +18,8 @@ module Pione
|
|
18
18
|
# Extract the content of +:expr+.
|
19
19
|
rule(:expr => simple(:obj)) { obj }
|
20
20
|
|
21
|
+
rule({:header => simple(:header), :expr => simple(:obj)}) { obj }
|
22
|
+
|
21
23
|
# Transform receiver and messages as Lang::Message.
|
22
24
|
rule({ :receiver => simple(:receiver),
|
23
25
|
:messages => sequence(:messages) }) {
|
data/lib/pione/lang/type.rb
CHANGED
@@ -25,7 +25,7 @@ module Pione
|
|
25
25
|
# @return [Boolean]
|
26
26
|
# true if it matches, or false
|
27
27
|
def match(env, target)
|
28
|
-
target_type = target.pione_type(env)
|
28
|
+
target_type = target.kind_of?(Type) ? target : target.pione_type(env)
|
29
29
|
while target_type do
|
30
30
|
return true if self == target_type
|
31
31
|
target_type = target_type.parent_type
|
@@ -47,7 +47,7 @@ module Pione
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# try immediate methods
|
50
|
-
_args = args.map {|arg| arg.
|
50
|
+
_args = args.map {|arg| arg.pione_type(env)} # FIXME : should be replaced by type inference
|
51
51
|
if group.has_key?(:immediate)
|
52
52
|
return group[:immediate].find {|m| m.validate_inputs(env, rec, _args)}
|
53
53
|
else
|
data/lib/pione/lang/variable.rb
CHANGED
@@ -15,6 +15,14 @@ module Pione
|
|
15
15
|
env.variable_get(self).pione_type(env)
|
16
16
|
end
|
17
17
|
|
18
|
+
def index_type(env)
|
19
|
+
env.variable_get(self).index_type(env)
|
20
|
+
end
|
21
|
+
|
22
|
+
def element_type(env)
|
23
|
+
env.variable_get(self).element_type(env)
|
24
|
+
end
|
25
|
+
|
18
26
|
# Get the value from variable table in the environment.
|
19
27
|
def eval(env)
|
20
28
|
env.variable_get(self)
|
data/lib/pione/pnml/compiler.rb
CHANGED
@@ -15,6 +15,7 @@ module Pione
|
|
15
15
|
@net = net
|
16
16
|
@net_name = option[:flow_rule_name] || "Main"
|
17
17
|
@env = option[:env] || Lang::Environment.new
|
18
|
+
setup_env(option[:package_pione])
|
18
19
|
|
19
20
|
@option = option
|
20
21
|
@net_rewriter = NetRewriter.new do |rules|
|
@@ -32,6 +33,22 @@ module Pione
|
|
32
33
|
@actions = []
|
33
34
|
end
|
34
35
|
|
36
|
+
def setup_env(package_pione)
|
37
|
+
@env = @env.setup_new_package(:pnml_compiler)
|
38
|
+
|
39
|
+
if package_pione and package_pione.exist?
|
40
|
+
parsed = Lang::DocumentParser.new.parse(package_pione.read)
|
41
|
+
package_document = Lang::DocumentTransformer.new.apply(parsed, {package_name: true, filename: true})
|
42
|
+
package_document.eval(@env)
|
43
|
+
end
|
44
|
+
|
45
|
+
val = Lang::KeyedSequence.new
|
46
|
+
val = val.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("pnml_compiler"))
|
47
|
+
@env.variable_set!(Lang::Variable.new("I"), val)
|
48
|
+
@env.variable_set!(Lang::Variable.new("*"), Lang::StringSequence.of("pnml_compiler"))
|
49
|
+
@env.variable_set!(Lang::Variable.new("O"), val)
|
50
|
+
end
|
51
|
+
|
35
52
|
# Compile a PNML file into PIONE document as a string.
|
36
53
|
def compile
|
37
54
|
# annotations
|
@@ -97,7 +114,7 @@ module Pione
|
|
97
114
|
# conditional branch
|
98
115
|
@net.transitions.each do |transition|
|
99
116
|
inputs = @net.find_all_places_by_target_id(transition.id).select do |place|
|
100
|
-
Perspective.data_place?(
|
117
|
+
Perspective.data_place?(@env, place)
|
101
118
|
end.map {|input| InputData.new(input)}
|
102
119
|
|
103
120
|
if Perspective.if_transition?(@env, transition)
|
@@ -151,12 +168,12 @@ module Pione
|
|
151
168
|
prev_transition = @net.find_transition_by_target_id(place.id)
|
152
169
|
if Perspective.constraint_transition?(@env, prev_transition)
|
153
170
|
@net.find_all_places_by_target_id(prev_transition.id).each do |_place|
|
154
|
-
if Perspective.data_place?(
|
171
|
+
if Perspective.data_place?(@env, _place)
|
155
172
|
inputs << InputData.new(_place)
|
156
173
|
end
|
157
174
|
end
|
158
175
|
else
|
159
|
-
if Perspective.data_place?(
|
176
|
+
if Perspective.data_place?(@env, place)
|
160
177
|
inputs << InputData.new(place)
|
161
178
|
end
|
162
179
|
end
|
@@ -190,9 +207,9 @@ module Pione
|
|
190
207
|
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, params|
|
191
208
|
if Perspective.param_place?(@env, place)
|
192
209
|
prev_transitions = @net.find_all_transitions_by_target_id(place.id)
|
193
|
-
keyword_transitions = prev_transitions.select{|t| Perspective.keyword_transition?(t)}
|
210
|
+
keyword_transitions = prev_transitions.select{|t| Perspective.keyword_transition?(@env, t)}
|
194
211
|
if keyword_transitions.empty?
|
195
|
-
params << Param.
|
212
|
+
params << Param.set_of(place)
|
196
213
|
end
|
197
214
|
end
|
198
215
|
end
|
@@ -213,7 +230,7 @@ module Pione
|
|
213
230
|
when 0
|
214
231
|
# ignore
|
215
232
|
when 1
|
216
|
-
if Perspective.expr_place?(place)
|
233
|
+
if Perspective.expr_place?(@env, place)
|
217
234
|
constraints << Constraint.new(place.name)
|
218
235
|
else
|
219
236
|
# the place should be constraint expression
|
@@ -234,8 +251,8 @@ module Pione
|
|
234
251
|
# tickets
|
235
252
|
def find_source_tickets(transition)
|
236
253
|
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, tickets|
|
237
|
-
if Perspective.ticket_place?(
|
238
|
-
tickets << Ticket.new(place)
|
254
|
+
if Perspective.ticket_place?(@env, place)
|
255
|
+
tickets << Ticket.new(place.name)
|
239
256
|
end
|
240
257
|
end
|
241
258
|
end
|
@@ -248,7 +265,7 @@ module Pione
|
|
248
265
|
# tickets
|
249
266
|
def find_target_tickets(transition)
|
250
267
|
@net.find_all_places_by_source_id(transition.id).each_with_object([]) do |place, tickets|
|
251
|
-
if Perspective.ticket_place?(
|
268
|
+
if Perspective.ticket_place?(@env, place)
|
252
269
|
tickets << Ticket.new(place.name)
|
253
270
|
end
|
254
271
|
end
|
@@ -262,9 +279,9 @@ module Pione
|
|
262
279
|
# features
|
263
280
|
def find_features(transition)
|
264
281
|
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, features|
|
265
|
-
if Perspective.feature_place?(
|
282
|
+
if Perspective.feature_place?(@env, place)
|
266
283
|
keyword_transitions = @net.find_all_transitions_by_target_id(place.id).select do |t|
|
267
|
-
Perspective.keyword_transition?(t)
|
284
|
+
Perspective.keyword_transition?(@env, t)
|
268
285
|
end
|
269
286
|
if keyword_transitions.empty?
|
270
287
|
features << Feature.new(place.name)
|
@@ -283,8 +300,8 @@ module Pione
|
|
283
300
|
condition = @net.find_place_by_source_id(transition.id)
|
284
301
|
|
285
302
|
nodes = @net.find_all_transitions_by_source_id(condition.id)
|
286
|
-
key_then = nodes.find{|node| Perspective.then_transition?(node)}
|
287
|
-
key_else = nodes.find{|node| Perspective.else_transition?(node)}
|
303
|
+
key_then = nodes.find{|node| Perspective.then_transition?(@env, node)}
|
304
|
+
key_else = nodes.find{|node| Perspective.else_transition?(@env, node)}
|
288
305
|
|
289
306
|
branch = ConditionalBranch.new(:if, condition.name)
|
290
307
|
|
@@ -295,11 +312,13 @@ module Pione
|
|
295
312
|
branch.table[:then] << rule
|
296
313
|
end
|
297
314
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
315
|
+
if key_else
|
316
|
+
find_next_rules(key_else).each do |transition|
|
317
|
+
rule = definition[transition.id]
|
318
|
+
rule.inputs += inputs
|
319
|
+
flow_elements.delete(rule)
|
320
|
+
branch.table[:else] << rule
|
321
|
+
end
|
303
322
|
end
|
304
323
|
|
305
324
|
return branch
|
@@ -315,8 +334,8 @@ module Pione
|
|
315
334
|
expr = @net.find_place_by_source_id(transition.id)
|
316
335
|
|
317
336
|
nodes = @net.find_all_transitions_by_source_id(expr.id)
|
318
|
-
keys_when = nodes.select{|node| Perspective.when_transition?(node)}
|
319
|
-
key_else = nodes.find{|node| Perspective.else_transition?(node)}
|
337
|
+
keys_when = nodes.select{|node| Perspective.when_transition?(@env, node)}
|
338
|
+
key_else = nodes.find{|node| Perspective.else_transition?(@env, node)}
|
320
339
|
|
321
340
|
branch = ConditionalBranch.new(:case, expr.name)
|
322
341
|
|
@@ -349,7 +368,7 @@ module Pione
|
|
349
368
|
def find_next_rules(base_rule)
|
350
369
|
@net.find_all_places_by_source_id(base_rule.id).each_with_object([]) do |place, res|
|
351
370
|
@net.find_all_transitions_by_source_id(place.id).each do |transition|
|
352
|
-
if Perspective.rule_transition?(transition)
|
371
|
+
if Perspective.rule_transition?(@env, transition)
|
353
372
|
res << transition
|
354
373
|
else
|
355
374
|
find_next_rules(transition)
|
@@ -380,10 +399,10 @@ module Pione
|
|
380
399
|
# @return [RuleDefinition]
|
381
400
|
# a flow rule definition for PNML net
|
382
401
|
def build(flow_elements, params, features, variable_bindings)
|
383
|
-
inputs = @net.places.select {|place| Perspective.net_input_data_place?(
|
402
|
+
inputs = @net.places.select {|place| Perspective.net_input_data_place?(@env, place)}
|
384
403
|
inputs = inputs.map {|input| InputData.new(input)}
|
385
404
|
|
386
|
-
outputs = @net.places.select {|place| Perspective.net_output_data_place?(
|
405
|
+
outputs = @net.places.select {|place| Perspective.net_output_data_place?(@env, place)}
|
387
406
|
outputs = outputs.map {|output| OutputData.new(output)}
|
388
407
|
|
389
408
|
option = {
|
@@ -5,7 +5,7 @@ module Pione
|
|
5
5
|
def initialize(env, net, option={})
|
6
6
|
@env = env
|
7
7
|
@net = net
|
8
|
-
@declarations = ExtractedDeclarations.new
|
8
|
+
@declarations = ExtractedDeclarations.new(@env)
|
9
9
|
end
|
10
10
|
|
11
11
|
def extract
|
@@ -54,7 +54,8 @@ module Pione
|
|
54
54
|
attr_reader :variable_bindings
|
55
55
|
attr_reader :features
|
56
56
|
|
57
|
-
def initialize
|
57
|
+
def initialize(env)
|
58
|
+
@env = env
|
58
59
|
@params = []
|
59
60
|
@variable_bindings = []
|
60
61
|
@features = []
|
@@ -65,7 +66,12 @@ module Pione
|
|
65
66
|
# @param param [String]
|
66
67
|
# a string of parameter
|
67
68
|
def add_param(param)
|
68
|
-
|
69
|
+
sentence = LabelExtractor.extract_param_sentence(param)
|
70
|
+
parsed = Lang::DocumentParser.new.parse(sentence)
|
71
|
+
value = Lang::DocumentTransformer.new.apply(parsed, {package_name: true, filename: true})
|
72
|
+
param_decl = value.elements.first
|
73
|
+
param_decl.eval(@env)
|
74
|
+
@params << sentence
|
69
75
|
end
|
70
76
|
|
71
77
|
# Add the variable binding.
|
@@ -73,8 +79,12 @@ module Pione
|
|
73
79
|
# @param variable_binding [String]
|
74
80
|
# a string of variable binding
|
75
81
|
def add_variable_binding(variable_binding)
|
76
|
-
|
77
|
-
|
82
|
+
sentence = LabelExtractor.extract_variable_binding(variable_binding)
|
83
|
+
parsed = Lang::DocumentParser.new.parse(sentence)
|
84
|
+
value = Lang::DocumentTransformer.new.apply(parsed, {package_name: true, filename: true})
|
85
|
+
variable_binding_decl = value.elements.first
|
86
|
+
variable_binding_decl.eval(@env)
|
87
|
+
@variable_bindings << variable_binding
|
78
88
|
end
|
79
89
|
|
80
90
|
# Add the feature.
|
@@ -83,7 +93,7 @@ module Pione
|
|
83
93
|
# a string of feature
|
84
94
|
def add_feature(feature)
|
85
95
|
@features <<
|
86
|
-
|
96
|
+
LabelExtractor.extract_feature_sentence(feature)
|
87
97
|
end
|
88
98
|
end
|
89
99
|
end
|