Sha256: a939b7ba422bc430c68ebca3be24d89df1db5adc1a682dd4287b8cdaa35c07ac
Contents?: true
Size: 860 Bytes
Versions: 2
Compression:
Stored size: 860 Bytes
Contents
=begin Copyright 2011 Shane Brinkman-Davis See README for licence information. http://babel-bridge.rubyforge.org/ =end module BabelBridge # rule node # subclassed automatically by parser.rule for each unique non-terminal class NonTerminalNode < Node def update_match_length @match_length = last_match ? last_match.offset_after_match - offset : 0 end #***************************** # Array interface implementation #***************************** def matches @matches ||= [] end def last_match matches[-1] end include Enumerable def length matches.length end def add_match(node) return if !node || node.kind_of?(EmptyNode) || node == self node.tap do matches << node update_match_length end end def [](i) matches[i] end def each(&block) matches.each(&block) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
babel_bridge-0.5.1 | lib/nodes/non_terminal_node.rb |
babel_bridge-0.5.0 | lib/nodes/non_terminal_node.rb |