class SheepAst::AstManager
Ast hanling class
@api private
Attributes
match_factory[RW]
node_factory[RW]
Public Class Methods
new(name, data_store, match_factory)
click to toggle source
Calls superclass method
SheepAst::Log::new
# File lib/sheep_ast/ast_manager.rb, line 57 def initialize(name, data_store, match_factory) super() name_arr = name.split('.') if name_arr.length != 2 application_error 'ast name should be format of "<domain>.<name>"' end @domain = name_arr[0] @name = name_arr[1] @full_name = name @node_factory = SheepAst::NodeFactory.new @data_store = data_store @match_factory = match_factory setup end
Public Instance Methods
add(matches, action, name)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 91 def add(matches, action, name) action.my_ast_manager = self @node_factory.register_nodes(matches, action, name) end
at_end(data, node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 201 def at_end(data, node) if @disable_action ldebug? and ldebug 'disable action is true, so return Finish without calling action' return MatchAction::Finish end ldebug? and ldebug "matched '#{data.expr.inspect}' at end" ldebug? and ldebug "invoking '#{node.my_action.inspect}' at end" res = T.must(T.must(node).my_action).action(data, node) return res end
condition_end_but_in_progress(data, _node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 189 def condition_end_but_in_progress(data, _node) ldebug? and ldebug "matched '#{data.expr.inspect}' next data" return MatchAction::Next end
condition_in_progress(data, _node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 153 def condition_in_progress(data, _node) ldebug? and ldebug "matched '#{data.expr.inspect}' stay node" return MatchAction::StayNode end
condition_start(data, _node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 165 def condition_start(data, _node) ldebug? and ldebug "matched '#{data.expr.inspect}' condition start. stay node" return MatchAction::StayNode end
disable_action()
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 43 def disable_action @disable_action = true end
dump_tree(logs = :pfatal)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 74 def dump_tree(logs = :pfatal) @node_factory.dump_tree(logs) end
enable_action()
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 48 def enable_action @disable_action = false end
find_next_node(data, node = nil)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 80 def find_next_node(data, node = nil) if node.nil? info = @node_factory.find_from_root_node(data) else info = node.find_next_node(data) end return info end
in_progress(data, _node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 177 def in_progress(data, _node) ldebug? and ldebug "matched '#{data.expr.inspect}' next data" return MatchAction::Next end
inspect()
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 37 def inspect "custom inspect <#{self.class.name} object_id = #{object_id},"\ " full_name = #{@full_name.inspect}>" end
not_found(data, _node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 115 def not_found(data, _node) ldebug? and ldebug "'#{data.expr.inspect}' not found." if @aboort_immediate.nil? @aboort_immediate = ENV['SHEEP_ABORT_FAST'] end if @abort_immediate return MatchAction::Abort else return MatchAction::LazyAbort end end
not_found_in_progress(data, _node)
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 134 def not_found_in_progress(data, _node) ldebug? and ldebug "'#{data.expr.inspect}' not found in progress" if @aboort_immediate.nil? @aboort_immediate = ENV['SHEEP_ABORT_FAST'] end if @abort_immediate return MatchAction::Abort else return MatchAction::LazyAbort end end
setup()
click to toggle source
# File lib/sheep_ast/ast_manager.rb, line 53 def setup; end