Class: ActionDispatch::Journey::Visitors::FunctionalVisitor
- Inherits:
-
Object
- Object
- ActionDispatch::Journey::Visitors::FunctionalVisitor
- Defined in:
- lib/action_dispatch/journey/visitors.rb
Overview
:nodoc:
Constant Summary collapse
- DISPATCH_CACHE =
{}
Instance Method Summary collapse
- #accept(node, seed) ⇒ Object
- #binary(node, seed) ⇒ Object
- #nary(node, seed) ⇒ Object
- #terminal(node, seed) ⇒ Object
- #unary(node, seed) ⇒ Object
- #visit(node, seed) ⇒ Object
- #visit_CAT(n, seed) ⇒ Object
- #visit_DOT(n, seed) ⇒ Object
- #visit_GROUP(n, seed) ⇒ Object
- #visit_LITERAL(n, seed) ⇒ Object
- #visit_OR(n, seed) ⇒ Object
- #visit_SLASH(n, seed) ⇒ Object
- #visit_STAR(n, seed) ⇒ Object
- #visit_SYMBOL(n, seed) ⇒ Object
Instance Method Details
#accept(node, seed) ⇒ Object
99 100 101 |
# File 'lib/action_dispatch/journey/visitors.rb', line 99 def accept(node, seed) visit(node, seed) end |
#binary(node, seed) ⇒ Object
107 108 109 |
# File 'lib/action_dispatch/journey/visitors.rb', line 107 def binary(node, seed) visit(node.right, visit(node.left, seed)) end |
#nary(node, seed) ⇒ Object
112 113 114 |
# File 'lib/action_dispatch/journey/visitors.rb', line 112 def nary(node, seed) node.children.inject(seed) { |s, c| visit(c, s) } end |
#terminal(node, seed) ⇒ Object
123 |
# File 'lib/action_dispatch/journey/visitors.rb', line 123 def terminal(node, seed); seed; end |
#unary(node, seed) ⇒ Object
117 118 119 |
# File 'lib/action_dispatch/journey/visitors.rb', line 117 def unary(node, seed) visit(node.left, seed) end |
#visit(node, seed) ⇒ Object
103 104 105 |
# File 'lib/action_dispatch/journey/visitors.rb', line 103 def visit(node, seed) send(DISPATCH_CACHE[node.type], node, seed) end |
#visit_CAT(n, seed) ⇒ Object
110 |
# File 'lib/action_dispatch/journey/visitors.rb', line 110 def visit_CAT(n, seed); binary(n, seed); end |
#visit_DOT(n, seed) ⇒ Object
127 |
# File 'lib/action_dispatch/journey/visitors.rb', line 127 def visit_DOT(n, seed); terminal(n, seed); end |
#visit_GROUP(n, seed) ⇒ Object
120 |
# File 'lib/action_dispatch/journey/visitors.rb', line 120 def visit_GROUP(n, seed); unary(n, seed); end |
#visit_LITERAL(n, seed) ⇒ Object
124 |
# File 'lib/action_dispatch/journey/visitors.rb', line 124 def visit_LITERAL(n, seed); terminal(n, seed); end |
#visit_OR(n, seed) ⇒ Object
115 |
# File 'lib/action_dispatch/journey/visitors.rb', line 115 def visit_OR(n, seed); nary(n, seed); end |
#visit_SLASH(n, seed) ⇒ Object
126 |
# File 'lib/action_dispatch/journey/visitors.rb', line 126 def visit_SLASH(n, seed); terminal(n, seed); end |
#visit_STAR(n, seed) ⇒ Object
121 |
# File 'lib/action_dispatch/journey/visitors.rb', line 121 def visit_STAR(n, seed); unary(n, seed); end |
#visit_SYMBOL(n, seed) ⇒ Object
125 |
# File 'lib/action_dispatch/journey/visitors.rb', line 125 def visit_SYMBOL(n, seed); terminal(n, seed); end |