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
@@ -22,11 +22,13 @@ module Pione
|
|
22
22
|
#
|
23
23
|
# @param net [PNML::Net]
|
24
24
|
# a net that is a target of this transformation
|
25
|
+
# @param env [Lang::Environment]
|
26
|
+
# language environment
|
25
27
|
# @return [void]
|
26
|
-
def rewrite(net)
|
28
|
+
def rewrite(net, env)
|
27
29
|
# find rewriting subjects
|
28
30
|
rule, subjects = @rules.inject(nil) do |res, _rule|
|
29
|
-
if res.nil? and _subjects = _rule.find_subjects(net)
|
31
|
+
if res.nil? and _subjects = _rule.find_subjects(net, env)
|
30
32
|
[_rule, _subjects]
|
31
33
|
else
|
32
34
|
res
|
@@ -35,8 +37,8 @@ module Pione
|
|
35
37
|
|
36
38
|
# rewrite the net with subjects and go next
|
37
39
|
if subjects
|
38
|
-
rule.rewrite(net, subjects)
|
39
|
-
rewrite(net)
|
40
|
+
rule.rewrite(net, subjects, env)
|
41
|
+
rewrite(net, env)
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -29,24 +29,26 @@ module Pione
|
|
29
29
|
#
|
30
30
|
# @param net [PNML::Net]
|
31
31
|
# rewriting target net
|
32
|
+
# @param env [Lang::Environment]
|
33
|
+
# language environment
|
32
34
|
# @return [Array]
|
33
35
|
# source place and component places
|
34
|
-
def self.find_subjects(net)
|
36
|
+
def self.find_subjects(net, env)
|
35
37
|
net.places.each do |place|
|
36
38
|
# source place should be empty
|
37
|
-
next unless
|
39
|
+
next unless Perspective.empty_place?(env, place)
|
38
40
|
|
39
41
|
# there should be more than 2 target transitions
|
40
42
|
transitions = net.find_all_transitions_by_source_id(place.id)
|
41
43
|
next unless transitions.size > 1
|
42
|
-
next unless transitions.all? {|transition|
|
44
|
+
next unless transitions.all? {|transition| Perspective.empty_transition?(env, transition)}
|
43
45
|
|
44
46
|
# each transition has only one output named place
|
45
47
|
component_places = []
|
46
48
|
next unless transitions.all? do |transition|
|
47
49
|
_places = net.find_all_places_by_source_id(transition.id)
|
48
50
|
component_places.concat(_places)
|
49
|
-
_places.size == 1 and not(_places.first
|
51
|
+
_places.size == 1 and not(Perspective.empty_place?(env, _places.first))
|
50
52
|
end
|
51
53
|
|
52
54
|
return [place, component_places]
|
@@ -61,16 +63,19 @@ module Pione
|
|
61
63
|
# rewriting target net
|
62
64
|
# @param subjects [Array]
|
63
65
|
# source place and component places
|
66
|
+
# @param env [Lang::Environment]
|
67
|
+
# language environment
|
64
68
|
# @return [void]
|
65
|
-
def self.rewrite(net, subjects)
|
69
|
+
def self.rewrite(net, subjects, env)
|
66
70
|
place, component_places = subjects
|
67
71
|
|
68
72
|
# component places' names
|
69
73
|
names = component_places.map do |component_place|
|
70
|
-
|
74
|
+
LabelExtractor.extract_data_expr(component_place.name)
|
71
75
|
end
|
72
76
|
|
73
|
-
|
77
|
+
modifier = Perspective.data_modifier(env, place) || ""
|
78
|
+
place.name = modifier + names.sort.join(" or ")
|
74
79
|
end
|
75
80
|
end
|
76
81
|
end
|
@@ -19,16 +19,18 @@ module Pione
|
|
19
19
|
#
|
20
20
|
# @param net [PNML::Net]
|
21
21
|
# rewriting target net
|
22
|
+
# @param env [Lang::Environment]
|
23
|
+
# language environment
|
22
24
|
# @return [Array]
|
23
25
|
# source place, target transition, and the arc
|
24
|
-
def self.find_subjects(net)
|
26
|
+
def self.find_subjects(net, env)
|
25
27
|
net.places.each do |place|
|
26
28
|
# source place should be empty
|
27
|
-
next unless Perspective.
|
29
|
+
next unless Perspective.empty_place?(env, place)
|
28
30
|
|
29
31
|
# source place should be an output of named transition
|
30
32
|
next if net.find_all_transitions_by_target_id(place.id).map do |transition|
|
31
|
-
Perspective.
|
33
|
+
not(Perspective.empty_transition?(env, transition))
|
32
34
|
end.empty?
|
33
35
|
|
34
36
|
transitions = net.find_all_transitions_by_source_id(place.id)
|
@@ -40,7 +42,7 @@ module Pione
|
|
40
42
|
# the transtion is connected to only one place at source side
|
41
43
|
if net.find_all_places_by_target_id(transition.id).size == 1
|
42
44
|
# target transition should be empty
|
43
|
-
next unless Perspective.empty?(transition)
|
45
|
+
next unless Perspective.empty?(env, transition)
|
44
46
|
|
45
47
|
return [place, transition, net.find_arc(place.id, transition.id)]
|
46
48
|
end
|
@@ -59,8 +61,12 @@ module Pione
|
|
59
61
|
#
|
60
62
|
# @param net [PNML::Net]
|
61
63
|
# rewriting target net
|
64
|
+
# @param subjects [Array]
|
65
|
+
# source transitions and target place
|
66
|
+
# @param env [Lang::Environment]
|
67
|
+
# language environment
|
62
68
|
# @return [void]
|
63
|
-
def self.rewrite(net, subjects)
|
69
|
+
def self.rewrite(net, subjects, env)
|
64
70
|
place, transition, arc = subjects
|
65
71
|
|
66
72
|
# remove subjects from the net
|
@@ -29,23 +29,25 @@ module Pione
|
|
29
29
|
#
|
30
30
|
# @param net [PNML::Net]
|
31
31
|
# rewriting target net
|
32
|
+
# @param env [Lang::Environment]
|
33
|
+
# language environment
|
32
34
|
# @return [Array]
|
33
35
|
# source places and synchronized place
|
34
|
-
def self.find_subjects(net)
|
36
|
+
def self.find_subjects(net, env)
|
35
37
|
net.transitions.each do |transition|
|
36
38
|
# target transition should be empty
|
37
|
-
next unless
|
39
|
+
next unless Perspective.empty_transition?(env, transition)
|
38
40
|
|
39
41
|
# the transition should have only one output place
|
40
42
|
synchronized_places = net.find_all_places_by_source_id(transition.id).select do |place|
|
41
|
-
Perspective.
|
43
|
+
Perspective.data_place?(env, place)
|
42
44
|
end
|
43
45
|
next unless synchronized_places.size == 1
|
44
46
|
|
45
47
|
# collect source places
|
46
48
|
source_places = net.find_all_places_by_target_id(transition.id)
|
47
49
|
next unless source_places.size > 1
|
48
|
-
next unless source_places.any? {|place|
|
50
|
+
next unless source_places.any? {|place| Perspective.empty_place?(env, place)}
|
49
51
|
|
50
52
|
# return subjects
|
51
53
|
return [source_places, synchronized_places.first]
|
@@ -60,15 +62,17 @@ module Pione
|
|
60
62
|
# rewriting target net
|
61
63
|
# @param subjects [Array]
|
62
64
|
# source places and synchronized place
|
65
|
+
# @param env [Lang::Environment]
|
66
|
+
# language environment
|
63
67
|
# @return [void]
|
64
|
-
def self.rewrite(net, subjects)
|
68
|
+
def self.rewrite(net, subjects, env)
|
65
69
|
source_places, synchronized_place = subjects
|
66
70
|
|
67
71
|
# rewrite names of empty source places
|
68
72
|
source_places.each do |place|
|
69
73
|
# rewrite name only if it is empty
|
70
|
-
if
|
71
|
-
place.name = synchronized_place.name
|
74
|
+
if Perspective.empty_place?(env, place)
|
75
|
+
place.name = LabelExtractor.extract_data_expr(synchronized_place.name)
|
72
76
|
end
|
73
77
|
end
|
74
78
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Pione
|
2
|
+
module PNML
|
3
|
+
class Parser < Parslet::Parser
|
4
|
+
include Util::ParsletParserExtension
|
5
|
+
include Lang::CommonParser
|
6
|
+
include Lang::LiteralParser
|
7
|
+
include Lang::ExprParser
|
8
|
+
include Lang::ContextParser
|
9
|
+
include Lang::ConditionalBranchParser
|
10
|
+
include Lang::DeclarationParser
|
11
|
+
|
12
|
+
#
|
13
|
+
# symbols and keywords
|
14
|
+
#
|
15
|
+
|
16
|
+
rule(:symbol_net_input_data) { str("<") }
|
17
|
+
rule(:symbol_net_output_data) { str(">") }
|
18
|
+
|
19
|
+
rule(:keyword_then) { str("then") }
|
20
|
+
rule(:keyword_extern) { str("extern") }
|
21
|
+
|
22
|
+
rule(:transition_keyword) {
|
23
|
+
keyword_if |
|
24
|
+
keyword_else |
|
25
|
+
keyword_then |
|
26
|
+
keyword_case |
|
27
|
+
keyword_when |
|
28
|
+
keyword_constraint |
|
29
|
+
keyword_extern
|
30
|
+
}
|
31
|
+
|
32
|
+
#
|
33
|
+
# transtion syntax
|
34
|
+
#
|
35
|
+
|
36
|
+
rule(:empty_transition) { space?.as(:tail) }
|
37
|
+
|
38
|
+
rule(:keyword_transition) {
|
39
|
+
space? >> transition_keyword >> space?.as(:tail)
|
40
|
+
}
|
41
|
+
|
42
|
+
rule(:if_transition) {space? >> keyword_if >> space?.as(:tail)}
|
43
|
+
rule(:else_transition) {space? >> keyword_else >> space?.as(:tail)}
|
44
|
+
rule(:then_transition) {space? >> keyword_then >> space?.as(:tail)}
|
45
|
+
rule(:case_transition) {space? >> keyword_case >> space?.as(:tail)}
|
46
|
+
rule(:when_transition) {space? >> keyword_when >> space?.as(:tail)}
|
47
|
+
rule(:constraint_transition) {space? >> keyword_constraint >> space?.as(:tail)}
|
48
|
+
|
49
|
+
rule(:rule_transition) {
|
50
|
+
external_rule_transition | internal_rule_transition
|
51
|
+
}
|
52
|
+
|
53
|
+
rule(:external_rule_transition) {
|
54
|
+
space? >> keyword_extern.as(:modifier) >> space? >>
|
55
|
+
expr.or_error("it should be rule exprssion") >>
|
56
|
+
space?.as(:tail)
|
57
|
+
}
|
58
|
+
|
59
|
+
rule(:internal_rule_transition) {
|
60
|
+
space? >>
|
61
|
+
(keyword_transition >> identifier_tail_character.absent?).absent? >>
|
62
|
+
expr >>
|
63
|
+
space?.as(:tail)
|
64
|
+
}
|
65
|
+
|
66
|
+
#
|
67
|
+
# place syntax
|
68
|
+
#
|
69
|
+
|
70
|
+
rule(:data_modifier) {
|
71
|
+
(symbol_net_input_data | symbol_net_output_data).as(:modifier)
|
72
|
+
}
|
73
|
+
|
74
|
+
rule(:empty_place) {
|
75
|
+
(space? >> data_modifier >> space?.as(:tail)) | space?.as(:tail)
|
76
|
+
}
|
77
|
+
|
78
|
+
rule(:data_place) {
|
79
|
+
(space? >> data_modifier >> expr_place) | expr_place
|
80
|
+
}
|
81
|
+
|
82
|
+
rule(:expr_place) {
|
83
|
+
space? >> expr >> space?.as(:tail)
|
84
|
+
}
|
85
|
+
|
86
|
+
#
|
87
|
+
# others
|
88
|
+
#
|
89
|
+
|
90
|
+
rule(:net_input_symbol) {
|
91
|
+
space? >> symbol_net_input_data >> space?
|
92
|
+
}
|
93
|
+
|
94
|
+
rule(:net_output_symbol) {
|
95
|
+
space? >> symbol_net_output_data >> space?
|
96
|
+
}
|
97
|
+
|
98
|
+
rule(:data_priority) {
|
99
|
+
space? >>
|
100
|
+
expr >>
|
101
|
+
space_char.repeat(0) >>
|
102
|
+
str("#") >> space? >> digit.repeat(1).as(:priority) >> space?
|
103
|
+
}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -2,168 +2,490 @@ module Pione
|
|
2
2
|
module PNML
|
3
3
|
# `Perspective` is a meta class for PIONE's concepts overlayed in PNML.
|
4
4
|
class Perspective
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
5
|
+
TRANSFORMER_OPT = {package_name: "", editor: "", tag: "", filename: ""}
|
6
|
+
|
7
|
+
class << self
|
8
|
+
# Return true if the node is empty.
|
9
|
+
#
|
10
|
+
# @param env [Lang::Environment]
|
11
|
+
# language environment
|
12
|
+
# @param node [PNML::Node]
|
13
|
+
# the node
|
14
|
+
# @return [Boolean]
|
15
|
+
# true if the node is empty
|
16
|
+
def empty?(env, node)
|
17
|
+
empty_place?(env, node) or empty_transition?(env, node)
|
18
|
+
end
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# node
|
18
|
-
return
|
20
|
+
# Return true if the node is an empty place.
|
21
|
+
#
|
22
|
+
# @param env [Lang::Environment]
|
23
|
+
# language environment
|
24
|
+
# @param node [PNML::Node]
|
25
|
+
# the node
|
26
|
+
# @return [Boolean]
|
27
|
+
# true if the node is an empty place
|
28
|
+
def empty_place?(env, node)
|
29
|
+
match_place_parser?(env, node, :empty_place)
|
30
|
+
end
|
19
31
|
|
20
|
-
|
21
|
-
|
22
|
-
|
32
|
+
# Return true if the node is an empty transition.
|
33
|
+
#
|
34
|
+
# @param env [Lang::Environment]
|
35
|
+
# language environment
|
36
|
+
# @param node [PNML::Node]
|
37
|
+
# the node
|
38
|
+
# @return [Boolean]
|
39
|
+
# true if the node is an empty transition
|
40
|
+
def empty_transition?(env, node)
|
41
|
+
match_transition_parser?(env, node, :empty_transition)
|
42
|
+
end
|
23
43
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
44
|
+
# Return true if the node is an expression place.
|
45
|
+
#
|
46
|
+
# @param env [Lang::Environment]
|
47
|
+
# language environment
|
48
|
+
# @param node [PNML::Node]
|
49
|
+
# the node
|
50
|
+
# @return [Boolean]
|
51
|
+
# true if the node is an exression place
|
52
|
+
def expr_place?(env, node)
|
53
|
+
match_place_parser?(node, :expr_place)
|
54
|
+
end
|
31
55
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
#
|
38
|
-
return
|
39
|
-
|
56
|
+
# Return true if the node is a data place.
|
57
|
+
#
|
58
|
+
# @param env [Lang::Environment]
|
59
|
+
# language environment
|
60
|
+
# @param node [PNML::Node]
|
61
|
+
# the node
|
62
|
+
# @return [Boolean]
|
63
|
+
# true if the node is a data place
|
64
|
+
def data_place?(env, node)
|
65
|
+
match_place_parser_with_type?(env, node, :data_place, :expr, Lang::TypeDataExpr)
|
66
|
+
end
|
40
67
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
68
|
+
# Return true if the node is a net input data place.
|
69
|
+
#
|
70
|
+
# @param env [Lang::Environment]
|
71
|
+
# language environment
|
72
|
+
# @param node [PNML::Node]
|
73
|
+
# the node
|
74
|
+
# @return [Boolean]
|
75
|
+
# true if the node is a net input data place
|
76
|
+
def net_input_data_place?(env, node)
|
77
|
+
if data_place?(env, node)
|
78
|
+
return net_input_data_symbol?(data_modifier(env, node))
|
79
|
+
else
|
80
|
+
return false
|
81
|
+
end
|
45
82
|
end
|
46
83
|
|
47
|
-
#
|
48
|
-
|
49
|
-
|
84
|
+
# Return true if the node is a net output data place.
|
85
|
+
#
|
86
|
+
# @param env [Lang::Environment]
|
87
|
+
# language environment
|
88
|
+
# @param node [PNML::Node]
|
89
|
+
# the node
|
90
|
+
# @return [Boolean]
|
91
|
+
# true if the node is a net output data place
|
92
|
+
def net_output_data_place?(env, node)
|
93
|
+
if data_place?(env, node)
|
94
|
+
return net_output_data_symbol?(data_modifier(node))
|
95
|
+
else
|
96
|
+
return false
|
97
|
+
end
|
98
|
+
end
|
50
99
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
#
|
57
|
-
return
|
100
|
+
# Return true if the node is a parameter.
|
101
|
+
#
|
102
|
+
# @param env [Lang::Environment]
|
103
|
+
# language environment
|
104
|
+
# @param node [PNML::Node]
|
105
|
+
# the node
|
106
|
+
# @return [Boolean]
|
107
|
+
# true if the node is a parameter
|
108
|
+
def param_place?(env, node)
|
109
|
+
match_place_parser_with_type?(env, node, :expr_place, :expr, Lang::TypeParameterSet)
|
110
|
+
end
|
58
111
|
|
59
|
-
#
|
60
|
-
|
112
|
+
# Return true if the node is a parameter sentence transition.
|
113
|
+
#
|
114
|
+
# @param env [Lang::Environment]
|
115
|
+
# language environment
|
116
|
+
# @param node [PNML::Node]
|
117
|
+
# PNML's node
|
118
|
+
# @return [Boolean]
|
119
|
+
# true if the node is a parameter sentence transition
|
120
|
+
def param_transition?(env, node)
|
121
|
+
match_transition_parser?(env, node, :param_sentence)
|
122
|
+
end
|
61
123
|
|
62
|
-
# the node
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
|
124
|
+
# Evaluate the node as a parameter sentence.
|
125
|
+
#
|
126
|
+
# @param env [Lang::Environment]
|
127
|
+
# language environment
|
128
|
+
# @param node [PNML::Node]
|
129
|
+
# PNML's node
|
130
|
+
# @return [Object]
|
131
|
+
# evaluated result
|
132
|
+
def eval_param_sentence(env, node)
|
133
|
+
eval_transition(env, node, :param_sentence, :param_sentence)
|
134
|
+
end
|
68
135
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
#
|
75
|
-
return
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
Lang::DocumentParser.new.param_sentence.parse(name)
|
80
|
-
return true
|
81
|
-
rescue
|
82
|
-
return false
|
136
|
+
# Return true if the node is a ticket place.
|
137
|
+
#
|
138
|
+
# @param env [Lang::Environment]
|
139
|
+
# language environment
|
140
|
+
# @param node [PNML::Node]
|
141
|
+
# the node
|
142
|
+
# @return [Boolean]
|
143
|
+
# true if the node is a ticket place
|
144
|
+
def ticket_place?(env, node)
|
145
|
+
match_place_parser_with_type?(env, node, :expr_place, :expr, Lang::TypeTicketExpr)
|
83
146
|
end
|
84
|
-
end
|
85
147
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
148
|
+
# Return true if the node is a feature place.
|
149
|
+
#
|
150
|
+
# @param env [Lang::Environment]
|
151
|
+
# language environment
|
152
|
+
# @param node [PNML::Node]
|
153
|
+
# the node
|
154
|
+
# @return [Boolean]
|
155
|
+
# true if the node is a feature place
|
156
|
+
def feature_place?(env, node)
|
157
|
+
match_place_parser_with_type?(env, node, :expr_place, :expr, Lang::TypeFeature)
|
158
|
+
end
|
95
159
|
|
96
|
-
|
160
|
+
# Return true if the node is a feature transition.
|
161
|
+
#
|
162
|
+
# @param env [Lang::Environment]
|
163
|
+
# language environment
|
164
|
+
# @param node [PNML::Node]
|
165
|
+
# the node
|
166
|
+
# @return [Boolean]
|
167
|
+
# true if the node is a feature transition
|
168
|
+
def feature_transition?(env, node)
|
169
|
+
match_place_parser?(env, node, :feature_sentence)
|
170
|
+
end
|
97
171
|
|
98
|
-
#
|
99
|
-
|
100
|
-
|
172
|
+
# Return true if the node is a variable binding transition.
|
173
|
+
#
|
174
|
+
# @param env [Lang::Environment]
|
175
|
+
# language environment
|
176
|
+
# @param node [PNML::Node]
|
177
|
+
# the node
|
178
|
+
# @return [Boolean]
|
179
|
+
# true if the node is a variable binding transition
|
180
|
+
def variable_binding_transition?(env, node)
|
181
|
+
match_transition_parser?(env, node, :variable_binding_sentence)
|
101
182
|
end
|
102
183
|
|
103
|
-
|
104
|
-
|
184
|
+
# Return true if the node is a rule.
|
185
|
+
#
|
186
|
+
# @param env [Lang::Environment]
|
187
|
+
# language environment
|
188
|
+
# @param node [PNML::Node]
|
189
|
+
# the node
|
190
|
+
# @return [Boolean]
|
191
|
+
# true if the node is a rule.
|
192
|
+
def rule_transition?(env, node)
|
193
|
+
match_transition_parser?(env, node, :rule_transition)
|
194
|
+
end
|
105
195
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
196
|
+
# Return ture if the node is an internal rule.
|
197
|
+
#
|
198
|
+
# @param env [Lang::Environment]
|
199
|
+
# language environment
|
200
|
+
# @param [PNML::Node] node
|
201
|
+
# PNML node
|
202
|
+
# @return [Boolean]
|
203
|
+
# true if the node is an internal rule
|
204
|
+
def internal_rule_transition?(env, node)
|
205
|
+
match_transition_parser?(env, node, :internal_rule_transition)
|
206
|
+
end
|
110
207
|
|
111
|
-
|
112
|
-
|
113
|
-
|
208
|
+
# Return ture if the node is an external rule.
|
209
|
+
#
|
210
|
+
# @param env [Lang::Environment]
|
211
|
+
# language environment
|
212
|
+
# @param [PNML::Node] node
|
213
|
+
# PNML node
|
214
|
+
# @return [Boolean]
|
215
|
+
# true if the node is an external rule
|
216
|
+
def external_rule_transition?(env, node)
|
217
|
+
match_transition_parser?(env, node, :external_rule_transition)
|
218
|
+
end
|
114
219
|
|
115
|
-
|
116
|
-
|
220
|
+
# Return the modifier of node name.
|
221
|
+
#
|
222
|
+
# @param env [Lang::Environment]
|
223
|
+
# language environment
|
224
|
+
# @param node [PNML::Node]
|
225
|
+
# the node
|
226
|
+
# @return [String]
|
227
|
+
# modifier or nil
|
228
|
+
def data_modifier(env, node)
|
229
|
+
if node.kind_of?(Place) and not(node.name.nil?)
|
230
|
+
begin
|
231
|
+
parsed = Parser.new.data_place.parse(node.name)
|
232
|
+
if parsed.kind_of?(Hash)
|
233
|
+
return parsed[:modifier].to_s
|
234
|
+
end
|
235
|
+
rescue Parslet::ParseFailed
|
236
|
+
begin
|
237
|
+
parsed = Parser.new.empty_place.parse(node.name)
|
238
|
+
if parsed.kind_of?(Hash)
|
239
|
+
return parsed[:modifier].to_s
|
240
|
+
end
|
241
|
+
rescue Parslet::ParseFailed
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
return nil
|
246
|
+
end
|
117
247
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
248
|
+
# Return true if the node is a transition with keyword.
|
249
|
+
#
|
250
|
+
# @param env [Lang::Environment]
|
251
|
+
# language environment
|
252
|
+
# @param node [PNML::Node]
|
253
|
+
# PNML's node
|
254
|
+
# @return [Boolean]
|
255
|
+
# true if the node is a transition with keyword
|
256
|
+
def keyword_transition?(env, node)
|
257
|
+
match_transition_parser?(env, node, :keyword_transition)
|
124
258
|
end
|
125
|
-
end
|
126
259
|
|
127
|
-
|
128
|
-
|
129
|
-
|
260
|
+
# Return true if the node is a transition with keyword "if".
|
261
|
+
#
|
262
|
+
# @param env [Lang::Environment]
|
263
|
+
# language environment
|
264
|
+
# @param node [PNML::Node]
|
265
|
+
# PNML's node
|
266
|
+
# @return [Boolean]
|
267
|
+
# true if the node is a transition with keyword "if"
|
268
|
+
def if_transition?(env, node)
|
269
|
+
match_transition_parser?(env, node, :if_transition)
|
270
|
+
end
|
130
271
|
|
131
|
-
|
132
|
-
|
133
|
-
|
272
|
+
# Return true if the node is a transition with keyword "then".
|
273
|
+
#
|
274
|
+
# @param env [Lang::Environment]
|
275
|
+
# language environment
|
276
|
+
# @param node [PNML::Node]
|
277
|
+
# PNML's node
|
278
|
+
# @return [Boolean]
|
279
|
+
# true if the node is a transition with keyword "then"
|
280
|
+
def then_transition?(env, node)
|
281
|
+
match_transition_parser?(env, node, :then_transition)
|
282
|
+
end
|
134
283
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
284
|
+
# Return true if the node is a transition with keyword "else".
|
285
|
+
#
|
286
|
+
# @param env [Lang::Environment]
|
287
|
+
# language environment
|
288
|
+
# @param node [PNML::Node]
|
289
|
+
# PNML's node
|
290
|
+
# @return [Boolean]
|
291
|
+
# true if the node is a transition with keyword "else"
|
292
|
+
def else_transition?(env, node)
|
293
|
+
match_transition_parser?(env, node, :else_transition)
|
294
|
+
end
|
144
295
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
296
|
+
# Return true if the node is a transition with keyword "case".
|
297
|
+
#
|
298
|
+
# @param env [Lang::Environment]
|
299
|
+
# language environment
|
300
|
+
# @param node [PNML::Node]
|
301
|
+
# PNML's node
|
302
|
+
# @return [Boolean]
|
303
|
+
# true if the node is a transition with keyword "case"
|
304
|
+
def case_transition?(env, node)
|
305
|
+
match_transition_parser?(env, node, :case_transition)
|
306
|
+
end
|
154
307
|
|
155
|
-
|
156
|
-
|
157
|
-
|
308
|
+
# Return true if the node is a transition with keyword "when".
|
309
|
+
#
|
310
|
+
# @param env [Lang::Environment]
|
311
|
+
# language environment
|
312
|
+
# @param node [PNML::Node]
|
313
|
+
# PNML's node
|
314
|
+
# @return [Boolean]
|
315
|
+
# true if the node is a transition with keyword "when"
|
316
|
+
def when_transition?(env, node)
|
317
|
+
match_transition_parser?(env, node, :when_transition)
|
158
318
|
end
|
159
|
-
|
160
|
-
|
319
|
+
|
320
|
+
# Return true if the node is a transition with keyword "constraint".
|
321
|
+
#
|
322
|
+
# @param env [Lang::Environment]
|
323
|
+
# language environment
|
324
|
+
# @param node [PNML::Node]
|
325
|
+
# PNML's node
|
326
|
+
# @return [Boolean]
|
327
|
+
# true if the node is a transition with keyword "constraint"
|
328
|
+
def constraint_transition?(env, node)
|
329
|
+
match_transition_parser?(env, node, :constraint_transition)
|
161
330
|
end
|
162
|
-
return ""
|
163
|
-
end
|
164
331
|
|
165
|
-
|
332
|
+
private
|
333
|
+
|
334
|
+
# Return true if the string is net input data symbol.
|
335
|
+
#
|
336
|
+
# @param [String]
|
337
|
+
# string
|
338
|
+
# @return [Boolean]
|
339
|
+
# true if the string is net input data symbol
|
340
|
+
def net_input_data_symbol?(str)
|
341
|
+
return false if str.nil?
|
342
|
+
|
343
|
+
Parser.new.net_input_symbol.parse(str)
|
344
|
+
return true
|
345
|
+
rescue Parslet::ParseFailed
|
346
|
+
return false
|
347
|
+
end
|
348
|
+
|
349
|
+
# Return true if the string is net output data symbol.
|
350
|
+
#
|
351
|
+
# @param [String]
|
352
|
+
# string
|
353
|
+
# @return [Boolean]
|
354
|
+
# true if the string is net output data symbol
|
355
|
+
def net_output_data_symbol?(str)
|
356
|
+
return false if str.nil?
|
357
|
+
|
358
|
+
Parser.new.net_output_symbol.parse(str)
|
359
|
+
return true
|
360
|
+
rescue Parslet::ParseFailed
|
361
|
+
return false
|
362
|
+
end
|
363
|
+
|
364
|
+
# Return true if the node matches the place parser.
|
365
|
+
#
|
366
|
+
# @param env [Lang::Environment]
|
367
|
+
# language environment
|
368
|
+
# @param node [PNML::Node]
|
369
|
+
# PNML's node
|
370
|
+
# @param parser_name [String]
|
371
|
+
# place parser name
|
372
|
+
# @return [Boolean]
|
373
|
+
# true if the node is the place parser
|
374
|
+
def parse_place(env, node, parser_name)
|
375
|
+
if node.kind_of?(Place) and not(node.name.nil?)
|
376
|
+
begin
|
377
|
+
return Parser.new.send(parser_name).parse(node.name)
|
378
|
+
rescue Parslet::ParseFailed
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
# Return true if the node matches the place parser.
|
384
|
+
#
|
385
|
+
# @param env [Lang::Environment]
|
386
|
+
# language environment
|
387
|
+
# @param node [PNML::Node]
|
388
|
+
# PNML's node
|
389
|
+
# @param parser_name [String]
|
390
|
+
# place parser name
|
391
|
+
# @return [Boolean]
|
392
|
+
# true if the node is the place parser
|
393
|
+
def match_place_parser?(env, node, parser_name)
|
394
|
+
parsed = parse_place(env, node, parser_name)
|
395
|
+
if not(parsed.nil?)
|
396
|
+
if block_given?
|
397
|
+
return yield parsed
|
398
|
+
else
|
399
|
+
return true
|
400
|
+
end
|
401
|
+
else
|
402
|
+
return false
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
# Return true if the node matches the place parser and expected type.
|
407
|
+
#
|
408
|
+
# @param env [Lang::Environment]
|
409
|
+
# language environment
|
410
|
+
# @param node [PNML::Node]
|
411
|
+
# PNML's node
|
412
|
+
# @param parser_name [String]
|
413
|
+
# place parser name
|
414
|
+
# @param target_name [Symbol]
|
415
|
+
# target name that has expected type
|
416
|
+
# @param expected_type [Pione::Lang::Type]
|
417
|
+
# expected PIONE type
|
418
|
+
# @return [Boolean]
|
419
|
+
# true if the node is the place parser
|
420
|
+
def match_place_parser_with_type?(env, node, parser_name, target_name, expected_type)
|
421
|
+
parsed = parse_place(env, node, parser_name)
|
422
|
+
if parsed and parsed[target_name]
|
423
|
+
expr = Lang::DocumentTransformer.new.apply(parsed[target_name], TRANSFORMER_OPT)
|
424
|
+
return expr.pione_type(env) == expected_type
|
425
|
+
else
|
426
|
+
return false
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
# Return true if the node matches the transition parser.
|
431
|
+
#
|
432
|
+
# @param env [Lang::Environment]
|
433
|
+
# language environment
|
434
|
+
# @param node [PNML::Node]
|
435
|
+
# PNML's node
|
436
|
+
# @param parser_name [Symbol]
|
437
|
+
# place parser name
|
438
|
+
# @return [Boolean]
|
439
|
+
# true if the node is the transition parser
|
440
|
+
def parse_transition(env, node, parser_name)
|
441
|
+
if node.kind_of?(Transition) and not(node.name.nil?)
|
442
|
+
begin
|
443
|
+
return Parser.new.send(parser_name).parse(node.name)
|
444
|
+
rescue Parslet::ParseFailed
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
# Return true if the node matches the transition parser.
|
450
|
+
#
|
451
|
+
# @param env [Lang::Environment]
|
452
|
+
# language environment
|
453
|
+
# @param node [PNML::Node]
|
454
|
+
# PNML's node
|
455
|
+
# @param parser_name [Symbol]
|
456
|
+
# transition parser name
|
457
|
+
# @return [Boolean]
|
458
|
+
# true if the node is the keyword
|
459
|
+
def match_transition_parser?(env, node, parser_name)
|
460
|
+
not(parse_transition(env, node, parser_name).nil?)
|
461
|
+
end
|
462
|
+
|
463
|
+
# Evaluate the transition and return the result.
|
464
|
+
#
|
465
|
+
# @param env [Lang::Environment]
|
466
|
+
# language environment
|
467
|
+
# @param node [PNML::Node]
|
468
|
+
# PNML's node
|
469
|
+
# @param parser_name [Symbol]
|
470
|
+
# place parser name
|
471
|
+
# @param target_name [Symbol]
|
472
|
+
# target name that has expected type
|
473
|
+
# @param expected_type [Pione::Lang::Type]
|
474
|
+
# expected PIONE type
|
475
|
+
# @return [Boolean]
|
476
|
+
# true if the node is the place parser
|
477
|
+
def eval_transition(env, node, parser_name, target_name)
|
478
|
+
parsed = parse_transition(node)
|
479
|
+
if parsed and parsed[target_name]
|
480
|
+
return Lang::DocumentTransformer.new.apply(parsed[target_name], TRANSFORMER_OPT)
|
481
|
+
else
|
482
|
+
return nil
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
166
487
|
|
488
|
+
class PioneModel
|
167
489
|
# Return an indented version of the string. Indentation size is calculated
|
168
490
|
# by the optional argument `:level`. If the level is zero, return the
|
169
491
|
# string as is.
|
@@ -178,8 +500,8 @@ module Pione
|
|
178
500
|
end
|
179
501
|
end
|
180
502
|
|
181
|
-
#
|
182
|
-
class ConstituentRule <
|
503
|
+
# ConstituentRule is a class represents PIONE's constituent rule.
|
504
|
+
class ConstituentRule < PioneModel
|
183
505
|
attr_reader :type
|
184
506
|
attr_reader :name
|
185
507
|
attr_reader :params
|
@@ -204,69 +526,46 @@ module Pione
|
|
204
526
|
|
205
527
|
private
|
206
528
|
|
207
|
-
# Return a string
|
529
|
+
# Return a string of rule expression.
|
530
|
+
#
|
531
|
+
# @return [String]
|
532
|
+
# a string of rule expression
|
208
533
|
def textize_rule_expr
|
209
534
|
[@name, textize_params].compact.join(" ")
|
210
535
|
end
|
211
536
|
|
212
|
-
# Return a string
|
537
|
+
# Return a string of parameter set.
|
538
|
+
#
|
539
|
+
# @return [String]
|
540
|
+
# a string of parameter set
|
213
541
|
def textize_params
|
214
542
|
unless @params.empty?
|
215
|
-
|
543
|
+
@params.inject(Param.new){|res, param| res + param}.as_expr
|
216
544
|
end
|
217
545
|
end
|
218
546
|
end
|
219
547
|
|
220
548
|
# `DataCondition` is a class represents PIONE's input and output data condition.
|
221
|
-
class
|
549
|
+
class Data < PioneModel
|
222
550
|
attr_reader :data_expr
|
223
551
|
attr_accessor :input_distribution
|
224
552
|
attr_accessor :output_distribution
|
225
|
-
attr_accessor :
|
226
|
-
attr_accessor :output_priority
|
553
|
+
attr_accessor :priority
|
227
554
|
attr_accessor :input_nonexistable
|
228
555
|
attr_accessor :output_nonexistable
|
229
556
|
attr_accessor :output_for_this_flow
|
230
557
|
|
231
|
-
# @param
|
558
|
+
# @param nod [PNML::Node]
|
232
559
|
# data expression as a PIONE's expression string
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
# input distribution type of either `:each` or `:all`
|
237
|
-
# @option attr [Symbol] :output_distribution
|
238
|
-
# output distribution type of either `:each` or `:all`
|
239
|
-
# @option attr [Integer] :input_priority
|
240
|
-
# priority of this input condition
|
241
|
-
# @option attr [Integer] :output_priority
|
242
|
-
# priority of this output condition
|
243
|
-
# @option attr [Boolean] :output_for_this_flow
|
244
|
-
# flag for this flow's output
|
245
|
-
def initialize(data_expr, attr={})
|
246
|
-
@data_expr = data_expr
|
247
|
-
@input_distribution = attr[:input_distribution]
|
248
|
-
@output_distribution = attr[:output_distribution]
|
249
|
-
@input_priority = attr[:input_priority] || 1
|
250
|
-
@output_priority = attr[:output_priority] || 1
|
251
|
-
@input_nonexistable = attr[:input_nonexistable]
|
252
|
-
@output_nonexistable = attr[:output_nonexistable]
|
253
|
-
@output_for_this_flow = attr[:output_for_this_flow]
|
254
|
-
end
|
255
|
-
|
256
|
-
# Return a declaration string of the data expression as input condition.
|
257
|
-
def as_input_declaration(option={})
|
258
|
-
indent("input %s" % textize_data_expr(:input), option)
|
259
|
-
end
|
260
|
-
|
261
|
-
# Return a declaration string of the data expression as output condition.
|
262
|
-
def as_output_declaration(option={})
|
263
|
-
indent("output %s" % textize_data_expr(:output), option)
|
560
|
+
def initialize(node)
|
561
|
+
@name = LabelExtractor.extract_data_expr(node.name)
|
562
|
+
@priority = LabelExtractor.extract_priority(node.name)
|
264
563
|
end
|
265
564
|
|
266
565
|
private
|
267
566
|
|
268
567
|
def textize_data_expr(type)
|
269
|
-
data_expr = "%s" % @
|
568
|
+
data_expr = "%s" % @name
|
270
569
|
if (type == :input and @input_nonexistable) or (type == :output and @output_nonexistable)
|
271
570
|
data_expr = data_expr + " or null"
|
272
571
|
end
|
@@ -280,28 +579,105 @@ module Pione
|
|
280
579
|
end
|
281
580
|
end
|
282
581
|
|
283
|
-
|
284
|
-
|
582
|
+
class InputData < Data
|
583
|
+
# Return a declaration string of the data expression as input condition.
|
584
|
+
def as_declaration(option={})
|
585
|
+
indent("input %s" % textize_data_expr(:input), option)
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
class OutputData < Data
|
590
|
+
# Return a declaration string of the data expression as output condition.
|
591
|
+
def as_declaration(option={})
|
592
|
+
indent("output %s" % textize_data_expr(:output), option)
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
# Param is a class represents PIONE's paramter set.
|
597
|
+
class Param < PioneModel
|
598
|
+
# Create a parameter from the parameter set node.
|
599
|
+
#
|
600
|
+
# @param node [PNML::Node]
|
601
|
+
# parameter set node
|
602
|
+
# @return [Param]
|
603
|
+
# parameter
|
604
|
+
def self.set_of(node)
|
605
|
+
new(LabelExtractor.extract_data_from_param_set(node.name))
|
606
|
+
end
|
607
|
+
|
608
|
+
# Create a parameter from the parameter sentence node.
|
609
|
+
#
|
610
|
+
# @param node [PNML::Node]
|
611
|
+
# parameter sentence node
|
612
|
+
# @return [Param]
|
613
|
+
# parameter
|
614
|
+
def self.sentence_of(node)
|
615
|
+
new(LabelExtractor.extract_data_from_param_sentence(node.name))
|
616
|
+
end
|
617
|
+
|
618
|
+
attr_reader :data
|
619
|
+
|
620
|
+
# @param data [Hash]
|
621
|
+
# param set data
|
622
|
+
def initialize(data={})
|
623
|
+
@data = data
|
624
|
+
end
|
625
|
+
|
626
|
+
def as_expr
|
627
|
+
@data.map do |var, expr|
|
628
|
+
"%s: %s" % [var, expr]
|
629
|
+
end.join(", ").tap {|x| return "{%s}" % x}
|
630
|
+
end
|
631
|
+
|
632
|
+
def as_declarations(option={})
|
633
|
+
@data.map do |var, expr|
|
634
|
+
indent("param $%s := %s" % [var, expr], option)
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
def +(other)
|
639
|
+
self.class.new(@data.merge(other.data))
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
# Constraint represents a PIONE's constraint declaration.
|
644
|
+
class Constraint < PioneModel
|
645
|
+
attr_reader :expr
|
646
|
+
|
647
|
+
def initialize(expr)
|
648
|
+
@expr = expr
|
649
|
+
end
|
650
|
+
|
651
|
+
def as_declaration(option={})
|
652
|
+
indent("constraint " + @expr, option)
|
653
|
+
end
|
654
|
+
end
|
655
|
+
|
656
|
+
# Ticket represents a PIONE's ticket declaration.
|
657
|
+
class Ticket < PioneModel
|
285
658
|
attr_reader :name
|
286
|
-
attr_reader :default_expr
|
287
659
|
|
288
|
-
|
289
|
-
# parameter name, note that this name doesn't include heading `$`
|
290
|
-
# @param default expr [String]
|
291
|
-
# default value expression
|
292
|
-
def initialize(name, default_expr)
|
660
|
+
def initialize(name)
|
293
661
|
@name = name
|
294
|
-
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
# Feature represents a feature declaration in PIONE.
|
666
|
+
class Feature < PioneModel
|
667
|
+
attr_reader :expr
|
668
|
+
|
669
|
+
def initialize(expr)
|
670
|
+
@expr = expr
|
295
671
|
end
|
296
672
|
|
297
673
|
def as_declaration(option={})
|
298
|
-
indent("
|
674
|
+
indent("feature " + @expr, option)
|
299
675
|
end
|
300
676
|
end
|
301
677
|
|
302
678
|
# ConditionalBranch is a class represents PIONE's conditional branch
|
303
679
|
# declaration.
|
304
|
-
class ConditionalBranch <
|
680
|
+
class ConditionalBranch < PioneModel
|
305
681
|
attr_reader :condition
|
306
682
|
attr_reader :table
|
307
683
|
|
@@ -315,21 +691,22 @@ module Pione
|
|
315
691
|
case @type
|
316
692
|
when :"if"
|
317
693
|
branch_then = @table[:then].map do |rule|
|
318
|
-
|
694
|
+
rule.as_declaration(option.merge(level: option[:level] + 1))
|
319
695
|
end.join("\n")
|
320
696
|
|
321
697
|
if @table[:else].empty?
|
322
698
|
indent(Util::Indentation.cut(TEMPLATE_IF) % [@condition, branch_then], option)
|
323
699
|
else
|
324
700
|
branch_else = @table[:else].map do |rule|
|
325
|
-
|
701
|
+
rule.as_declaration(option.merge(level: option[:level] + 1))
|
326
702
|
end.join("\n")
|
327
703
|
indent(Util::Indentation.cut(TEMPLATE_IF_ELSE) % [@condition, branch_then, branch_else], option)
|
328
704
|
end
|
329
705
|
when :"case"
|
330
|
-
branches = @table.each_with_object([]) do |(val, rules),
|
331
|
-
|
332
|
-
|
706
|
+
branches = @table.each_with_object([]) do |(val, rules), lines|
|
707
|
+
lines << ((val == :else) ? "else" : "when %s" % val)
|
708
|
+
level = (option[:level] || 0) + 1
|
709
|
+
lines.concat(rules.map{|rule| rule.as_declaration(option.merge(level: level))})
|
333
710
|
end.join("\n")
|
334
711
|
indent(Util::Indentation.cut(TEMPLATE_CASE) % [@condition, branches], option)
|
335
712
|
end
|
@@ -356,22 +733,34 @@ module Pione
|
|
356
733
|
TXT
|
357
734
|
end
|
358
735
|
|
359
|
-
class RuleDefinition <
|
360
|
-
attr_accessor :name
|
736
|
+
class RuleDefinition < PioneModel
|
361
737
|
attr_accessor :type
|
362
738
|
attr_accessor :inputs
|
363
739
|
attr_accessor :outputs
|
364
740
|
attr_accessor :params
|
741
|
+
attr_accessor :constraints
|
742
|
+
attr_accessor :features
|
743
|
+
attr_accessor :source_tickets
|
744
|
+
attr_accessor :target_tickets
|
365
745
|
attr_accessor :conditions
|
746
|
+
attr_accessor :variable_bindings
|
366
747
|
attr_accessor :flow_elements
|
367
748
|
attr_accessor :action_content
|
368
749
|
|
369
|
-
def initialize(name, type, option={})
|
750
|
+
def initialize(name, type, is_external, net_name, index, option={})
|
370
751
|
@name = name
|
371
752
|
@type = type
|
753
|
+
@is_external = is_external
|
754
|
+
@net_name = net_name
|
755
|
+
@index = index
|
372
756
|
@inputs = option[:inputs] || []
|
373
757
|
@outputs = option[:outputs] || []
|
374
758
|
@params = option[:params] || []
|
759
|
+
@constraints = option[:constraints] || []
|
760
|
+
@features = option[:features] || []
|
761
|
+
@source_tickets = option[:source_tickets] || []
|
762
|
+
@target_tickets = option[:target_tickets] || []
|
763
|
+
@variable_bindings = option[:variable_bindings] || []
|
375
764
|
@conditions = option[:conditions] || []
|
376
765
|
@flow_elements = option[:flow_elements] || []
|
377
766
|
@action_content = nil
|
@@ -385,70 +774,136 @@ module Pione
|
|
385
774
|
@type == :action
|
386
775
|
end
|
387
776
|
|
388
|
-
def
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
777
|
+
def external?
|
778
|
+
@is_external
|
779
|
+
end
|
780
|
+
|
781
|
+
def name
|
782
|
+
external? ? generate_wrapper_name(@name) : @name
|
783
|
+
end
|
784
|
+
|
785
|
+
# Return the declaration form string.
|
786
|
+
def as_declaration(option={})
|
787
|
+
expr_source_tickets =
|
788
|
+
if @source_tickets.size > 0
|
789
|
+
"(%s) ==> " % @source_tickets.map {|ticket| "%s" % ticket.name}.join(" | ")
|
790
|
+
else
|
791
|
+
""
|
792
|
+
end
|
793
|
+
expr_target_tickets =
|
794
|
+
if @target_tickets.size > 0
|
795
|
+
" ==> (%s)" % @target_tickets.map {|ticket| "%s" % ticket.name}.join(" | ")
|
796
|
+
else
|
797
|
+
""
|
798
|
+
end
|
799
|
+
"rule %s%s%s" % [expr_source_tickets, name, expr_target_tickets]
|
800
|
+
end
|
801
|
+
|
802
|
+
# Make rule conditions.
|
803
|
+
#
|
804
|
+
# @return [Array<String>]
|
805
|
+
# rule condition lines
|
806
|
+
def rule_conditions
|
807
|
+
conditions = []
|
808
|
+
sort_data_list(@inputs).each do |input|
|
809
|
+
conditions << input.as_declaration
|
810
|
+
end
|
811
|
+
sort_data_list(@outputs).each do |output|
|
812
|
+
conditions << output.as_declaration
|
813
|
+
end
|
814
|
+
@params.each do |param|
|
815
|
+
conditions += param.as_declarations
|
816
|
+
end
|
817
|
+
@constraints.each do |constraint|
|
818
|
+
conditions << constraint.as_declaration
|
819
|
+
end
|
820
|
+
@features.each do |feature|
|
821
|
+
conditions << feature.as_declaration
|
822
|
+
end
|
823
|
+
conditions
|
824
|
+
end
|
825
|
+
|
826
|
+
def sort_data_list(data_list)
|
827
|
+
data_list.sort do |a, b|
|
828
|
+
priority_a = a.priority
|
829
|
+
priority_b = b.priority
|
830
|
+
|
831
|
+
if a.priority and b.priority
|
832
|
+
a.priority <=> b.priority
|
833
|
+
elsif a.priority
|
834
|
+
1
|
835
|
+
elsif b.priority
|
836
|
+
-1
|
394
837
|
else
|
395
|
-
|
838
|
+
0
|
396
839
|
end
|
397
840
|
end
|
841
|
+
end
|
842
|
+
|
843
|
+
def textize
|
398
844
|
ERB.new(template, nil, "-").result(binding)
|
399
845
|
end
|
400
846
|
|
847
|
+
def template
|
848
|
+
if external?
|
849
|
+
return Util::Indentation.cut(WRAPPER_TEMPLATE)
|
850
|
+
end
|
851
|
+
|
852
|
+
if flow?
|
853
|
+
return Util::Indentation.cut(FLOW_RULE_TEMPLATE)
|
854
|
+
end
|
855
|
+
|
856
|
+
if @action_content
|
857
|
+
return Util::Indentation.cut(LITERATE_ACTION_RULE_TEMPLATE)
|
858
|
+
else
|
859
|
+
return Util::Indentation.cut(ACTION_RULE_TEMPLATE)
|
860
|
+
end
|
861
|
+
end
|
862
|
+
|
863
|
+
# Generate a name for wrapper rule.
|
864
|
+
def generate_wrapper_name(name)
|
865
|
+
"__%s_%s_%s__" % [@net_name, @name, @index]
|
866
|
+
end
|
867
|
+
|
401
868
|
FLOW_RULE_TEMPLATE = <<-RULE
|
402
|
-
Rule <%=
|
403
|
-
<%-
|
404
|
-
|
405
|
-
<%- end -%>
|
406
|
-
<%- @outputs.each do |output| -%>
|
407
|
-
output <%= output %>
|
408
|
-
<%- end -%>
|
409
|
-
<%- @params.each do |param| -%>
|
410
|
-
<%= param.as_declaration %>
|
869
|
+
Rule <%= name %>
|
870
|
+
<%- rule_conditions.each do |condition| -%>
|
871
|
+
<%= condition %>
|
411
872
|
<%- end -%>
|
412
873
|
Flow
|
413
874
|
<%- @flow_elements.each do |element| -%>
|
414
|
-
|
415
|
-
rule <%= element.name %>
|
416
|
-
<%- else -%>
|
417
|
-
<%= element.as_declaration(level: 1) %>
|
418
|
-
<%- end -%>
|
875
|
+
<%= element.as_declaration(level: 1) %>
|
419
876
|
<%- end -%>
|
420
877
|
End
|
421
878
|
RULE
|
422
879
|
|
423
880
|
ACTION_RULE_TEMPLATE = <<-RULE
|
424
|
-
Rule <%=
|
425
|
-
<%-
|
426
|
-
|
427
|
-
<%- end -%>
|
428
|
-
<%- @outputs.each do |output| -%>
|
429
|
-
output (<%= output %>).touch
|
430
|
-
<%- end -%>
|
431
|
-
<%- @params.each do |param| -%>
|
432
|
-
<%= param.as_declaration %>
|
881
|
+
Rule <%= name %>
|
882
|
+
<%- rule_conditions.each do |condition| -%>
|
883
|
+
<%= condition %>
|
433
884
|
<%- end -%>
|
434
885
|
End
|
435
886
|
RULE
|
436
887
|
|
437
888
|
LITERATE_ACTION_RULE_TEMPLATE = <<-RULE
|
438
|
-
Rule <%=
|
439
|
-
<%-
|
440
|
-
|
441
|
-
<%- end -%>
|
442
|
-
<%- @outputs.each do |output| -%>
|
443
|
-
output <%= output %>
|
444
|
-
<%- end -%>
|
445
|
-
<%- @params.each do |param| -%>
|
446
|
-
<%= param.as_declaration %>
|
889
|
+
Rule <%= name %>
|
890
|
+
<%- rule_conditions.each do |condition| -%>
|
891
|
+
<%= condition %>
|
447
892
|
<%- end -%>
|
448
893
|
Action
|
449
894
|
<%= Util::Indentation.indent(@action_content, 2) -%>
|
450
895
|
End
|
451
896
|
RULE
|
897
|
+
|
898
|
+
WRAPPER_TEMPLATE = <<-RULE
|
899
|
+
Rule <%= name %>
|
900
|
+
<%- rule_conditions.each do |condition| -%>
|
901
|
+
<%= condition %>
|
902
|
+
<%- end -%>
|
903
|
+
Flow
|
904
|
+
rule <%= @name %>
|
905
|
+
End
|
906
|
+
RULE
|
452
907
|
end
|
453
908
|
end
|
454
909
|
end
|