module PryCoolline::ParenMatch::AST

This module contains the different kinds of AST nodes generated when trying to match pairs of opening and closing characters.

Constants

Root

The root of the AST tree. @attr [Array<Leaf, DanglingClose, Node>] elements All the top-level

nodes of the tree.

Public Instance Methods

pair_at(pos) click to toggle source

Finds the opening and closing tokens that should be matched at a certain position in the string.

It is assumed you can be looking for the closing parenthesis when on the opening one, or for the opening one when selecting the character that immediately follows it.

@param [Integer] pos

@return [Pair] An (open, close) pair. Notice both the opening and

closing tokens coud be nil.
# File lib/pry-coolline/paren_match.rb, line 96
def pair_at(pos)
  elements.each do |el|
    if pair = el.pair_at(pos)
      return pair
    end
  end

  Pair.new
end