Sha256: 0c3386a4973ed70ac202fae739915299629d5cc24a992d354531cfb5aebc6e5e

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

#
# pairmatcher.rb - a pair matching parser
#
# Copyright (C) 2005 Akira Tanaka <akr@m17n.org> 
#     All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms of 
# the GNU General Public License version 2.
#

require 'langscan/_common'
require 'langscan/pairmatcher/pairmatcher'

class Struct::LangScanPair
  def outmost
    ret = self
    while o = ret.outer
      ret = o
    end
    ret
  end

end

module LangScan
  def PairMatcher.fragmentsorter(block)
    buf = []
    pos = 0
    lambda {|f|
      if pos == f.beg_byteno
        pos += f.text.length
        block.call(f)
        buf.sort! {|f1, f2| f1.beg_byteno <=> f2.beg_byteno }
        while !buf.empty? && buf.first.beg_byteno == pos
          f = buf.first
          pos += f.text.length
          block.call(f)
          buf.shift
        end
      else
        buf << f
      end
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
langscan-1.2-x86-mswin32-60 lib/langscan/_pairmatcher.rb
langscan-1.2 lib/langscan/_pairmatcher.rb