pione 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/History.txt +9 -2
  2. data/Rakefile +1 -1
  3. data/example/Fib/Fib.pione +5 -5
  4. data/example/SequentialProcess/SequentialProcess.pione +69 -0
  5. data/lib/pione.rb +7 -11
  6. data/lib/pione/agent/input-generator.rb +3 -2
  7. data/lib/pione/agent/task-worker.rb +6 -3
  8. data/lib/pione/agent/trivial-routine-worker.rb +6 -5
  9. data/lib/pione/command/basic-command.rb +7 -1
  10. data/lib/pione/command/child-process.rb +5 -1
  11. data/lib/pione/command/front-owner-command.rb +15 -4
  12. data/lib/pione/command/pione-client.rb +16 -9
  13. data/lib/pione/command/pione-syntax-checker.rb +45 -30
  14. data/lib/pione/command/pione-task-worker.rb +22 -13
  15. data/lib/pione/command/pione-tuple-space-provider.rb +4 -2
  16. data/lib/pione/command/pione-tuple-space-receiver.rb +10 -5
  17. data/lib/pione/front/task-worker-owner.rb +1 -0
  18. data/lib/pione/model/basic-model.rb +3 -0
  19. data/lib/pione/model/block.rb +2 -1
  20. data/lib/pione/model/call-rule.rb +10 -0
  21. data/lib/pione/model/feature-expr.rb +143 -54
  22. data/lib/pione/model/float.rb +0 -1
  23. data/lib/pione/model/rule-expr.rb +132 -7
  24. data/lib/pione/model/rule.rb +53 -17
  25. data/lib/pione/model/ticket-expr.rb +124 -0
  26. data/lib/pione/parser/expr-parser.rb +75 -38
  27. data/lib/pione/parser/literal-parser.rb +14 -0
  28. data/lib/pione/parser/parslet-extension.rb +143 -0
  29. data/lib/pione/rule-handler/flow-handler.rb +33 -3
  30. data/lib/pione/system/global.rb +10 -3
  31. data/lib/pione/transformer.rb +24 -0
  32. data/lib/pione/transformer/block-transformer.rb +6 -5
  33. data/lib/pione/transformer/document-transformer.rb +5 -10
  34. data/lib/pione/transformer/expr-transformer.rb +56 -30
  35. data/lib/pione/transformer/feature-expr-transformer.rb +9 -5
  36. data/lib/pione/transformer/flow-element-transformer.rb +21 -23
  37. data/lib/pione/transformer/literal-transformer.rb +39 -35
  38. data/lib/pione/transformer/rule-definition-transformer.rb +8 -6
  39. data/lib/pione/transformer/transformer-module.rb +7 -5
  40. data/lib/pione/tuple/ticket-tuple.rb +8 -0
  41. data/lib/pione/util/{message.rb → console-message.rb} +54 -26
  42. data/lib/pione/version.rb +1 -1
  43. data/pione.gemspec +2 -1
  44. data/test/model/spec_feature-expr.rb +18 -3
  45. data/test/model/spec_feature-expr.yml +28 -16
  46. data/test/model/spec_ticket-expr.rb +67 -0
  47. data/test/parser/spec_expr-parser.yml +74 -25
  48. data/test/parser/spec_literal-parser.yml +11 -0
  49. data/test/test-util.rb +1 -1
  50. data/test/transformer/spec_expr-transformer.rb +27 -54
  51. data/test/transformer/spec_literal-transformer.rb +6 -0
  52. metadata +29 -7
  53. data/lib/pione/parser/syntax-error.rb +0 -61
@@ -13,27 +13,29 @@ expr_operator:
13
13
  - "*"
14
14
  - "%"
15
15
  - "/"
16
+ - ">>>"
17
+ - "==>"
16
18
  expr_operator_application:
17
19
  valid:
18
- - true == true
19
- - true != false
20
- - 10 >= 1
21
- - 1 <= 10
22
- - 10 > 1
23
- - 1 < 10
24
- - true && true
25
- - true || false
26
- - 1 + 1
27
- - 1 - 1
28
- - 1 * 1
29
- - 1 % 1
30
- - 1 / 1
20
+ - "true == true"
21
+ - "true != false"
22
+ - "10 >= 1"
23
+ - "1 <= 10"
24
+ - "10 > 1"
25
+ - "1 < 10"
26
+ - "true && true"
27
+ - "true || false"
28
+ - "1 + 1"
29
+ - "1 - 1"
30
+ - "1 * 1"
31
+ - "1 % 1"
32
+ - "1 / 1"
31
33
  message:
32
34
  valid:
33
- - .abc(1)
34
- - .sync
35
- - .abc(1, "s", '*.txt')
36
- - .abc(1.0.abc(3.def))
35
+ - ".abc(1)"
36
+ - ".sync"
37
+ - ".abc(1, \"s\", '*.txt')"
38
+ - ".abc(1.0.abc(3.def))"
37
39
  rule_expr:
38
40
  valid:
39
41
  - "&package:rule_name"
@@ -63,20 +65,67 @@ index:
63
65
  - "[1,1]"
64
66
  - "[1,2,3]"
65
67
  - "[1, 2, 3]"
68
+ - "[\"a\"]"
69
+ - "[\"a\", \"b\"]"
70
+ - "[\"a\", \"b\", \"c\"]"
71
+ - "[1,\n2]"
66
72
  invalid:
67
73
  - "[]"
68
- - "[1,\n2]"
69
74
  expr:
70
75
  valid:
71
76
  - "1"
72
- - (1)
77
+ - "(1)"
73
78
  - '"a" == "a"'
74
79
  - '"a" != "b"'
75
- - true && true
76
- - true || false
77
- - ($Var1 == "a") && ($Var2 == "b")
78
- - ($Var1 == "a") || $Var2
79
- - ($Var1 == ($Var2 == "a"))
80
- - true == true == true
80
+ - "true && true"
81
+ - "true || false"
82
+ - '($Var1 == "a") && ($Var2 == "b")'
83
+ - '($Var1 == "a") || $Var2'
84
+ - '($Var1 == ($Var2 == "a"))'
85
+ - "true == true == true"
86
+ # message
87
+ - 'abc.a'
88
+ - 'abc.a.b'
89
+ - 'abc.a.b.c'
90
+ - 'abc.a("a").b("b").c("c")'
91
+ # index
81
92
  - "abc[1]"
93
+ - "abc[1,2]"
94
+ - "abc[1,2,3]"
95
+ - "abc[1][2]"
96
+ - "abc[1][2][3]"
97
+ - "abc[\"a\"]"
98
+ - "abc[\"a\", \"b\"]"
99
+ - "abc[\"a\", \"b\", \"c\"]"
100
+ - "abc[\"a\"][\"b\"]"
101
+ - "abc[\"a\"][\"b\"][\"c\"]"
102
+ - "abc [1]"
103
+ - "abc [1] [2]"
82
104
  - "1[1]"
105
+ # parameters
106
+ - "abc {}"
107
+ - "abc {A: 1}"
108
+ - "abc {A: 1, B: 2}"
109
+ - "abc{A:1}"
110
+ - "abc {A:1} {B:2}"
111
+ # reverse order method
112
+ - "not :: true"
113
+ - "not::true"
114
+ - 'author :: "test"'
115
+ - 'abc("def") :: "test"'
116
+ - "a :: (b)"
117
+ - "a :: (b :: c)"
118
+ - "a :: b :: c"
119
+ - "a :: b :: c :: d"
120
+ # complex form
121
+ - "abc[1].a"
122
+ - "abc.a[1]"
123
+ - "abc.a.b[1][2]"
124
+ - "abc[1].a"
125
+ - "abc[1].a.b[2]"
126
+ - "abc[1] {V:1}"
127
+ invalid:
128
+ - "(a) :: b"
129
+ - "(a :: b) :: c"
130
+ - "a :: (b :: c) :: d"
131
+
@@ -121,3 +121,14 @@ float:
121
121
  - '0.1a'
122
122
  - '0.a1'
123
123
  - '0.1e'
124
+ ticket:
125
+ valid:
126
+ - "<t>"
127
+ - "<T>"
128
+ - "<1>"
129
+ - "<Ticket>"
130
+ - "< T >"
131
+ - "<T >"
132
+ - "< T>"
133
+ invalid:
134
+ - "<a b>"
data/test/test-util.rb CHANGED
@@ -120,7 +120,7 @@ module TestUtil::Transformer
120
120
  testcases.instance_eval(&b)
121
121
  context.describe name do
122
122
  testcases.each do |tc|
123
- it "should get %s:%s%s" % [name, tc.string.include?("\n") ? "\n" : "", tc.string.chomp] do
123
+ it "should get %s:%s%s" % [name, tc.string.include?("\n") ? "\n" : " ", tc.string.chomp] do
124
124
  res = DocumentTransformer.new.apply(
125
125
  DocumentParser.new.send(parser).parse(tc.string)
126
126
  )
@@ -3,87 +3,57 @@ require_relative '../test-util'
3
3
  describe 'Pione::Transformer::ExprTransformer' do
4
4
  transformer_spec("binary operator", :expr) do
5
5
  tc "1 + 2" do
6
- BinaryOperator.new(
7
- "+",
8
- PioneInteger.new(1),
9
- PioneInteger.new(2)
10
- )
6
+ BinaryOperator.new("+", 1.to_pione, 2.to_pione)
11
7
  end
8
+
12
9
  tc '"a" + "b"' do
13
- BinaryOperator.new(
14
- "+",
15
- PioneString.new("a"),
16
- PioneString.new("b")
17
- )
10
+ BinaryOperator.new("+", "a".to_pione, "b".to_pione)
18
11
  end
12
+
19
13
  tc "false || true" do
20
- BinaryOperator.new(
21
- "||",
22
- PioneBoolean.false,
23
- PioneBoolean.true
24
- )
25
- end
26
- tc "$var * 3" do
27
- BinaryOperator.new(
28
- "*",
29
- Variable.new("var"),
30
- PioneInteger.new(3)
31
- )
14
+ BinaryOperator.new("||", PioneBoolean.false, PioneBoolean.true)
15
+ end
16
+
17
+ tc "$Var * 3" do
18
+ BinaryOperator.new("*", Variable.new("Var"), 3.to_pione)
32
19
  end
20
+
33
21
  tc "($Var1 == \"a\") && ($Var2 == \"b\")" do
34
- BinaryOperator.new(
35
- "&&",
36
- BinaryOperator.new(
37
- "==",
38
- Variable.new("Var1"),
39
- PioneString.new("a")
40
- ),
41
- BinaryOperator.new(
42
- "==",
43
- Variable.new("Var2"),
44
- PioneString.new("b")
45
- )
46
- )
22
+ left = BinaryOperator.new("==", Variable.new("Var1"), "a".to_pione)
23
+ right = BinaryOperator.new("==", Variable.new("Var2"), PioneString.new("b"))
24
+ BinaryOperator.new("&&", left, right)
47
25
  end
48
26
  end
49
27
 
50
28
  transformer_spec("message", :expr) do
51
29
  tc "1.next" do
52
- Message.new("next", PioneInteger.new(1))
30
+ Message.new("next", 1.to_pione)
53
31
  end
32
+
54
33
  tc "1.next.next" do
55
- Message.new(
56
- "next",
57
- Message.new("next", PioneInteger.new(1))
58
- )
34
+ Message.new("next", Message.new("next", 1.to_pione))
59
35
  end
36
+
60
37
  tc "\"abc\".index(1,1)" do
61
- Message.new(
62
- "index",
63
- PioneString.new("abc"),
64
- PioneInteger.new(1),
65
- PioneInteger.new(1)
66
- )
38
+ Message.new("index", "abc".to_pione, 1.to_pione, 1.to_pione)
67
39
  end
40
+
68
41
  tc "(1 + 2).prev" do
69
- Message.new(
70
- "prev",
71
- BinaryOperator.new(
72
- "+",
73
- PioneInteger.new(1),
74
- PioneInteger.new(2)
75
- )
76
- )
42
+ Message.new("prev", BinaryOperator.new("+", 1.to_pione, 2.to_pione))
77
43
  end
44
+
78
45
  tc "abc.sync" do
79
46
  Message.new("sync", RuleExpr.new(Package.new("main"), "abc"))
80
47
  end
48
+
81
49
  tc "'*.txt'.all" do
82
50
  Message.new("all", DataExpr.new("*.txt"))
83
51
  end
52
+
84
53
  tc "'*.txt'.all()" do
85
54
  Message.new("all", DataExpr.new("*.txt"))
86
55
  end
56
+
87
57
  tc "'*.txt'.all(true)" do
88
58
  Message.new("all", DataExpr.new("*.txt"), PioneBoolean.true)
89
59
  end
@@ -93,12 +63,15 @@ describe 'Pione::Transformer::ExprTransformer' do
93
63
  tc "{}" do
94
64
  Parameters.new({})
95
65
  end
66
+
96
67
  tc "{var1: 1}" do
97
68
  {"var1" => 1}.to_params
98
69
  end
70
+
99
71
  tc "{var1: 1, var2: 2}" do
100
72
  {"var1" => 1, "var2" => 2}.to_params
101
73
  end
74
+
102
75
  tc "{var1: \"a\", var2: \"b\", var3: \"c\"}" do
103
76
  {"var1" => "a", "var2" => "b", "var3" => "c"}.to_params
104
77
  end
@@ -55,4 +55,10 @@ describe 'Pione::Transformer::LiteralTransformer' do
55
55
  transformer_spec('rule_name', :rule_name) do
56
56
  tc("abc" => RuleExpr.new(Package.new("main"), "abc"))
57
57
  end
58
+
59
+ transformer_spec('ticket', :ticket) do
60
+ tc("<T>" => Ticket.new("T"))
61
+ tc("< T>" => Ticket.new("T"))
62
+ tc("<T >" => Ticket.new("T"))
63
+ end
58
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pione
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.4.0
21
+ version: 1.5.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.4.0
29
+ version: 1.5.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: uuidtools
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.6.15
62
+ - !ruby/object:Gem::Dependency
63
+ name: hamster
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.4'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.4'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: naming
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -271,6 +287,7 @@ files:
271
287
  - example/MakePair/data/3.i
272
288
  - example/MakePair/data/4.i
273
289
  - example/MakePair/data/5.i
290
+ - example/SequentialProcess/SequentialProcess.pione
274
291
  - example/SieveOfEratosthenes/SieveOfEratosthenes.pione
275
292
  - example/SingleParticlesWithRef/Makefile
276
293
  - example/SingleParticlesWithRef/SingleParticlesWithRef.Display2.pione
@@ -426,6 +443,7 @@ files:
426
443
  - lib/pione/model/rule-io.rb
427
444
  - lib/pione/model/rule.rb
428
445
  - lib/pione/model/string.rb
446
+ - lib/pione/model/ticket-expr.rb
429
447
  - lib/pione/model/undefined-value.rb
430
448
  - lib/pione/model/variable-table.rb
431
449
  - lib/pione/model/variable.rb
@@ -437,8 +455,8 @@ files:
437
455
  - lib/pione/parser/feature-expr-parser.rb
438
456
  - lib/pione/parser/flow-element-parser.rb
439
457
  - lib/pione/parser/literal-parser.rb
458
+ - lib/pione/parser/parslet-extension.rb
440
459
  - lib/pione/parser/rule-definition-parser.rb
441
- - lib/pione/parser/syntax-error.rb
442
460
  - lib/pione/patch/array-patch.rb
443
461
  - lib/pione/patch/drb-patch.rb
444
462
  - lib/pione/patch/monitor-patch.rb
@@ -467,6 +485,7 @@ files:
467
485
  - lib/pione/system/identifier.rb
468
486
  - lib/pione/system/init.rb
469
487
  - lib/pione/system/object.rb
488
+ - lib/pione/transformer.rb
470
489
  - lib/pione/transformer/block-transformer.rb
471
490
  - lib/pione/transformer/document-transformer.rb
472
491
  - lib/pione/transformer/expr-transformer.rb
@@ -501,14 +520,15 @@ files:
501
520
  - lib/pione/tuple/shift-tuple.rb
502
521
  - lib/pione/tuple/task-tuple.rb
503
522
  - lib/pione/tuple/task-worker-resource-tuple.rb
523
+ - lib/pione/tuple/ticket-tuple.rb
504
524
  - lib/pione/tuple/working-tuple.rb
505
525
  - lib/pione/uri-scheme/basic-scheme.rb
506
526
  - lib/pione/uri-scheme/broadcast-scheme.rb
507
527
  - lib/pione/uri-scheme/dropbox-scheme.rb
508
528
  - lib/pione/uri-scheme/local-scheme.rb
529
+ - lib/pione/util/console-message.rb
509
530
  - lib/pione/util/error-report.rb
510
531
  - lib/pione/util/log.rb
511
- - lib/pione/util/message.rb
512
532
  - lib/pione/util/misc.rb
513
533
  - lib/pione/util/terminal.rb
514
534
  - lib/pione/util/waiter-table.rb
@@ -547,6 +567,7 @@ files:
547
567
  - test/model/spec_rule-io.rb
548
568
  - test/model/spec_rule.rb
549
569
  - test/model/spec_string.rb
570
+ - test/model/spec_ticket-expr.rb
550
571
  - test/model/spec_variable-table.rb
551
572
  - test/model/spec_variable.rb
552
573
  - test/parser/spec_block-parser.rb
@@ -616,7 +637,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
616
637
  version: '0'
617
638
  segments:
618
639
  - 0
619
- hash: -1058953212253299218
640
+ hash: 1523774398215455370
620
641
  requirements: []
621
642
  rubyforge_project:
622
643
  rubygems_version: 1.8.24
@@ -650,6 +671,7 @@ test_files:
650
671
  - test/model/spec_rule-io.rb
651
672
  - test/model/spec_rule.rb
652
673
  - test/model/spec_string.rb
674
+ - test/model/spec_ticket-expr.rb
653
675
  - test/model/spec_variable-table.rb
654
676
  - test/model/spec_variable.rb
655
677
  - test/parser/spec_block-parser.rb
@@ -1,61 +0,0 @@
1
- module Pione
2
- module Parser
3
- # ParserError is raised when the parser finds syntax error.
4
- class ParserError < Parslet::ParseFailed
5
- # Creates an error.
6
- # @param [String] str
7
- # target string
8
- # @param [Array<String>] expected
9
- # expected names
10
- # @param [Parslet::Source] source
11
- # parser source
12
- def initialize(str, expected, source)
13
- @str = str
14
- @expected = expected
15
- @source = source
16
- super(str)
17
- end
18
-
19
- # @api private
20
- def message
21
- line, column = @source.line_and_column
22
- expected = @expected.join(", ")
23
- left = @source.consume(@source.chars_left)
24
- "%s(expected: %s, line: %s, column: %s):\n%s" % [
25
- @str, expected, line, column, left
26
- ]
27
- end
28
- end
29
-
30
- # @api private
31
- class SyntaxErrorAtom < Parslet::Atoms::Base
32
- def initialize(msg, expected_elements=[])
33
- @msg = msg
34
- @expected_elements = expected_elements
35
- end
36
-
37
- def try(source, context)
38
- raise ParserError.new(@msg, @expected_elements, source)
39
- end
40
-
41
- def to_s_inner(prec)
42
- "SYNTAX_ERROR"
43
- end
44
- end
45
-
46
- # SyntaxError provides notification methods for syntax error.
47
- module SyntaxError
48
- # Raises syntax error. This method returns a dummy atom and the parser
49
- # evaluates it as error.
50
- # @param [String] msg
51
- # error message
52
- # @param [Array<String>] expected_elements
53
- # expected name list
54
- # @return [SyntaxErrorAtom]
55
- # dummy atom for parser
56
- def syntax_error(msg, *expected_elements)
57
- SyntaxErrorAtom.new(msg, expected_elements)
58
- end
59
- end
60
- end
61
- end