Sha256: 5303c005409b66afe76d2e9fb18dc61b212a2c9532a13db979c76114a67fdf89

Contents?: true

Size: 360 Bytes

Versions: 17

Compression:

Stored size: 360 Bytes

Contents

module Faml
  module ParserUtils
    module_function

    def balance(scanner, start, finish, depth = 1)
      re = /(#{Regexp.escape(start)}|#{Regexp.escape(finish)})/
      while depth > 0 && scanner.scan_until(re)
        if scanner.matched == start
          depth += 1
        else
          depth -= 1
        end
      end
      depth
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
faml-0.2.16 lib/faml/parser_utils.rb
faml-0.2.15 lib/faml/parser_utils.rb
faml-0.2.14 lib/faml/parser_utils.rb
faml-0.2.13 lib/faml/parser_utils.rb
faml-0.2.12 lib/faml/parser_utils.rb
faml-0.2.11 lib/faml/parser_utils.rb
faml-0.2.10 lib/faml/parser_utils.rb
faml-0.2.9 lib/faml/parser_utils.rb
faml-0.2.8 lib/faml/parser_utils.rb
faml-0.2.7 lib/faml/parser_utils.rb
faml-0.2.6 lib/faml/parser_utils.rb
faml-0.2.5 lib/faml/parser_utils.rb
faml-0.2.4 lib/faml/parser_utils.rb
faml-0.2.3 lib/faml/parser_utils.rb
faml-0.2.2 lib/faml/parser_utils.rb
faml-0.2.1 lib/faml/parser_utils.rb
faml-0.2.0 lib/faml/parser_utils.rb