Class: Alf::Algebra::ToDot
Instance Method Summary
collapse
-
#call(expr, buf = "") ⇒ Object
-
#on_autonum(expr, buf = "") ⇒ Object
-
#on_binary_operator(expr, buf, label) ⇒ Object
-
#on_clip(expr, buf = "") ⇒ Object
-
#on_coerce(expr, buf = "") ⇒ Object
-
#on_compact(expr, buf = "") ⇒ Object
-
#on_defaults(expr, buf = "") ⇒ Object
-
#on_extend(expr, buf = "") ⇒ Object
-
#on_generator(expr, buf = "") ⇒ Object
-
#on_group(expr, buf = "") ⇒ Object
-
#on_infer_heading(expr, buf = "") ⇒ Object
-
#on_intersect(expr, buf = "") ⇒ Object
-
#on_join(expr, buf = "") ⇒ Object
-
#on_leaf_operand(expr, buf = "") ⇒ Object
-
#on_matching(expr, buf = "") ⇒ Object
-
#on_minus(expr, buf = "") ⇒ Object
-
#on_not_matching(expr, buf = "") ⇒ Object
-
#on_project(expr, buf = "") ⇒ Object
-
#on_quota(expr, buf = "") ⇒ Object
-
#on_rank(expr, buf = "") ⇒ Object
-
#on_rename(expr, buf = "") ⇒ Object
-
#on_restrict(expr, buf = "") ⇒ Object
-
#on_sort(expr, buf = "") ⇒ Object
-
#on_summarize(expr, buf = "") ⇒ Object
-
#on_type_safe(expr, buf = "") ⇒ Object
-
#on_unary_operator(expr, buf, label) ⇒ Object
-
#on_ungroup(expr, buf = "") ⇒ Object
-
#on_union(expr, buf = "") ⇒ Object
-
#on_unwrap(expr, buf = "") ⇒ Object
-
#on_wrap(expr, buf = "") ⇒ Object
#dot_label
Methods inherited from Compiler
#apply, #not_supported, #on_missing
Methods included from Visitor
#copy_and_apply
Instance Method Details
#call(expr, buf = "") ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 6
def call(expr, buf = "")
buf << "/* #{expr} */\n"
buf << "digraph \"Alf\" {\n"
buf << "node [width=0.375,height=0.25,shape=record];\n"
super
buf << "}\n"
buf
end
|
#on_autonum(expr, buf = "") ⇒ Object
48
49
50
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 48
def on_autonum(expr, buf = "")
on_unary_operator(expr, buf, "Autonum|#{as(expr)}")
end
|
#on_binary_operator(expr, buf, label) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 21
def on_binary_operator(expr, buf, label)
buf << "#{expr.object_id} [label=#{dot_label(label)}];\n"
apply(expr.left, buf)
apply(expr.right, buf)
buf << "#{expr.object_id} -> #{expr.left.object_id} [label=\"left\"];\n"
buf << "#{expr.object_id} -> #{expr.right.object_id} [label=\"right\"];\n"
end
|
#on_clip(expr, buf = "") ⇒ Object
52
53
54
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 52
def on_clip(expr, buf = "")
on_unary_operator(expr, buf, "Clip|#{allbut(expr)}#{attributes(expr)}")
end
|
#on_coerce(expr, buf = "") ⇒ Object
56
57
58
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 56
def on_coerce(expr, buf = "")
on_unary_operator(expr, buf, "Coerce|#{expr.coercions}")
end
|
#on_compact(expr, buf = "") ⇒ Object
60
61
62
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 60
def on_compact(expr, buf = "")
on_unary_operator(expr, buf, "Compact")
end
|
#on_defaults(expr, buf = "") ⇒ Object
64
65
66
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 64
def on_defaults(expr, buf = "")
on_unary_operator(expr, buf, "Defaults|#{strict}#{expr.defaults}")
end
|
#on_extend(expr, buf = "") ⇒ Object
68
69
70
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 68
def on_extend(expr, buf = "")
on_unary_operator(expr, buf, "Extend|#{expr.ext}")
end
|
#on_generator(expr, buf = "") ⇒ Object
72
73
74
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 72
def on_generator(expr, buf = "")
on_unary_operator(expr, buf, "Generator|#{expr.size}#{as(expr)}")
end
|
#on_group(expr, buf = "") ⇒ Object
76
77
78
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 76
def on_group(expr, buf = "")
on_unary_operator(expr, buf, "Group|#{allbut(expr)}#{attributes(expr)}#{as(expr)}")
end
|
#on_infer_heading(expr, buf = "") ⇒ Object
80
81
82
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 80
def on_infer_heading(expr, buf = "")
on_unary_operator(expr, buf, "InferHeading")
end
|
#on_intersect(expr, buf = "") ⇒ Object
84
85
86
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 84
def on_intersect(expr, buf = "")
on_binary_operator(expr, buf, "Intersect")
end
|
#on_join(expr, buf = "") ⇒ Object
88
89
90
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 88
def on_join(expr, buf = "")
on_binary_operator(expr, buf, "Join")
end
|
#on_leaf_operand(expr, buf = "") ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 29
def on_leaf_operand(expr, buf = "")
case expr
when Operand::Named
buf << "#{expr.object_id} [label=#{dot_label(expr.name)}];\n"
when Operand::Proxy
buf << "#{expr.object_id} [label=#{dot_label(expr.subject)}];\n"
when Relvar::Virtual
buf << "#{expr.object_id} [label=\"Relvar::Virtual\"];\n"
apply(expr.expr, buf)
buf << "#{expr.object_id} -> #{expr.expr.object_id} [label=\"definition\"];\n"
when Relation
buf << "#{expr.object_id} [label=\"Relation\"];\n"
else
buf << "#{expr.object_id} [label=#{dot_label(expr)}];\n"
end
end
|
#on_matching(expr, buf = "") ⇒ Object
92
93
94
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 92
def on_matching(expr, buf = "")
on_binary_operator(expr, buf, "Matching")
end
|
#on_minus(expr, buf = "") ⇒ Object
96
97
98
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 96
def on_minus(expr, buf = "")
on_binary_operator(expr, buf, "Minus")
end
|
#on_not_matching(expr, buf = "") ⇒ Object
100
101
102
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 100
def on_not_matching(expr, buf = "")
on_binary_operator(expr, buf, "NotMatching")
end
|
#on_project(expr, buf = "") ⇒ Object
104
105
106
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 104
def on_project(expr, buf = "")
on_unary_operator(expr, buf, "Project|#{allbut(expr)}#{attributes(expr)}")
end
|
#on_quota(expr, buf = "") ⇒ Object
108
109
110
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 108
def on_quota(expr, buf = "")
on_unary_operator(expr, buf, "Quota|#{by(expr)}")
end
|
#on_rank(expr, buf = "") ⇒ Object
112
113
114
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 112
def on_rank(expr, buf = "")
on_unary_operator(expr, buf, "Rank|#{order(expr)}#{as(expr)}")
end
|
#on_rename(expr, buf = "") ⇒ Object
116
117
118
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 116
def on_rename(expr, buf = "")
on_unary_operator(expr, buf, "Rename|#{renaming(expr)}")
end
|
#on_restrict(expr, buf = "") ⇒ Object
120
121
122
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 120
def on_restrict(expr, buf = "")
on_unary_operator(expr, buf, "Restrict|#{predicate(expr)}")
end
|
#on_sort(expr, buf = "") ⇒ Object
124
125
126
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 124
def on_sort(expr, buf = "")
on_unary_operator(expr, buf, "Sort|#{ordering(expr)}")
end
|
#on_summarize(expr, buf = "") ⇒ Object
128
129
130
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 128
def on_summarize(expr, buf = "")
on_unary_operator(expr, buf, "Sumarize|#{allbut(expr)}#{by(expr)}")
end
|
#on_type_safe(expr, buf = "") ⇒ Object
132
133
134
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 132
def on_type_safe(expr, buf = "")
on_unary_operator(expr, buf, "TypeSafe|#{strict(expr)}#{heading(expr)}")
end
|
#on_unary_operator(expr, buf, label) ⇒ Object
15
16
17
18
19
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 15
def on_unary_operator(expr, buf, label)
buf << "#{expr.object_id} [label=#{dot_label(label)}];\n"
apply(expr.operand, buf)
buf << "#{expr.object_id} -> #{expr.operand.object_id} [label=\"operand\"];\n"
end
|
#on_ungroup(expr, buf = "") ⇒ Object
136
137
138
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 136
def on_ungroup(expr, buf = "")
on_unary_operator(expr, buf, "Ungroup|#{expr.attribute}")
end
|
#on_union(expr, buf = "") ⇒ Object
140
141
142
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 140
def on_union(expr, buf = "")
on_binary_operator(expr, buf, "Union")
end
|
#on_unwrap(expr, buf = "") ⇒ Object
144
145
146
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 144
def on_unwrap(expr, buf = "")
on_unary_operator(expr, buf, "Unwrap|#{expr.attribute}")
end
|
#on_wrap(expr, buf = "") ⇒ Object
148
149
150
|
# File 'lib/alf-algebra/alf/algebra/support/to_dot.rb', line 148
def on_wrap(expr, buf = "")
on_unary_operator(expr, buf, "Wrap|#{allbut(expr)}#{attributes(expr)}#{as(expr)}")
end
|