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.
Files changed (306) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +1 -1
  3. data/History.txt +6 -0
  4. data/example/ActionError/ActionError.action.md +11 -0
  5. data/example/ActionError/ActionError.pione +6 -3
  6. data/example/ActionError/ActionError.pnml +86 -0
  7. data/example/ActionError/Package.pione +2 -0
  8. data/example/ActionError/pione-package.json +5 -1
  9. data/example/CTFCorrection/CTFCorrection.action.md +46 -0
  10. data/example/CTFCorrection/CTFCorrection.pione +19 -41
  11. data/example/CTFCorrection/CTFCorrection.pnml +839 -0
  12. data/example/CTFCorrection/Package.pione +1 -0
  13. data/example/CTFCorrection/Params.pione +21 -0
  14. data/example/CTFCorrection/pione-package.json +20 -0
  15. data/example/ChildPackage/ChildPackage.pione +8 -0
  16. data/example/ChildPackage/pione-package.json +20 -0
  17. data/example/CountChar/CountChar.pione +31 -0
  18. data/example/CountChar/CountChar.pnml +239 -0
  19. data/example/CountChar/Main.pione +6 -26
  20. data/example/CountChar/Main.pnml +32 -100
  21. data/example/CountChar/Package.pione +1 -0
  22. data/example/CountChar/pione-package.json +3 -1
  23. data/example/DeferredChoice/DeferredChoice.action.md +46 -0
  24. data/example/DeferredChoice/DeferredChoice.pione +2 -7
  25. data/example/DeferredChoice/DeferredChoice.pnml +371 -0
  26. data/example/DeferredChoice/Package.pione +4 -0
  27. data/example/DeferredChoice/pione-package.json +7 -3
  28. data/example/DeferredChoiceWithPage/DeferredChoiceWithPage.action.md +34 -0
  29. data/example/DeferredChoiceWithPage/DefferredChoiceWithPage.pnml +371 -0
  30. data/example/DeferredChoiceWithPage/Package.pione +2 -0
  31. data/example/FeatureExample/FeatureExample.action.md +7 -0
  32. data/example/FeatureExample/FeatureExample.pione +7 -4
  33. data/example/FeatureExample/FeatureExample.pnml +86 -0
  34. data/example/FeatureExample/Package.pione +1 -0
  35. data/example/FeatureExample/pione-package.json +4 -0
  36. data/example/Fib/Fib.action.md +33 -0
  37. data/example/Fib/Fib.pnml +208 -0
  38. data/example/Fib/FibN.pnml +807 -0
  39. data/example/Fib/Package.pione +6 -0
  40. data/example/HelloWorld/HelloWorld.action.md +7 -0
  41. data/example/HelloWorld/HelloWorld.pione +6 -2
  42. data/example/HelloWorld/HelloWorld.pnml +86 -0
  43. data/example/HelloWorld/Package.pione +2 -0
  44. data/example/HelloWorld/pione-package.json +5 -1
  45. data/example/Interaction/Interaction.action.md +21 -0
  46. data/example/Interaction/Interaction.pnml +89 -0
  47. data/example/Interaction/Package.pione +2 -0
  48. data/example/LoopByTouch/LoopByTouch.pione +32 -12
  49. data/example/LoopByTouch/LoopByTouch.pnml +575 -0
  50. data/example/LoopByTouch/Package.pione +3 -0
  51. data/example/LoopByTouch/PairLoop.pione +6 -7
  52. data/example/LoopByTouch/PairLoop.pnml +188 -0
  53. data/example/LoopByTouch/SingleLoop.pione +6 -0
  54. data/example/LoopByTouch/SingleLoop.pnml +86 -0
  55. data/example/LoopByTouch/TripletLoop.pione +12 -13
  56. data/example/LoopByTouch/TripletLoop.pnml +239 -0
  57. data/example/LoopByTouch/pione-package.json +7 -3
  58. data/example/LucasNumber/LucasNumber.action.md +25 -0
  59. data/example/LucasNumber/LucasNumber.pnml +244 -0
  60. data/example/LucasNumber/LucasNumberN.pnml +1719 -0
  61. data/example/LucasNumber/Package.pione +2 -0
  62. data/example/MakePair/MakePair.pione +8 -10
  63. data/example/MakePair/MakePair.pnml +1141 -0
  64. data/example/MakePair/Package.pione +2 -0
  65. data/example/MakePair/pione-package.json +7 -3
  66. data/example/MakePair/scenario/case1/pione-scenario.json +30 -30
  67. data/example/MakePair/scenario/case2/pione-scenario.json +10 -10
  68. data/example/MakePair/scenario/case3/pione-scenario.json +28 -28
  69. data/example/OddSelector/OddSelector.pione +8 -8
  70. data/example/OddSelector/OddSelector.pnml +401 -0
  71. data/example/OddSelector/Package.pione +2 -0
  72. data/example/OddSelector/pione-package.json +4 -0
  73. data/example/OddSelector/scenario/pione-scenario.json +8 -8
  74. data/example/ParentPackage/ParentPackage.pione +13 -0
  75. data/example/ParentPackage/pione-package.json +18 -0
  76. data/example/PegasusWMS/Merge/Package.pione +2 -0
  77. data/example/PegasusWMS/Merge/PegasusWMSMerge.action.md +17 -0
  78. data/example/PegasusWMS/Merge/{Merge.pione → PegasusWMSMerge.pione} +9 -10
  79. data/example/PegasusWMS/Merge/PegasusWMSMerge.pnml +217 -0
  80. data/example/PegasusWMS/Merge/pione-package.json +6 -2
  81. data/example/PegasusWMS/Pipeline/Package.pione +2 -0
  82. data/example/PegasusWMS/Pipeline/PegasusWMSPipeline.action.md +17 -0
  83. data/example/PegasusWMS/Pipeline/{Pipeline.pione → PegasusWMSPipeline.pione} +7 -9
  84. data/example/PegasusWMS/Pipeline/PegasusWMSPipeline.pnml +137 -0
  85. data/example/PegasusWMS/Pipeline/pione-package.json +6 -2
  86. data/example/PegasusWMS/Split/Package.pione +2 -0
  87. data/example/PegasusWMS/Split/PegasusWMSSplit.action.md +19 -0
  88. data/example/PegasusWMS/Split/{Split.pione → PegasusWMSSplit.pione} +9 -10
  89. data/example/PegasusWMS/Split/PegasusWMSSplit.pnml +293 -0
  90. data/example/PegasusWMS/Split/pione-package.json +6 -2
  91. data/example/ScoreAggregation/Package.pione +2 -0
  92. data/example/ScoreAggregation/ScoreAggregation.action.md +56 -0
  93. data/example/ScoreAggregation/ScoreAggregation.pione +37 -76
  94. data/example/ScoreAggregation/ScoreAggregation.pnml +1221 -0
  95. data/example/ScoreAggregation/pione-package.json +6 -2
  96. data/example/ScoreAggregation/scenario/case1/pione-scenario.json +21 -21
  97. data/example/SelectRuleByParam/Package.pione +2 -0
  98. data/example/SelectRuleByParam/SelectRuleByParam.action.md +19 -0
  99. data/example/SelectRuleByParam/SelectRuleByParam.pnml +388 -0
  100. data/example/SequentialParameter/Package.pione +2 -0
  101. data/example/SequentialParameter/SequentialParameter.pione +9 -3
  102. data/example/SequentialParameter/SequentialParameter.pnml +140 -0
  103. data/example/SequentialParameter/pione-package.json +19 -0
  104. data/example/SerialProcessing/A.pione +25 -0
  105. data/example/SerialProcessing/A.pnml +395 -0
  106. data/example/SerialProcessing/B.pione +25 -0
  107. data/example/SerialProcessing/B.pnml +395 -0
  108. data/example/SerialProcessing/Package.pione +2 -0
  109. data/example/SerialProcessing/SerialProcessing.pione +9 -60
  110. data/example/SerialProcessing/SerialProcessing.pnml +160 -0
  111. data/example/SerialProcessing/pione-package.json +7 -1
  112. data/example/SieveOfEratosthenes/CreateUndeterminedNumbers.pnml +157 -0
  113. data/example/SieveOfEratosthenes/Package.pione +4 -0
  114. data/example/SieveOfEratosthenes/Sieve.pnml +1493 -0
  115. data/example/SieveOfEratosthenes/SieveOfEratosthenes.pnml +174 -0
  116. data/example/SingleParticlesWithRef/Create3dinfo.pnml +342 -0
  117. data/example/SingleParticlesWithRef/Package.pione +42 -0
  118. data/example/SingleParticlesWithRef/SingleParticlesWithRef.action.md +34 -0
  119. data/example/SingleParticlesWithRef/SingleParticlesWithRef.pnml +404 -0
  120. data/example/SingleParticlesWithRef/{Makefile → misc/Makefile} +0 -0
  121. data/example/SingleParticlesWithRef/{SingleParticlesWithRef.Display2.pione → misc/SingleParticlesWithRef.Display2.pione} +0 -0
  122. data/example/SingleParticlesWithRef/{SingleParticlesWithRef.Makefile → misc/SingleParticlesWithRef.Makefile} +0 -0
  123. data/example/SingleParticlesWithRef/{SingleParticlesWithRefFull.pione → misc/SingleParticlesWithRefFull.pione} +0 -0
  124. data/example/Sum/CalcEachLine.pione +30 -0
  125. data/example/Sum/CalcEachLine.pnml +327 -0
  126. data/example/Sum/Package.pione +2 -0
  127. data/example/Sum/Sum.action.md +35 -0
  128. data/example/Sum/Sum.pione +9 -35
  129. data/example/Sum/Sum.pnml +191 -0
  130. data/example/Sum/pione-package.json +5 -0
  131. data/example/Touch/Package.pione +2 -0
  132. data/example/Touch/Touch.pione +8 -2
  133. data/example/Touch/Touch.pnml +89 -0
  134. data/example/Touch/pione-package.json +4 -0
  135. data/example/WorkflowPatterns/01_Sequence/Package.pione +2 -0
  136. data/example/WorkflowPatterns/01_Sequence/Sequence.pione +9 -9
  137. data/example/WorkflowPatterns/01_Sequence/Sequence.pnml +191 -0
  138. data/example/WorkflowPatterns/01_Sequence/pione-package.json +19 -0
  139. data/example/WorkflowPatterns/02_PrallelSplit/Package.pione +2 -0
  140. data/example/WorkflowPatterns/02_PrallelSplit/ParallelSplit.pione +12 -12
  141. data/example/WorkflowPatterns/02_PrallelSplit/ParallelSplit.pnml +265 -0
  142. data/example/WorkflowPatterns/02_PrallelSplit/pione-package.json +19 -0
  143. data/example/WorkflowPatterns/03_Synchronization/Package.pione +2 -0
  144. data/example/WorkflowPatterns/03_Synchronization/Synchronization.pione +12 -13
  145. data/example/WorkflowPatterns/03_Synchronization/Synchronization.pnml +273 -0
  146. data/example/WorkflowPatterns/03_Synchronization/pione-package.json +19 -0
  147. data/example/WorkflowPatterns/04_ExclusiveChoice/ExclusiveChoice.pione +15 -22
  148. data/example/WorkflowPatterns/04_ExclusiveChoice/ExclusiveChoice.pnml +533 -0
  149. data/example/WorkflowPatterns/04_ExclusiveChoice/Package.pione +4 -0
  150. data/example/WorkflowPatterns/04_ExclusiveChoice/pione-package.json +19 -0
  151. data/example/WorkflowPatterns/05_SimpleMerge/Package.pione +4 -0
  152. data/example/WorkflowPatterns/05_SimpleMerge/SimpleMerge.pione +10 -18
  153. data/example/WorkflowPatterns/05_SimpleMerge/SimpleMerge.pnml +431 -0
  154. data/example/WorkflowPatterns/05_SimpleMerge/pione-package.json +19 -0
  155. data/example/WorkflowPatterns/06_MultiChoice/MultiChoice.pione +20 -28
  156. data/example/WorkflowPatterns/06_MultiChoice/MultiChoice.pnml +797 -0
  157. data/example/WorkflowPatterns/06_MultiChoice/Package.pione +5 -0
  158. data/example/WorkflowPatterns/06_MultiChoice/pione-package.json +19 -0
  159. data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/Package.pione +5 -0
  160. data/example/WorkflowPatterns/07_StructuredSynchronizingMerge/StructuredSynchronizingMerge.pnml +668 -0
  161. data/example/WorkflowPatterns/08_MultiMerge/MultiMerge.pione +9 -20
  162. data/example/WorkflowPatterns/08_MultiMerge/MultiMerge.pnml +551 -0
  163. data/example/WorkflowPatterns/08_MultiMerge/Package.pione +4 -0
  164. data/example/WorkflowPatterns/08_MultiMerge/pione-package.json +19 -0
  165. data/example/WorkflowPatterns/11_ImplicitTermination/ImplicitTermination.pione +9 -17
  166. data/example/WorkflowPatterns/11_ImplicitTermination/ImplicitTermination.pnml +188 -0
  167. data/example/WorkflowPatterns/11_ImplicitTermination/Package.pione +2 -0
  168. data/example/WorkflowPatterns/11_ImplicitTermination/pione-package.json +19 -0
  169. data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/MultipleInstancesWithoutSynchronization.pione +11 -11
  170. data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/MultipleInstancesWithoutSynchronization.pnml +319 -0
  171. data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/Package.pione +4 -0
  172. data/example/WorkflowPatterns/12_MultipleInstancesWithoutSynchronization/pione-package.json +19 -0
  173. data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/MultipleInstancesWithDesignTimeKnowledge.pione +11 -11
  174. data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/MultipleInstancesWithDesignTimeKnowledge.pnml +319 -0
  175. data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/Package.pione +2 -0
  176. data/example/WorkflowPatterns/13_MultipleInstancesWithDesignTimeKnowledge/pione-package.json +19 -0
  177. data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/MultipleInstancesWithRunTimeKnowledge.pione +14 -17
  178. data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/MultipleInstancesWithRunTimeKnowledge.pnml +355 -0
  179. data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/Package.pione +4 -0
  180. data/example/WorkflowPatterns/14_MultipleInstancesWithRunTimeKnowledge/pione-package.json +19 -0
  181. data/example/WorkflowPatterns/33_GeneralizedANDJoin/GeneralizedANDJoin.pione +9 -10
  182. data/example/WorkflowPatterns/33_GeneralizedANDJoin/GeneralizedANDJoin.pnml +409 -0
  183. data/example/WorkflowPatterns/33_GeneralizedANDJoin/Package.pione +2 -0
  184. data/example/WorkflowPatterns/33_GeneralizedANDJoin/pione-package.json +19 -0
  185. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/A.pione +34 -0
  186. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/A.pnml +570 -0
  187. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/LocalSynchronizingMerge.pione +36 -70
  188. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/LocalSynchronizingMerge.pnml +854 -0
  189. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/Package.pione +5 -0
  190. data/example/WorkflowPatterns/37_LocalSynchronizingMerge/pione-package.json +20 -0
  191. data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/GeneralSynchronizingMerge.pnml +1003 -0
  192. data/example/WorkflowPatterns/38_GeneralSynchronizingMerge/Package.pione +6 -0
  193. data/example/WorkflowPatterns/41_ThreadMerge/A.pnml +429 -0
  194. data/example/WorkflowPatterns/41_ThreadMerge/A1.pnml +141 -0
  195. data/example/WorkflowPatterns/41_ThreadMerge/Package.pione +2 -0
  196. data/example/WorkflowPatterns/41_ThreadMerge/ThreadMerge.pnml +205 -0
  197. data/example/WorkflowPatterns/42_ThreadSplit/Package.pione +2 -0
  198. data/example/WorkflowPatterns/42_ThreadSplit/ThreadSplit.pnml +217 -0
  199. data/lib/pione/agent/job-manager.rb +4 -3
  200. data/lib/pione/agent/task-worker.rb +2 -7
  201. data/lib/pione/command.rb +1 -0
  202. data/lib/pione/command/basic-command.rb +3 -1
  203. data/lib/pione/command/command-exception.rb +14 -0
  204. data/lib/pione/command/pione-action-exec.rb +4 -1
  205. data/lib/pione/command/pione-clean.rb +13 -6
  206. data/lib/pione/command/pione-client.rb +5 -5
  207. data/lib/pione/command/pione-compile.rb +1 -1
  208. data/lib/pione/command/pione-log-format.rb +1 -1
  209. data/lib/pione/command/pione-package-add.rb +1 -1
  210. data/lib/pione/command/pione-package-build.rb +87 -32
  211. data/lib/pione/command/pione-package-remove.rb +117 -0
  212. data/lib/pione/command/pione-package.rb +1 -0
  213. data/lib/pione/command/spawner.rb +12 -3
  214. data/lib/pione/lang/boolean.rb +1 -1
  215. data/lib/pione/lang/common-parser.rb +5 -3
  216. data/lib/pione/lang/context-parser.rb +8 -2
  217. data/lib/pione/lang/context-transformer.rb +13 -3
  218. data/lib/pione/lang/context.rb +20 -2
  219. data/lib/pione/lang/data-expr.rb +1 -1
  220. data/lib/pione/lang/declaration-parser.rb +18 -4
  221. data/lib/pione/lang/declaration-transformer.rb +1 -1
  222. data/lib/pione/lang/declaration.rb +5 -3
  223. data/lib/pione/lang/definition.rb +1 -0
  224. data/lib/pione/lang/environment.rb +37 -2
  225. data/lib/pione/lang/expr.rb +10 -12
  226. data/lib/pione/lang/feature-expr.rb +1 -1
  227. data/lib/pione/lang/float.rb +1 -1
  228. data/lib/pione/lang/integer.rb +1 -1
  229. data/lib/pione/lang/keyed-sequence.rb +5 -5
  230. data/lib/pione/lang/lang-exception.rb +9 -5
  231. data/lib/pione/lang/literal-parser.rb +2 -2
  232. data/lib/pione/lang/literal-transformer.rb +3 -0
  233. data/lib/pione/lang/message.rb +3 -3
  234. data/lib/pione/lang/ordinal-sequence.rb +1 -1
  235. data/lib/pione/lang/package-expr.rb +1 -1
  236. data/lib/pione/lang/parameters.rb +1 -1
  237. data/lib/pione/lang/pione-method.rb +16 -16
  238. data/lib/pione/lang/rule-expr.rb +6 -1
  239. data/lib/pione/lang/sequence.rb +8 -3
  240. data/lib/pione/lang/string.rb +1 -1
  241. data/lib/pione/lang/ticket-expr.rb +1 -1
  242. data/lib/pione/lang/type.rb +17 -8
  243. data/lib/pione/lang/variable.rb +4 -1
  244. data/lib/pione/literate-action.rb +1 -2
  245. data/lib/pione/literate-action/document.rb +1 -1
  246. data/lib/pione/literate-action/handler.rb +22 -7
  247. data/lib/pione/literate-action/{parser.rb → markdown-parser.rb} +2 -1
  248. data/lib/pione/log/domain-log.rb +1 -1
  249. data/lib/pione/model/task-worker-broker-model.rb +1 -1
  250. data/lib/pione/package/package-database.rb +16 -2
  251. data/lib/pione/package/package-exception.rb +1 -1
  252. data/lib/pione/package/package-handler.rb +11 -7
  253. data/lib/pione/package/package-info.rb +13 -7
  254. data/lib/pione/package/package-scanner.rb +1 -1
  255. data/lib/pione/package/scenario-info.rb +2 -2
  256. data/lib/pione/pnml.rb +6 -0
  257. data/lib/pione/pnml/compiler.rb +329 -95
  258. data/lib/pione/pnml/declaration-extractor.rb +90 -0
  259. data/lib/pione/pnml/input-merge-complement.rb +17 -11
  260. data/lib/pione/pnml/input-parallelization-complement.rb +10 -6
  261. data/lib/pione/pnml/input-reduction.rb +5 -5
  262. data/lib/pione/pnml/invalid-arc-elimination.rb +2 -2
  263. data/lib/pione/pnml/io-expansion.rb +9 -5
  264. data/lib/pione/pnml/isolated-element-elimination.rb +2 -2
  265. data/lib/pione/pnml/label-extractor.rb +258 -0
  266. data/lib/pione/pnml/net-rewriter.rb +6 -4
  267. data/lib/pione/pnml/output-decomposition-complement.rb +12 -7
  268. data/lib/pione/pnml/output-reduction.rb +11 -5
  269. data/lib/pione/pnml/output-synchronization-complement.rb +11 -7
  270. data/lib/pione/pnml/parser.rb +106 -0
  271. data/lib/pione/pnml/pione-model.rb +685 -230
  272. data/lib/pione/pnml/pnml-model.rb +73 -41
  273. data/lib/pione/pnml/ticket-instantiation.rb +42 -0
  274. data/lib/pione/rule-engine/action-handler.rb +212 -135
  275. data/lib/pione/rule-engine/basic-handler.rb +29 -3
  276. data/lib/pione/rule-engine/engine-exception.rb +10 -6
  277. data/lib/pione/system/status.rb +12 -6
  278. data/lib/pione/version.rb +1 -1
  279. data/lib/rootage/help.md.erb +45 -0
  280. data/lib/rootage/help.rb +1 -0
  281. data/lib/rootage/scenario.rb +20 -2
  282. data/misc/pione-completion.bash +15 -5
  283. data/misc/pione-completion.zsh +16 -6
  284. data/test/command/spec_pione-client.rb +60 -60
  285. data/test/lang/data/context-parser.yml +12 -1
  286. data/test/lang/spec_pione-method.rb +7 -6
  287. data/test/literate-action/spec_handler.rb +19 -13
  288. data/test/literate-action/{spec_parser.rb → spec_markdown-parser.rb} +3 -3
  289. data/test/log/spec_message-log-receiver.rb +1 -1
  290. data/test/package/spec_package-info.rb +1 -1
  291. data/test/pnml/spec_input-merge-complement.rb +4 -2
  292. data/test/pnml/spec_input-parallelization-complement.rb +4 -2
  293. data/test/pnml/spec_input-reduction.rb +8 -4
  294. data/test/pnml/spec_invalid-arc-elimination.rb +2 -1
  295. data/test/pnml/spec_io-expansion.rb +4 -2
  296. data/test/pnml/spec_isolated-element-elimination.rb +2 -1
  297. data/test/pnml/spec_label-extractor.rb +100 -0
  298. data/test/pnml/spec_output-decomposition-complement.rb +4 -2
  299. data/test/pnml/spec_output-reduction.rb +8 -4
  300. data/test/pnml/spec_output-synchronization-complement.rb +4 -2
  301. data/test/pnml/spec_pione-element.rb +116 -37
  302. data/test/pnml/spec_pnml-element.rb +32 -8
  303. data/test/rule-engine/spec_action-handler.rb +12 -20
  304. metadata +159 -16
  305. data/example/CTFCorrection/package.yml +0 -1
  306. 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
- if digest = Global.package_database.find(name, editor, tag)
110
- parent_location = PackageCache.directory_cache(digest)
111
- handler = PackageHandler.new(parent_location, digest: digest)
112
- handler.eval(env)
113
- return env.current_package_id
114
- else
115
- raise NotFound.new(name, editor, tag)
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 to_json
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 /^[^.].+.pione$/.match(entry.basename)
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
 
@@ -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 = build_constituent_rule_definitions
41
- definition_main = build_flow_rule_definition(@option[:flow_rule_name] || "Main", flow_elements)
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
- [*annotations, "", definition_main.textize, *rules.map {|rule| rule.textize}].join("\n")
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 constituent rule definitions by transitions in the net.
59
- def build_constituent_rule_definitions
60
- definition = @net.transitions.each_with_object({}) do |transition, table|
61
- if Perspective.rule?(transition)
62
- type = Perspective.flow_rule?(transition) ? :flow : :action
63
- rule = RuleDefinition.new(transition.name, type)
64
-
65
- # inputs
66
- @net.find_all_places_by_target_id(transition.id).each do |place|
67
- if Perspective.file?(place)
68
- rule.inputs << Perspective.normalize_data_name(place.name)
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
- @net.find_all_places_by_source_id(transition.id).each do |place|
73
- # outputs
74
- if Perspective.file?(place)
75
- rule.outputs << Perspective.normalize_data_name(place.name)
76
- end
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
- # params
79
- if Perspective.param?(place)
80
- rule.params << Param.new(place.name, nil)
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
- table[transition.id] = rule
163
+ rescue AmbiguousNetQueryResult
164
+ # ignore
85
165
  end
86
166
  end
167
+ end
87
168
 
88
- # save all inner rules
89
- rules = definition.values.select{|rule_def| rule_def.action?}.compact
90
- flow_elements = definition.values.compact
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
- # conditional branch
93
- @net.transitions.each do |transition|
94
- places = @net.find_all_places_by_target_id(transition.id)
95
- input_places = places.select {|place| Perspective.file?(place)}
96
- inputs = input_places.map {|input| Perspective.normalize_data_name(input.name)}
97
-
98
- case Perspective.normalize_data_name(transition.name)
99
- when "if"
100
- # if-branch
101
- condition = @net.find_place_by_source_id(transition.id)
102
-
103
- keywords = @net.find_all_transitions_by_source_id(condition.id)
104
- key_then = keywords.find{|key| Perspective.compact(key.name) == "then"}
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
- find_next_rules(key_else).each do |transition|
117
- rule = definition[transition.id]
118
- rule.inputs += inputs
119
- flow_elements.delete(rule)
120
- branch.table[:else] << rule
121
- end
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
- flow_elements << branch
124
- when "case"
125
- expr = @net.find_place_by_source_id(transition.id)
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
- keywords = @net.find_all_transtions_by_source_id(expr.id)
128
- keys_when = keywords.select{|key| Perspective.compact(key.name) == "then"}
129
- key_else = keywords.find{|key| Perspective.compact(key.name) == "else"}
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
- branch = ConditionalBranch.new(:case, expr.name)
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
- keys_when.each do |key|
134
- find_next_rules(key).each do |transition|
135
- rule = definition[transition.id]
136
- rule.inputs += inputs
137
- flow_elements.delete(rule)
138
- branch.table[key.name] << rule
139
- end
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
- find_next_rules(key_else).each do |transition|
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
- return [rules, flow_elements]
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
- # Make a main rule.
157
- def build_flow_rule_definition(name, flow_elements)
158
- inputs = @net.places.select {|place| Perspective.file?(place) and Perspective.net_input?(place)}
159
- inputs = inputs.map {|input| Perspective.normalize_data_name(input.name)}
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
- outputs = @net.places.select {|place| Perspective.file?(place) and Perspective.net_output?(place)}
162
- outputs = outputs.map {|output| Perspective.normalize_data_name(output.name)}
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
- option = {
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
- RuleDefinition.new(name, :flow, option)
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.rule?(transition)
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