class Mustermann::AST::Boundaries

Make sure start and stop is set on every node and within its parents start and stop. @!visibility private

Public Class Methods

set_boundaries(ast, string: nil, start: 0, stop: string.length) click to toggle source

@return [Mustermann::AST::Node] the ast passed as first argument @!visibility private

# File lib/mustermann/ast/boundaries.rb, line 10
def self.set_boundaries(ast, string: nil, start: 0, stop: string.length)
  new.translate(ast, start, stop)
  ast
end

Public Instance Methods

set_boundaries(node, start, stop) click to toggle source

Checks that a node is within the given boundaries. @!visibility private

# File lib/mustermann/ast/boundaries.rb, line 37
def set_boundaries(node, start, stop)
  node.start = start                      if node.start.nil? or node.start < start
  node.stop  = node.start + node.min_size if node.stop.nil?  or node.stop  < node.start
  node.stop  = stop                       if node.stop > stop
end