gisele 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -3
- data/Gemfile.lock +15 -7
- data/bin/tast2fsp +53 -0
- data/examples/dqaad/dqaad.gif +0 -0
- data/examples/dqaad/dqaad.gis +31 -0
- data/examples/meeting-scheduler/MeetingScheduling.dot +46 -0
- data/examples/meeting-scheduler/MeetingScheduling.gif +0 -0
- data/examples/meeting-scheduler/MeetingScheduling.gis +1 -1
- data/examples/rectal-cancer-pathway/RectalCancerPathway.dot +55 -0
- data/examples/rectal-cancer-pathway/RectalCancerPathway.gif +0 -0
- data/examples/union/breast.gis +19 -0
- data/examples/union/breast/deterministic.dot +33 -0
- data/examples/union/breast/deterministic.gif +0 -0
- data/examples/union/breast/glts.dot +53 -0
- data/examples/union/breast/glts.gif +0 -0
- data/examples/union/breast/minimal.dot +31 -0
- data/examples/union/breast/minimal.gif +0 -0
- data/examples/union/breast/wf.dot +21 -0
- data/examples/union/breast/wf.gif +0 -0
- data/examples/union/dot.rb +6 -0
- data/examples/union/merged.dot +42 -0
- data/examples/union/merged.gif +0 -0
- data/examples/union/minim.dot +41 -0
- data/examples/union/minim.gif +0 -0
- data/examples/union/rectal.gis +20 -0
- data/examples/union/rectal/deterministic.dot +37 -0
- data/examples/union/rectal/deterministic.gif +0 -0
- data/examples/union/rectal/glts.dot +59 -0
- data/examples/union/rectal/glts.gif +0 -0
- data/examples/union/rectal/minimal.dot +35 -0
- data/examples/union/rectal/minimal.gif +0 -0
- data/examples/union/rectal/wf.dot +23 -0
- data/examples/union/rectal/wf.gif +0 -0
- data/examples/union/union.gis +48 -0
- data/examples/union/union.rb +39 -0
- data/examples/while/while-deteministic.gif +0 -0
- data/examples/while/while.dot +30 -0
- data/examples/while/while.gif +0 -0
- data/examples/while/while.gis +10 -0
- data/gisele.gemspec +2 -3
- data/gisele.noespec +3 -4
- data/lib/gisele.rb +0 -1
- data/lib/gisele/command.rb +30 -8
- data/lib/gisele/errors.rb +4 -0
- data/lib/gisele/loader.rb +1 -2
- data/lib/gisele/version.rb +2 -2
- data/spec/command/main/gisele_glts.stdout +89 -83
- data/spec/command/main/gisele_help.stdout +3 -0
- data/spec/command/main/gisele_no_sugar.stdout +34 -1
- data/spec/command/main/gisele_version.stdout +1 -1
- data/spec/fixtures/tasks/complete.gis +5 -1
- metadata +88 -43
- data/examples/merge/BreastCancer.dot +0 -30
- data/examples/merge/BreastCancer.gif +0 -0
- data/examples/merge/BreastCancer.gis +0 -17
- data/examples/merge/Merge.dot +0 -46
- data/examples/merge/Merge.gif +0 -0
- data/examples/merge/RectalCancer.dot +0 -22
- data/examples/merge/RectalCancer.gif +0 -0
- data/examples/merge/RectalCancer.gis +0 -15
- data/lib/gisele/compiling.rb +0 -2
- data/lib/gisele/compiling/to_glts.rb +0 -125
- data/lib/gisele/compiling/to_graph.rb +0 -160
- data/lib/gisele/compiling/to_graph.yml +0 -20
- data/spec/unit/compiling/test_to_glts.rb +0 -20
- data/spec/unit/compiling/test_to_graph.rb +0 -19
@@ -1,30 +0,0 @@
|
|
1
|
-
digraph G {
|
2
|
-
graph [rankdir="LR"];
|
3
|
-
10 [color="black" fillcolor="green" shape="circle" style="filled"];
|
4
|
-
16 [color="black" fillcolor="white" shape="circle" style="filled"];
|
5
|
-
15 [color="black" fillcolor="white" shape="circle" style="filled"];
|
6
|
-
19 [color="black" fillcolor="white" shape="circle" style="filled"];
|
7
|
-
18 [color="black" fillcolor="white" shape="circle" style="filled"];
|
8
|
-
112 [color="black" fillcolor="white" shape="circle" style="filled"];
|
9
|
-
115 [color="black" fillcolor="white" shape="circle" style="filled"];
|
10
|
-
118 [color="black" fillcolor="white" shape="circle" style="filled"];
|
11
|
-
117 [color="black" fillcolor="white" shape="circle" style="filled"];
|
12
|
-
123 [color="black" fillcolor="white" shape="circle" style="filled"];
|
13
|
-
126 [color="black" fillcolor="white" shape="circle" style="filled"];
|
14
|
-
132 [color="black" fillcolor="white" shape="circle" style="filled"];
|
15
|
-
129 [color="black" fillcolor="white" shape="circle" style="filled"];
|
16
|
-
10 -> 16 [label="Diagnosis:start"];
|
17
|
-
16 -> 15 [label="Diagnosis:end"];
|
18
|
-
15 -> 19 [label="Psy:start"];
|
19
|
-
19 -> 18 [label="Psy:end"];
|
20
|
-
18 -> 112 [label="Staff:start"];
|
21
|
-
112 -> 115 [label="Staff:end"];
|
22
|
-
115 -> 118 [label="[t] / Radio:start"];
|
23
|
-
118 -> 117 [label="Radio:end"];
|
24
|
-
123 -> 126 [label="Chimio:end"];
|
25
|
-
129 -> 117 [label="Consultation:end"];
|
26
|
-
126 -> 129 [label="[not(ok)] / Consultation:start"];
|
27
|
-
132 -> 117 [label="Radio:end"];
|
28
|
-
126 -> 132 [label="[ok] / Radio:start"];
|
29
|
-
115 -> 123 [label="[not(t)] / Chimio:start"];
|
30
|
-
}
|
Binary file
|
data/examples/merge/Merge.dot
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
digraph G {
|
2
|
-
graph [rankdir="LR"];
|
3
|
-
|
4
|
-
20 [color="black" fillcolor="orange" shape="circle" style="filled"];
|
5
|
-
26 [color="black" fillcolor="orange" shape="circle" style="filled"];
|
6
|
-
25 [color="black" fillcolor="orange" shape="circle" style="filled"];
|
7
|
-
|
8
|
-
19 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
9
|
-
18 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
10
|
-
112 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
11
|
-
115 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
12
|
-
118 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
13
|
-
117 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
14
|
-
123 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
15
|
-
126 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
16
|
-
129 [color="black" fillcolor="yellow" shape="circle" style="filled"];
|
17
|
-
|
18
|
-
29 [color="black" fillcolor="red" shape="circle" style="filled"];
|
19
|
-
212 [color="black" fillcolor="red" shape="circle" style="filled"];
|
20
|
-
217 [color="black" fillcolor="red" shape="circle" style="filled"];
|
21
|
-
220 [color="black" fillcolor="red" shape="circle" style="filled"];
|
22
|
-
|
23
|
-
117 [color="black" fillcolor="orange" shape="circle" style="filled"];
|
24
|
-
|
25
|
-
20 -> 26 [label="Diagnosis:start"];
|
26
|
-
26 -> 25 [label="Diagnosis:end"];
|
27
|
-
25 -> 19 [label="[wf1] / Psy:start"];
|
28
|
-
19 -> 18 [label="Psy:end"];
|
29
|
-
18 -> 112 [label="Staff:start"];
|
30
|
-
112 -> 115 [label="Staff:end"];
|
31
|
-
115 -> 118 [label="[t] / Radio:start"];
|
32
|
-
118 -> 117 [label="Radio:end"];
|
33
|
-
123 -> 126 [label="Chimio:end"];
|
34
|
-
129 -> 117 [label="Consultation:end"];
|
35
|
-
126 -> 129 [label="[not(ok)] / Consultation:start"];
|
36
|
-
126 -> 118 [label="[ok] / Radio:start"];
|
37
|
-
115 -> 123 [label="[not(t)] / Chimio:start"];
|
38
|
-
|
39
|
-
25 -> 29 [label="[wf2] / Staff:start"];
|
40
|
-
29 -> 212 [label="Staff:end"];
|
41
|
-
217 -> 220 [label="Chimio:end"];
|
42
|
-
220 -> 29 [label="[not(ok)] / Staff:start"];
|
43
|
-
212 -> 217 [label="[not(t and m)] / Chimio:start"];
|
44
|
-
212 -> 118 [label="[t and m] / Radio:start"]
|
45
|
-
220 -> 118 [label="[ok] / Radio:start"]
|
46
|
-
}
|
data/examples/merge/Merge.gif
DELETED
Binary file
|
@@ -1,22 +0,0 @@
|
|
1
|
-
digraph G {
|
2
|
-
graph [rankdir="LR"];
|
3
|
-
20 [color="black" fillcolor="green" shape="circle" style="filled"];
|
4
|
-
26 [color="black" fillcolor="white" shape="circle" style="filled"];
|
5
|
-
25 [color="black" fillcolor="white" shape="circle" style="filled"];
|
6
|
-
29 [color="black" fillcolor="white" shape="circle" style="filled"];
|
7
|
-
212 [color="black" fillcolor="white" shape="circle" style="filled"];
|
8
|
-
217 [color="black" fillcolor="white" shape="circle" style="filled"];
|
9
|
-
220 [color="black" fillcolor="white" shape="circle" style="filled"];
|
10
|
-
226 [color="black" fillcolor="white" shape="circle" style="filled"];
|
11
|
-
225 [color="black" fillcolor="white" shape="circle" style="filled"];
|
12
|
-
20 -> 26 [label="Diagnosis:start"];
|
13
|
-
26 -> 25 [label="Diagnosis:end"];
|
14
|
-
25 -> 29 [label="Staff:start"];
|
15
|
-
29 -> 212 [label="Staff:end"];
|
16
|
-
217 -> 220 [label="Chimio:end"];
|
17
|
-
220 -> 29 [label="[not(ok)] / Staff:start"];
|
18
|
-
212 -> 217 [label="[not(t and m)] / Chimio:start"];
|
19
|
-
226 -> 225 [label="Radio:end"];
|
20
|
-
212 -> 226 [label="[t and m] / Radio:start"]
|
21
|
-
220 -> 226 [label="[ok] / Radio:start"]
|
22
|
-
}
|
Binary file
|
data/lib/gisele/compiling.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
module Gisele
|
2
|
-
module Compiling
|
3
|
-
class ToGlts < Sexpr::Rewriter
|
4
|
-
grammar Language
|
5
|
-
|
6
|
-
DOT_REWRITER = lambda{|elm,kind|
|
7
|
-
case kind
|
8
|
-
when :automaton
|
9
|
-
{:rankdir => "LR"}
|
10
|
-
when :state
|
11
|
-
{:shape => "circle",
|
12
|
-
:style => "filled",
|
13
|
-
:color => "black",
|
14
|
-
:fillcolor => (elm.initial? ? "green" : "white")}
|
15
|
-
when :edge
|
16
|
-
label = elm[:guard] ? "[#{elm[:guard].label}]" : elm[:symbol]
|
17
|
-
{:label => label || ''}
|
18
|
-
end
|
19
|
-
}
|
20
|
-
|
21
|
-
# if/elsif/else -> guarded commands
|
22
|
-
use Language::IfToCase
|
23
|
-
|
24
|
-
def on_unit_def(sexpr)
|
25
|
-
sexpr.
|
26
|
-
sexpr_body.
|
27
|
-
select{|n| n.first == :task_def}.
|
28
|
-
map{|taskdef| apply(taskdef) }
|
29
|
-
end
|
30
|
-
|
31
|
-
def on_task_def(sexpr)
|
32
|
-
@glts = Stamina::Automaton.new
|
33
|
-
|
34
|
-
entry = add_state(sexpr, :initial => true)
|
35
|
-
exit = add_state(sexpr)
|
36
|
-
c_entry, c_exit = apply(sexpr.last)
|
37
|
-
connect(entry, c_entry)
|
38
|
-
connect(c_exit, exit)
|
39
|
-
|
40
|
-
@glts
|
41
|
-
end
|
42
|
-
|
43
|
-
def on_seq_st(sexpr)
|
44
|
-
mine = entry_and_exit(sexpr)
|
45
|
-
current = mine.first
|
46
|
-
sexpr.sexpr_body.each do |child|
|
47
|
-
c_entry, c_exit = apply(child)
|
48
|
-
connect(current, c_entry)
|
49
|
-
current = c_exit
|
50
|
-
end
|
51
|
-
connect(current, mine.last)
|
52
|
-
mine
|
53
|
-
end
|
54
|
-
alias :on_par_st :on_seq_st
|
55
|
-
|
56
|
-
def on_case_st(sexpr)
|
57
|
-
cond, *clauses = sexpr.sexpr_body
|
58
|
-
|
59
|
-
entry, exit = entry_and_exit(sexpr)
|
60
|
-
|
61
|
-
diamond = add_state(sexpr)
|
62
|
-
connect(entry, diamond)
|
63
|
-
|
64
|
-
clauses.each do |clause|
|
65
|
-
c_entry, c_exit = apply(clause.last)
|
66
|
-
connect(diamond, c_entry, clause[1])
|
67
|
-
connect(c_exit, exit)
|
68
|
-
end
|
69
|
-
|
70
|
-
[entry, exit]
|
71
|
-
end
|
72
|
-
|
73
|
-
def on_while_st(sexpr)
|
74
|
-
cond, dost, = sexpr.sexpr_body
|
75
|
-
|
76
|
-
entry, exit = entry_and_exit(sexpr)
|
77
|
-
|
78
|
-
diamond = add_state(sexpr)
|
79
|
-
connect(entry, diamond)
|
80
|
-
|
81
|
-
c_entry, c_exit = apply(sexpr.last)
|
82
|
-
|
83
|
-
connect(diamond, exit, cond.negate)
|
84
|
-
connect(diamond, c_entry, cond)
|
85
|
-
connect(c_exit, diamond)
|
86
|
-
|
87
|
-
[entry, exit]
|
88
|
-
end
|
89
|
-
|
90
|
-
def on_task_call_st(sexpr)
|
91
|
-
entry, exit = entry_and_exit(sexpr)
|
92
|
-
middle = add_state(sexpr)
|
93
|
-
connect(entry, middle, transition(sexpr, "start"))
|
94
|
-
connect(middle, exit, transition(sexpr, "end"))
|
95
|
-
[entry, exit]
|
96
|
-
end
|
97
|
-
|
98
|
-
private
|
99
|
-
|
100
|
-
def entry_and_exit(sexpr)
|
101
|
-
@glts.add_n_states(2)
|
102
|
-
end
|
103
|
-
|
104
|
-
def add_state(sexpr, attrs = nil)
|
105
|
-
@glts.add_state(attrs || {})
|
106
|
-
end
|
107
|
-
|
108
|
-
def connect(source, target, attrs = {:symbol => nil})
|
109
|
-
attrs = transition(attrs) unless Hash===attrs
|
110
|
-
@glts.connect(source, target, attrs)
|
111
|
-
end
|
112
|
-
|
113
|
-
def transition(sexpr, kind = nil)
|
114
|
-
raise UnexpectedNodeError, "Node expected, got #{sexpr}" unless Sexpr===sexpr
|
115
|
-
case sexpr.first
|
116
|
-
when :task_call_st then {:symbol => "#{sexpr.label}:#{kind}"}
|
117
|
-
when :bool_expr then {:symbol => "[guard]", :guard => sexpr}
|
118
|
-
else
|
119
|
-
raise UnexpectedNodeError, "Unexpected event kind #{sexpr.inspect}"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
end # class ToGlts
|
124
|
-
end # module Compiling
|
125
|
-
end # module Gisele
|
@@ -1,160 +0,0 @@
|
|
1
|
-
module Gisele
|
2
|
-
module Compiling
|
3
|
-
class ToGraph < Sexpr::Rewriter
|
4
|
-
grammar Language
|
5
|
-
|
6
|
-
# We do not support the elsif syntactic sugar here; rewrite it as 'else if'.
|
7
|
-
use Language::ElsifFlattener
|
8
|
-
|
9
|
-
# This is a marker for the graph nodes we can remove later.
|
10
|
-
module Connector; end
|
11
|
-
|
12
|
-
def on_unit_def(sexpr)
|
13
|
-
sexpr.
|
14
|
-
sexpr_body.
|
15
|
-
select{|n| n.first == :task_def}.
|
16
|
-
map{|taskdef| apply(taskdef) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def on_task_def(sexpr)
|
20
|
-
@graph = Yargi::Digraph.new
|
21
|
-
|
22
|
-
entry, exit = add_vertex(sexpr), add_vertex(sexpr)
|
23
|
-
c_entry, c_exit = apply(sexpr.last)
|
24
|
-
connect(entry, c_entry)
|
25
|
-
connect(c_exit, exit)
|
26
|
-
|
27
|
-
@graph.vertices(Connector).each do |vertex|
|
28
|
-
next unless vertex.out_edges.size == 1
|
29
|
-
target = vertex.out_edges.first.target
|
30
|
-
@graph.reconnect(vertex.in_edges, nil, target)
|
31
|
-
@graph.remove_vertex(vertex)
|
32
|
-
end
|
33
|
-
|
34
|
-
@graph
|
35
|
-
end
|
36
|
-
|
37
|
-
def on_seq_st(sexpr)
|
38
|
-
mine = entry_and_exit(sexpr)
|
39
|
-
current = mine.first
|
40
|
-
sexpr.sexpr_body.each do |child|
|
41
|
-
c_entry, c_exit = apply(child)
|
42
|
-
connect(current, c_entry)
|
43
|
-
current = c_exit
|
44
|
-
end
|
45
|
-
connect(current, mine.last)
|
46
|
-
mine
|
47
|
-
end
|
48
|
-
|
49
|
-
def on_par_st(sexpr)
|
50
|
-
entry, exit = add_vertex(sexpr), add_vertex(sexpr)
|
51
|
-
sexpr.sexpr_body.each do |child|
|
52
|
-
c_entry, c_exit = apply(child)
|
53
|
-
connect(entry, c_entry)
|
54
|
-
connect(c_exit, exit)
|
55
|
-
end
|
56
|
-
[entry, exit]
|
57
|
-
end
|
58
|
-
|
59
|
-
def on_if_st(sexpr)
|
60
|
-
cond, then_clause, else_clause, = sexpr.sexpr_body
|
61
|
-
|
62
|
-
entry, exit = entry_and_exit(sexpr)
|
63
|
-
|
64
|
-
diamond = add_vertex(sexpr)
|
65
|
-
connect(entry, diamond)
|
66
|
-
|
67
|
-
c_entry, c_exit = apply(then_clause)
|
68
|
-
connect(diamond, c_entry, true_ast_sexpr)
|
69
|
-
connect(c_exit, exit)
|
70
|
-
|
71
|
-
if else_clause
|
72
|
-
c_entry, c_exit = apply(else_clause.last)
|
73
|
-
connect(diamond, c_entry, false_ast_sexpr)
|
74
|
-
connect(c_exit, exit)
|
75
|
-
else
|
76
|
-
connect(diamond, exit, false_ast_sexpr)
|
77
|
-
end
|
78
|
-
|
79
|
-
[entry, exit]
|
80
|
-
end
|
81
|
-
|
82
|
-
def on_case_st(sexpr)
|
83
|
-
cond, *clauses = sexpr.sexpr_body
|
84
|
-
|
85
|
-
entry, exit = entry_and_exit(sexpr)
|
86
|
-
|
87
|
-
diamond = add_vertex(sexpr)
|
88
|
-
connect(entry, diamond)
|
89
|
-
|
90
|
-
clauses.each do |clause|
|
91
|
-
c_entry, c_exit = apply(clause.last)
|
92
|
-
connect(diamond, c_entry, clause)
|
93
|
-
connect(c_exit, exit)
|
94
|
-
end
|
95
|
-
|
96
|
-
[entry, exit]
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
def on_while_st(sexpr)
|
101
|
-
cond, dost, = sexpr.sexpr_body
|
102
|
-
|
103
|
-
entry, exit = entry_and_exit(sexpr)
|
104
|
-
|
105
|
-
diamond = add_vertex(sexpr)
|
106
|
-
connect(entry, diamond)
|
107
|
-
|
108
|
-
c_entry, c_exit = apply(sexpr.last)
|
109
|
-
|
110
|
-
connect(diamond, exit, false_ast_sexpr)
|
111
|
-
connect(diamond, c_entry, true_ast_sexpr)
|
112
|
-
connect(c_exit, diamond)
|
113
|
-
|
114
|
-
[entry, exit]
|
115
|
-
end
|
116
|
-
|
117
|
-
def on_task_call_st(sexpr)
|
118
|
-
entry, exit = entry_and_exit(sexpr)
|
119
|
-
task = add_vertex(sexpr)
|
120
|
-
connect(entry, task)
|
121
|
-
connect(task, exit)
|
122
|
-
[entry, exit]
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def add_vertex(sexpr)
|
128
|
-
@graph.add_vertex(dot_attributes(sexpr))
|
129
|
-
end
|
130
|
-
|
131
|
-
def entry_and_exit(sexpr, tag = Connector)
|
132
|
-
@graph.add_n_vertices(2, tag)
|
133
|
-
end
|
134
|
-
|
135
|
-
def connect(source, target, sexpr = nil)
|
136
|
-
@graph.connect(source, target, dot_attributes(sexpr))
|
137
|
-
end
|
138
|
-
|
139
|
-
def false_ast_sexpr
|
140
|
-
sexpr(parse("false", :root => :bool_expr))
|
141
|
-
end
|
142
|
-
|
143
|
-
def true_ast_sexpr
|
144
|
-
sexpr(parse("true", :root => :bool_expr))
|
145
|
-
end
|
146
|
-
|
147
|
-
DOT_ATTRIBUTES = YAML.load_file(Path.dir/"to_graph.yml")
|
148
|
-
def dot_attributes(sexpr)
|
149
|
-
if Sexpr===sexpr
|
150
|
-
attrs = DOT_ATTRIBUTES["graphviz"][sexpr.first.to_s] || {}
|
151
|
-
attrs = attrs.merge(:label => sexpr.label) if sexpr.respond_to?(:label)
|
152
|
-
attrs
|
153
|
-
else
|
154
|
-
{} # sometimes, sexpr is simply nil
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
end # class ToGraph
|
159
|
-
end # module Compiling
|
160
|
-
end # module Gisele
|
@@ -1,20 +0,0 @@
|
|
1
|
-
graphviz:
|
2
|
-
task_def:
|
3
|
-
shape: circle
|
4
|
-
style: filled
|
5
|
-
fillcolor: black
|
6
|
-
fixed: true
|
7
|
-
width: 0.1
|
8
|
-
task_call_st:
|
9
|
-
shape: box
|
10
|
-
while_st:
|
11
|
-
shape: diamond
|
12
|
-
if_st:
|
13
|
-
shape: diamond
|
14
|
-
case_st:
|
15
|
-
shape: diamond
|
16
|
-
par_st:
|
17
|
-
shape: box
|
18
|
-
height: 0.1
|
19
|
-
style: filled
|
20
|
-
fillcolor: black
|