flor 0.0.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +13 -0
- data/LICENSE.txt +1 -1
- data/Makefile +66 -0
- data/README.md +57 -0
- data/fail.txt +7 -0
- data/flor.gemspec +12 -9
- data/intercepted.txt +123 -0
- data/lib/flor/colours.rb +140 -0
- data/lib/flor/conf.rb +88 -0
- data/lib/flor/core/executor.rb +473 -0
- data/lib/flor/core/node.rb +397 -0
- data/lib/flor/core/procedure.rb +600 -0
- data/lib/flor/core/texecutor.rb +209 -0
- data/lib/flor/core.rb +93 -0
- data/lib/flor/dollar.rb +248 -0
- data/lib/flor/errors.rb +36 -0
- data/lib/flor/flor.rb +556 -0
- data/lib/flor/log.rb +336 -0
- data/lib/flor/migrations/0001_tables.rb +122 -0
- data/lib/flor/parser.rb +414 -0
- data/lib/flor/pcore/_arr.rb +49 -0
- data/lib/flor/pcore/_atom.rb +43 -0
- data/lib/flor/pcore/_att.rb +160 -0
- data/lib/flor/pcore/_dump.rb +60 -0
- data/lib/flor/pcore/_err.rb +30 -0
- data/lib/flor/pcore/_happly.rb +73 -0
- data/lib/flor/pcore/_obj.rb +65 -0
- data/lib/flor/pcore/_skip.rb +63 -0
- data/lib/flor/pcore/apply.rb +60 -0
- data/lib/flor/pcore/arith.rb +46 -0
- data/lib/flor/pcore/break.rb +71 -0
- data/lib/flor/pcore/cmp.rb +72 -0
- data/lib/flor/pcore/cond.rb +57 -0
- data/lib/flor/pcore/cursor.rb +223 -0
- data/lib/flor/pcore/define.rb +96 -0
- data/lib/flor/pcore/fail.rb +45 -0
- data/lib/flor/pcore/ife.rb +56 -0
- data/lib/flor/pcore/loop.rb +53 -0
- data/lib/flor/pcore/map.rb +75 -0
- data/lib/flor/pcore/match.rb +70 -0
- data/lib/flor/pcore/move.rb +65 -0
- data/lib/flor/pcore/noeval.rb +46 -0
- data/lib/flor/pcore/noret.rb +47 -0
- data/lib/flor/pcore/push.rb +69 -0
- data/lib/flor/pcore/sequence.rb +39 -0
- data/lib/flor/pcore/set.rb +76 -0
- data/lib/flor/pcore/stall.rb +35 -0
- data/lib/flor/pcore/until.rb +122 -0
- data/lib/flor/pcore/val.rb +40 -0
- data/lib/flor/punit/cancel.rb +69 -0
- data/lib/flor/punit/cmap.rb +76 -0
- data/lib/flor/punit/concurrence.rb +149 -0
- data/lib/flor/punit/every.rb +46 -0
- data/lib/flor/punit/on.rb +81 -0
- data/lib/flor/punit/schedule.rb +68 -0
- data/lib/flor/punit/signal.rb +47 -0
- data/lib/flor/punit/sleep.rb +53 -0
- data/lib/flor/punit/task.rb +109 -0
- data/lib/flor/punit/trace.rb +51 -0
- data/lib/flor/punit/trap.rb +100 -0
- data/lib/flor/to_string.rb +81 -0
- data/lib/flor/tools/env.rb +103 -0
- data/lib/flor/tools/repl.rb +231 -0
- data/lib/flor/unit/executor.rb +260 -0
- data/lib/flor/unit/hooker.rb +186 -0
- data/lib/flor/unit/journal.rb +52 -0
- data/lib/flor/unit/loader.rb +181 -0
- data/lib/flor/unit/logger.rb +181 -0
- data/lib/flor/unit/models/execution.rb +105 -0
- data/lib/flor/unit/models/pointer.rb +31 -0
- data/lib/flor/unit/models/timer.rb +52 -0
- data/lib/flor/unit/models/trace.rb +31 -0
- data/lib/flor/unit/models/trap.rb +130 -0
- data/lib/flor/unit/models.rb +106 -0
- data/lib/flor/unit/scheduler.rb +419 -0
- data/lib/flor/unit/storage.rb +633 -0
- data/lib/flor/unit/tasker.rb +191 -0
- data/lib/flor/unit/waiter.rb +146 -0
- data/lib/flor/unit/wlist.rb +77 -0
- data/lib/flor/unit.rb +50 -0
- data/lib/flor.rb +40 -3
- metadata +152 -22
- checksums.yaml +0 -7
- data/Rakefile +0 -52
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Dump < Flor::Procedure
|
27
|
+
|
28
|
+
name '_dump'
|
29
|
+
|
30
|
+
def pre_execute
|
31
|
+
|
32
|
+
@node['atts'] = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def receive_last
|
36
|
+
|
37
|
+
if n = @execution['nodes']['0']
|
38
|
+
|
39
|
+
dump = {}
|
40
|
+
|
41
|
+
dump['message'] = Flor.dup(@message)
|
42
|
+
dump['node'] = Flor.dup(@node)
|
43
|
+
|
44
|
+
vars = {}
|
45
|
+
pn = @node
|
46
|
+
while pn
|
47
|
+
if vs = pn['vars']
|
48
|
+
vs.each { |k, v| vars[k] = Flor.dup(v) unless vars.has_key?(k) }
|
49
|
+
end
|
50
|
+
pn = @execution['nodes'][pn['parent']]
|
51
|
+
end
|
52
|
+
dump['vars'] = vars
|
53
|
+
|
54
|
+
(n['vars']['dumps'] ||= []) << dump
|
55
|
+
end
|
56
|
+
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Err < Flor::Procedure
|
27
|
+
|
28
|
+
name '_err'
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Happly < Flor::Procedure
|
27
|
+
|
28
|
+
name '_happly'
|
29
|
+
|
30
|
+
def pre_execute
|
31
|
+
|
32
|
+
@node['atts'] = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute
|
36
|
+
|
37
|
+
queue(
|
38
|
+
'point' => 'execute',
|
39
|
+
'nid' => Flor.child_nid(nid, tree[1].size),
|
40
|
+
'tree' => tree[0])
|
41
|
+
end
|
42
|
+
|
43
|
+
def receive
|
44
|
+
|
45
|
+
fcid = Flor.child_id(message['from'])
|
46
|
+
|
47
|
+
return reply if @node['applied']
|
48
|
+
return super unless fcid == tree[1].size
|
49
|
+
|
50
|
+
ret = payload['ret']
|
51
|
+
|
52
|
+
@node['hret'] = payload['ret']
|
53
|
+
execute_child(0)
|
54
|
+
end
|
55
|
+
|
56
|
+
def receive_last
|
57
|
+
|
58
|
+
hret = @node['hret']
|
59
|
+
|
60
|
+
return reply('ret' => hret) unless Flor.is_func_tree?(hret)
|
61
|
+
|
62
|
+
args = @node['atts'].collect(&:last)
|
63
|
+
|
64
|
+
hret[1].merge!('head' => true, 'nid' => nid)
|
65
|
+
|
66
|
+
msgs = apply(hret, args, tree[2])
|
67
|
+
|
68
|
+
@node['applied'] = msgs.first['nid']
|
69
|
+
|
70
|
+
msgs
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Obj < Flor::Procedure
|
27
|
+
|
28
|
+
name '_obj'
|
29
|
+
|
30
|
+
def pre_execute
|
31
|
+
|
32
|
+
@node['rets'] = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def receive_first
|
36
|
+
|
37
|
+
return reply('ret' => {}) if children == 0
|
38
|
+
|
39
|
+
cn = children
|
40
|
+
.inject([]) { |a, e| a << (a.size.even? ? stringify(e) : e); a }
|
41
|
+
|
42
|
+
@node['tree'] = [ tree[0], cn, tree[2] ] if children != cn
|
43
|
+
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def receive_last
|
48
|
+
|
49
|
+
payload['ret'] =
|
50
|
+
@node['rets']
|
51
|
+
.each_slice(2)
|
52
|
+
.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
|
53
|
+
|
54
|
+
reply
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def stringify(t)
|
60
|
+
|
61
|
+
return t unless t[1] == [] && t[0].is_a?(String)
|
62
|
+
[ '_sqs', deref(t[0]) || t[0], t[2] ]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Skip < Flor::Procedure
|
27
|
+
#
|
28
|
+
# Skips x messages, mostly used for testing flor.
|
29
|
+
#
|
30
|
+
# ```
|
31
|
+
# concurrence
|
32
|
+
# sequence
|
33
|
+
# set f.i 0
|
34
|
+
# while tag: 'xx'
|
35
|
+
# true
|
36
|
+
# set f.i (+ f.i 1)
|
37
|
+
# sequence
|
38
|
+
# _skip 7 # after 7 messages will go on
|
39
|
+
# break ref: 'xx'
|
40
|
+
# ```
|
41
|
+
|
42
|
+
name '_skip'
|
43
|
+
|
44
|
+
def receive
|
45
|
+
|
46
|
+
return super unless @node.has_key?('count')
|
47
|
+
|
48
|
+
@node['count'] -= 1
|
49
|
+
|
50
|
+
return reply if @node['count'] < 1
|
51
|
+
|
52
|
+
reply('nid' => nid, 'from' => Flor.child_nid(nid, children.size))
|
53
|
+
end
|
54
|
+
|
55
|
+
def receive_last
|
56
|
+
|
57
|
+
@node['count'] = payload['ret'].to_i
|
58
|
+
payload['ret'] = node_payload_ret
|
59
|
+
|
60
|
+
receive
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Apply < Flor::Procedure
|
27
|
+
|
28
|
+
name 'apply'
|
29
|
+
|
30
|
+
def pre_execute
|
31
|
+
|
32
|
+
@node['atts'] = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def receive
|
36
|
+
|
37
|
+
return reply if from && from == @node['applied']
|
38
|
+
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def receive_last
|
43
|
+
|
44
|
+
args = @node['atts'].collect(&:last)
|
45
|
+
|
46
|
+
nht = @node['heat']
|
47
|
+
|
48
|
+
src =
|
49
|
+
Flor.is_proc_tree?(nht) && nht[1]['proc'] == 'apply' ?
|
50
|
+
args.shift :
|
51
|
+
nht
|
52
|
+
|
53
|
+
ms = apply(src, args, tree[2])
|
54
|
+
|
55
|
+
@node['applied'] = ms.first['nid']
|
56
|
+
|
57
|
+
ms
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Arith < Flor::Procedure
|
27
|
+
|
28
|
+
names %w[ + - * / ]
|
29
|
+
|
30
|
+
DEFAULTS = { :+ => 0, :* => 1, :- => 0, :/ => 1 }
|
31
|
+
|
32
|
+
def pre_execute
|
33
|
+
|
34
|
+
@node['rets'] = []
|
35
|
+
end
|
36
|
+
|
37
|
+
def receive_last
|
38
|
+
|
39
|
+
sign = tree.first.to_sym
|
40
|
+
|
41
|
+
payload['ret'] = @node['rets'].reduce(&sign) || DEFAULTS[sign]
|
42
|
+
|
43
|
+
reply
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Break < Flor::Procedure
|
27
|
+
#
|
28
|
+
# Breaks or continues a "while" or "until".
|
29
|
+
#
|
30
|
+
# ```
|
31
|
+
# until false
|
32
|
+
# # do something
|
33
|
+
# continue if f.x == 0
|
34
|
+
# break if f.x == 1
|
35
|
+
# # do something more
|
36
|
+
# ```
|
37
|
+
|
38
|
+
name 'break', 'continue'
|
39
|
+
|
40
|
+
def pre_execute
|
41
|
+
|
42
|
+
@node['atts'] = []
|
43
|
+
end
|
44
|
+
|
45
|
+
def receive_last
|
46
|
+
|
47
|
+
ref = att('ref')
|
48
|
+
nid = tags_to_nids(ref).first || @node['heat'][1]['nid']
|
49
|
+
#p [ :break, @node['heap'], nid ]
|
50
|
+
|
51
|
+
payload['ret'] = att(nil) if has_att?(nil)
|
52
|
+
|
53
|
+
ms = []
|
54
|
+
|
55
|
+
if nid
|
56
|
+
|
57
|
+
ms += reply('point' => 'cancel', 'nid' => nid, 'flavour' => @node['heap'])
|
58
|
+
end
|
59
|
+
|
60
|
+
unless is_ancestor_node?(nid)
|
61
|
+
|
62
|
+
pl = ms.any? ? payload.copy_current : payload.current
|
63
|
+
pl['ret'] = node_payload_ret
|
64
|
+
|
65
|
+
ms += reply('payload' => pl)
|
66
|
+
end
|
67
|
+
|
68
|
+
ms
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Cmp < Flor::Procedure
|
27
|
+
|
28
|
+
names %w[ = == < > ]
|
29
|
+
|
30
|
+
def pre_execute
|
31
|
+
|
32
|
+
@node['rets'] = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def receive_last
|
36
|
+
|
37
|
+
payload['ret'] =
|
38
|
+
if @node['rets'].size > 1
|
39
|
+
case tree[0]
|
40
|
+
when '=', '==' then check_equal
|
41
|
+
when '<', '>' then check_lesser
|
42
|
+
else true
|
43
|
+
end
|
44
|
+
else
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
reply
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def check_equal
|
54
|
+
|
55
|
+
@node['rets'].first == @node['rets'].last
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_lesser
|
59
|
+
|
60
|
+
a, b = @node['rets'][-2], @node['rets'][-1]
|
61
|
+
|
62
|
+
case tree[0]
|
63
|
+
when '<' then return false if a >= b
|
64
|
+
when '<=' then return false if a > b
|
65
|
+
when '>' then return false if a <= b
|
66
|
+
when '>=' then return false if a < b
|
67
|
+
end
|
68
|
+
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
#
|
22
|
+
# Made in Japan.
|
23
|
+
#++
|
24
|
+
|
25
|
+
|
26
|
+
class Flor::Pro::Cond < Flor::Procedure
|
27
|
+
|
28
|
+
name 'cond'
|
29
|
+
|
30
|
+
def receive_non_att
|
31
|
+
|
32
|
+
return execute_child(0) if @message['point'] == 'execute'
|
33
|
+
return reply if @node['found']
|
34
|
+
|
35
|
+
tf2 = tree[1][@fcid + 2]
|
36
|
+
|
37
|
+
if Flor.true?(payload['ret'])
|
38
|
+
@node['found'] = true
|
39
|
+
execute_child(@fcid + 1)
|
40
|
+
elsif tf2 && tf2[0, 2] == [ 'else', [] ]
|
41
|
+
@node['found'] = true
|
42
|
+
execute_child(@fcid + 3)
|
43
|
+
else
|
44
|
+
execute_child(@fcid + 2)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def execute_child(i)
|
51
|
+
|
52
|
+
payload['ret'] = node_payload_ret unless tree[1][i]
|
53
|
+
|
54
|
+
super(i)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|