pione 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -1
- data/example/AbstractRule/AbstractRule.pione +40 -0
- data/example/Fib/Fib.pione +12 -5
- data/example/LucasNumber/LucasNumber.pione +1 -1
- data/example/MakePair/MakePair.pione +21 -6
- data/example/OddSelector/OddSelector.pione +17 -0
- data/example/OddSelector/data/1.i +0 -0
- data/example/OddSelector/data/10.i +0 -0
- data/example/OddSelector/data/2.i +0 -0
- data/example/OddSelector/data/3.i +0 -0
- data/example/OddSelector/data/4.i +0 -0
- data/example/OddSelector/data/5.i +0 -0
- data/example/OddSelector/data/6.i +0 -0
- data/example/OddSelector/data/7.i +0 -0
- data/example/OddSelector/data/8.i +0 -0
- data/example/OddSelector/data/9.i +0 -0
- data/example/SequentialParameter/SequentialParameter.pione +4 -0
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +31 -43
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +1 -1
- data/example/Touch/Touch.pione +3 -0
- data/lib/pione/command/pione-syntax-checker.rb +4 -4
- data/lib/pione/model/assignment.rb +6 -1
- data/lib/pione/model/basic-model.rb +92 -278
- data/lib/pione/model/binary-operator.rb +5 -1
- data/lib/pione/model/block.rb +17 -0
- data/lib/pione/model/boolean.rb +54 -22
- data/lib/pione/model/constraints.rb +34 -0
- data/lib/pione/model/data-expr.rb +184 -297
- data/lib/pione/model/feature-expr.rb +13 -4
- data/lib/pione/model/float.rb +24 -41
- data/lib/pione/model/integer.rb +75 -41
- data/lib/pione/model/keyed-sequence.rb +143 -0
- data/lib/pione/model/list.rb +12 -8
- data/lib/pione/model/message.rb +8 -4
- data/lib/pione/model/ordinal-sequence.rb +75 -0
- data/lib/pione/model/package.rb +6 -2
- data/lib/pione/model/parameters.rb +61 -9
- data/lib/pione/model/pione-method.rb +146 -0
- data/lib/pione/model/rule-expr.rb +44 -38
- data/lib/pione/model/rule-io.rb +11 -3
- data/lib/pione/model/rule.rb +105 -155
- data/lib/pione/model/sequence.rb +273 -0
- data/lib/pione/model/string.rb +75 -29
- data/lib/pione/model/ticket-expr.rb +17 -29
- data/lib/pione/model/type.rb +242 -0
- data/lib/pione/model/variable-table.rb +52 -53
- data/lib/pione/model/variable.rb +8 -4
- data/lib/pione/model.rb +34 -0
- data/lib/pione/parser/block-parser.rb +44 -20
- data/lib/pione/parser/common-parser.rb +2 -1
- data/lib/pione/parser/document-parser.rb +6 -1
- data/lib/pione/parser/expr-parser.rb +57 -11
- data/lib/pione/parser/flow-element-parser.rb +2 -2
- data/lib/pione/parser/rule-definition-parser.rb +23 -1
- data/lib/pione/patch/rinda-patch.rb +1 -5
- data/lib/pione/rule-handler/action-handler.rb +5 -5
- data/lib/pione/rule-handler/basic-handler.rb +30 -7
- data/lib/pione/rule-handler/empty-handler.rb +14 -0
- data/lib/pione/rule-handler/flow-handler.rb +132 -115
- data/lib/pione/rule-handler/root-handler.rb +6 -2
- data/lib/pione/rule-handler/update-criteria.rb +152 -0
- data/lib/pione/rule-handler.rb +14 -0
- data/lib/pione/system/identifier.rb +9 -9
- data/lib/pione/transformer/block-transformer.rb +4 -0
- data/lib/pione/transformer/expr-transformer.rb +1 -1
- data/lib/pione/transformer/flow-element-transformer.rb +4 -2
- data/lib/pione/transformer/literal-transformer.rb +14 -3
- data/lib/pione/transformer/rule-definition-transformer.rb +17 -5
- data/lib/pione/tuple-space/data-finder.rb +15 -52
- data/lib/pione/version.rb +1 -1
- data/lib/pione.rb +12 -38
- data/test/agent/spec_task-worker.rb +13 -12
- data/test/model/spec_assignment.rb +2 -2
- data/test/model/spec_binary-operator.rb +10 -10
- data/test/model/spec_block.rb +8 -8
- data/test/model/spec_boolean.rb +1 -72
- data/test/model/spec_boolean.yml +134 -0
- data/test/model/spec_data-expr.rb +50 -237
- data/test/model/spec_data-expr.yml +16 -45
- data/test/model/spec_data-expr_match.yml +45 -0
- data/test/model/spec_feature-expr.rb +2 -43
- data/test/model/spec_feature-expr.yml +0 -28
- data/test/model/spec_feature-expr_decide.yml +28 -0
- data/test/model/spec_float.rb +1 -119
- data/test/model/spec_float.yml +17 -0
- data/test/model/spec_integer.rb +1 -119
- data/test/model/spec_integer.yml +57 -0
- data/test/model/spec_keyed-sequence.rb +5 -0
- data/test/model/spec_keyed-sequence.yml +22 -0
- data/test/model/spec_message.rb +7 -7
- data/test/model/spec_parameters.rb +50 -63
- data/test/model/spec_pione-method.rb +56 -0
- data/test/model/spec_rule-expr.rb +18 -8
- data/test/model/spec_rule.rb +12 -12
- data/test/model/spec_sequence.rb +5 -0
- data/test/model/spec_sequence.yml +60 -0
- data/test/model/spec_string.rb +3 -70
- data/test/model/spec_string.yml +83 -0
- data/test/model/spec_ticket-expr.rb +4 -54
- data/test/model/spec_ticket-expr.yml +11 -0
- data/test/model/spec_variable-table.rb +41 -42
- data/test/model/spec_variable.rb +20 -22
- data/test/parser/spec_block-parser.yml +9 -0
- data/test/parser/spec_expr-parser.yml +0 -17
- data/test/parser/spec_flow-element-parser.yml +1 -1
- data/test/parser/spec_rule-definition-parser.yml +0 -4
- data/test/rule-handler/spec_update-criteria.pione +39 -0
- data/test/rule-handler/spec_update-criteria.rb +53 -0
- data/test/rule-handler/spec_update-criteria.yml +158 -0
- data/test/test-util.rb +25 -0
- data/test/transformer/spec_block-transformer.rb +7 -0
- data/test/transformer/spec_expr-transformer.rb +64 -19
- data/test/transformer/spec_flow-element-transformer.rb +11 -11
- data/test/transformer/spec_literal-transformer.rb +29 -29
- data/test/transformer/spec_rule-definition-transformer.rb +39 -21
- metadata +57 -11
- data/lib/pione/model/undefined-value.rb +0 -24
- data/lib/pione/tuple-space/update-criteria.rb +0 -97
- data/test/model/spec_list.rb +0 -26
- data/test/model/spec_rule-io.rb +0 -32
- 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 <
|
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].
|
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].
|
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 =>
|
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 =>
|
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],
|
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],
|
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,
|
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 <
|
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
|
-
|
10
|
-
|
11
|
-
|
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
|
20
|
-
#
|
21
|
-
# @
|
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
|
-
# @
|
33
|
+
# @option attributes [Model::TicketExpr] :output_ticket_expr
|
24
34
|
# output ticket condition
|
25
|
-
def initialize(package, name,
|
35
|
+
def initialize(package, name, attributes={})
|
26
36
|
@package = package
|
27
37
|
@name = name
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
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
|
-
|
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
|
-
|
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, @
|
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
|
-
|
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 [
|
118
|
+
# @return [RuleExpr]
|
105
119
|
# evaluation result
|
106
120
|
def eval(vtable)
|
107
|
-
|
108
|
-
|
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
|
-
|
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 @
|
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 + @
|
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
|
-
|
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(
|
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)
|
data/lib/pione/model/rule-io.rb
CHANGED
@@ -64,13 +64,17 @@ module Pione
|
|
64
64
|
rec.call_pione_method("match")
|
65
65
|
end
|
66
66
|
|
67
|
-
define_pione_method("[]", [TypeInteger],
|
68
|
-
rec.match[i.value
|
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],
|
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
|