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
@@ -17,6 +17,7 @@ module Pione
|
|
17
17
|
require 'pione/command/pione-package-build'
|
18
18
|
require 'pione/command/pione-package-show'
|
19
19
|
require 'pione/command/pione-package-update'
|
20
|
+
require 'pione/command/pione-package-remove'
|
20
21
|
end
|
21
22
|
|
22
23
|
PioneCommand.define_subcommand("package", PionePackage)
|
@@ -23,9 +23,14 @@ module Pione
|
|
23
23
|
# keep to watch child process
|
24
24
|
@thread = Process.detach(@pid)
|
25
25
|
|
26
|
+
# fail to spawn if the monitor thread is nil
|
27
|
+
unless @thread
|
28
|
+
return self
|
29
|
+
end
|
30
|
+
|
26
31
|
# find child front while child process is alive
|
27
32
|
Timeout.timeout(10) do
|
28
|
-
while @thread
|
33
|
+
while @thread.alive? do
|
29
34
|
# find front and save its uri and pid
|
30
35
|
if child_front = find_child_front(@pid)
|
31
36
|
@child_front = child_front
|
@@ -36,8 +41,12 @@ module Pione
|
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
39
|
-
#
|
40
|
-
|
44
|
+
# error if the process has failed
|
45
|
+
unless not(@thread.alive?) and @thread.value.success?
|
46
|
+
raise SpawnError.child_process_is_dead(@model[:scenario_name], @name, @argv)
|
47
|
+
end
|
48
|
+
|
49
|
+
return self
|
41
50
|
end
|
42
51
|
rescue Timeout::Error
|
43
52
|
raise SpawnError.new(@model[:scenario_name], @name, @argv, "timed out")
|
data/lib/pione/lang/boolean.rb
CHANGED
@@ -154,13 +154,15 @@ module Pione
|
|
154
154
|
rule(:number!) { number.or_error("it should be number") }
|
155
155
|
|
156
156
|
# +space+ matches sequences of space character, tab, or comment.
|
157
|
-
rule(:
|
157
|
+
rule(:space_char) {match("[ \t]")}
|
158
|
+
rule(:space) { (space_char | comment).repeat(1) }
|
158
159
|
|
159
160
|
# +space?+ matches +space+ or empty.
|
160
161
|
rule(:space?) { space.maybe }
|
161
162
|
|
162
163
|
# +pad+ matches sequences of space character, tab, newline, or comment.
|
163
|
-
rule(:
|
164
|
+
rule(:pad_char) {match("[ \t\n]")}
|
165
|
+
rule(:pad) { (pad_char | comment).repeat(1) }
|
164
166
|
|
165
167
|
# +pad?+ matches +pad+ or empty.
|
166
168
|
rule(:pad?) { pad.maybe }
|
@@ -194,7 +196,7 @@ module Pione
|
|
194
196
|
|
195
197
|
# Create an atom that matches a line with the content.
|
196
198
|
def line(content)
|
197
|
-
space? >> content >> line_end
|
199
|
+
space? >> content >> line_end.as(:tail)
|
198
200
|
end
|
199
201
|
end
|
200
202
|
end
|
@@ -16,8 +16,14 @@ module Pione
|
|
16
16
|
# +param_context+ matches parameter block contexts.
|
17
17
|
rule(:param_context) {structural_context.as(:param_context)}
|
18
18
|
|
19
|
-
# +
|
20
|
-
rule(:
|
19
|
+
# +flow_rule_condition_context+ matches flow rule condition contexts.
|
20
|
+
rule(:flow_rule_condition_context) {structural_context.as(:flow_rule_condition_context)}
|
21
|
+
|
22
|
+
# +action_rule_condition_context+ matches action rule condition contexts.
|
23
|
+
rule(:action_rule_condition_context) {structural_context.as(:action_rule_condition_context)}
|
24
|
+
|
25
|
+
# +empty_rule_condition_context+ matches empty rule condition contexts.
|
26
|
+
rule(:empty_rule_condition_context) {structural_context.as(:empty_rule_condition_context)}
|
21
27
|
|
22
28
|
# +flow_context+ matches flow contexts.
|
23
29
|
rule(:flow_context) {structural_context.as(:flow_context)}
|
@@ -14,9 +14,19 @@ module Pione
|
|
14
14
|
Lang::ParamContext.new(elements)
|
15
15
|
}
|
16
16
|
|
17
|
-
# Transform +
|
18
|
-
rule(:
|
19
|
-
Lang::
|
17
|
+
# Transform +flow_rule_condition_context+ into Lang::FlowRuleConditionContext.
|
18
|
+
rule(:flow_rule_condition_context => sequence(:elements)) {
|
19
|
+
Lang::FlowRuleConditionContext.new(elements)
|
20
|
+
}
|
21
|
+
|
22
|
+
# Transform +action_rule_condition_context+ into Lang::ActionRuleConditionContext.
|
23
|
+
rule(:action_rule_condition_context => sequence(:elements)) {
|
24
|
+
Lang::ActionRuleConditionContext.new(elements)
|
25
|
+
}
|
26
|
+
|
27
|
+
# Transform +empty_rule_condition_context+ into Lang::EmptyRuleConditionContext.
|
28
|
+
rule(:empty_rule_condition_context => sequence(:elements)) {
|
29
|
+
Lang::EmptyRuleConditionContext.new(elements)
|
20
30
|
}
|
21
31
|
|
22
32
|
# Transform +flow_context+ into Lang::FlowContext.
|
data/lib/pione/lang/context.rb
CHANGED
@@ -169,12 +169,30 @@ module Pione
|
|
169
169
|
|
170
170
|
# Evaluate the rule condition context. Return a new definition of rule condition.
|
171
171
|
def eval(env)
|
172
|
-
|
173
|
-
env.temp(current_definition:
|
172
|
+
create_condition.tap do |condition|
|
173
|
+
env.temp(current_definition: condition) {|_env| super(_env)}
|
174
174
|
end
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
+
class FlowRuleConditionContext < RuleConditionContext
|
179
|
+
def create_condition
|
180
|
+
RuleCondition.new(type: :flow)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
class ActionRuleConditionContext < RuleConditionContext
|
185
|
+
def create_condition
|
186
|
+
RuleCondition.new(type: :action)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class EmptyRuleConditionContext < RuleConditionContext
|
191
|
+
def create_condition
|
192
|
+
RuleCondition.new(type: :empty)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
178
196
|
# FlowContext is a context for flow rule body.
|
179
197
|
class FlowContext < StructuralContext
|
180
198
|
accept VariableBindingDeclaration
|
data/lib/pione/lang/data-expr.rb
CHANGED
@@ -73,10 +73,24 @@ module Pione
|
|
73
73
|
# +param_sentence+ matches parameter declarations.
|
74
74
|
rule(:param_sentence) {
|
75
75
|
type = (keyword_basic | keyword_advanced).as(:type)
|
76
|
+
|
77
|
+
line(((type >> pad).maybe >> keyword_param.as(:declarator) >> pad >> param_expr).as(:param_sentence))
|
78
|
+
}
|
79
|
+
|
80
|
+
# +param_expr+ matches a parameter expression.
|
81
|
+
rule(:param_expr) {
|
76
82
|
with_default = expr.as(:expr1) >> padded?(binding_operator) >> expr!.as(:expr2)
|
77
83
|
without_default = expr.as(:expr1)
|
78
84
|
|
79
|
-
|
85
|
+
with_default | without_default
|
86
|
+
}
|
87
|
+
|
88
|
+
# +param_expr+ natches a parameter expression with variable explicitly.
|
89
|
+
rule(:strict_param_expr) {
|
90
|
+
with_default = variable.as(:expr1) >> padded?(binding_operator) >> expr!.as(:expr2)
|
91
|
+
without_default = variable.as(:expr1)
|
92
|
+
|
93
|
+
with_default | without_default
|
80
94
|
}
|
81
95
|
|
82
96
|
# +rule_binding_sentence+ matches rule binding declarations.
|
@@ -144,21 +158,21 @@ module Pione
|
|
144
158
|
|
145
159
|
# +flow_rule_block+ matches flow rule declarations.
|
146
160
|
rule(:flow_rule_block) {
|
147
|
-
( rule_header >>
|
161
|
+
( rule_header >> flow_rule_condition_context.as(:context1) >>
|
148
162
|
line(keyword_Flow) >> flow_context.as(:context2) >> rule_footer!
|
149
163
|
).as(:flow_rule_block)
|
150
164
|
}
|
151
165
|
|
152
166
|
# +action_rule_block+ matches action rule declarations.
|
153
167
|
rule(:action_rule_block) {
|
154
|
-
( rule_header >>
|
168
|
+
( rule_header >> action_rule_condition_context.as(:context1) >>
|
155
169
|
line(keyword_Action) >> action_context.as(:context2) >> rule_footer!
|
156
170
|
).as(:action_rule_block)
|
157
171
|
}
|
158
172
|
|
159
173
|
# +empty_rule_block+ matches empty rule declarations.
|
160
174
|
rule(:empty_rule_block) {
|
161
|
-
(rule_header >>
|
175
|
+
(rule_header >> empty_rule_condition_context.as(:context) >> rule_footer!).as(:empty_rule_block)
|
162
176
|
}
|
163
177
|
|
164
178
|
# +rule_header+ matches rule headers.
|
@@ -25,7 +25,7 @@ module Pione
|
|
25
25
|
}
|
26
26
|
|
27
27
|
# Transform +param_sentence+ into +Lang::ParamDeclaration+.
|
28
|
-
rule(:param_sentence => subtree(:tree)) {
|
28
|
+
rule(:param_sentence => subtree(:tree), :tail => simple(:tail_message)) {
|
29
29
|
type = (tree[:type] || "basic").to_sym
|
30
30
|
|
31
31
|
Lang::ParamDeclaration.new(type, tree[:expr1], tree[:expr2]).tap do |declaration|
|
@@ -265,7 +265,9 @@ module Pione
|
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
-
class
|
268
|
+
class RuleDeclaration < Declaration; end
|
269
|
+
|
270
|
+
class FlowRuleDeclaration < RuleDeclaration
|
269
271
|
member :expr # rule name
|
270
272
|
member :rule_condition_context # rule condition context
|
271
273
|
member :flow_context # flow context
|
@@ -285,7 +287,7 @@ module Pione
|
|
285
287
|
end
|
286
288
|
end
|
287
289
|
|
288
|
-
class ActionRuleDeclaration <
|
290
|
+
class ActionRuleDeclaration < RuleDeclaration
|
289
291
|
member :expr # rule name
|
290
292
|
member :condition_context # rule condition context
|
291
293
|
member :action_context # action context
|
@@ -305,7 +307,7 @@ module Pione
|
|
305
307
|
end
|
306
308
|
end
|
307
309
|
|
308
|
-
class EmptyRuleDeclaration <
|
310
|
+
class EmptyRuleDeclaration < RuleDeclaration
|
309
311
|
member :expr # rule name
|
310
312
|
member :condition_context # rule condition context
|
311
313
|
|
@@ -2,6 +2,7 @@ module Pione
|
|
2
2
|
module Lang
|
3
3
|
# RuleCondition is a storage of rule conditions.
|
4
4
|
class RuleCondition < StructX
|
5
|
+
member :type
|
5
6
|
member :inputs, default: lambda { Array.new }
|
6
7
|
member :outputs, default: lambda { Array.new }
|
7
8
|
member :features, default: lambda { Array.new }
|
@@ -231,6 +231,35 @@ module Pione
|
|
231
231
|
rule_table.get!(self, setup_package_id(ref))
|
232
232
|
end
|
233
233
|
|
234
|
+
# Return name of entrance rule.
|
235
|
+
#
|
236
|
+
# @param package_id [String]
|
237
|
+
# pakcage id
|
238
|
+
# @return [String]
|
239
|
+
# name of entrance rule
|
240
|
+
def entrance_rule_name(package_id=current_package_id)
|
241
|
+
# find main rule name from annotations
|
242
|
+
annotations = package_get(Lang::PackageExpr.new(package_id: package_id)).annotations
|
243
|
+
annotations.each do |annotation|
|
244
|
+
if annotation.annotation_type == "Entrance"
|
245
|
+
return annotation.pieces.first.name
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# default name
|
250
|
+
return "Main"
|
251
|
+
end
|
252
|
+
|
253
|
+
# Return entrance rule.
|
254
|
+
#
|
255
|
+
# @param package_id [String]
|
256
|
+
# pakcage id
|
257
|
+
# @return [RuleDeclaration]
|
258
|
+
# entrance rule
|
259
|
+
def entrance_rule(package_id=current_package_id)
|
260
|
+
rule_get!(Lang::RuleExpr.new(entrance_rule_name(package_id)))
|
261
|
+
end
|
262
|
+
|
234
263
|
# Get the expression of the reference.
|
235
264
|
def rule_get_value(ref)
|
236
265
|
if val = rule_table.get_value(self, setup_package_id(ref))
|
@@ -335,17 +364,23 @@ module Pione
|
|
335
364
|
set(current_package_id: package_id, current_definition: definition)
|
336
365
|
end
|
337
366
|
|
367
|
+
# Make a root rule definition.
|
368
|
+
#
|
369
|
+
# @param main_param_set [ParameterSet]
|
370
|
+
# main parameter set
|
371
|
+
# @return [RuleDefinition]
|
372
|
+
# root rule definition
|
338
373
|
def make_root_rule(main_param_set)
|
339
374
|
# put variable of parameter set for main rule
|
340
375
|
variable_set(Variable.new("MAIN_PARAM_SET"), ParameterSetSequence.of(main_param_set))
|
341
376
|
|
342
377
|
# make root rule
|
343
|
-
Package::Document.parse(<<-PIONE, current_package_id, nil, nil, "*System*").eval(self)
|
378
|
+
Package::Document.parse(<<-PIONE % entrance_rule_name, current_package_id, nil, nil, "*System*").eval(self)
|
344
379
|
Rule Root
|
345
380
|
input '*'.all or null
|
346
381
|
output '*'.all
|
347
382
|
Flow
|
348
|
-
rule
|
383
|
+
rule %s.param($MAIN_PARAM_SET)
|
349
384
|
End
|
350
385
|
PIONE
|
351
386
|
rule_get(RuleExpr.new("Root"))
|
data/lib/pione/lang/expr.rb
CHANGED
@@ -6,21 +6,19 @@ module Pione
|
|
6
6
|
immutable true
|
7
7
|
|
8
8
|
class << self
|
9
|
-
attr_reader :pione_type
|
10
|
-
|
11
9
|
# Set pione model type of the model.
|
12
|
-
def pione_type(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
def pione_type(env=nil)
|
11
|
+
@pione_type
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_pione_type(type)
|
15
|
+
@pione_type = type
|
16
|
+
Type.table[type.name][:sequence_class] = self
|
19
17
|
end
|
20
18
|
|
21
19
|
def inherited(subclass)
|
22
20
|
if @pione_type
|
23
|
-
subclass.
|
21
|
+
subclass.set_pione_type(@pione_type)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -54,7 +52,7 @@ module Pione
|
|
54
52
|
# check arguments
|
55
53
|
raise ArgumentError.new(args) unless args.is_a?(Array)
|
56
54
|
|
57
|
-
if pione_method = pione_type.find_method(env, name, self, args)
|
55
|
+
if pione_method = pione_type(env).find_method(env, name, self, args)
|
58
56
|
# evaluate arguments if the method type is immediate
|
59
57
|
if pione_method.method_type == :immediate
|
60
58
|
args = args.map {|arg| arg.eval(env)}
|
@@ -62,7 +60,7 @@ module Pione
|
|
62
60
|
# call it
|
63
61
|
pione_method.call(env, self, args)
|
64
62
|
else
|
65
|
-
raise MethodNotFound.new(name, self, args)
|
63
|
+
raise MethodNotFound.new(env, name, self, args)
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
@@ -157,7 +157,7 @@ module Pione
|
|
157
157
|
|
158
158
|
# FeatureSequence represents disjunction of feature pieces.
|
159
159
|
class FeatureSequence < OrdinalSequence
|
160
|
-
|
160
|
+
set_pione_type TypeFeature
|
161
161
|
piece_class EmptyFeature
|
162
162
|
piece_class AlmightyFeature
|
163
163
|
piece_class PossibleFeature
|
data/lib/pione/lang/float.rb
CHANGED
data/lib/pione/lang/integer.rb
CHANGED
@@ -2,7 +2,7 @@ module Pione
|
|
2
2
|
module Lang
|
3
3
|
# KeyedSequence is a sequence that have key and value pairs.
|
4
4
|
class KeyedSequence < Sequence
|
5
|
-
|
5
|
+
set_pione_type TypeKeyedSequence
|
6
6
|
|
7
7
|
member :pieces, default: {}
|
8
8
|
member :piece_type
|
@@ -43,12 +43,12 @@ module Pione
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def index_type
|
47
|
-
pieces.keys.first.pione_type
|
46
|
+
def index_type(env)
|
47
|
+
pieces.keys.first.pione_type(env)
|
48
48
|
end
|
49
49
|
|
50
|
-
def element_type
|
51
|
-
pieces.values.first.pione_type
|
50
|
+
def element_type(env)
|
51
|
+
pieces.values.first.pione_type(env)
|
52
52
|
end
|
53
53
|
|
54
54
|
def eval(env)
|
@@ -156,15 +156,16 @@ module Pione
|
|
156
156
|
|
157
157
|
# LangTypeError represents type mismatch error in PIONE language.
|
158
158
|
class LangTypeError < StandardError
|
159
|
-
def initialize(obj, type)
|
159
|
+
def initialize(obj, type, env)
|
160
160
|
@obj = obj
|
161
161
|
@type = type
|
162
|
+
@env = env
|
162
163
|
end
|
163
164
|
|
164
165
|
def message
|
165
166
|
args = [
|
166
167
|
@type.name,
|
167
|
-
@obj.pione_type.name,
|
168
|
+
@obj.pione_type(env).name,
|
168
169
|
@obj.line,
|
169
170
|
@obj.column
|
170
171
|
]
|
@@ -179,21 +180,24 @@ module Pione
|
|
179
180
|
attr_reader :arguments
|
180
181
|
|
181
182
|
# Creates an exception.
|
183
|
+
# @param env [Environment]
|
184
|
+
# language environment
|
182
185
|
# @param name [String]
|
183
186
|
# method name
|
184
187
|
# @param receiver [Callable]
|
185
188
|
# method reciever
|
186
189
|
# @param arguments [Array<Callable>]
|
187
190
|
# method arguments
|
188
|
-
def initialize(name, receiver, arguments)
|
191
|
+
def initialize(env, name, receiver, arguments)
|
192
|
+
@env = env
|
189
193
|
@name = name
|
190
194
|
@receiver = receiver
|
191
195
|
@arguments = arguments
|
192
196
|
end
|
193
197
|
|
194
198
|
def message
|
195
|
-
rec_type = @receiver.pione_type
|
196
|
-
arg_types = @arguments.map{|arg| arg.pione_type}.join(" -> ")
|
199
|
+
rec_type = @receiver.pione_type(@env)
|
200
|
+
arg_types = @arguments.map{|arg| arg.pione_type(@env)}.join(" -> ")
|
197
201
|
"PIONE method \"%s\" is not found: %s. %s" % [@name, rec_type, arg_types]
|
198
202
|
end
|
199
203
|
end
|