pione 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.simplecov +1 -0
- data/History.txt +9 -0
- data/Rakefile +1 -71
- data/example/Fib/Fib.pione +9 -8
- data/example/HelloWorld/HelloWorld.pione +2 -0
- data/example/HelloWorld/pione-package.json +15 -0
- data/example/HelloWorld/scenario/Scenario.pione +2 -0
- data/example/HelloWorld/scenario/pione-scenario.json +10 -0
- data/example/SerialProcessing/SerialProcessing.pione +2 -0
- data/example/SerialProcessing/pione-package.json +15 -0
- data/example/SerialProcessing/scenario/Scenario.pione +1 -0
- data/example/SerialProcessing/scenario/pione-scenario.json +10 -0
- data/lib/pione.rb +28 -35
- data/lib/pione/agent.rb +4 -4
- data/lib/pione/agent/agent-exception.rb +52 -0
- data/lib/pione/agent/basic-agent.rb +246 -239
- data/lib/pione/agent/broker.rb +232 -216
- data/lib/pione/agent/input-generator.rb +113 -133
- data/lib/pione/agent/job-terminator.rb +38 -0
- data/lib/pione/agent/logger.rb +24 -54
- data/lib/pione/agent/messenger.rb +11 -16
- data/lib/pione/agent/process-manager.rb +50 -19
- data/lib/pione/agent/task-worker.rb +126 -236
- data/lib/pione/agent/tuple-space-client.rb +16 -39
- data/lib/pione/agent/tuple-space-provider.rb +66 -0
- data/lib/pione/agent/tuple-space-receiver.rb +137 -0
- data/lib/pione/command.rb +2 -3
- data/lib/pione/command/basic-command.rb +347 -207
- data/lib/pione/command/command-exception.rb +38 -0
- data/lib/pione/command/option.rb +112 -104
- data/lib/pione/command/pione-broker.rb +85 -43
- data/lib/pione/command/pione-clean.rb +51 -8
- data/lib/pione/command/pione-client.rb +321 -292
- data/lib/pione/command/pione-log.rb +92 -53
- data/lib/pione/command/pione-package.rb +112 -59
- data/lib/pione/command/pione-relay-account-db.rb +107 -78
- data/lib/pione/command/pione-relay-client-db.rb +93 -72
- data/lib/pione/command/pione-relay.rb +37 -32
- data/lib/pione/command/pione-syntax-checker.rb +112 -87
- data/lib/pione/command/pione-task-worker.rb +135 -118
- data/lib/pione/command/pione-tuple-space-provider.rb +83 -50
- data/lib/pione/command/pione-tuple-space-receiver.rb +89 -50
- data/lib/pione/command/pione-tuple-space-viewer.rb +101 -99
- data/lib/pione/command/pione-val.rb +50 -29
- data/lib/pione/command/spawner.rb +74 -0
- data/lib/pione/front.rb +0 -2
- data/lib/pione/front/basic-front.rb +48 -26
- data/lib/pione/front/broker-front.rb +8 -16
- data/lib/pione/front/client-front.rb +10 -18
- data/lib/pione/front/front-exception.rb +12 -0
- data/lib/pione/front/relay-front.rb +6 -6
- data/lib/pione/front/task-worker-front.rb +3 -9
- data/lib/pione/front/tuple-space-provider-front.rb +6 -14
- data/lib/pione/front/tuple-space-receiver-front.rb +4 -11
- data/lib/pione/global.rb +135 -0
- data/lib/pione/global/broker-variable.rb +20 -0
- data/lib/pione/global/client-variable.rb +18 -0
- data/lib/pione/global/input-generator-variable.rb +7 -0
- data/lib/pione/global/log-variable.rb +53 -0
- data/lib/pione/global/network-variable.rb +7 -0
- data/lib/pione/global/package-variable.rb +28 -0
- data/lib/pione/global/path-variable.rb +52 -0
- data/lib/pione/global/relay-variable.rb +86 -0
- data/lib/pione/global/system-variable.rb +39 -0
- data/lib/pione/global/task-worker-variable.rb +17 -0
- data/lib/pione/global/tuple-space-notifier-variable.rb +60 -0
- data/lib/pione/lang.rb +55 -0
- data/lib/pione/lang/basic-model.rb +45 -0
- data/lib/pione/lang/boolean.rb +86 -0
- data/lib/pione/lang/common-parser.rb +202 -0
- data/lib/pione/lang/conditional-branch-parser.rb +57 -0
- data/lib/pione/lang/conditional-branch-transformer.rb +36 -0
- data/lib/pione/lang/conditional-branch.rb +73 -0
- data/lib/pione/lang/context-parser.rb +39 -0
- data/lib/pione/lang/context-transformer.rb +41 -0
- data/lib/pione/lang/context.rb +229 -0
- data/lib/pione/lang/data-expr.rb +265 -0
- data/lib/pione/lang/declaration-parser.rb +174 -0
- data/lib/pione/lang/declaration-transformer.rb +153 -0
- data/lib/pione/lang/declaration.rb +322 -0
- data/lib/pione/lang/definition.rb +88 -0
- data/lib/pione/lang/document-parser.rb +19 -0
- data/lib/pione/lang/document-transformer.rb +12 -0
- data/lib/pione/lang/environment.rb +344 -0
- data/lib/pione/{parser → lang}/error-message.yml +0 -0
- data/lib/pione/lang/expr-parser.rb +228 -0
- data/lib/pione/{transformer → lang}/expr-transformer.rb +32 -44
- data/lib/pione/lang/expr.rb +70 -0
- data/lib/pione/lang/feature-expr.rb +425 -0
- data/lib/pione/lang/float.rb +104 -0
- data/lib/pione/lang/integer.rb +159 -0
- data/lib/pione/lang/interpolator-parser.rb +44 -0
- data/lib/pione/lang/interpolator-transformer.rb +13 -0
- data/lib/pione/lang/keyed-sequence.rb +98 -0
- data/lib/pione/lang/lang-exception.rb +224 -0
- data/lib/pione/lang/literal-parser.rb +134 -0
- data/lib/pione/lang/literal-transformer.rb +171 -0
- data/lib/pione/lang/message.rb +41 -0
- data/lib/pione/lang/ordinal-sequence.rb +203 -0
- data/lib/pione/lang/package-expr.rb +86 -0
- data/lib/pione/lang/parameters.rb +121 -0
- data/lib/pione/lang/piece.rb +42 -0
- data/lib/pione/{model → lang}/pione-method.rb +26 -63
- data/lib/pione/lang/rule-expr.rb +70 -0
- data/lib/pione/lang/sequence.rb +215 -0
- data/lib/pione/lang/string.rb +116 -0
- data/lib/pione/lang/ticket-expr.rb +48 -0
- data/lib/pione/{model → lang}/type.rb +70 -99
- data/lib/pione/lang/variable.rb +35 -0
- data/lib/pione/location.rb +13 -1
- data/lib/pione/{uri-scheme → location}/broadcast-scheme.rb +2 -2
- data/lib/pione/location/data-location.rb +22 -5
- data/lib/pione/location/dropbox-location.rb +10 -8
- data/lib/pione/{uri-scheme → location}/dropbox-scheme.rb +2 -2
- data/lib/pione/location/ftp-location.rb +6 -0
- data/lib/pione/location/git-repository-location.rb +6 -17
- data/lib/pione/{uri-scheme → location}/git-scheme.rb +2 -2
- data/lib/pione/location/http-location.rb +8 -1
- data/lib/pione/location/local-location.rb +57 -4
- data/lib/pione/{uri-scheme → location}/local-scheme.rb +2 -2
- data/lib/pione/location/{exception.rb → location-exception.rb} +13 -1
- data/lib/pione/{uri-scheme/basic-scheme.rb → location/location-scheme.rb} +7 -6
- data/lib/pione/{uri-scheme → location}/myftp-scheme.rb +2 -2
- data/lib/pione/log.rb +7 -6
- data/lib/pione/log/debug.rb +75 -0
- data/lib/pione/log/domain-log.rb +4 -5
- data/lib/pione/log/message-log.rb +2 -2
- data/lib/pione/log/process-log.rb +16 -25
- data/lib/pione/log/process-record.rb +1 -0
- data/lib/pione/log/system-log.rb +165 -55
- data/lib/pione/package.rb +21 -0
- data/lib/pione/package/document.rb +27 -0
- data/lib/pione/package/package-archiver.rb +152 -0
- data/lib/pione/package/package-cache.rb +79 -0
- data/lib/pione/package/package-database.rb +121 -0
- data/lib/pione/package/package-exception.rb +38 -0
- data/lib/pione/{component → package}/package-expander.rb +13 -7
- data/lib/pione/package/package-filename.rb +46 -0
- data/lib/pione/package/package-handler.rb +106 -0
- data/lib/pione/package/package-info.rb +72 -0
- data/lib/pione/package/package-reader.rb +202 -0
- data/lib/pione/package/package-scanner.rb +133 -0
- data/lib/pione/package/scenario-handler.rb +95 -0
- data/lib/pione/package/scenario-info.rb +34 -0
- data/lib/pione/package/scenario-reader.rb +29 -0
- data/lib/pione/package/scenario-scanner.rb +96 -0
- data/lib/pione/patch.rb +0 -1
- data/lib/pione/patch/drb-patch.rb +377 -298
- data/lib/pione/patch/rinda-patch.rb +4 -3
- data/lib/pione/relay/relay-socket.rb +1 -4
- data/lib/pione/rule-engine.rb +27 -0
- data/lib/pione/{rule-handler → rule-engine}/action-handler.rb +41 -40
- data/lib/pione/rule-engine/basic-handler.rb +266 -0
- data/lib/pione/rule-engine/data-finder.rb +97 -0
- data/lib/pione/{rule-handler → rule-engine}/empty-handler.rb +2 -3
- data/lib/pione/rule-engine/engine-exception.rb +33 -0
- data/lib/pione/rule-engine/flow-handler.rb +490 -0
- data/lib/pione/{rule-handler → rule-engine}/root-handler.rb +5 -14
- data/lib/pione/{rule-handler → rule-engine}/system-handler.rb +1 -1
- data/lib/pione/rule-engine/update-criteria.rb +111 -0
- data/lib/pione/system.rb +3 -1
- data/lib/pione/system/config.rb +12 -45
- data/lib/pione/system/domain-info.rb +3 -12
- data/lib/pione/system/init.rb +2 -8
- data/lib/pione/system/system-exception.rb +29 -0
- data/lib/pione/test-helper.rb +43 -0
- data/lib/pione/test-helper/command-helper.rb +65 -0
- data/lib/pione/test-helper/extension.rb +9 -0
- data/lib/pione/test-helper/lang-helper.rb +196 -0
- data/lib/pione/test-helper/location-helper.rb +27 -0
- data/lib/pione/test-helper/package-helper.rb +11 -0
- data/lib/pione/test-helper/parser-helper.rb +45 -0
- data/lib/pione/test-helper/transformer-helper.rb +136 -0
- data/lib/pione/test-helper/tuple-helper.rb +13 -0
- data/lib/pione/test-helper/tuple-space-helper.rb +31 -0
- data/lib/pione/test-helper/webserver.rb +50 -0
- data/lib/pione/tuple-space.rb +4 -6
- data/lib/pione/{tuple → tuple-space}/basic-tuple.rb +63 -50
- data/lib/pione/tuple-space/tuple-definition.yml +165 -0
- data/lib/pione/tuple-space/tuple-space-exception.rb +25 -0
- data/lib/pione/tuple-space/tuple-space-interface.rb +123 -0
- data/lib/pione/tuple-space/tuple-space-server.rb +15 -26
- data/lib/pione/util.rb +16 -11
- data/lib/pione/util/backslash-notation.rb +11 -0
- data/lib/pione/util/digest.rb +71 -0
- data/lib/pione/util/embeded-expr-expander.rb +23 -0
- data/lib/pione/util/evaluatable.rb +9 -6
- data/lib/pione/util/free-thread-generator.rb +46 -0
- data/lib/pione/util/ftp-server.rb +3 -4
- data/lib/pione/util/id.rb +28 -23
- data/lib/pione/util/misc.rb +22 -4
- data/lib/pione/util/package-parameters-list.rb +12 -9
- data/lib/pione/{parser → util}/parslet-extension.rb +75 -64
- data/lib/pione/util/positionable.rb +65 -0
- data/lib/pione/util/zip.rb +12 -11
- data/lib/pione/version.rb +1 -1
- data/{test → misc}/endurance-test/graph.plt +0 -0
- data/{test → misc}/endurance-test/run.sh +0 -0
- data/pione.gemspec +45 -37
- data/test/agent/spec_basic-agent.rb +116 -99
- data/test/agent/spec_broker.rb +41 -25
- data/test/agent/spec_input-generator.rb +66 -57
- data/test/agent/spec_job-terminator.rb +27 -0
- data/test/agent/spec_logger.rb +28 -25
- data/test/agent/spec_messenger.rb +6 -6
- data/test/agent/spec_task-worker.rb +97 -246
- data/test/agent/spec_tuple-space-client.rb +19 -15
- data/test/agent/spec_tuple-space-provider.rb +26 -0
- data/test/agent/spec_tuple-space-receiver.rb +47 -0
- data/test/command/command-behavior.rb +2 -2
- data/test/command/data/PionePackageP1/P1.pione +9 -0
- data/test/command/data/PionePackageP1/pione-package.json +15 -0
- data/test/command/data/PionePackageP2/P2.pione +10 -0
- data/test/command/data/PionePackageP2/pione-package.json +16 -0
- data/test/command/data/PionePackageP3/P3.pione +10 -0
- data/test/command/data/PionePackageP3/pione-package.json +16 -0
- data/test/command/data/PionePackageP4/P4.pione +10 -0
- data/test/command/data/PionePackageP4/pione-package.json +17 -0
- data/test/command/data/pione-process.log +471 -0
- data/test/command/data/pione-val.domain.dump +0 -0
- data/test/command/spec_pione-clean.rb +12 -0
- data/test/command/spec_pione-client.rb +6 -6
- data/test/command/spec_pione-log.rb +28 -0
- data/test/command/spec_pione-package.rb +111 -12
- data/test/command/spec_pione-val.rb +4 -4
- data/test/lang/data/boolean.yml +134 -0
- data/test/lang/data/common-parser.yml +187 -0
- data/test/{parser/spec_flow-element-parser.yml → lang/data/conditional-branch-parser.yml} +12 -50
- data/test/lang/data/context-parser.yml +148 -0
- data/test/lang/data/data-expr.yml +93 -0
- data/test/lang/data/data-expr_match.yml +59 -0
- data/test/lang/data/declaration-parser.yml +279 -0
- data/test/lang/data/document-parser.yml +29 -0
- data/test/{parser/spec_expr-parser.yml → lang/data/expr-parser.yml} +9 -11
- data/test/lang/data/feature-expr.yml +148 -0
- data/test/lang/data/float.yml +30 -0
- data/test/lang/data/integer.yml +80 -0
- data/test/lang/data/interpolator-parser.yml +61 -0
- data/test/lang/data/keyed-sequence.yml +27 -0
- data/test/lang/data/literal-parser.yml +207 -0
- data/test/lang/data/parameter-set.yml +14 -0
- data/test/lang/data/rule-expr.yml +27 -0
- data/test/lang/data/sequence.yml +66 -0
- data/test/lang/data/string.yml +92 -0
- data/test/{model/spec_ticket-expr.yml → lang/data/ticket-expr.yml} +0 -0
- data/test/lang/spec_boolean.rb +5 -0
- data/test/{parser → lang}/spec_common-parser.rb +10 -32
- data/test/lang/spec_conditional-branch-parser.rb +5 -0
- data/test/lang/spec_conditional-branch-transformer.rb +97 -0
- data/test/lang/spec_conditional-branch.rb +176 -0
- data/test/lang/spec_context-parser.rb +5 -0
- data/test/lang/spec_context-transformer.rb +206 -0
- data/test/lang/spec_context.rb +283 -0
- data/test/lang/spec_data-expr.rb +198 -0
- data/test/lang/spec_declaration-parser.rb +5 -0
- data/test/lang/spec_declaration-transformer.rb +272 -0
- data/test/lang/spec_declaration.rb +550 -0
- data/test/lang/spec_document-parser.rb +5 -0
- data/test/lang/spec_document-transformer.rb +10 -0
- data/test/lang/spec_environment.rb +129 -0
- data/test/lang/spec_expr-parser.rb +6 -0
- data/test/lang/spec_expr-transformer.rb +149 -0
- data/test/lang/spec_feature-expr.rb +5 -0
- data/test/lang/spec_float.rb +23 -0
- data/test/lang/spec_integer.rb +29 -0
- data/test/lang/spec_interpolator-parser.rb +5 -0
- data/test/lang/spec_interpolator-transformer.rb +15 -0
- data/test/lang/spec_keyed-sequence.rb +5 -0
- data/test/lang/spec_literal-parser.rb +5 -0
- data/test/lang/spec_literal-transformer.rb +111 -0
- data/test/lang/spec_message.rb +22 -0
- data/test/lang/spec_package-expr.rb +19 -0
- data/test/lang/spec_parameter-set.rb +64 -0
- data/test/lang/spec_pione-method.rb +57 -0
- data/test/lang/spec_rule-expr.rb +18 -0
- data/test/lang/spec_sequence.rb +5 -0
- data/test/lang/spec_string.rb +5 -0
- data/test/lang/spec_ticket-expr.rb +39 -0
- data/test/lang/spec_variable.rb +29 -0
- data/test/{uri-scheme/spec_myftp-scheme.yml → location/data/myftp-scheme.yml} +0 -0
- data/test/location/location-behavior.rb +2 -2
- data/test/location/spec_basic-location.rb +5 -1
- data/test/{uri-scheme → location}/spec_broadcast-scheme.rb +4 -4
- data/test/{uri-scheme → location}/spec_dropbox-scheme.rb +3 -3
- data/test/location/spec_ftp-location.rb +3 -2
- data/test/location/spec_git-repository-location.rb +19 -19
- data/test/{uri-scheme → location}/spec_git-scheme.rb +2 -2
- data/test/location/spec_http-location.rb +4 -12
- data/test/location/spec_https-location.rb +1 -3
- data/test/location/spec_local-location.rb +1 -1
- data/test/{uri-scheme → location}/spec_local-scheme.rb +3 -3
- data/test/{uri-scheme → location}/spec_myftp-scheme.rb +8 -10
- data/test/log/spec_debug.rb +53 -0
- data/test/log/spec_domain-log.rb +4 -5
- data/test/log/spec_message-log.rb +39 -33
- data/test/log/spec_process-log.rb +4 -2
- data/test/log/spec_process-record.rb +12 -10
- data/test/log/spec_system-log.rb +29 -11
- data/test/log/spec_xes-log.rb +6 -4
- data/test/package/data/HelloWorld+v0.1.1.ppg +0 -0
- data/test/package/data/HelloWorld-gitrepos.zip +0 -0
- data/test/{test-data/package → package/data}/HelloWorld/HelloWorld.pione +3 -0
- data/test/package/data/HelloWorld/pione-package.json +16 -0
- data/test/package/data/HelloWorld/scenario/Scenario.pione +2 -0
- data/test/{test-data/package → package/data}/HelloWorld/scenario/output/message.txt +0 -0
- data/test/package/data/HelloWorld/scenario/pione-scenario.json +10 -0
- data/test/{test-data/package → package/data}/HelloWorld/scenario/scenario.yml +0 -0
- data/test/package/data/PackageScannerP1/P1.pione +11 -0
- data/test/package/data/PackageScannerP2/P2.pione +9 -0
- data/test/package/data/PackageScannerP3/P3.pione +17 -0
- data/test/package/data/PackageScannerP4/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/Doc1.pione +8 -0
- data/test/package/data/PackageScannerP4/Doc2.pione +6 -0
- data/test/package/data/PackageScannerP4/Doc3.pione +6 -0
- data/test/package/data/PackageScannerP4/P4.pione +8 -0
- data/test/package/data/PackageScannerP4/sub1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub1/Doc4.pione +6 -0
- data/test/package/data/PackageScannerP4/sub1/sub1-1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub1/sub1-1/Doc5.pione +6 -0
- data/test/package/data/PackageScannerP4/sub2/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-1/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-1/Doc6.pione +6 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-2/.Ignore.pione +1 -0
- data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-2/Doc7.pione +6 -0
- data/test/package/data/PackageScannerP5/P5.pione +8 -0
- data/test/{model/spec_feature-expr.yml → package/data/PackageScannerP5/scenario1/Scenario.pione} +0 -0
- data/test/package/data/PackageScannerP5/scenario2/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/scenario3/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub1/scenario4/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub1/sub1-1/scenario5/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub2/sub2-1/sub2-1-1/scenario6/Scenario.pione +0 -0
- data/test/package/data/PackageScannerP5/sub2/sub2-1/sub2-1-2/scenario7/Scenario.pione +0 -0
- data/test/package/data/ScenarioScannerS1/Scenario.pione +1 -0
- data/test/package/data/ScenarioScannerS1/input/i1 +0 -0
- data/test/package/data/ScenarioScannerS1/input/i2 +0 -0
- data/test/package/data/ScenarioScannerS1/input/i3 +0 -0
- data/test/package/data/ScenarioScannerS1/output/o1 +0 -0
- data/test/package/data/ScenarioScannerS1/output/o2 +0 -0
- data/test/package/data/ScenarioScannerS1/output/o3 +0 -0
- data/test/package/data/ScenarioScannerS2/Scenario.pione +1 -0
- data/test/package/data/ScenarioScannerS2/output/o1 +0 -0
- data/test/package/data/ScenarioScannerS3/Scenario.pione +2 -0
- data/test/package/data/ScenarioScannerS4/Scenario.pione +0 -0
- data/test/package/data/ScenarioScannerS5/Scenario.pione +2 -0
- data/test/package/data/ScenarioScannerS6/Scenario.pione +5 -0
- data/test/package/data/ScenarioScannerS8/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1+v0.1.0.ppg +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/Test.pione +3 -0
- data/test/{test-data/package → package/data}/TestPackage1/bin/count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/package.yml +0 -0
- data/test/package/data/TestPackage1/pione-package.json +18 -0
- data/test/package/data/TestPackage1/scenario/case1/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/input/1.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/output/1.count +0 -0
- data/test/package/data/TestPackage1/scenario/case1/pione-scenario.json +10 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/scenario.yml +0 -0
- data/test/package/data/TestPackage1/scenario/case2/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/1.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/2.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/3.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/1.count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/2.count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/3.count +0 -0
- data/test/package/data/TestPackage1/scenario/case2/pione-scenario.json +14 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/scenario.yml +0 -0
- data/test/package/data/TestPackage1/scenario/case3/Scenario.pione +1 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/input/a.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/input/b.txt +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/output/a.count +0 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/output/b.count +0 -0
- data/test/package/data/TestPackage1/scenario/case3/pione-scenario.json +12 -0
- data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/scenario.yml +0 -0
- data/test/{component → package}/spec_document.pione +0 -0
- data/test/package/spec_document.rb +52 -0
- data/test/package/spec_package-archiver.rb +31 -0
- data/test/package/spec_package-database.rb +42 -0
- data/test/package/spec_package-expander.rb +14 -0
- data/test/package/spec_package-filename.rb +56 -0
- data/test/package/spec_package-handler.rb +50 -0
- data/test/package/spec_package-info.rb +22 -0
- data/test/package/spec_package-reader.rb +85 -0
- data/test/package/spec_package-scanner.rb +68 -0
- data/test/package/spec_scenario-handler.rb +46 -0
- data/test/package/spec_scenario-info.rb +16 -0
- data/test/package/spec_scenario-scanner.rb +92 -0
- data/test/patch/spec_rinda-patch.rb +1 -1
- data/test/patch/spec_uri-patch.rb +1 -1
- data/test/{rule-handler → rule-engine}/spec_action-handler.pione +0 -0
- data/test/rule-engine/spec_action-handler.rb +94 -0
- data/test/rule-engine/spec_data-finder.rb +94 -0
- data/test/{tuple-space → rule-engine}/spec_data-finder.yml +39 -28
- data/test/rule-engine/spec_empty-handler.rb +170 -0
- data/test/{rule-handler → rule-engine}/spec_flow-handler.pione +0 -0
- data/test/rule-engine/spec_flow-handler.rb +421 -0
- data/test/{rule-handler → rule-engine}/spec_update-criteria.pione +0 -0
- data/test/{rule-handler → rule-engine}/spec_update-criteria.rb +16 -12
- data/test/{rule-handler → rule-engine}/spec_update-criteria.yml +0 -0
- data/test/system/spec_domain-info.rb +13 -9
- data/test/system/spec_file-cache.rb +9 -9
- data/test/tuple-space/spec_tuple-space-server.rb +42 -40
- data/test/tuple/spec_basic-tuple.rb +77 -75
- data/test/tuple/spec_data-tuple.rb +4 -4
- data/test/tuple/spec_finished-tuple.rb +5 -6
- data/test/tuple/spec_message-tuple.rb +3 -3
- data/test/tuple/spec_task-tuple.rb +11 -9
- data/test/tuple/spec_touch-tuple.rb +3 -3
- data/test/tuple/spec_working-tuple.rb +8 -12
- data/test/tuple/tuple-behavior.rb +1 -1
- data/test/util/data/HelloWorld+v0.1.1.ppg +0 -0
- data/test/util/spec_cpu.rb +1 -1
- data/test/util/spec_digest.rb +15 -0
- data/test/util/spec_evaluatable.rb +3 -3
- data/test/util/spec_free-thread-generator.rb +42 -0
- data/test/util/spec_ftp-server.rb +4 -9
- data/test/util/spec_id.rb +53 -36
- data/test/util/spec_indentation.rb +1 -1
- data/test/util/spec_ip-address.rb +1 -1
- data/test/util/spec_package-parameters-list.rb +10 -9
- data/test/util/spec_process-info.rb +2 -2
- data/test/util/spec_uuid.rb +1 -1
- data/test/util/spec_variable-holdable.rb +1 -1
- data/test/util/spec_zip.rb +1 -1
- metadata +508 -364
- data/example/SerialProcessing/package.yml +0 -5
- data/example/SerialProcessing/scenario/scenario.yml +0 -10
- data/lib/pione/agent/command-listener.rb +0 -47
- data/lib/pione/agent/rule-provider.rb +0 -59
- data/lib/pione/agent/trivial-routine-worker.rb +0 -29
- data/lib/pione/agent/tuple-space-server-client-life-checker.rb +0 -31
- data/lib/pione/command/child-process.rb +0 -56
- data/lib/pione/command/daemon-process.rb +0 -10
- data/lib/pione/command/front-owner-command.rb +0 -25
- data/lib/pione/component.rb +0 -13
- data/lib/pione/component/document.rb +0 -88
- data/lib/pione/component/package-archiver.rb +0 -92
- data/lib/pione/component/package-filename.rb +0 -38
- data/lib/pione/component/package-reader.rb +0 -276
- data/lib/pione/component/package.rb +0 -199
- data/lib/pione/component/rule.rb +0 -206
- data/lib/pione/front/task-worker-owner.rb +0 -43
- data/lib/pione/front/tuple-space-provider-owner.rb +0 -11
- data/lib/pione/model.rb +0 -32
- data/lib/pione/model/assignment.rb +0 -120
- data/lib/pione/model/basic-model.rb +0 -228
- data/lib/pione/model/block.rb +0 -262
- data/lib/pione/model/boolean.rb +0 -168
- data/lib/pione/model/call-rule.rb +0 -86
- data/lib/pione/model/constraints.rb +0 -46
- data/lib/pione/model/data-expr.rb +0 -548
- data/lib/pione/model/feature-expr.rb +0 -875
- data/lib/pione/model/float.rb +0 -105
- data/lib/pione/model/integer.rb +0 -166
- data/lib/pione/model/keyed-sequence.rb +0 -150
- data/lib/pione/model/message.rb +0 -95
- data/lib/pione/model/ordinal-sequence.rb +0 -73
- data/lib/pione/model/package-expr.rb +0 -53
- data/lib/pione/model/parameters.rb +0 -374
- data/lib/pione/model/rule-expr.rb +0 -234
- data/lib/pione/model/sequence.rb +0 -273
- data/lib/pione/model/string.rb +0 -127
- data/lib/pione/model/ticket-expr.rb +0 -71
- data/lib/pione/model/variable-table.rb +0 -344
- data/lib/pione/model/variable.rb +0 -116
- data/lib/pione/parser.rb +0 -14
- data/lib/pione/parser/block-parser.rb +0 -107
- data/lib/pione/parser/common-parser.rb +0 -173
- data/lib/pione/parser/document-parser.rb +0 -141
- data/lib/pione/parser/expr-parser.rb +0 -354
- data/lib/pione/parser/feature-expr-parser.rb +0 -105
- data/lib/pione/parser/flow-element-parser.rb +0 -181
- data/lib/pione/parser/literal-parser.rb +0 -196
- data/lib/pione/parser/rule-definition-parser.rb +0 -158
- data/lib/pione/patch/monitor-patch.rb +0 -16
- data/lib/pione/rule-handler.rb +0 -14
- data/lib/pione/rule-handler/basic-handler.rb +0 -326
- data/lib/pione/rule-handler/flow-handler.rb +0 -414
- data/lib/pione/rule-handler/update-criteria.rb +0 -175
- data/lib/pione/system/global.rb +0 -433
- data/lib/pione/transformer.rb +0 -24
- data/lib/pione/transformer/block-transformer.rb +0 -28
- data/lib/pione/transformer/document-transformer.rb +0 -58
- data/lib/pione/transformer/feature-expr-transformer.rb +0 -60
- data/lib/pione/transformer/flow-element-transformer.rb +0 -66
- data/lib/pione/transformer/literal-transformer.rb +0 -91
- data/lib/pione/transformer/rule-definition-transformer.rb +0 -80
- data/lib/pione/transformer/transformer-module.rb +0 -39
- data/lib/pione/tuple-space/data-finder.rb +0 -155
- data/lib/pione/tuple-space/presence-notifier.rb +0 -84
- data/lib/pione/tuple-space/tuple-space-provider.rb +0 -85
- data/lib/pione/tuple-space/tuple-space-receiver.rb +0 -141
- data/lib/pione/tuple-space/tuple-space-server-interface.rb +0 -123
- data/lib/pione/tuple.rb +0 -30
- data/lib/pione/tuple/agent-tuple.rb +0 -10
- data/lib/pione/tuple/attribute-tuple.rb +0 -7
- data/lib/pione/tuple/base-location-tuple.rb +0 -9
- data/lib/pione/tuple/bye-tuple.rb +0 -9
- data/lib/pione/tuple/command-tuple.rb +0 -9
- data/lib/pione/tuple/data-null-tuple.rb +0 -14
- data/lib/pione/tuple/data-tuple.rb +0 -21
- data/lib/pione/tuple/dry-run-tuple.rb +0 -8
- data/lib/pione/tuple/exception-tuple.rb +0 -11
- data/lib/pione/tuple/finished-tuple.rb +0 -17
- data/lib/pione/tuple/foreground-tuple.rb +0 -7
- data/lib/pione/tuple/lift-tuple.rb +0 -14
- data/lib/pione/tuple/message-tuple.rb +0 -7
- data/lib/pione/tuple/process-info-tuple.rb +0 -9
- data/lib/pione/tuple/process-log-tuple.rb +0 -13
- data/lib/pione/tuple/request-rule-tuple.rb +0 -9
- data/lib/pione/tuple/rule-tuple.rb +0 -10
- data/lib/pione/tuple/task-tuple.rb +0 -40
- data/lib/pione/tuple/task-worker-resource-tuple.rb +0 -9
- data/lib/pione/tuple/ticket-tuple.rb +0 -8
- data/lib/pione/tuple/touch-tuple.rb +0 -14
- data/lib/pione/tuple/working-tuple.rb +0 -13
- data/lib/pione/uri-scheme.rb +0 -11
- data/lib/pione/util/error-report.rb +0 -27
- data/test/agent/spec_command-listener.rb +0 -30
- data/test/agent/spec_rule-provider.rb +0 -78
- data/test/command/spec_pione-val.domain.dump +0 -0
- data/test/component/spec_document.rb +0 -67
- data/test/component/spec_package-archiver.rb +0 -27
- data/test/component/spec_package-expander.rb +0 -11
- data/test/component/spec_package-filename.rb +0 -79
- data/test/component/spec_package-reader.rb +0 -100
- data/test/component/spec_package.rb +0 -109
- data/test/component/spec_rule.rb +0 -140
- data/test/model/spec_assignment.rb +0 -52
- data/test/model/spec_block.rb +0 -108
- data/test/model/spec_boolean.rb +0 -39
- data/test/model/spec_boolean.yml +0 -134
- data/test/model/spec_call-rule.rb +0 -23
- data/test/model/spec_data-expr.rb +0 -361
- data/test/model/spec_data-expr.yml +0 -24
- data/test/model/spec_data-expr_match.yml +0 -45
- data/test/model/spec_feature-expr.rb +0 -333
- data/test/model/spec_feature-expr_decide.yml +0 -28
- data/test/model/spec_float.rb +0 -23
- data/test/model/spec_float.yml +0 -30
- data/test/model/spec_integer.rb +0 -23
- data/test/model/spec_integer.yml +0 -68
- data/test/model/spec_keyed-sequence.rb +0 -5
- data/test/model/spec_keyed-sequence.yml +0 -27
- data/test/model/spec_message.rb +0 -40
- data/test/model/spec_package-expr.rb +0 -19
- data/test/model/spec_parameters.rb +0 -103
- data/test/model/spec_pione-method.rb +0 -57
- data/test/model/spec_rule-expr.rb +0 -28
- data/test/model/spec_rule-expr.yml +0 -11
- data/test/model/spec_sequence.rb +0 -5
- data/test/model/spec_sequence.yml +0 -66
- data/test/model/spec_string.rb +0 -47
- data/test/model/spec_string.yml +0 -91
- data/test/model/spec_ticket-expr.rb +0 -39
- data/test/model/spec_variable-table.rb +0 -116
- data/test/model/spec_variable.rb +0 -82
- data/test/parser/spec_block-parser.rb +0 -5
- data/test/parser/spec_block-parser.yml +0 -94
- data/test/parser/spec_document-parser.rb +0 -5
- data/test/parser/spec_document-parser.yml +0 -77
- data/test/parser/spec_expr-parser.rb +0 -6
- data/test/parser/spec_feature-expr-parser.rb +0 -32
- data/test/parser/spec_feature-expr-parser.yml +0 -25
- data/test/parser/spec_flow-element-parser.rb +0 -5
- data/test/parser/spec_literal-parser.rb +0 -5
- data/test/parser/spec_literal-parser.yml +0 -134
- data/test/parser/spec_rule-definition-parser.rb +0 -5
- data/test/parser/spec_rule-definition-parser.yml +0 -94
- data/test/rule-handler/spec_action-handler.rb +0 -79
- data/test/rule-handler/spec_flow-handler.rb +0 -61
- data/test/spec_common.rb +0 -14
- data/test/spec_object.rb +0 -20
- data/test/test-data/package/HelloWorld+v0.1.0.ppg +0 -0
- data/test/test-data/package/HelloWorld-gitrepos.zip +0 -0
- data/test/test-data/package/HelloWorld/package.yml +0 -6
- data/test/test-util.rb +0 -211
- data/test/test-util/command.rb +0 -53
- data/test/test-util/package.rb +0 -9
- data/test/test-util/parser.rb +0 -45
- data/test/test-util/transformer.rb +0 -50
- data/test/test-util/webserver.rb +0 -43
- data/test/transformer/spec_block-transformer.rb +0 -33
- data/test/transformer/spec_document-transformer.rb +0 -50
- data/test/transformer/spec_expr-transformer.rb +0 -126
- data/test/transformer/spec_feature-expr-transformer.rb +0 -21
- data/test/transformer/spec_flow-element-transformer.rb +0 -154
- data/test/transformer/spec_literal-transformer.rb +0 -64
- data/test/transformer/spec_rule-definition-transformer.rb +0 -172
- data/test/tuple-space/spec_data-finder.rb +0 -94
- data/test/tuple-space/spec_tuple-space-provider.rb +0 -36
- data/test/tuple-space/spec_tuple-space-receiver.rb +0 -32
- data/test/util/spec_error-report.rb +0 -51
@@ -0,0 +1,174 @@
|
|
1
|
+
module Pione
|
2
|
+
module Lang
|
3
|
+
# DeclarationParser is a set of parsers for PIONE declaration setences and
|
4
|
+
# blocks.
|
5
|
+
module DeclarationParser
|
6
|
+
include Parslet
|
7
|
+
|
8
|
+
#
|
9
|
+
# outline
|
10
|
+
#
|
11
|
+
|
12
|
+
# SENTENCES is a list of declarative sentences in PIONE language.
|
13
|
+
SENTENCES = [
|
14
|
+
:variable_binding_sentence,
|
15
|
+
:package_binding_sentence,
|
16
|
+
:param_sentence,
|
17
|
+
:rule_binding_sentence,
|
18
|
+
:constituent_rule_sentence,
|
19
|
+
:input_sentence,
|
20
|
+
:output_sentence,
|
21
|
+
:feature_sentence,
|
22
|
+
:constraint_sentence,
|
23
|
+
:annotation_sentence,
|
24
|
+
:expr_sentence
|
25
|
+
]
|
26
|
+
|
27
|
+
# BLOCKS is a list of declaration blocks in PIONE language.
|
28
|
+
BLOCKS = [
|
29
|
+
:param_block,
|
30
|
+
:flow_rule_block,
|
31
|
+
:action_rule_block,
|
32
|
+
:empty_rule_block
|
33
|
+
]
|
34
|
+
|
35
|
+
# +declarative_sentence+ match all declarative sentences.
|
36
|
+
rule(:declarative_sentence) {
|
37
|
+
SENTENCES.inject(nil) {|res, elt| res ? res | send(elt) : send(elt)}
|
38
|
+
}
|
39
|
+
|
40
|
+
# +declarative_block+ match all declarative blocks.
|
41
|
+
rule(:declarative_block) {
|
42
|
+
BLOCKS.inject(nil) {|res, elt| res ? res | send(elt) : send(elt)}
|
43
|
+
}
|
44
|
+
|
45
|
+
# +declaration+ match all declarations.
|
46
|
+
rule(:declaration) { declarative_sentence | declarative_block }
|
47
|
+
|
48
|
+
#
|
49
|
+
# sentences
|
50
|
+
#
|
51
|
+
|
52
|
+
# Make a parser for binding sentences.
|
53
|
+
def binding_sentence(declarator, operator, omittable)
|
54
|
+
binding = expr.as(:expr1) >> padded?(operator) >> expr!.as(:expr2)
|
55
|
+
|
56
|
+
if omittable
|
57
|
+
line((declarator.as(:declarator) >> pad).maybe >> binding)
|
58
|
+
else
|
59
|
+
line(declarator.as(:declarator) >> pad >> binding)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# +variable_binding_sentence+ matches variable binding declarations.
|
64
|
+
rule(:variable_binding_sentence) {
|
65
|
+
binding_sentence(keyword_bind, binding_operator!, true).as(:variable_binding_sentence)
|
66
|
+
}
|
67
|
+
|
68
|
+
# +package_binding_sentence+ matches all package binding setences.
|
69
|
+
rule(:package_binding_sentence) {
|
70
|
+
binding_sentence(keyword_package, generating_operator!, false).as(:package_binding_sentence)
|
71
|
+
}
|
72
|
+
|
73
|
+
# +param_sentence+ matches parameter declarations.
|
74
|
+
rule(:param_sentence) {
|
75
|
+
type = (keyword_basic | keyword_advanced).as(:type)
|
76
|
+
with_default = expr.as(:expr1) >> padded?(binding_operator) >> expr!.as(:expr2)
|
77
|
+
without_default = expr.as(:expr1)
|
78
|
+
|
79
|
+
line(((type >> pad).maybe >> keyword_param.as(:declarator) >> pad >> (with_default | without_default)).as(:param_sentence))
|
80
|
+
}
|
81
|
+
|
82
|
+
# +rule_binding_sentence+ matches rule binding declarations.
|
83
|
+
rule(:rule_binding_sentence) {
|
84
|
+
binding_sentence(keyword_rule, binding_operator, false).as(:rule_binding_sentence)
|
85
|
+
}
|
86
|
+
|
87
|
+
# +constituent_sentence+ matches constituent rule declarations.
|
88
|
+
rule(:constituent_rule_sentence) {
|
89
|
+
line(keyword_rule.as(:declarator) >> pad >> expr!.as(:expr)).as(:constituent_rule_sentence)
|
90
|
+
}
|
91
|
+
|
92
|
+
# +input_sentence+ matches input condition declarations.
|
93
|
+
rule(:input_sentence) {
|
94
|
+
line(keyword_input.as(:declarator) >> pad >> expr!.as(:expr)).as(:input_sentence)
|
95
|
+
}
|
96
|
+
|
97
|
+
# +output_sentence+ matches output condition declarations.
|
98
|
+
rule(:output_sentence) {
|
99
|
+
line(keyword_output.as(:declarator) >> pad >> expr!.as(:expr)).as(:output_sentence)
|
100
|
+
}
|
101
|
+
|
102
|
+
# +feature_sentence+ matches feature declarations.
|
103
|
+
rule(:feature_sentence) {
|
104
|
+
line(keyword_feature.as(:declarator) >> pad >> expr!.as(:expr)).as(:feature_sentence)
|
105
|
+
}
|
106
|
+
|
107
|
+
# +constraint_sentence+ matches constraint declarations.
|
108
|
+
rule(:constraint_sentence) {
|
109
|
+
line(keyword_constraint.as(:declarator) >> pad >> expr!.as(:expr)).as(:constraint_sentence)
|
110
|
+
}
|
111
|
+
|
112
|
+
# +annotation_sentence+ matches annotation declarations.
|
113
|
+
rule(:annotation_sentence) {
|
114
|
+
line((dot >> atmark).as(:declarator) >> pad >> expr!.as(:expr)).as(:annotation_sentence)
|
115
|
+
}
|
116
|
+
|
117
|
+
# +expr_sentence+ matches expression declarations(maybe this is ignored in normal contexts).
|
118
|
+
rule(:expr_sentence) {
|
119
|
+
( line(question.as(:declarator) >> pad? >> expr!.as(:expr)) |
|
120
|
+
line(expr.as(:expr))
|
121
|
+
).as(:expr_sentence)
|
122
|
+
}
|
123
|
+
|
124
|
+
#
|
125
|
+
# blocks
|
126
|
+
#
|
127
|
+
|
128
|
+
# +param_block+ matches parameter declarations.
|
129
|
+
rule(:param_block) {
|
130
|
+
(param_block_header >> param_context.as(:context) >> param_block_footer!).as(:param_block)
|
131
|
+
}
|
132
|
+
|
133
|
+
# +param_block_header+ matches parameter block headers.
|
134
|
+
rule(:param_block_header) {
|
135
|
+
line((param_block_modifier.as(:type) >> space).maybe >> keyword_Param.as(:declarator))
|
136
|
+
}
|
137
|
+
|
138
|
+
# +param_block_modifier+ matches all parameter block modifiers.
|
139
|
+
rule(:param_block_modifier) { keyword_Basic | keyword_Advanced }
|
140
|
+
|
141
|
+
# +param_block_footer+ matches parameter declaration block footer.
|
142
|
+
rule(:param_block_footer) { line(keyword_End) }
|
143
|
+
rule(:param_block_footer!) { param_block_footer.or_error("it should be parameter block end") }
|
144
|
+
|
145
|
+
# +flow_rule_block+ matches flow rule declarations.
|
146
|
+
rule(:flow_rule_block) {
|
147
|
+
( rule_header >> rule_condition_context.as(:context1) >>
|
148
|
+
line(keyword_Flow) >> flow_context.as(:context2) >> rule_footer!
|
149
|
+
).as(:flow_rule_block)
|
150
|
+
}
|
151
|
+
|
152
|
+
# +action_rule_block+ matches action rule declarations.
|
153
|
+
rule(:action_rule_block) {
|
154
|
+
( rule_header >> rule_condition_context.as(:context1) >>
|
155
|
+
line(keyword_Action) >> action_context.as(:context2) >> rule_footer!
|
156
|
+
).as(:action_rule_block)
|
157
|
+
}
|
158
|
+
|
159
|
+
# +empty_rule_block+ matches empty rule declarations.
|
160
|
+
rule(:empty_rule_block) {
|
161
|
+
(rule_header >> rule_condition_context.as(:context) >> rule_footer!).as(:empty_rule_block)
|
162
|
+
}
|
163
|
+
|
164
|
+
# +rule_header+ matches rule headers.
|
165
|
+
rule(:rule_header) {
|
166
|
+
line(keyword_Rule.as(:declarator) >> space >> expr!("should be rule name").as(:expr))
|
167
|
+
}
|
168
|
+
|
169
|
+
# +rule_footer+ matches rule end keywords.
|
170
|
+
rule(:rule_footer) { line(keyword_End) }
|
171
|
+
rule(:rule_footer!) { rule_footer.or_error("rule footer not found") }
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
module Pione
|
2
|
+
module Lang
|
3
|
+
# DeclarationTransformer is a transformer for all declarations.
|
4
|
+
module DeclarationTransformer
|
5
|
+
include Util::ParsletTransformerModule
|
6
|
+
|
7
|
+
#
|
8
|
+
# sentences
|
9
|
+
#
|
10
|
+
|
11
|
+
# Transform +variable_binding_sentence+ into +Lang::VariableBindingDeclaration+.
|
12
|
+
rule(:variable_binding_sentence => subtree(:tree)) {
|
13
|
+
Lang::VariableBindingDeclaration.new(tree[:expr1], tree[:expr2]).tap do |declaration|
|
14
|
+
line, col = (tree[:declarator] || tree[:expr1]).line_and_column
|
15
|
+
declaration.set_source_position(package_name, filename, line, col)
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
# Transform +package_binding_sentence+ into +Lang::PackageBindingDeclaration+.
|
20
|
+
rule(:package_binding_sentence => subtree(:tree)) {
|
21
|
+
Lang::PackageBindingDeclaration.new(tree[:expr1], tree[:expr2]).tap do |declaration|
|
22
|
+
line, col = tree[:declarator].line_and_column
|
23
|
+
declaration.set_source_position(package_name, filename, line, col)
|
24
|
+
end
|
25
|
+
}
|
26
|
+
|
27
|
+
# Transform +param_sentence+ into +Lang::ParamDeclaration+.
|
28
|
+
rule(:param_sentence => subtree(:tree)) {
|
29
|
+
type = (tree[:type] || "basic").to_sym
|
30
|
+
|
31
|
+
Lang::ParamDeclaration.new(type, tree[:expr1], tree[:expr2]).tap do |declaration|
|
32
|
+
line, col = (tree[:type] || tree[:declarator]).line_and_column
|
33
|
+
declaration.set_source_position(package_name, filename, line, col)
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
# Transform +rule_binding_sentence+ into +Lang::RuleBindingDeclaration+.
|
38
|
+
rule(:rule_binding_sentence => subtree(:tree)) {
|
39
|
+
Lang::RuleBindingDeclaration.new(tree[:expr1], tree[:expr2]).tap do |declaration|
|
40
|
+
line, col = tree[:declarator].line_and_column
|
41
|
+
declaration.set_source_position(package_name, filename, line, col)
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
# Transform +constituent_rule_sentence+ into +Lang::ConstituentRuleDeclaration+.
|
46
|
+
rule(:constituent_rule_sentence => subtree(:tree)) {
|
47
|
+
Lang::ConstituentRuleDeclaration.new(tree[:expr]).tap do |declaration|
|
48
|
+
line, col = tree[:declarator].line_and_column
|
49
|
+
declaration.set_source_position(package_name, filename, line, col)
|
50
|
+
end
|
51
|
+
}
|
52
|
+
|
53
|
+
# Transform +:input_sentence+ into +Lang::InputDeclaration+.
|
54
|
+
rule(:input_sentence => subtree(:tree)) {
|
55
|
+
Lang::InputDeclaration.new(tree[:expr]).tap do |declaration|
|
56
|
+
line, col = tree[:declarator].line_and_column
|
57
|
+
declaration.set_source_position(package_name, filename, line, col)
|
58
|
+
end
|
59
|
+
}
|
60
|
+
|
61
|
+
# Transform +output_sentence+ into +Lang::OutputDeclaration+.
|
62
|
+
rule(:output_sentence => subtree(:tree)) {
|
63
|
+
Lang::OutputDeclaration.new(tree[:expr]).tap do |declaration|
|
64
|
+
line, col = tree[:declarator].line_and_column
|
65
|
+
declaration.set_source_position(package_name, filename, line, col)
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
69
|
+
# Transform +feature_sentence+ into +Lang::FeatureDeclaration+.
|
70
|
+
rule(:feature_sentence => subtree(:tree)) {
|
71
|
+
Lang::FeatureDeclaration.new(tree[:expr]).tap do |declaration|
|
72
|
+
line, col = tree[:declarator].line_and_column
|
73
|
+
declaration.set_source_position(package_name, filename, line, col)
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
77
|
+
# Transform +constraint_sentence+ into +Lang::ConstraintDeclaration+.
|
78
|
+
rule(:constraint_sentence => subtree(:tree)) {
|
79
|
+
Lang::ConstraintDeclaration.new(tree[:expr]).tap do |declaration|
|
80
|
+
line, col = tree[:declarator].line_and_column
|
81
|
+
declaration.set_source_position(package_name, filename, line, col)
|
82
|
+
end
|
83
|
+
}
|
84
|
+
|
85
|
+
# Transform +annotation_sentence+ into +Lang::AnnotationDeclaration+.
|
86
|
+
rule(:annotation_sentence => subtree(:tree)) {
|
87
|
+
Lang::AnnotationDeclaration.new(tree[:expr]).tap do |declaration|
|
88
|
+
line, col = tree[:declarator].line_and_column
|
89
|
+
declaration.set_source_position(package_name, filename, line, col)
|
90
|
+
end
|
91
|
+
}
|
92
|
+
|
93
|
+
# Transform +expr_sentence+ into +Lang::ExprDeclaration+.
|
94
|
+
rule(:expr_sentence => subtree(:tree)) {
|
95
|
+
Lang::ExprDeclaration.new(tree[:expr]).tap do |declaration|
|
96
|
+
line, col = (tree[:declarator] || tree[:expr]).line_and_column
|
97
|
+
declaration.set_source_position(package_name, filename, line, col)
|
98
|
+
end
|
99
|
+
}
|
100
|
+
|
101
|
+
#
|
102
|
+
# blocks
|
103
|
+
#
|
104
|
+
|
105
|
+
# Transform +param_block+ into +Lang::ParamBlock+.
|
106
|
+
rule(:param_block => subtree(:tree)) {
|
107
|
+
type = (tree[:type] || "basic").to_s.downcase.to_sym
|
108
|
+
context = tree[:context].set(type: type)
|
109
|
+
|
110
|
+
Lang::ParamBlockDeclaration.new(type, context).tap do |declaration|
|
111
|
+
line, col = (tree[:type] || tree[:declarator]).line_and_column
|
112
|
+
declaration.set_source_position(package_name, filename, line, col)
|
113
|
+
end
|
114
|
+
}
|
115
|
+
|
116
|
+
# Transform +flow_rule_block+ into +Lang::FlowRuleDeclaration+.
|
117
|
+
rule(:flow_rule_block => subtree(:tree)) {
|
118
|
+
expr = tree[:expr]
|
119
|
+
condition_context = tree[:context1]
|
120
|
+
flow_context = tree[:context2]
|
121
|
+
|
122
|
+
Lang::FlowRuleDeclaration.new(expr, condition_context, flow_context).tap do |declaration|
|
123
|
+
line, col = tree[:declarator].line_and_column
|
124
|
+
declaration.set_source_position(package_name, filename, line, col)
|
125
|
+
end
|
126
|
+
}
|
127
|
+
|
128
|
+
# Transform +action_rule_block+ into +Lang::ActionRuleDeclaration+.
|
129
|
+
rule(:action_rule_block => subtree(:tree)) {
|
130
|
+
expr = tree[:expr]
|
131
|
+
condition_context = tree[:context1]
|
132
|
+
action_context = tree[:context2]
|
133
|
+
|
134
|
+
Lang::ActionRuleDeclaration.new(expr, condition_context, action_context).tap do |declaration|
|
135
|
+
line, col = tree[:declarator].line_and_column
|
136
|
+
declaration.set_source_position(package_name, filename, line, col)
|
137
|
+
end
|
138
|
+
}
|
139
|
+
|
140
|
+
# Transform +empty_rule_block+ into +Lang::EmptyRuleDeclaration+.
|
141
|
+
rule(:empty_rule_block => subtree(:tree)) {
|
142
|
+
expr = tree[:expr]
|
143
|
+
condition_context = tree[:context]
|
144
|
+
|
145
|
+
Lang::EmptyRuleDeclaration.new(expr, condition_context).tap do |declaration|
|
146
|
+
line, col = tree[:declarator].line_and_column
|
147
|
+
declaration.set_source_position(package_name, filename, line, col)
|
148
|
+
end
|
149
|
+
}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
@@ -0,0 +1,322 @@
|
|
1
|
+
module Pione
|
2
|
+
module Lang
|
3
|
+
# Declaration is a base class for all declarations.
|
4
|
+
class Declaration < StructX
|
5
|
+
include Util::Positionable
|
6
|
+
immutable true
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def inherited(cls)
|
10
|
+
members.each {|member_name| subclass.member(member_name, default: default_values[member_name])}
|
11
|
+
immutable true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def eval!(env)
|
16
|
+
eval(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Get reference object. If it has no package id, set current package id in
|
22
|
+
# the environment.
|
23
|
+
def get_reference(env, name, expected)
|
24
|
+
# evaluate the name expression if it has unexpected type
|
25
|
+
# e.g. "$p.var($x) := 1"
|
26
|
+
unless name.is_a?(expected)
|
27
|
+
name = name.eval(env)
|
28
|
+
|
29
|
+
# raise error if it has unexpected type
|
30
|
+
unless name.is_a?(expected)
|
31
|
+
raise StructuralError.new(expected, name.pos)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# set current package id if it has no package id
|
36
|
+
if name.is_a?(Sequence)
|
37
|
+
name.map {|piece| piece.package_id ? piece : piece.set(package_id: env.current_package_id)}
|
38
|
+
else
|
39
|
+
name.package_id ? name : name.set(package_id: env.current_package_id)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get the package id.
|
44
|
+
def get_package_id(env, name)
|
45
|
+
if package_id = name.package_id
|
46
|
+
# get package id from the name
|
47
|
+
return package_id
|
48
|
+
else
|
49
|
+
# or current package id in the environment
|
50
|
+
return env.current_package_id
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# VariableBindingDeclaration is a declaration for binding variable to expression.
|
56
|
+
class VariableBindingDeclaration < Declaration
|
57
|
+
member :expr1 # variable name
|
58
|
+
member :expr2 # bound expression
|
59
|
+
|
60
|
+
# Update variable table in the environment with the variable and bound
|
61
|
+
# expression. We expect +expr1+ is a variable or variable generating
|
62
|
+
# expression.
|
63
|
+
def eval(env)
|
64
|
+
var = get_reference(env, expr1, Variable)
|
65
|
+
val = expr2
|
66
|
+
|
67
|
+
# update variable table
|
68
|
+
env.variable_set(var, val)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# PackageBindingDeclaration is a declaration for package binding sentences.
|
73
|
+
class PackageBindingDeclaration < Declaration
|
74
|
+
member :expr1 # variable name
|
75
|
+
member :expr2 # expression for generating new package
|
76
|
+
|
77
|
+
# Update variable table and package table.
|
78
|
+
def eval(env)
|
79
|
+
# variable name
|
80
|
+
var = get_reference(env, expr1, Variable)
|
81
|
+
|
82
|
+
# check the parent package
|
83
|
+
parent_package = expr2.eval(env)
|
84
|
+
|
85
|
+
# evaluate expr2 and get new package instance
|
86
|
+
child_pieces = parent_package.pieces.map do |parent_piece|
|
87
|
+
# definition of parent package
|
88
|
+
parent_definition = env.package_get(parent_piece)
|
89
|
+
# generate new id
|
90
|
+
child_id = Util::PackageID.generate(env, parent_piece.name)
|
91
|
+
# validate parameter set
|
92
|
+
parent_piece.param.pieces.each do |param_piece|
|
93
|
+
param_piece.table.keys do |key|
|
94
|
+
unless parent_definition.param_definition.has_key?(key.name)
|
95
|
+
raise ParamError.new(key.name, parent_piece.package_id)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
# update package table
|
100
|
+
definition = PackageDefinition.new(
|
101
|
+
package_id: child_id,
|
102
|
+
parent_ids: [parent_piece.package_id],
|
103
|
+
param_definition: parent_definition.param_definition,
|
104
|
+
param: parent_definition.param.merge(parent_piece.param)
|
105
|
+
)
|
106
|
+
# create child piece
|
107
|
+
child_piece = parent_piece.set(package_id: child_id, parent_ids: [parent_piece.package_id])
|
108
|
+
# register the child to package table
|
109
|
+
env.package_set(child_piece, definition)
|
110
|
+
# result
|
111
|
+
child_piece
|
112
|
+
end
|
113
|
+
child_package = PackageExprSequence.of(*child_pieces)
|
114
|
+
|
115
|
+
# update variable table with the result
|
116
|
+
VariableBindingDeclaration.new(var, child_package).eval(env)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# ParamDeclaration is a declaration thae the parameter is neeeded.
|
121
|
+
class ParamDeclaration < Declaration
|
122
|
+
member :type # basic/advanced
|
123
|
+
member :expr1 # variable name
|
124
|
+
member :expr2 # default expression
|
125
|
+
|
126
|
+
def set_type(new_type)
|
127
|
+
set(type: new_type)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Add the parameter in current rule definition.
|
131
|
+
def eval(env)
|
132
|
+
# get variable
|
133
|
+
var = get_reference(env, expr1, Variable)
|
134
|
+
|
135
|
+
# we don't permit to declare parameters of other packages
|
136
|
+
if not(var.package_id.nil?) and var.package_id != env.current_package_id
|
137
|
+
raise ParamDeclarationError.new(self)
|
138
|
+
end
|
139
|
+
|
140
|
+
# get the value(don't evaluate in this time)
|
141
|
+
default_val = expr2
|
142
|
+
|
143
|
+
begin
|
144
|
+
env.variable_get(var)
|
145
|
+
rescue UnboundError
|
146
|
+
# bind default value
|
147
|
+
env.variable_set(var, default_val)
|
148
|
+
end
|
149
|
+
|
150
|
+
param = ParameterDefinition.new(type, var.name, default_val)
|
151
|
+
|
152
|
+
# select target definition
|
153
|
+
definition = nil
|
154
|
+
if env.current_definition
|
155
|
+
# in rule definition context
|
156
|
+
definition = env.current_definition
|
157
|
+
else
|
158
|
+
# in package context
|
159
|
+
definition = env.package_get(PackageExpr.new(package_id: var.package_id))
|
160
|
+
end
|
161
|
+
|
162
|
+
if definition.param_definition[var.name]
|
163
|
+
raise RebindError.new(var)
|
164
|
+
else
|
165
|
+
definition.param_definition[var.name] = param
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# RuleBindingDeclaration is a declaration for rule binding stentences.
|
171
|
+
class RuleBindingDeclaration < Declaration
|
172
|
+
member :expr1 # new rule name
|
173
|
+
member :expr2 # referent
|
174
|
+
|
175
|
+
# Update rule table with the rule name and reference definition.
|
176
|
+
# e.g. "rule A := B"
|
177
|
+
def eval(env)
|
178
|
+
# rule name
|
179
|
+
refs = get_reference(env, expr1, RuleExprSequence)
|
180
|
+
|
181
|
+
refs.pieces.each do |ref|
|
182
|
+
referents = expr2.eval!(env)
|
183
|
+
referents.pieces.each do |referent|
|
184
|
+
# merge param sets
|
185
|
+
definition = env.rule_get_value(referent)
|
186
|
+
param_sets = definition.param_sets.merge(referent.param_sets)
|
187
|
+
_referent = referent.set(param_sets: param_sets)
|
188
|
+
|
189
|
+
# update rule table
|
190
|
+
env.rule_set(ref, _referent)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# ConstituentRuleDeclaration is a declaration for constituent rule sentences.
|
197
|
+
class ConstituentRuleDeclaration < Declaration
|
198
|
+
member :expr
|
199
|
+
|
200
|
+
# Append the constituent rule to the current definition.
|
201
|
+
def eval(env)
|
202
|
+
env.current_definition.rules += expr.eval!(env)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# InputDeclaration is a declaration for input condition sentences.
|
207
|
+
class InputDeclaration < Declaration
|
208
|
+
member :expr
|
209
|
+
|
210
|
+
# Append the input condition to the current definition.
|
211
|
+
def eval(env)
|
212
|
+
env.current_definition.inputs << expr
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# OutputDeclaration is a declaration for output condition sentences.
|
217
|
+
class OutputDeclaration < Declaration
|
218
|
+
member :expr
|
219
|
+
|
220
|
+
# Append the output condition to the current definition.
|
221
|
+
def eval(env)
|
222
|
+
env.current_definition.outputs << expr
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
class FeatureDeclaration < Declaration
|
227
|
+
member :expr
|
228
|
+
|
229
|
+
def eval(env)
|
230
|
+
env.current_definition.features << expr
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
class ConstraintDeclaration < Declaration
|
235
|
+
member :expr
|
236
|
+
|
237
|
+
def eval(env)
|
238
|
+
env.current_definition.constraints << expr
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
class AnnotationDeclaration < Declaration
|
243
|
+
member :expr
|
244
|
+
|
245
|
+
def eval(env)
|
246
|
+
env.current_definition.annotations << expr.eval(env)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
class ExprDeclaration < Declaration
|
251
|
+
member :expr
|
252
|
+
|
253
|
+
# Return evaluation result of the value.
|
254
|
+
def eval(env)
|
255
|
+
expr.eval(env)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
class ParamBlockDeclaration < Declaration
|
260
|
+
member :type
|
261
|
+
member :context
|
262
|
+
|
263
|
+
def eval(env)
|
264
|
+
context.eval(env)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
class FlowRuleDeclaration < Declaration
|
269
|
+
member :expr # rule name
|
270
|
+
member :rule_condition_context # rule condition context
|
271
|
+
member :flow_context # flow context
|
272
|
+
|
273
|
+
def eval(env)
|
274
|
+
rules = get_reference(env, expr, RuleExprSequence)
|
275
|
+
rules.pieces.each do |piece|
|
276
|
+
ref = piece.set(package_id: get_package_id(env, piece))
|
277
|
+
|
278
|
+
definition = FlowRuleDefinition.new(
|
279
|
+
rule_condition_context: rule_condition_context,
|
280
|
+
flow_context: flow_context
|
281
|
+
)
|
282
|
+
|
283
|
+
env.rule_set(ref, definition)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
class ActionRuleDeclaration < Declaration
|
289
|
+
member :expr # rule name
|
290
|
+
member :condition_context # rule condition context
|
291
|
+
member :action_context # action context
|
292
|
+
|
293
|
+
def eval(env)
|
294
|
+
rules = get_reference(env, expr, RuleExprSequence)
|
295
|
+
rules.pieces.each do |piece|
|
296
|
+
ref = piece.set(package_id: get_package_id(env, piece))
|
297
|
+
|
298
|
+
definition = ActionRuleDefinition.new(
|
299
|
+
rule_condition_context: condition_context,
|
300
|
+
action_context: action_context
|
301
|
+
)
|
302
|
+
|
303
|
+
env.rule_set(ref, definition)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
class EmptyRuleDeclaration < Declaration
|
309
|
+
member :expr # rule name
|
310
|
+
member :condition_context # rule condition context
|
311
|
+
|
312
|
+
def eval(env)
|
313
|
+
rules = get_reference(env, expr, RuleExprSequence)
|
314
|
+
rules.pieces.each do |piece|
|
315
|
+
ref = piece.set(package_id: get_package_id(env, piece))
|
316
|
+
definition = EmptyRuleDefinition.new(condition_context)
|
317
|
+
env.rule_set(ref, definition)
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|