Class: Alf::Algebra::Rewriter
- Inherits:
-
Object
- Object
- Alf::Algebra::Rewriter
show all
- Includes:
- Visitor
- Defined in:
- lib/alf/algebra/support/rewriter.rb
Instance Method Summary
collapse
-
#apply(expr, *args, &bl) ⇒ Object
copy all default implementation.
-
#call(expr, search = nil) ⇒ Object
-
#not_supported(expr, *args, &bl) ⇒ Object
-
#on_leaf_operand(expr, *args, &bl) ⇒ Object
-
#on_missing(expr, *args, &bl) ⇒ Object
-
#on_shortcut(expr, *args, &bl) ⇒ Object
Methods included from Visitor
#copy_and_apply
Instance Method Details
#apply(expr, *args, &bl) ⇒ Object
copy all default implementation
14
15
16
|
# File 'lib/alf/algebra/support/rewriter.rb', line 14
def apply(expr, *args, &bl)
send to_method_name(expr, "on_"), expr, *args, &bl
end
|
#call(expr, search = nil) ⇒ Object
8
9
10
|
# File 'lib/alf/algebra/support/rewriter.rb', line 8
def call(expr, search = nil)
apply(expr)
end
|
#not_supported(expr, *args, &bl) ⇒ Object
30
31
32
|
# File 'lib/alf/algebra/support/rewriter.rb', line 30
def not_supported(expr, *args, &bl)
raise NotSupportedError, "Unexpected operand `#{expr}`"
end
|
#on_leaf_operand(expr, *args, &bl) ⇒ Object
18
19
20
|
# File 'lib/alf/algebra/support/rewriter.rb', line 18
def on_leaf_operand(expr, *args, &bl)
expr
end
|
#on_missing(expr, *args, &bl) ⇒ Object
26
27
28
|
# File 'lib/alf/algebra/support/rewriter.rb', line 26
def on_missing(expr, *args, &bl)
copy_and_apply(expr, *args, &bl)
end
|
#on_shortcut(expr, *args, &bl) ⇒ Object
22
23
24
|
# File 'lib/alf/algebra/support/rewriter.rb', line 22
def on_shortcut(expr, *args, &bl)
apply(expr.expand, *args, &bl)
end
|