pione 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/History.txt
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# History
|
|
2
2
|
|
|
3
|
-
## 0.1.
|
|
3
|
+
## 0.1.4(2013/05/13)
|
|
4
|
+
|
|
5
|
+
* Sequence based expressions.
|
|
6
|
+
* Enable to distribute tasks based on parameters.
|
|
7
|
+
* Added many methods.
|
|
8
|
+
* Added annotations.
|
|
9
|
+
* Added remove and touch operation as data tuple operations.
|
|
10
|
+
* Modified update criteria.
|
|
11
|
+
* Added empty rule.
|
|
12
|
+
* Added new examples.
|
|
13
|
+
|
|
14
|
+
## 0.1.3(2013/04/25)
|
|
4
15
|
|
|
5
16
|
* Added new data expression literal "null" for accepting data nonexistence
|
|
6
17
|
* Added new data expression property keyword "neglect" and "care" for the update criterion about data mtime
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Rule Main
|
|
2
|
+
output 'message.txt'
|
|
3
|
+
param $NAME := "A"
|
|
4
|
+
Flow
|
|
5
|
+
case $NAME
|
|
6
|
+
when "A"
|
|
7
|
+
$RULE := A
|
|
8
|
+
when "B"
|
|
9
|
+
$RULE := B
|
|
10
|
+
when "C"
|
|
11
|
+
$RULE := C
|
|
12
|
+
end
|
|
13
|
+
rule Abstract {R: $RULE}
|
|
14
|
+
End
|
|
15
|
+
|
|
16
|
+
Rule Abstract
|
|
17
|
+
output 'message.txt'
|
|
18
|
+
param $R
|
|
19
|
+
Flow
|
|
20
|
+
rule $R
|
|
21
|
+
End
|
|
22
|
+
|
|
23
|
+
Rule A
|
|
24
|
+
output 'message.txt'
|
|
25
|
+
Action
|
|
26
|
+
echo "This is rule A." > {$O[1]}
|
|
27
|
+
End
|
|
28
|
+
|
|
29
|
+
Rule B
|
|
30
|
+
output 'message.txt'
|
|
31
|
+
Action
|
|
32
|
+
echo "This is rule B." > {$O[1]}
|
|
33
|
+
End
|
|
34
|
+
|
|
35
|
+
Rule C
|
|
36
|
+
output 'message.txt'
|
|
37
|
+
Action
|
|
38
|
+
echo "This is rule C." > {$O[1]}
|
|
39
|
+
End
|
|
40
|
+
|
data/example/Fib/Fib.pione
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
@ author :: "Keita Yamaguchi"
|
|
2
|
+
@ "Fib.pione calculates the value of Fibonacci number."
|
|
3
|
+
|
|
4
|
+
param ($NUM := 3)
|
|
2
5
|
|
|
3
6
|
Rule Main
|
|
4
7
|
output 'result.txt'
|
|
5
8
|
Flow
|
|
6
9
|
rule Fib {N: $NUM}
|
|
7
|
-
rule Result
|
|
10
|
+
rule Result
|
|
8
11
|
End
|
|
9
12
|
|
|
10
13
|
Rule Fib0
|
|
14
|
+
@ "the value of fib(0) is 0"
|
|
11
15
|
output 'fib0.txt'
|
|
12
16
|
Action
|
|
13
17
|
echo -n '0' > fib0.txt
|
|
14
18
|
End
|
|
15
19
|
|
|
16
20
|
Rule Fib1
|
|
21
|
+
@ "the value of fib(1) is 1"
|
|
17
22
|
output 'fib1.txt'
|
|
18
23
|
Action
|
|
19
24
|
echo -n '1' > fib1.txt
|
|
20
25
|
End
|
|
21
26
|
|
|
22
27
|
Rule Fib
|
|
28
|
+
@ "fib(n) is fib(0), fib(1), or fib(n-1) + fib(n-2)"
|
|
23
29
|
output 'fib{$N}.txt'
|
|
24
30
|
param $N
|
|
25
31
|
Flow
|
|
@@ -38,6 +44,7 @@ Flow
|
|
|
38
44
|
End
|
|
39
45
|
|
|
40
46
|
Rule Calc
|
|
47
|
+
@ "calculate the value of fib(n-1) + fib(n-2)"
|
|
41
48
|
input 'fib{$P1}.txt'
|
|
42
49
|
input 'fib{$P2}.txt'
|
|
43
50
|
output 'fib{$N}.txt'
|
|
@@ -49,9 +56,9 @@ Action
|
|
|
49
56
|
End
|
|
50
57
|
|
|
51
58
|
Rule Result
|
|
52
|
-
|
|
59
|
+
@ "make the result"
|
|
60
|
+
input 'fib*.txt'
|
|
53
61
|
output 'result.txt'
|
|
54
|
-
param $N
|
|
55
62
|
Action
|
|
56
|
-
|
|
63
|
+
cp {$I[1]} {$O[1]}
|
|
57
64
|
End
|
|
@@ -2,13 +2,28 @@ Rule Main
|
|
|
2
2
|
input '*.i'.all
|
|
3
3
|
output '*.pair'.all
|
|
4
4
|
Flow
|
|
5
|
-
rule
|
|
5
|
+
rule SuccessorPair
|
|
6
|
+
rule PermutationPair
|
|
7
|
+
rule CombinationPair
|
|
6
8
|
End
|
|
7
9
|
|
|
8
|
-
Rule
|
|
10
|
+
Rule SuccessorPair
|
|
9
11
|
input '*.i'
|
|
10
|
-
input '
|
|
11
|
-
output '{
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
input '*.i'
|
|
13
|
+
output 'succ-{$I[1][1]}-{$I[2][1]}.pair'.touch
|
|
14
|
+
constraint ($I[1][1].i + 1) == $I[2][1].i
|
|
15
|
+
End
|
|
16
|
+
|
|
17
|
+
Rule PermutationPair
|
|
18
|
+
input '*.i'
|
|
19
|
+
input '*.i'
|
|
20
|
+
output 'perm-{$I[1][1]}-{$I[2][1]}.pair'.touch
|
|
21
|
+
constraint $I[1][1].i != $I[2][1].i
|
|
22
|
+
End
|
|
23
|
+
|
|
24
|
+
Rule CombinationPair
|
|
25
|
+
input '*.i'
|
|
26
|
+
input '*.i'
|
|
27
|
+
output 'comb-{$I[1][1]}-{$I[2][1]}.pair'.touch
|
|
28
|
+
constraint $I[1][1].i < $I[2][1].i
|
|
14
29
|
End
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Rule Main
|
|
2
|
+
input '*.i'.all
|
|
3
|
+
output '*.res'.all
|
|
4
|
+
Flow
|
|
5
|
+
rule OddFilter >>> MakeResult
|
|
6
|
+
End
|
|
7
|
+
|
|
8
|
+
Rule OddFilter
|
|
9
|
+
input '*.i'
|
|
10
|
+
output '*.i'.remove
|
|
11
|
+
constraint ($I[1][1].i % 2) == 0
|
|
12
|
+
End
|
|
13
|
+
|
|
14
|
+
Rule MakeResult
|
|
15
|
+
input '*.i'
|
|
16
|
+
output '{$*}.res'.touch
|
|
17
|
+
End
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,62 +1,50 @@
|
|
|
1
|
-
param $MAX :=
|
|
1
|
+
param $MAX := 10
|
|
2
2
|
|
|
3
3
|
Rule Main
|
|
4
4
|
output '*.prime'.all
|
|
5
5
|
Flow
|
|
6
|
-
rule Sieve
|
|
6
|
+
rule CreateUndeterminedNumbers >>> Sieve
|
|
7
|
+
End
|
|
8
|
+
|
|
9
|
+
Rule CreateUndeterminedNumbers
|
|
10
|
+
output '*.ud'.all
|
|
11
|
+
param $N := 2.upto($MAX)
|
|
12
|
+
Flow
|
|
13
|
+
rule CreateData {NAME: "{$N}.ud"}
|
|
7
14
|
End
|
|
8
15
|
|
|
9
16
|
Rule Sieve
|
|
10
|
-
input '
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
input '*.ud'.all or null
|
|
18
|
+
input '*.prime'.all or null
|
|
19
|
+
output '*.prime'.all.neglect
|
|
20
|
+
output 'finished'
|
|
21
|
+
param $N := 2
|
|
13
22
|
Flow
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if not :: $*.as_data_expr.match?($NUM.as_string)
|
|
18
|
-
rule CreatePrime {N: $NUM}
|
|
19
|
-
if ($NUM * $NUM) <= $MAX
|
|
20
|
-
rule CreateNotPrimeAll {P: $NUM} >>> $NEXT_RULE
|
|
23
|
+
if $*.as_data_expr.match?($N.str)
|
|
24
|
+
if ($N * $N) <= $MAX
|
|
25
|
+
rule CreateData {NAME: "{$N}.prime"} >>> RemoveUndeterminedNumber >>> Sieve {N: $N+1}
|
|
21
26
|
else
|
|
22
|
-
rule
|
|
27
|
+
rule UndeterminedNumber2Prime
|
|
28
|
+
rule CreateData {NAME: "finished"}
|
|
23
29
|
end
|
|
24
30
|
else
|
|
25
|
-
|
|
26
|
-
rule $NEXT_RULE
|
|
27
|
-
end
|
|
31
|
+
rule Sieve {N: $N+1}
|
|
28
32
|
end
|
|
29
33
|
End
|
|
30
34
|
|
|
31
|
-
Rule
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if ($P * ($INDEX + 1)) <= $MAX
|
|
37
|
-
rule CreateNotPrimeAll {P: $P, INDEX: $INDEX + 1}
|
|
38
|
-
end
|
|
39
|
-
rule CreateNotPrime {P: $P, N: $P * $INDEX}
|
|
35
|
+
Rule RemoveUndeterminedNumber
|
|
36
|
+
input '*.prime'
|
|
37
|
+
input '*.ud'
|
|
38
|
+
output '{$I[2][1]}.ud'.remove
|
|
39
|
+
constraint ($I[2][1].i % $I[1][1].i) == 0
|
|
40
40
|
End
|
|
41
41
|
|
|
42
|
-
Rule
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
param $N
|
|
46
|
-
Action
|
|
47
|
-
touch {$N}-{$P}.not_prime
|
|
42
|
+
Rule UndeterminedNumber2Prime
|
|
43
|
+
input '*.ud'
|
|
44
|
+
output '{$*}.prime'.touch
|
|
48
45
|
End
|
|
49
46
|
|
|
50
|
-
Rule
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Action
|
|
54
|
-
touch {$N}.prime
|
|
47
|
+
Rule CreateData
|
|
48
|
+
param $NAME
|
|
49
|
+
output '{$NAME}'.touch
|
|
55
50
|
End
|
|
56
|
-
|
|
57
|
-
Rule Current
|
|
58
|
-
output '{$N}.current'
|
|
59
|
-
param $N
|
|
60
|
-
Action
|
|
61
|
-
touch {$N}.current
|
|
62
|
-
End
|
|
@@ -40,9 +40,9 @@ module Pione
|
|
|
40
40
|
when :readline
|
|
41
41
|
action_readline_mode
|
|
42
42
|
when :file
|
|
43
|
-
print_result(Pathname.new(option[:document]).read)
|
|
43
|
+
print_result(DocumentParser.new, Pathname.new(option[:document]).read)
|
|
44
44
|
when :expr
|
|
45
|
-
print_result(option[:expr])
|
|
45
|
+
print_result(DocumentParser.new.expr, option[:expr])
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -109,10 +109,10 @@ module Pione
|
|
|
109
109
|
# @param str [String]
|
|
110
110
|
# PIONE expression
|
|
111
111
|
# @return [void]
|
|
112
|
-
def print_result(str)
|
|
112
|
+
def print_result(parser, str)
|
|
113
113
|
begin
|
|
114
114
|
puts Terminal.green("syntax:")
|
|
115
|
-
stree =
|
|
115
|
+
stree = parser.parse(str)
|
|
116
116
|
pp stree
|
|
117
117
|
if option[:transform]
|
|
118
118
|
puts Terminal.green("model:")
|
|
@@ -10,7 +10,7 @@ module Pione
|
|
|
10
10
|
# # assigning a variable value
|
|
11
11
|
# $X := $Y
|
|
12
12
|
# # => Assignment.new(Variable.new('X'), Variable.new('Y'))
|
|
13
|
-
class Assignment <
|
|
13
|
+
class Assignment < Callable
|
|
14
14
|
set_pione_model_type TypeAssignment
|
|
15
15
|
|
|
16
16
|
# Return the variable part of assignment.
|
|
@@ -99,5 +99,10 @@ module Pione
|
|
|
99
99
|
@variable.hash + @expr.hash
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
|
+
|
|
103
|
+
# class AssignmentSequence < Sequence
|
|
104
|
+
# set_pione_model_type TypeAssignment
|
|
105
|
+
# set_element_class Assignment
|
|
106
|
+
# end
|
|
102
107
|
end
|
|
103
108
|
end
|