pione 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/History.txt +12 -1
  2. data/example/AbstractRule/AbstractRule.pione +40 -0
  3. data/example/Fib/Fib.pione +12 -5
  4. data/example/LucasNumber/LucasNumber.pione +1 -1
  5. data/example/MakePair/MakePair.pione +21 -6
  6. data/example/OddSelector/OddSelector.pione +17 -0
  7. data/example/OddSelector/data/1.i +0 -0
  8. data/example/OddSelector/data/10.i +0 -0
  9. data/example/OddSelector/data/2.i +0 -0
  10. data/example/OddSelector/data/3.i +0 -0
  11. data/example/OddSelector/data/4.i +0 -0
  12. data/example/OddSelector/data/5.i +0 -0
  13. data/example/OddSelector/data/6.i +0 -0
  14. data/example/OddSelector/data/7.i +0 -0
  15. data/example/OddSelector/data/8.i +0 -0
  16. data/example/OddSelector/data/9.i +0 -0
  17. data/example/SequentialParameter/SequentialParameter.pione +4 -0
  18. data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +31 -43
  19. data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +1 -1
  20. data/example/Touch/Touch.pione +3 -0
  21. data/lib/pione/command/pione-syntax-checker.rb +4 -4
  22. data/lib/pione/model/assignment.rb +6 -1
  23. data/lib/pione/model/basic-model.rb +92 -278
  24. data/lib/pione/model/binary-operator.rb +5 -1
  25. data/lib/pione/model/block.rb +17 -0
  26. data/lib/pione/model/boolean.rb +54 -22
  27. data/lib/pione/model/constraints.rb +34 -0
  28. data/lib/pione/model/data-expr.rb +184 -297
  29. data/lib/pione/model/feature-expr.rb +13 -4
  30. data/lib/pione/model/float.rb +24 -41
  31. data/lib/pione/model/integer.rb +75 -41
  32. data/lib/pione/model/keyed-sequence.rb +143 -0
  33. data/lib/pione/model/list.rb +12 -8
  34. data/lib/pione/model/message.rb +8 -4
  35. data/lib/pione/model/ordinal-sequence.rb +75 -0
  36. data/lib/pione/model/package.rb +6 -2
  37. data/lib/pione/model/parameters.rb +61 -9
  38. data/lib/pione/model/pione-method.rb +146 -0
  39. data/lib/pione/model/rule-expr.rb +44 -38
  40. data/lib/pione/model/rule-io.rb +11 -3
  41. data/lib/pione/model/rule.rb +105 -155
  42. data/lib/pione/model/sequence.rb +273 -0
  43. data/lib/pione/model/string.rb +75 -29
  44. data/lib/pione/model/ticket-expr.rb +17 -29
  45. data/lib/pione/model/type.rb +242 -0
  46. data/lib/pione/model/variable-table.rb +52 -53
  47. data/lib/pione/model/variable.rb +8 -4
  48. data/lib/pione/model.rb +34 -0
  49. data/lib/pione/parser/block-parser.rb +44 -20
  50. data/lib/pione/parser/common-parser.rb +2 -1
  51. data/lib/pione/parser/document-parser.rb +6 -1
  52. data/lib/pione/parser/expr-parser.rb +57 -11
  53. data/lib/pione/parser/flow-element-parser.rb +2 -2
  54. data/lib/pione/parser/rule-definition-parser.rb +23 -1
  55. data/lib/pione/patch/rinda-patch.rb +1 -5
  56. data/lib/pione/rule-handler/action-handler.rb +5 -5
  57. data/lib/pione/rule-handler/basic-handler.rb +30 -7
  58. data/lib/pione/rule-handler/empty-handler.rb +14 -0
  59. data/lib/pione/rule-handler/flow-handler.rb +132 -115
  60. data/lib/pione/rule-handler/root-handler.rb +6 -2
  61. data/lib/pione/rule-handler/update-criteria.rb +152 -0
  62. data/lib/pione/rule-handler.rb +14 -0
  63. data/lib/pione/system/identifier.rb +9 -9
  64. data/lib/pione/transformer/block-transformer.rb +4 -0
  65. data/lib/pione/transformer/expr-transformer.rb +1 -1
  66. data/lib/pione/transformer/flow-element-transformer.rb +4 -2
  67. data/lib/pione/transformer/literal-transformer.rb +14 -3
  68. data/lib/pione/transformer/rule-definition-transformer.rb +17 -5
  69. data/lib/pione/tuple-space/data-finder.rb +15 -52
  70. data/lib/pione/version.rb +1 -1
  71. data/lib/pione.rb +12 -38
  72. data/test/agent/spec_task-worker.rb +13 -12
  73. data/test/model/spec_assignment.rb +2 -2
  74. data/test/model/spec_binary-operator.rb +10 -10
  75. data/test/model/spec_block.rb +8 -8
  76. data/test/model/spec_boolean.rb +1 -72
  77. data/test/model/spec_boolean.yml +134 -0
  78. data/test/model/spec_data-expr.rb +50 -237
  79. data/test/model/spec_data-expr.yml +16 -45
  80. data/test/model/spec_data-expr_match.yml +45 -0
  81. data/test/model/spec_feature-expr.rb +2 -43
  82. data/test/model/spec_feature-expr.yml +0 -28
  83. data/test/model/spec_feature-expr_decide.yml +28 -0
  84. data/test/model/spec_float.rb +1 -119
  85. data/test/model/spec_float.yml +17 -0
  86. data/test/model/spec_integer.rb +1 -119
  87. data/test/model/spec_integer.yml +57 -0
  88. data/test/model/spec_keyed-sequence.rb +5 -0
  89. data/test/model/spec_keyed-sequence.yml +22 -0
  90. data/test/model/spec_message.rb +7 -7
  91. data/test/model/spec_parameters.rb +50 -63
  92. data/test/model/spec_pione-method.rb +56 -0
  93. data/test/model/spec_rule-expr.rb +18 -8
  94. data/test/model/spec_rule.rb +12 -12
  95. data/test/model/spec_sequence.rb +5 -0
  96. data/test/model/spec_sequence.yml +60 -0
  97. data/test/model/spec_string.rb +3 -70
  98. data/test/model/spec_string.yml +83 -0
  99. data/test/model/spec_ticket-expr.rb +4 -54
  100. data/test/model/spec_ticket-expr.yml +11 -0
  101. data/test/model/spec_variable-table.rb +41 -42
  102. data/test/model/spec_variable.rb +20 -22
  103. data/test/parser/spec_block-parser.yml +9 -0
  104. data/test/parser/spec_expr-parser.yml +0 -17
  105. data/test/parser/spec_flow-element-parser.yml +1 -1
  106. data/test/parser/spec_rule-definition-parser.yml +0 -4
  107. data/test/rule-handler/spec_update-criteria.pione +39 -0
  108. data/test/rule-handler/spec_update-criteria.rb +53 -0
  109. data/test/rule-handler/spec_update-criteria.yml +158 -0
  110. data/test/test-util.rb +25 -0
  111. data/test/transformer/spec_block-transformer.rb +7 -0
  112. data/test/transformer/spec_expr-transformer.rb +64 -19
  113. data/test/transformer/spec_flow-element-transformer.rb +11 -11
  114. data/test/transformer/spec_literal-transformer.rb +29 -29
  115. data/test/transformer/spec_rule-definition-transformer.rb +39 -21
  116. metadata +57 -11
  117. data/lib/pione/model/undefined-value.rb +0 -24
  118. data/lib/pione/tuple-space/update-criteria.rb +0 -97
  119. data/test/model/spec_list.rb +0 -26
  120. data/test/model/spec_rule-io.rb +0 -32
  121. data/test/spec_update-criteria.rb +0 -83
@@ -1,7 +1,10 @@
1
1
  module Pione
2
2
  module Model
3
3
  # Parameters is a PIONE mode class for parameters.
4
- class Parameters < BasicModel
4
+ class Parameters < Callable
5
+ set_pione_model_type TypeParameters
6
+ include Enumerable
7
+
5
8
  # InvalidParameter is raised when you specify invalid parameter.
6
9
  class InvalidParameter < TypeError
7
10
  # Create a error.
@@ -59,7 +62,6 @@ module Pione
59
62
  end
60
63
 
61
64
  attr_reader :data
62
- set_pione_model_type TypeParameters
63
65
 
64
66
  # Create a parameters object.
65
67
  #
@@ -158,7 +160,7 @@ module Pione
158
160
  # @return [Parameters]
159
161
  # new parameters with the parameter
160
162
  def set_safety(name, value)
161
- if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
163
+ if not(@data.has_key?(name)) or @data[name].void?
162
164
  set(name, value)
163
165
  end
164
166
  end
@@ -171,7 +173,7 @@ module Pione
171
173
  # value
172
174
  # @return [void]
173
175
  def set_safety!(name, value)
174
- if not(@data.has_key?(name)) or @data[name].kind_of?(UndefinedValue)
176
+ if not(@data.has_key?(name)) or @data[name].void?
175
177
  set!(name, value)
176
178
  end
177
179
  end
@@ -208,7 +210,7 @@ module Pione
208
210
  when Parameters
209
211
  self.class.new(@data.merge(other.data))
210
212
  when Variable
211
- self.class.new(@data.merge({other => UndefinedValue.new}))
213
+ self.class.new(@data.merge({other => Sequence.void}))
212
214
  when Assignment
213
215
  self.class.new(@data.merge({other.variable => other.expr}))
214
216
  else
@@ -226,7 +228,7 @@ module Pione
226
228
  when Parameters
227
229
  @data.merge!(other.data)
228
230
  when Variable
229
- @data.merge!({other => UndefinedValue.new})
231
+ @data.merge!({other => Sequence.void})
230
232
  when Assignment
231
233
  @data.merge!({other.variable => other.expr})
232
234
  else
@@ -250,6 +252,47 @@ module Pione
250
252
  @data.keys.sort
251
253
  end
252
254
 
255
+ # Expand parameter value sequences.
256
+ #
257
+ # @yield [Parameters]
258
+ # sequences expanded parameters
259
+ # @return [void]
260
+ def each
261
+ array = @data.map do |k, v|
262
+ [k, (v.respond_to?(:each) and v.each?) ? v.each : v]
263
+ end
264
+ find_atomic_parameters_rec(array, Hamster.hash) do |table|
265
+ yield Parameters.new(table.reduce(Hash.new){|h, k, v| h[k] = v; h})
266
+ end
267
+ end
268
+
269
+ # Find atomic parameters recursively.
270
+ #
271
+ # @param array [Array]
272
+ # key and value associated list
273
+ # @param table [Hamster::Hash]
274
+ # immutable hash table
275
+ # @param b [Proc]
276
+ # the process executes when atomic parameters found
277
+ # @return [void]
278
+ def find_atomic_parameters_rec(array, table, &b)
279
+ if array.empty?
280
+ b.call(table)
281
+ else
282
+ key, enum = array.first
283
+ tail = array.drop(1)
284
+ loop do
285
+ if enum.kind_of?(Enumerator)
286
+ find_atomic_parameters_rec(tail, table.put(key, enum.next), &b)
287
+ else
288
+ find_atomic_parameters_rec(tail, table.put(key, enum), &b)
289
+ raise StopIteration
290
+ end
291
+ end
292
+ enum.rewind if enum.kind_of?(Enumerator)
293
+ end
294
+ end
295
+
253
296
  # @api private
254
297
  def string_form
255
298
  "{" + @data.map{|k,v| "#{k}: #{v}"}.join(", ") + "}"
@@ -274,6 +317,11 @@ module Pione
274
317
  end
275
318
  end
276
319
 
320
+ # class ParametersSequence < Sequence
321
+ # set_pione_model_type TypeParameters
322
+ # set_element_class Parameters
323
+ # end
324
+
277
325
  TypeParameters.instance_eval do
278
326
  define_pione_method('==', [TypeParameters], TypeBoolean) do |rec, other|
279
327
  PioneBoolean.new(rec.data == other.data)
@@ -283,17 +331,17 @@ module Pione
283
331
  PioneBoolean.not(rec.call_pione_method("==", other))
284
332
  end
285
333
 
286
- define_pione_method("[]", [TypeString], TypeAny) do |rec, name|
334
+ define_pione_method("[]", [TypeString], TypeSequence) do |rec, name|
287
335
  rec.get(Variable.new(name.value))
288
336
  end
289
337
 
290
- define_pione_method("get", [TypeString], TypeAny) do |rec, name|
338
+ define_pione_method("get", [TypeString], TypeSequence) do |rec, name|
291
339
  rec.get(Variable.new(name.value))
292
340
  end
293
341
 
294
342
  define_pione_method(
295
343
  "set",
296
- [TypeString, TypeAny],
344
+ [TypeString, TypeSequence],
297
345
  TypeParameters
298
346
  ) do |rec, name, val|
299
347
  rec.set(Variable.new(name.value), val)
@@ -306,6 +354,10 @@ module Pione
306
354
  define_pione_method("as_string", [], TypeString) do |rec|
307
355
  PioneString.new(rec.string_form)
308
356
  end
357
+
358
+ define_pione_method("str", [], TypeString) do |rec|
359
+ rec.call_pione_method("as_string")
360
+ end
309
361
  end
310
362
  end
311
363
  end
@@ -0,0 +1,146 @@
1
+ module Pione
2
+ module Model
3
+ # MethodInterfaceError is a exception for method interface mismatching.
4
+ class MethodInterfaceError < StandardError
5
+ attr_reader :kind
6
+ attr_reader :name
7
+ attr_reader :types
8
+ attr_reader :values
9
+
10
+ # @param kind [Symbol]
11
+ # :input or :output
12
+ # @param name [String]
13
+ # method name
14
+ # @param types [Array<Type>]
15
+ # expected types
16
+ # @param values [Array<BasicModel>]
17
+ # values
18
+ def initialize(kind, name, types, values)
19
+ @kind = kind
20
+ @name = name
21
+ @types = types
22
+ @values = values
23
+ end
24
+
25
+ def message
26
+ types = @types.map{|type| type}.join(" -> ")
27
+ values = @values.map{|value| value.inspect}.join(" -> ")
28
+ '"%s" expected %s but got %s' % [@name, types, values]
29
+ end
30
+ end
31
+
32
+ # PioneMethod is a class represents method in PIONE system.
33
+ class PioneMethod < Pione::PioneObject
34
+ attr_reader :name
35
+ attr_reader :inputs
36
+ attr_reader :output
37
+ attr_reader :body
38
+
39
+ # @param name [String]
40
+ # method name
41
+ # @param inputs [Array<Type>]
42
+ # input types
43
+ # @param output [Type]
44
+ # ouutput types
45
+ def initialize(name, inputs, output, body)
46
+ @name = name
47
+ @inputs = inputs
48
+ @output = output
49
+ @body = body
50
+ end
51
+
52
+ # Call the method with recevier and arguemnts.
53
+ #
54
+ # @param receiver [BasicModel]
55
+ # receiver object
56
+ # @param args [Array<BasicModel>]
57
+ # arguments
58
+ # @return [BasicModel]
59
+ # the result
60
+ def call(receiver, *args)
61
+ output = receiver.pione_model_type.instance_exec(receiver, *args, &@body)
62
+ validate_output(receiver, output)
63
+ return output
64
+ end
65
+
66
+ # Validate inputs data types for the method.
67
+ #
68
+ # @param receiver_type [Type]
69
+ # receiver type
70
+ # @param args [Array<Object>]
71
+ # arguments
72
+ # @return [Boolean]
73
+ # true if input data are valid
74
+ def validate_inputs(receiver, *args)
75
+ # check size
76
+ return false unless @inputs.size == args.size
77
+
78
+ # check type
79
+ @inputs.each_with_index do |input, i|
80
+ input = get_type(input, receiver)
81
+ unless input.match(args[i])
82
+ return false
83
+ end
84
+ end
85
+ return true
86
+ end
87
+
88
+ # Validate output data type for the method.
89
+ #
90
+ # @param receiver_type [Type]
91
+ # recevier type
92
+ # @param value [BasicModel]
93
+ # output value
94
+ # @return [void]
95
+ def validate_output(receiver, value)
96
+ output = get_type(@output, receiver)
97
+ unless output.match(value)
98
+ raise MethodInterfaceError.new(:output, @name, [output], [value])
99
+ end
100
+ end
101
+
102
+ # Get the input types of receiver.
103
+ #
104
+ # @param receiver [Callable]
105
+ # receiver
106
+ # @return [Type]
107
+ # input types
108
+ def get_input_types(receiver)
109
+ @inputs.map{|input| get_type(input, receiver)}
110
+ end
111
+
112
+ # Get the output type of receiver.
113
+ #
114
+ # @param receiver [Callable]
115
+ # receiver
116
+ # @return [Type]
117
+ # output type
118
+ def get_output_type(receiver)
119
+ get_type(@output, receiver)
120
+ end
121
+
122
+ private
123
+
124
+ # Get a type object.
125
+ #
126
+ # @param type [Type, Symbol]
127
+ # type object or special type symbol
128
+ # @param receiver [BasicModel]
129
+ # receiver
130
+ # @return [Type]
131
+ # type
132
+ def get_type(type, receiver)
133
+ case type
134
+ when :index_type
135
+ receiver.index_type
136
+ when :element_type
137
+ receiver.element_type
138
+ when :receiver_type
139
+ receiver.pione_model_type
140
+ else
141
+ type
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -1,14 +1,22 @@
1
1
  module Pione
2
2
  module Model
3
3
  # Rule representation in the flow element context.
4
- class RuleExpr < BasicModel
4
+ class RuleExpr < Callable
5
5
  set_pione_model_type TypeRuleExpr
6
6
 
7
+ # @return [String]
8
+ # package name
7
9
  attr_reader :package
10
+
11
+ # @return [String]
12
+ # rule name
8
13
  attr_reader :name
9
- attr_reader :params
10
- attr_reader :input_ticket_expr
11
- attr_reader :output_ticket_expr
14
+
15
+ # @return [Hash]
16
+ # attributes of the rule expression
17
+ attr_reader :attributes
18
+
19
+ forward_as_key! :@attributes, :params, :input_ticket_expr, :output_ticket_expr
12
20
 
13
21
  # Create a rule expression.
14
22
  #
@@ -16,18 +24,21 @@ module Pione
16
24
  # package name
17
25
  # @param name [String]
18
26
  # rule name
19
- # @param params [Parameters]
20
- # parameters
21
- # @param input_ticket_expr [TicketExpr]
27
+ # @param attributes [Hash]
28
+ # attributes of the expression
29
+ # @option attributes [Model::Parameters] :params
30
+ # rule parameters
31
+ # @option attributes [Model::TicketExpr] :input_ticket_expr
22
32
  # input ticket condition
23
- # @param output_ticket_expr [TicketExpr]
33
+ # @option attributes [Model::TicketExpr] :output_ticket_expr
24
34
  # output ticket condition
25
- def initialize(package, name, params, input_ticket_expr, output_ticket_expr)
35
+ def initialize(package, name, attributes={})
26
36
  @package = package
27
37
  @name = name
28
- @params = params
29
- @input_ticket_expr = input_ticket_expr
30
- @output_ticket_expr = output_ticket_expr
38
+ @attributes = {}
39
+ @attributes[:params] = attributes[:params] || Model::Parameters.empty
40
+ @attributes[:input_ticket_expr] = attributes[:input_ticket_expr] || Model::TicketExprSequence.empty
41
+ @attributes[:output_ticket_expr] = attributes[:output_ticket_expr] || Model::TicketExprSequence.empty
31
42
  super()
32
43
  end
33
44
 
@@ -63,7 +74,8 @@ module Pione
63
74
  # @return [RuleExpr]
64
75
  # new rule expression
65
76
  def add_input_ticket_expr(ticket_expr)
66
- return self.class.new(@package, @name, @params, @input_ticket_expr + ticket_expr, @output_ticket_expr)
77
+ new_attributes = @attributes.merge(input_ticket_expr: @attributes[:input_ticket_expr].concat(ticket_expr))
78
+ return self.class.new(@package, @name, new_attributes)
67
79
  end
68
80
 
69
81
  # Create a new rule expression with adding the ticket expression as output
@@ -74,7 +86,8 @@ module Pione
74
86
  # @return [RuleExpr]
75
87
  # new rule expression
76
88
  def add_output_ticket_expr(ticket_expr)
77
- return self.class.new(@package, @name, @params, @input_ticket_expr, @output_ticket_expr + ticket_expr)
89
+ new_attributes = @attributes.merge(output_ticket_expr: @attributes[:output_ticket_expr].concat(ticket_expr))
90
+ return self.class.new(@package, @name, new_attributes)
78
91
  end
79
92
 
80
93
  # Sets a package name and returns a new expression.
@@ -84,7 +97,7 @@ module Pione
84
97
  # @return [RuleExpr]
85
98
  # new rule expression with the package name
86
99
  def set_package(package)
87
- return self.class.new(package, @name, @params, @input_ticket_expr, @output_ticket_expr)
100
+ return self.class.new(package, @name, @attributes)
88
101
  end
89
102
 
90
103
  # Set parameters and returns a new expression.
@@ -94,23 +107,19 @@ module Pione
94
107
  # @return [RuleExpr]
95
108
  # new rule expression with the parameters
96
109
  def set_params(params)
97
- return self.class.new(@package, @name, params, @input_ticket_expr, @output_ticket_expr)
110
+ new_attributes = @attributes.merge(params: params)
111
+ return self.class.new(@package, @name, new_attributes)
98
112
  end
99
113
 
100
114
  # Evaluate the object with the variable table.
101
115
  #
102
116
  # @param vtable [VariableTable]
103
117
  # variable table for evaluation
104
- # @return [BasicModel]
118
+ # @return [RuleExpr]
105
119
  # evaluation result
106
120
  def eval(vtable)
107
- return self.class.new(
108
- @package.eval(vtable),
109
- @name,
110
- @params.eval(vtable),
111
- @input_ticket_expr.eval(vtable),
112
- @output_ticket_expr.eval(vtable)
113
- )
121
+ new_attributes = Hash[@attributes.map{|key, val| [key, val.eval(vtable)]}]
122
+ return self.class.new(@package.eval(vtable), @name, new_attributes)
114
123
  end
115
124
 
116
125
  # Return true if the package or parameters include variables.
@@ -118,11 +127,7 @@ module Pione
118
127
  # @return [Boolean]
119
128
  # true if the package or parameters include variables
120
129
  def include_variable?
121
- [ @package.include_variable?,
122
- @params.include_variable?,
123
- @input_ticket_expr.include_variable?,
124
- @output_ticket_expr.include_variable?
125
- ].any?
130
+ @package.include_variable? or @attributes.values.any?{|val| val.include_variable?}
126
131
  end
127
132
 
128
133
  # @api private
@@ -130,14 +135,14 @@ module Pione
130
135
  return false unless other.kind_of?(self.class)
131
136
  return false unless @package = other.package
132
137
  return false unless @name == other.name
133
- return false unless @params == other.params
138
+ return false unless @attributes == other.attributes
134
139
  return true
135
140
  end
136
141
  alias :eql? :"=="
137
142
 
138
143
  # @api private
139
144
  def hash
140
- @package.hash + @name.hash + @params.hash
145
+ @package.hash + @name.hash + @attributes.hash
141
146
  end
142
147
 
143
148
  # Return a set that contains self as a single element.
@@ -215,16 +220,17 @@ module Pione
215
220
  end
216
221
  end
217
222
 
223
+ class RuleExprSequence < Sequence
224
+ set_pione_model_type TypeRuleExpr
225
+ end
226
+
218
227
  TypeRuleExpr.instance_eval do
219
228
  define_pione_method("==", [TypeRuleExpr], TypeBoolean) do |rec, other|
220
229
  PioneBoolean.new(
221
230
  rec.package == other.package &&
222
231
  rec.name == other.name &&
223
- rec.params == other.params)
224
- end
225
-
226
- define_pione_method("!=", [TypeRuleExpr], TypeBoolean) do |rec, other|
227
- PioneBoolean.not(rec.call_pione_method("==", other))
232
+ rec.params == other.params
233
+ ).to_seq
228
234
  end
229
235
 
230
236
  define_pione_method("params", [TypeParameters], TypeRuleExpr) do |rec, params|
@@ -232,7 +238,7 @@ module Pione
232
238
  end
233
239
 
234
240
  define_pione_method("as_string", [], TypeString) do |rec|
235
- PioneString.new(rec.name)
241
+ PioneString.new(rec.name).to_seq
236
242
  end
237
243
 
238
244
  define_pione_method("==>", [TypeTicketExpr], TypeRuleExpr) do |rec, ticket_expr|
@@ -240,7 +246,7 @@ module Pione
240
246
  end
241
247
 
242
248
  define_pione_method(">>>", [TypeRuleExpr], TypeRuleExpr) do |rec, other|
243
- ticket_expr = TicketExpr.new([rec.path])
249
+ ticket_expr = TicketExpr.new(rec.path).to_seq
244
250
  left = rec.add_output_ticket_expr(ticket_expr)
245
251
  right = other.add_input_ticket_expr(ticket_expr)
246
252
  CompositionalRuleExpr.new(left, right)
@@ -64,13 +64,17 @@ module Pione
64
64
  rec.call_pione_method("match")
65
65
  end
66
66
 
67
- define_pione_method("[]", [TypeInteger], TypeAny) do |rec, i|
68
- rec.match[i.value-1]
67
+ define_pione_method("[]", [TypeInteger], TypeSequence) do |rec, i|
68
+ rec.match[i.value]
69
69
  end
70
70
 
71
71
  define_pione_method("as_string", [], TypeString) do |rec|
72
72
  rec.name
73
73
  end
74
+
75
+ define_pione_method("str", [], TypeString) do |rec|
76
+ rec.call_pione_method("as_string")
77
+ end
74
78
  end
75
79
 
76
80
  # RuleIOList is a input or output list for RuleIOElement.
@@ -146,7 +150,7 @@ module Pione
146
150
  PioneBoolean.not(rec.call_pione_method("==", other))
147
151
  end
148
152
 
149
- define_pione_method("[]", [TypeInteger], TypeAny) do |rec, i|
153
+ define_pione_method("[]", [TypeInteger], TypeSequence) do |rec, i|
150
154
  rec.elements[i.value-1]
151
155
  end
152
156
 
@@ -165,6 +169,10 @@ module Pione
165
169
  }.join(DataExpr::SEPARATOR)
166
170
  )
167
171
  end
172
+
173
+ define_pione_method("str", [], TypeString) do |rec|
174
+ rec.call_pione_method("as_string")
175
+ end
168
176
  end
169
177
  end
170
178
  end