pione 0.4.2 → 0.5.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +1 -1
- data/History.txt +6 -0
- data/example/ActionError/ActionError.action.md +11 -0
- data/example/ActionError/ActionError.pione +6 -3
- data/example/ActionError/ActionError.pnml +86 -0
- data/example/ActionError/Package.pione +2 -0
- data/example/ActionError/pione-package.json +5 -1
- data/example/CTFCorrection/CTFCorrection.action.md +46 -0
- data/example/CTFCorrection/CTFCorrection.pione +19 -41
- data/example/CTFCorrection/CTFCorrection.pnml +839 -0
- data/example/CTFCorrection/Package.pione +1 -0
- data/example/CTFCorrection/Params.pione +21 -0
- data/example/CTFCorrection/pione-package.json +20 -0
- data/example/ChildPackage/ChildPackage.pione +8 -0
- data/example/ChildPackage/pione-package.json +20 -0
- data/example/CountChar/CountChar.pione +31 -0
- data/example/CountChar/CountChar.pnml +239 -0
- data/example/CountChar/Main.pione +6 -26
- data/example/CountChar/Main.pnml +32 -100
- data/example/CountChar/Package.pione +1 -0
- data/example/CountChar/pione-package.json +3 -1
- data/example/DeferredChoice/DeferredChoice.action.md +46 -0
- data/example/DeferredChoice/DeferredChoice.pione +2 -7
- data/example/DeferredChoice/DeferredChoice.pnml +371 -0
- data/example/DeferredChoice/Package.pione +4 -0
- data/example/DeferredChoice/pione-package.json +7 -3
- data/example/DeferredChoiceWithPage/DeferredChoiceWithPage.action.md +34 -0
- data/example/DeferredChoiceWithPage/DefferredChoiceWithPage.pnml +371 -0
- data/example/DeferredChoiceWithPage/Package.pione +2 -0
- data/example/FeatureExample/FeatureExample.action.md +7 -0
- data/example/FeatureExample/FeatureExample.pione +7 -4
- data/example/FeatureExample/FeatureExample.pnml +86 -0
- data/example/FeatureExample/Package.pione +1 -0
- data/example/FeatureExample/pione-package.json +4 -0
- data/example/Fib/Fib.action.md +33 -0
- data/example/Fib/Fib.pnml +208 -0
- data/example/Fib/FibN.pnml +807 -0
- data/example/Fib/Package.pione +6 -0
- data/example/HelloWorld/HelloWorld.action.md +7 -0
- data/example/HelloWorld/HelloWorld.pione +6 -2
- data/example/HelloWorld/HelloWorld.pnml +86 -0
- data/example/HelloWorld/Package.pione +2 -0
- data/example/HelloWorld/pione-package.json +5 -1
- data/example/Interaction/Interaction.action.md +21 -0
- data/example/Interaction/Interaction.pnml +89 -0
- data/example/Interaction/Package.pione +2 -0
- data/example/LoopByTouch/LoopByTouch.pione +32 -12
- data/example/LoopByTouch/LoopByTouch.pnml +575 -0
- data/example/LoopByTouch/Package.pione +3 -0
- data/example/LoopByTouch/PairLoop.pione +6 -7
- data/example/LoopByTouch/PairLoop.pnml +188 -0
- data/example/LoopByTouch/SingleLoop.pione +6 -0
- data/example/LoopByTouch/SingleLoop.pnml +86 -0
- data/example/LoopByTouch/TripletLoop.pione +12 -13
- data/example/LoopByTouch/TripletLoop.pnml +239 -0
- data/example/LoopByTouch/pione-package.json +7 -3
- data/example/LucasNumber/LucasNumber.action.md +25 -0
- data/example/LucasNumber/LucasNumber.pnml +244 -0
- data/example/LucasNumber/LucasNumberN.pnml +1719 -0
- data/example/LucasNumber/Package.pione +2 -0
- data/example/MakePair/MakePair.pione +8 -10
- data/example/MakePair/MakePair.pnml +1141 -0
- data/example/MakePair/Package.pione +2 -0
- data/example/MakePair/pione-package.json +7 -3
- data/example/MakePair/scenario/case1/pione-scenario.json +30 -30
- data/example/MakePair/scenario/case2/pione-scenario.json +10 -10
- data/example/MakePair/scenario/case3/pione-scenario.json +28 -28
- data/example/OddSelector/OddSelector.pione +8 -8
- data/example/OddSelector/OddSelector.pnml +401 -0
- data/example/OddSelector/Package.pione +2 -0
- data/example/OddSelector/pione-package.json +4 -0
- data/example/OddSelector/scenario/pione-scenario.json +8 -8
- data/example/ParentPackage/ParentPackage.pione +13 -0
- data/example/ParentPackage/pione-package.json +18 -0
- data/example/PegasusWMS/Merge/Package.pione +2 -0
- data/example/PegasusWMS/Merge/PegasusWMSMerge.action.md +17 -0
- data/example/PegasusWMS/Merge/{Merge.pione → PegasusWMSMerge.pione} +9 -10
- data/example/PegasusWMS/Merge/PegasusWMSMerge.pnml +217 -0
- data/example/PegasusWMS/Merge/pione-package.json +6 -2
- data/example/PegasusWMS/Pipeline/Package.pione +2 -0
- data/example/PegasusWMS/Pipeline/PegasusWMSPipeline.action.md +17 -0
- data/example/PegasusWMS/Pipeline/{Pipeline.pione → PegasusWMSPipeline.pione} +7 -9
- data/example/PegasusWMS/Pipeline/PegasusWMSPipeline.pnml +137 -0
- data/example/PegasusWMS/Pipeline/pione-package.json +6 -2
- data/example/PegasusWMS/Split/Package.pione +2 -0
- data/example/PegasusWMS/Split/PegasusWMSSplit.action.md +19 -0
- data/example/PegasusWMS/Split/{Split.pione → PegasusWMSSplit.pione} +9 -10
- data/example/PegasusWMS/Split/PegasusWMSSplit.pnml +293 -0
- data/example/PegasusWMS/Split/pione-package.json +6 -2
- data/example/ScoreAggregation/Package.pione +2 -0
- data/example/ScoreAggregation/ScoreAggregation.action.md +56 -0
- data/example/ScoreAggregation/ScoreAggregation.pione +37 -76
- data/example/ScoreAggregation/ScoreAggregation.pnml +1221 -0
- data/example/ScoreAggregation/pione-package.json +6 -2
- data/example/ScoreAggregation/scenario/case1/pione-scenario.json +21 -21
- data/example/SelectRuleByParam/Package.pione +2 -0
- data/example/SelectRuleByParam/SelectRuleByParam.action.md +19 -0
- data/example/SelectRuleByParam/SelectRuleByParam.pnml +388 -0
- data/example/SequentialParameter/Package.pione +2 -0
- data/example/SequentialParameter/SequentialParameter.pione +9 -3
- data/example/SequentialParameter/SequentialParameter.pnml +140 -0
- data/example/SequentialParameter/pione-package.json +19 -0
- data/example/SerialProcessing/A.pione +25 -0
- data/example/SerialProcessing/A.pnml +395 -0
- data/example/SerialProcessing/B.pione +25 -0
- data/example/SerialProcessing/B.pnml +395 -0
- data/example/SerialProcessing/Package.pione +2 -0
- data/example/SerialProcessing/SerialProcessing.pione +9 -60
- data/example/SerialProcessing/SerialProcessing.pnml +160 -0
- data/example/SerialProcessing/pione-package.json +7 -1
- data/example/SieveOfEratosthenes/CreateUndeterminedNumbers.pnml +157 -0
- data/example/SieveOfEratosthenes/Package.pione +4 -0
- data/example/SieveOfEratosthenes/Sieve.pnml +1493 -0
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pnml +174 -0
- data/example/SingleParticlesWithRef/Create3dinfo.pnml +342 -0
- data/example/SingleParticlesWithRef/Package.pione +42 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.action.md +34 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pnml +404 -0
- data/example/SingleParticlesWithRef/{Makefile → misc/Makefile} +0 -0
- data/example/SingleParticlesWithRef/{SingleParticlesWithRef.Display2.pione → misc/SingleParticlesWithRef.Display2.pione} +0 -0
- data/example/SingleParticlesWithRef/{SingleParticlesWithRef.Makefile → misc/SingleParticlesWithRef.Makefile} +0 -0
- data/example/SingleParticlesWithRef/{SingleParticlesWithRefFull.pione → misc/SingleParticlesWithRefFull.pione} +0 -0
- data/example/Sum/CalcEachLine.pione +30 -0
- data/example/Sum/CalcEachLine.pnml +327 -0
- data/example/Sum/Package.pione +2 -0
- data/example/Sum/Sum.action.md +35 -0
- data/example/Sum/Sum.pione +9 -35
- data/example/Sum/Sum.pnml +191 -0
- data/example/Sum/pione-package.json +5 -0
- data/example/Touch/Package.pione +2 -0
- data/example/Touch/Touch.pione +8 -2
- data/example/Touch/Touch.pnml +89 -0
- data/example/Touch/pione-package.json +4 -0
- data/example/WorkflowPatterns/01_Sequence/Package.pione +2 -0
- data/example/WorkflowPatterns/01_Sequence/Sequence.pione +9 -9
- data/example/WorkflowPatterns/01_Sequence/Sequence.pnml +191 -0
- data/example/WorkflowPatterns/01_Sequence/pione-package.json +19 -0
- data/example/WorkflowPatterns/02_PrallelSplit/Package.pione +2 -0
- data/example/WorkflowPatterns/02_PrallelSplit/ParallelSplit.pione +12 -12
- data/example/WorkflowPatterns/02_PrallelSplit/ParallelSplit.pnml +265 -0
- data/example/WorkflowPatterns/02_PrallelSplit/pione-package.json +19 -0
- data/example/WorkflowPatterns/03_Synchronization/Package.pione +2 -0
- data/example/WorkflowPatterns/03_Synchronization/Synchronization.pione +12 -13
- data/example/WorkflowPatterns/03_Synchronization/Synchronization.pnml +273 -0
- data/example/WorkflowPatterns/03_Synchronization/pione-package.json +19 -0
- data/example/WorkflowPatterns/04_ExclusiveChoice/ExclusiveChoice.pione +15 -22
- data/example/WorkflowPatterns/04_ExclusiveChoice/ExclusiveChoice.pnml +533 -0
- data/example/WorkflowPatterns/04_ExclusiveChoice/Package.pione +4 -0
- data/example/WorkflowPatterns/04_ExclusiveChoice/pione-package.json +19 -0
- data/example/WorkflowPatterns/05_SimpleMerge/Package.pione +4 -0
- data/example/WorkflowPatterns/05_SimpleMerge/SimpleMerge.pione +10 -18
- data/example/WorkflowPatterns/05_SimpleMerge/SimpleMerge.pnml +431 -0
- data/example/WorkflowPatterns/05_SimpleMerge/pione-package.json +19 -0
- data/example/WorkflowPatterns/06_MultiChoice/MultiChoice.pione +20 -28
- data/example/WorkflowPatterns/06_MultiChoice/MultiChoice.pnml +797 -0
- data/example/WorkflowPatterns/06_MultiChoice/Package.pione +5 -0
- data/example/WorkflowPatterns/06_MultiChoice/pione-package.json +19 -0
- data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/Package.pione +5 -0
- data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/StructuredSynchronizingMerge.pnml +668 -0
- data/example/WorkflowPatterns/08_MultiMerge/MultiMerge.pione +9 -20
- data/example/WorkflowPatterns/08_MultiMerge/MultiMerge.pnml +551 -0
- data/example/WorkflowPatterns/08_MultiMerge/Package.pione +4 -0
- data/example/WorkflowPatterns/08_MultiMerge/pione-package.json +19 -0
- data/example/WorkflowPatterns/11_ImplicitTermination/ImplicitTermination.pione +9 -17
- data/example/WorkflowPatterns/11_ImplicitTermination/ImplicitTermination.pnml +188 -0
- data/example/WorkflowPatterns/11_ImplicitTermination/Package.pione +2 -0
- data/example/WorkflowPatterns/11_ImplicitTermination/pione-package.json +19 -0
- data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/MultipleInstancesWithoutSynchronization.pione +11 -11
- data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/MultipleInstancesWithoutSynchronization.pnml +319 -0
- data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/Package.pione +4 -0
- data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/pione-package.json +19 -0
- data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/MultipleInstancesWithDesignTimeKnowledge.pione +11 -11
- data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/MultipleInstancesWithDesignTimeKnowledge.pnml +319 -0
- data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/Package.pione +2 -0
- data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/pione-package.json +19 -0
- data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/MultipleInstancesWithRunTimeKnowledge.pione +14 -17
- data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/MultipleInstancesWithRunTimeKnowledge.pnml +355 -0
- data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/Package.pione +4 -0
- data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/pione-package.json +19 -0
- data/example/WorkflowPatterns/33_GeneralizedANDJoin/GeneralizedANDJoin.pione +9 -10
- data/example/WorkflowPatterns/33_GeneralizedANDJoin/GeneralizedANDJoin.pnml +409 -0
- data/example/WorkflowPatterns/33_GeneralizedANDJoin/Package.pione +2 -0
- data/example/WorkflowPatterns/33_GeneralizedANDJoin/pione-package.json +19 -0
- data/example/WorkflowPatterns/37_LocalSynchronizingMerge/A.pione +34 -0
- data/example/WorkflowPatterns/37_LocalSynchronizingMerge/A.pnml +570 -0
- data/example/WorkflowPatterns/37_LocalSynchronizingMerge/LocalSynchronizingMerge.pione +36 -70
- data/example/WorkflowPatterns/37_LocalSynchronizingMerge/LocalSynchronizingMerge.pnml +854 -0
- data/example/WorkflowPatterns/37_LocalSynchronizingMerge/Package.pione +5 -0
- data/example/WorkflowPatterns/37_LocalSynchronizingMerge/pione-package.json +20 -0
- data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/GeneralSynchronizingMerge.pnml +1003 -0
- data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/Package.pione +6 -0
- data/example/WorkflowPatterns/41_ThreadMerge/A.pnml +429 -0
- data/example/WorkflowPatterns/41_ThreadMerge/A1.pnml +141 -0
- data/example/WorkflowPatterns/41_ThreadMerge/Package.pione +2 -0
- data/example/WorkflowPatterns/41_ThreadMerge/ThreadMerge.pnml +205 -0
- data/example/WorkflowPatterns/42_ThreadSplit/Package.pione +2 -0
- data/example/WorkflowPatterns/42_ThreadSplit/ThreadSplit.pnml +217 -0
- data/lib/pione/agent/job-manager.rb +4 -3
- data/lib/pione/agent/task-worker.rb +2 -7
- data/lib/pione/command.rb +1 -0
- data/lib/pione/command/basic-command.rb +3 -1
- data/lib/pione/command/command-exception.rb +14 -0
- data/lib/pione/command/pione-action-exec.rb +4 -1
- data/lib/pione/command/pione-clean.rb +13 -6
- data/lib/pione/command/pione-client.rb +5 -5
- data/lib/pione/command/pione-compile.rb +1 -1
- data/lib/pione/command/pione-log-format.rb +1 -1
- data/lib/pione/command/pione-package-add.rb +1 -1
- data/lib/pione/command/pione-package-build.rb +87 -32
- data/lib/pione/command/pione-package-remove.rb +117 -0
- data/lib/pione/command/pione-package.rb +1 -0
- data/lib/pione/command/spawner.rb +12 -3
- data/lib/pione/lang/boolean.rb +1 -1
- data/lib/pione/lang/common-parser.rb +5 -3
- data/lib/pione/lang/context-parser.rb +8 -2
- data/lib/pione/lang/context-transformer.rb +13 -3
- data/lib/pione/lang/context.rb +20 -2
- data/lib/pione/lang/data-expr.rb +1 -1
- data/lib/pione/lang/declaration-parser.rb +18 -4
- data/lib/pione/lang/declaration-transformer.rb +1 -1
- data/lib/pione/lang/declaration.rb +5 -3
- data/lib/pione/lang/definition.rb +1 -0
- data/lib/pione/lang/environment.rb +37 -2
- data/lib/pione/lang/expr.rb +10 -12
- data/lib/pione/lang/feature-expr.rb +1 -1
- data/lib/pione/lang/float.rb +1 -1
- data/lib/pione/lang/integer.rb +1 -1
- data/lib/pione/lang/keyed-sequence.rb +5 -5
- data/lib/pione/lang/lang-exception.rb +9 -5
- data/lib/pione/lang/literal-parser.rb +2 -2
- data/lib/pione/lang/literal-transformer.rb +3 -0
- data/lib/pione/lang/message.rb +3 -3
- data/lib/pione/lang/ordinal-sequence.rb +1 -1
- data/lib/pione/lang/package-expr.rb +1 -1
- data/lib/pione/lang/parameters.rb +1 -1
- data/lib/pione/lang/pione-method.rb +16 -16
- data/lib/pione/lang/rule-expr.rb +6 -1
- data/lib/pione/lang/sequence.rb +8 -3
- data/lib/pione/lang/string.rb +1 -1
- data/lib/pione/lang/ticket-expr.rb +1 -1
- data/lib/pione/lang/type.rb +17 -8
- data/lib/pione/lang/variable.rb +4 -1
- data/lib/pione/literate-action.rb +1 -2
- data/lib/pione/literate-action/document.rb +1 -1
- data/lib/pione/literate-action/handler.rb +22 -7
- data/lib/pione/literate-action/{parser.rb → markdown-parser.rb} +2 -1
- data/lib/pione/log/domain-log.rb +1 -1
- data/lib/pione/model/task-worker-broker-model.rb +1 -1
- data/lib/pione/package/package-database.rb +16 -2
- data/lib/pione/package/package-exception.rb +1 -1
- data/lib/pione/package/package-handler.rb +11 -7
- data/lib/pione/package/package-info.rb +13 -7
- data/lib/pione/package/package-scanner.rb +1 -1
- data/lib/pione/package/scenario-info.rb +2 -2
- data/lib/pione/pnml.rb +6 -0
- data/lib/pione/pnml/compiler.rb +329 -95
- data/lib/pione/pnml/declaration-extractor.rb +90 -0
- data/lib/pione/pnml/input-merge-complement.rb +17 -11
- data/lib/pione/pnml/input-parallelization-complement.rb +10 -6
- data/lib/pione/pnml/input-reduction.rb +5 -5
- data/lib/pione/pnml/invalid-arc-elimination.rb +2 -2
- data/lib/pione/pnml/io-expansion.rb +9 -5
- data/lib/pione/pnml/isolated-element-elimination.rb +2 -2
- data/lib/pione/pnml/label-extractor.rb +258 -0
- data/lib/pione/pnml/net-rewriter.rb +6 -4
- data/lib/pione/pnml/output-decomposition-complement.rb +12 -7
- data/lib/pione/pnml/output-reduction.rb +11 -5
- data/lib/pione/pnml/output-synchronization-complement.rb +11 -7
- data/lib/pione/pnml/parser.rb +106 -0
- data/lib/pione/pnml/pione-model.rb +685 -230
- data/lib/pione/pnml/pnml-model.rb +73 -41
- data/lib/pione/pnml/ticket-instantiation.rb +42 -0
- data/lib/pione/rule-engine/action-handler.rb +212 -135
- data/lib/pione/rule-engine/basic-handler.rb +29 -3
- data/lib/pione/rule-engine/engine-exception.rb +10 -6
- data/lib/pione/system/status.rb +12 -6
- data/lib/pione/version.rb +1 -1
- data/lib/rootage/help.md.erb +45 -0
- data/lib/rootage/help.rb +1 -0
- data/lib/rootage/scenario.rb +20 -2
- data/misc/pione-completion.bash +15 -5
- data/misc/pione-completion.zsh +16 -6
- data/test/command/spec_pione-client.rb +60 -60
- data/test/lang/data/context-parser.yml +12 -1
- data/test/lang/spec_pione-method.rb +7 -6
- data/test/literate-action/spec_handler.rb +19 -13
- data/test/literate-action/{spec_parser.rb → spec_markdown-parser.rb} +3 -3
- data/test/log/spec_message-log-receiver.rb +1 -1
- data/test/package/spec_package-info.rb +1 -1
- data/test/pnml/spec_input-merge-complement.rb +4 -2
- data/test/pnml/spec_input-parallelization-complement.rb +4 -2
- data/test/pnml/spec_input-reduction.rb +8 -4
- data/test/pnml/spec_invalid-arc-elimination.rb +2 -1
- data/test/pnml/spec_io-expansion.rb +4 -2
- data/test/pnml/spec_isolated-element-elimination.rb +2 -1
- data/test/pnml/spec_label-extractor.rb +100 -0
- data/test/pnml/spec_output-decomposition-complement.rb +4 -2
- data/test/pnml/spec_output-reduction.rb +8 -4
- data/test/pnml/spec_output-synchronization-complement.rb +4 -2
- data/test/pnml/spec_pione-element.rb +116 -37
- data/test/pnml/spec_pnml-element.rb +32 -8
- data/test/rule-engine/spec_action-handler.rb +12 -20
- metadata +159 -16
- data/example/CTFCorrection/package.yml +0 -1
- data/example/DeferredChoice/bin/ui.xml +0 -28
@@ -106,14 +106,18 @@ module Pione
|
|
106
106
|
# Load parent packages from package database. Parent packages should be
|
107
107
|
# recorded in the database, or Package::NotFound error is raised.
|
108
108
|
def load_parent_package(env, name, editor, tag)
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
109
|
+
db = Database::load(Global.package_database_location)
|
110
|
+
|
111
|
+
if record = db.find(name, editor, tag)
|
112
|
+
if digest = record.digest
|
113
|
+
parent_location = PackageCache.directory_cache(digest)
|
114
|
+
handler = PackageHandler.new(parent_location, digest: digest)
|
115
|
+
_env = handler.eval(env)
|
116
|
+
return _env.current_package_id
|
117
|
+
end
|
116
118
|
end
|
119
|
+
|
120
|
+
raise NotFound.new(name, editor, tag)
|
117
121
|
end
|
118
122
|
end
|
119
123
|
end
|
@@ -41,11 +41,11 @@ module Pione
|
|
41
41
|
data["PackageName"] = name
|
42
42
|
data["Editor"] = editor if editor
|
43
43
|
data["Tag"] = tag if tag
|
44
|
-
data["Parents"] = parents
|
45
|
-
data["Documents"] = documents
|
46
|
-
data["Scenarios"] = scenarios
|
47
|
-
data["Bins"] = bins
|
48
|
-
data["Etcs"] = etcs
|
44
|
+
data["Parents"] = parents.sort
|
45
|
+
data["Documents"] = documents.sort
|
46
|
+
data["Scenarios"] = scenarios.sort
|
47
|
+
data["Bins"] = bins.sort
|
48
|
+
data["Etcs"] = etcs.sort
|
49
49
|
data.to_json(*args)
|
50
50
|
end
|
51
51
|
end
|
@@ -64,12 +64,18 @@ module Pione
|
|
64
64
|
new(args)
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def <=>(other)
|
68
|
+
(name <=> other.name).tap {|x| return x unless x == 0}
|
69
|
+
(editor <=> other.editor).tap {|x| return x unless x == 0}
|
70
|
+
(tag <=> other.tag).tap {|x| return x unless x == 0}
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_json(*args)
|
68
74
|
data = {}
|
69
75
|
data["PackageName"] = name
|
70
76
|
data["Editor"] = editor if editor
|
71
77
|
data["Tag"] = tag if tag
|
72
|
-
data.to_json
|
78
|
+
data.to_json(*args)
|
73
79
|
end
|
74
80
|
end
|
75
81
|
end
|
@@ -50,7 +50,7 @@ module Pione
|
|
50
50
|
location.entries.each_with_object([]) do |entry, paths|
|
51
51
|
if entry.file?
|
52
52
|
# PIONE document has extension ".pione"
|
53
|
-
if /^[^.]
|
53
|
+
if /^[^.].*.pione$/.match(entry.basename)
|
54
54
|
# document path should be relative
|
55
55
|
paths << entry.path.relative_path_from(@package_location.path).to_s
|
56
56
|
end
|
@@ -26,8 +26,8 @@ module Pione
|
|
26
26
|
data = Hash.new
|
27
27
|
data["ScenarioName"] = name
|
28
28
|
data["ParamSet"] = textual_param_sets
|
29
|
-
data["Inputs"] = inputs
|
30
|
-
data["Outputs"] = outputs
|
29
|
+
data["Inputs"] = inputs.sort
|
30
|
+
data["Outputs"] = outputs.sort
|
31
31
|
data.to_json(*args)
|
32
32
|
end
|
33
33
|
end
|
data/lib/pione/pnml.rb
CHANGED
@@ -3,11 +3,15 @@ module Pione
|
|
3
3
|
module PNML; end
|
4
4
|
end
|
5
5
|
|
6
|
+
require 'pione/pnml/pnml-exception'
|
7
|
+
|
6
8
|
#
|
7
9
|
# language model
|
8
10
|
#
|
9
11
|
|
12
|
+
require 'pione/pnml/parser'
|
10
13
|
require 'pione/pnml/pnml-model' # source models
|
14
|
+
require 'pione/pnml/label-extractor'
|
11
15
|
require 'pione/pnml/pione-model' # target models
|
12
16
|
|
13
17
|
#
|
@@ -24,12 +28,14 @@ require 'pione/pnml/output-decomposition-complement'
|
|
24
28
|
require 'pione/pnml/output-synchronization-complement'
|
25
29
|
require 'pione/pnml/io-expansion'
|
26
30
|
require 'pione/pnml/invalid-arc-elimination'
|
31
|
+
require 'pione/pnml/ticket-instantiation'
|
27
32
|
|
28
33
|
#
|
29
34
|
# utility
|
30
35
|
#
|
31
36
|
|
32
37
|
require 'pione/pnml/annotation-extractor'
|
38
|
+
require 'pione/pnml/declaration-extractor'
|
33
39
|
require 'pione/pnml/reader'
|
34
40
|
require 'pione/pnml/compiler'
|
35
41
|
|
data/lib/pione/pnml/compiler.rb
CHANGED
@@ -13,6 +13,9 @@ module Pione
|
|
13
13
|
|
14
14
|
def initialize(net, option={})
|
15
15
|
@net = net
|
16
|
+
@net_name = option[:flow_rule_name] || "Main"
|
17
|
+
@env = option[:env] || Lang::Environment.new
|
18
|
+
|
16
19
|
@option = option
|
17
20
|
@net_rewriter = NetRewriter.new do |rules|
|
18
21
|
rules << IsolatedElementElimination
|
@@ -24,6 +27,7 @@ module Pione
|
|
24
27
|
rules << InputParallelizationComplement
|
25
28
|
rules << OutputDecompositionComplement
|
26
29
|
rules << OutputSynchronizationComplement
|
30
|
+
rules << TicketInstantiation
|
27
31
|
end
|
28
32
|
@actions = []
|
29
33
|
end
|
@@ -32,13 +36,19 @@ module Pione
|
|
32
36
|
def compile
|
33
37
|
# annotations
|
34
38
|
annotations = AnnotationExtractor.new(@net, @option).extract
|
39
|
+
declarations = DeclarationExtractor.new(@env, @net).extract
|
35
40
|
|
36
41
|
# apply net rewriting rules
|
37
|
-
@net_rewriter.rewrite(@net)
|
42
|
+
@net_rewriter.rewrite(@net, @env)
|
38
43
|
|
39
44
|
# build rules
|
40
|
-
rules, flow_elements =
|
41
|
-
definition_main =
|
45
|
+
rules, flow_elements = ConstituentRuleBuilder.new(@net, @net_name, @env).build()
|
46
|
+
definition_main = FlowRuleBuilder.new(@net, @net_name, @env).build(
|
47
|
+
flow_elements,
|
48
|
+
declarations.params,
|
49
|
+
declarations.features,
|
50
|
+
declarations.variable_bindings
|
51
|
+
)
|
42
52
|
|
43
53
|
# merge literate actions
|
44
54
|
rules.each do |rule|
|
@@ -50,131 +60,296 @@ module Pione
|
|
50
60
|
end
|
51
61
|
|
52
62
|
# textize
|
53
|
-
|
63
|
+
sections = []
|
64
|
+
if annotations and annotations.size > 0
|
65
|
+
sections << annotations << ""
|
66
|
+
end
|
67
|
+
sections << definition_main.textize
|
68
|
+
rules.each {|rule| sections << rule.textize}
|
69
|
+
return sections.join("\n")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# ConstituentRuleBuilder builds constituent rule definitions.
|
74
|
+
class ConstituentRuleBuilder
|
75
|
+
# @param net [PNML::Net]
|
76
|
+
# net
|
77
|
+
# @param net_name [String]
|
78
|
+
# name of the net
|
79
|
+
# @param env [Lang::Environment]
|
80
|
+
# language environment
|
81
|
+
def initialize(net, net_name, env)
|
82
|
+
@net = net
|
83
|
+
@net_name = net_name
|
84
|
+
@env = env
|
85
|
+
end
|
86
|
+
|
87
|
+
# Build a consituent rule definitions by transitions in the net.
|
88
|
+
#
|
89
|
+
# @return [Array(Array<RuleDefinition>,Array)]
|
90
|
+
def build
|
91
|
+
definition = build_rule_definition_table()
|
92
|
+
|
93
|
+
# save all inner rules
|
94
|
+
rules = definition.values.compact
|
95
|
+
flow_elements = definition.values.compact
|
96
|
+
|
97
|
+
# conditional branch
|
98
|
+
@net.transitions.each do |transition|
|
99
|
+
inputs = @net.find_all_places_by_target_id(transition.id).select do |place|
|
100
|
+
Perspective.data_place?(place, @env)
|
101
|
+
end.map {|input| InputData.new(input)}
|
102
|
+
|
103
|
+
if Perspective.if_transition?(@env, transition)
|
104
|
+
flow_elements << create_if_branch(transition, definition, inputs, flow_elements)
|
105
|
+
elsif Perspective.case_transition?(@env, transition)
|
106
|
+
flow_elements << create_case_branch(transition, definition, inputs, flow_elements)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
return [rules, flow_elements]
|
54
111
|
end
|
55
112
|
|
56
113
|
private
|
57
114
|
|
58
|
-
# Build
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
115
|
+
# Build rule definition table.
|
116
|
+
#
|
117
|
+
# @return [Hash{String=>RuleDefinition}]
|
118
|
+
# relatioin table between transition ID and rule definition
|
119
|
+
def build_rule_definition_table
|
120
|
+
return @net.transitions.each_with_object({}) do |transition, table|
|
121
|
+
if Perspective.rule_transition?(@env, transition)
|
122
|
+
type = :action
|
123
|
+
rule_name = LabelExtractor.extract_rule_expr(transition.name)
|
124
|
+
is_external = Perspective.external_rule_transition?(@env, transition)
|
125
|
+
rule = RuleDefinition.new(rule_name, type, is_external, @net_name, table.size)
|
71
126
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
127
|
+
# setup rule conditions
|
128
|
+
rule.inputs = find_inputs(transition)
|
129
|
+
rule.outputs = find_outputs(transition)
|
130
|
+
rule.params = find_params(transition)
|
131
|
+
rule.constraints = find_constraints(transition)
|
132
|
+
rule.source_tickets = find_source_tickets(transition)
|
133
|
+
rule.target_tickets = find_target_tickets(transition)
|
134
|
+
rule.features = find_features(transition)
|
135
|
+
|
136
|
+
table[transition.id] = rule
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
77
140
|
|
78
|
-
|
79
|
-
|
80
|
-
|
141
|
+
# Find inputs from net.
|
142
|
+
#
|
143
|
+
# @param transition [Transition]
|
144
|
+
# base transition
|
145
|
+
# @return [Array<InputData>]
|
146
|
+
# rule inputs
|
147
|
+
def find_inputs(transition)
|
148
|
+
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, inputs|
|
149
|
+
begin
|
150
|
+
# consideration for constraint nodes
|
151
|
+
prev_transition = @net.find_transition_by_target_id(place.id)
|
152
|
+
if Perspective.constraint_transition?(@env, prev_transition)
|
153
|
+
@net.find_all_places_by_target_id(prev_transition.id).each do |_place|
|
154
|
+
if Perspective.data_place?(_place, @env)
|
155
|
+
inputs << InputData.new(_place)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
else
|
159
|
+
if Perspective.data_place?(place, @env)
|
160
|
+
inputs << InputData.new(place)
|
81
161
|
end
|
82
162
|
end
|
83
|
-
|
84
|
-
|
163
|
+
rescue AmbiguousNetQueryResult
|
164
|
+
# ignore
|
85
165
|
end
|
86
166
|
end
|
167
|
+
end
|
87
168
|
|
88
|
-
|
89
|
-
|
90
|
-
|
169
|
+
# Find outputs from net.
|
170
|
+
#
|
171
|
+
# @param transition [Transition]
|
172
|
+
# base transition
|
173
|
+
# @return [Array]
|
174
|
+
# rule outputs
|
175
|
+
def find_outputs(transition)
|
176
|
+
@net.find_all_places_by_source_id(transition.id).each_with_object([]) do |place, outputs|
|
177
|
+
if Perspective.data_place?(@env, place)
|
178
|
+
outputs << OutputData.new(place)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
91
182
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
key_else = keywords.find{|key| Perspective.compact(key.name) == "else"}
|
106
|
-
|
107
|
-
branch = ConditionalBranch.new(:if, condition.name)
|
108
|
-
|
109
|
-
find_next_rules(key_then).each do |transition|
|
110
|
-
rule = definition[transition.id]
|
111
|
-
rule.inputs += inputs
|
112
|
-
flow_elements.delete(rule)
|
113
|
-
branch.table[:then] << rule
|
183
|
+
# Find parameters from net.
|
184
|
+
#
|
185
|
+
# @param transition [Transition]
|
186
|
+
# base transition
|
187
|
+
# @return [Array<Param>]
|
188
|
+
# rule parameters
|
189
|
+
def find_params(transition)
|
190
|
+
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, params|
|
191
|
+
if Perspective.param_place?(@env, place)
|
192
|
+
prev_transitions = @net.find_all_transitions_by_target_id(place.id)
|
193
|
+
keyword_transitions = prev_transitions.select{|t| Perspective.keyword_transition?(t)}
|
194
|
+
if keyword_transitions.empty?
|
195
|
+
params << Param.new(place)
|
114
196
|
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
115
200
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
201
|
+
# Find constraints from net.
|
202
|
+
#
|
203
|
+
# @param transition [Transition]
|
204
|
+
# base transition
|
205
|
+
# @return [Array<Constraint>]
|
206
|
+
# rule constraints
|
207
|
+
def find_constraints(transition)
|
208
|
+
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, constraints|
|
209
|
+
prev_transitions = @net.find_all_transitions_by_target_id(place.id)
|
210
|
+
constraint_transitions = prev_transitions.select{|t| Perspective.constraint_transition?(@env, t)}
|
122
211
|
|
123
|
-
|
124
|
-
when
|
125
|
-
|
212
|
+
case constraint_transitions.size
|
213
|
+
when 0
|
214
|
+
# ignore
|
215
|
+
when 1
|
216
|
+
if Perspective.expr_place?(place)
|
217
|
+
constraints << Constraint.new(place.name)
|
218
|
+
else
|
219
|
+
# the place should be constraint expression
|
220
|
+
raise CompilerError.should_be_constraint_expr(place)
|
221
|
+
end
|
222
|
+
else
|
223
|
+
# multiple constraint keywords found
|
224
|
+
raise CompilerError.multiple_constraint_keywords(transition.name)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
126
228
|
|
127
|
-
|
128
|
-
|
129
|
-
|
229
|
+
# Find source tickets from net.
|
230
|
+
#
|
231
|
+
# @param transition [Transition]
|
232
|
+
# base transition
|
233
|
+
# @return [Array<Ticket>]
|
234
|
+
# tickets
|
235
|
+
def find_source_tickets(transition)
|
236
|
+
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, tickets|
|
237
|
+
if Perspective.ticket_place?(place, @env)
|
238
|
+
tickets << Ticket.new(place)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
130
242
|
|
131
|
-
|
243
|
+
# Find target tickets from net.
|
244
|
+
#
|
245
|
+
# @param transition [Transition]
|
246
|
+
# base transition
|
247
|
+
# @return [Array<Ticket>]
|
248
|
+
# tickets
|
249
|
+
def find_target_tickets(transition)
|
250
|
+
@net.find_all_places_by_source_id(transition.id).each_with_object([]) do |place, tickets|
|
251
|
+
if Perspective.ticket_place?(place, @env)
|
252
|
+
tickets << Ticket.new(place.name)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
132
256
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
257
|
+
# Find features from net.
|
258
|
+
#
|
259
|
+
# @param transition [Transition]
|
260
|
+
# base transition
|
261
|
+
# @return [Array<Feature>]
|
262
|
+
# features
|
263
|
+
def find_features(transition)
|
264
|
+
@net.find_all_places_by_target_id(transition.id).each_with_object([]) do |place, features|
|
265
|
+
if Perspective.feature_place?(place, @env)
|
266
|
+
keyword_transitions = @net.find_all_transitions_by_target_id(place.id).select do |t|
|
267
|
+
Perspective.keyword_transition?(t)
|
140
268
|
end
|
141
|
-
|
142
|
-
|
143
|
-
rule = definition[transition.id]
|
144
|
-
rule.inputs += inputs
|
145
|
-
flow_elements.delete(rule)
|
146
|
-
branch.table[:else] << rule
|
269
|
+
if keyword_transitions.empty?
|
270
|
+
features << Feature.new(place.name)
|
147
271
|
end
|
148
|
-
|
149
|
-
flow_elements << branch
|
150
272
|
end
|
151
273
|
end
|
274
|
+
end
|
152
275
|
|
153
|
-
|
276
|
+
# Create a if-branch from the transiton.
|
277
|
+
#
|
278
|
+
# @param transition [PNML::Transition]
|
279
|
+
# base transition
|
280
|
+
# @return [ConditionalBranch]
|
281
|
+
# conditional branch
|
282
|
+
def create_if_branch(transition, definition, inputs, flow_elements)
|
283
|
+
condition = @net.find_place_by_source_id(transition.id)
|
284
|
+
|
285
|
+
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)}
|
288
|
+
|
289
|
+
branch = ConditionalBranch.new(:if, condition.name)
|
290
|
+
|
291
|
+
find_next_rules(key_then).each do |transition|
|
292
|
+
rule = definition[transition.id]
|
293
|
+
rule.inputs += inputs
|
294
|
+
flow_elements.delete(rule)
|
295
|
+
branch.table[:then] << rule
|
296
|
+
end
|
297
|
+
|
298
|
+
find_next_rules(key_else).each do |transition|
|
299
|
+
rule = definition[transition.id]
|
300
|
+
rule.inputs += inputs
|
301
|
+
flow_elements.delete(rule)
|
302
|
+
branch.table[:else] << rule
|
303
|
+
end
|
304
|
+
|
305
|
+
return branch
|
154
306
|
end
|
155
307
|
|
156
|
-
#
|
157
|
-
|
158
|
-
|
159
|
-
|
308
|
+
# Create a case-branch from the transiton.
|
309
|
+
#
|
310
|
+
# @param transition [PNML::Transition]
|
311
|
+
# base transition
|
312
|
+
# @return [ConditionalBranch]
|
313
|
+
# conditional branch
|
314
|
+
def create_case_branch(transition, definition, inputs, flow_elements)
|
315
|
+
expr = @net.find_place_by_source_id(transition.id)
|
160
316
|
|
161
|
-
|
162
|
-
|
317
|
+
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)}
|
163
320
|
|
164
|
-
|
165
|
-
:inputs => inputs,
|
166
|
-
:outputs => outputs,
|
167
|
-
:params => @net.places.select {|place| Perspective.param?(place) and Perspective.net_input?},
|
168
|
-
:flow_elements => flow_elements,
|
169
|
-
}
|
321
|
+
branch = ConditionalBranch.new(:case, expr.name)
|
170
322
|
|
171
|
-
|
323
|
+
keys_when.each do |key|
|
324
|
+
find_next_rules(key).each do |transition|
|
325
|
+
rule = definition[transition.id]
|
326
|
+
rule.inputs += inputs
|
327
|
+
flow_elements.delete(rule)
|
328
|
+
conditional_value_place = @net.find_place_by_source_id(key.id)
|
329
|
+
branch.table[conditional_value_place.name] << rule
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
if key_else
|
334
|
+
find_next_rules(key_else).each do |transition|
|
335
|
+
rule = definition[transition.id]
|
336
|
+
rule.inputs += inputs
|
337
|
+
flow_elements.delete(rule)
|
338
|
+
branch.table[:else] << rule
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
return branch
|
172
343
|
end
|
173
344
|
|
345
|
+
# Find next rules.
|
346
|
+
#
|
347
|
+
# @param base_rule [PNML::Transition]
|
348
|
+
# base transition
|
174
349
|
def find_next_rules(base_rule)
|
175
350
|
@net.find_all_places_by_source_id(base_rule.id).each_with_object([]) do |place, res|
|
176
351
|
@net.find_all_transitions_by_source_id(place.id).each do |transition|
|
177
|
-
if Perspective.
|
352
|
+
if Perspective.rule_transition?(transition)
|
178
353
|
res << transition
|
179
354
|
else
|
180
355
|
find_next_rules(transition)
|
@@ -183,5 +358,64 @@ module Pione
|
|
183
358
|
end
|
184
359
|
end
|
185
360
|
end
|
361
|
+
|
362
|
+
# FlowRuleBuilder builds a flow rule definition for PNML net.
|
363
|
+
class FlowRuleBuilder
|
364
|
+
# @param net [PNML::Net]
|
365
|
+
# PNML net
|
366
|
+
# @param net_name [String]
|
367
|
+
# name of the net
|
368
|
+
# @param env [Lang::Environment]
|
369
|
+
# language environment
|
370
|
+
def initialize(net, net_name, env)
|
371
|
+
@net = net
|
372
|
+
@net_name = net_name
|
373
|
+
@env = env
|
374
|
+
end
|
375
|
+
|
376
|
+
# Build a flow rule definition for PNML net.
|
377
|
+
#
|
378
|
+
# @param flow_elements [Array]
|
379
|
+
# flow elements
|
380
|
+
# @return [RuleDefinition]
|
381
|
+
# a flow rule definition for PNML net
|
382
|
+
def build(flow_elements, params, features, variable_bindings)
|
383
|
+
inputs = @net.places.select {|place| Perspective.net_input_data_place?(place, @env)}
|
384
|
+
inputs = inputs.map {|input| InputData.new(input)}
|
385
|
+
|
386
|
+
outputs = @net.places.select {|place| Perspective.net_output_data_place?(place, @env)}
|
387
|
+
outputs = outputs.map {|output| OutputData.new(output)}
|
388
|
+
|
389
|
+
option = {
|
390
|
+
:inputs => inputs,
|
391
|
+
:outputs => outputs,
|
392
|
+
:params => params,
|
393
|
+
:features => features,
|
394
|
+
:variable_bindings => variable_bindings,
|
395
|
+
:flow_elements => flow_elements
|
396
|
+
}
|
397
|
+
|
398
|
+
RuleDefinition.new(@net_name, :flow, false, @net_name, 0, option)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
# CompilerError represents compiler errors.
|
403
|
+
class CompilerError < StandardError
|
404
|
+
# Raise an exception for the case of invalid constraint expression.
|
405
|
+
#
|
406
|
+
# @param node [Node]
|
407
|
+
# node that has invalid constraint expression
|
408
|
+
def self.should_be_constraint_expr(node)
|
409
|
+
new('The node "%s" should be a PIONE expression because of constraint keyword.' % node.name)
|
410
|
+
end
|
411
|
+
|
412
|
+
# Raise an exception for the case multiple constraint keywords found.
|
413
|
+
#
|
414
|
+
# @param rule_name [String]
|
415
|
+
# rule name
|
416
|
+
def self.multiple_constraint_keywords(rule_name)
|
417
|
+
new('Cannot connect multiple constraint nodes with rule "%s".' % rule_name)
|
418
|
+
end
|
419
|
+
end
|
186
420
|
end
|
187
421
|
end
|