class RedParse::ListInNode::RangeNode
Public Class Methods
[](*list)
click to toggle source
def self.[] *list
result=RawOpNode[*list] result.extend RangeNode return result
end
# File lib/redparse/node.rb, line 1720 def self.[] *list new(*list) end
new(*args)
click to toggle source
Calls superclass method
RedParse::ListInNode::RawOpNode::new
# File lib/redparse/node.rb, line 1695 def initialize(*args) options=Hash===args.last ? args.pop : {} if args.size==2 left,right=*args op=".." else left,op,right=*args op=op.ident if op.respond_to? :ident end @exclude_end=!!op[2] @as_flow_control=false super(left,op,right,options) end
Public Instance Methods
begin()
click to toggle source
# File lib/redparse/node.rb, line 1708 def begin; first end
end()
click to toggle source
# File lib/redparse/node.rb, line 1709 def end; last end
exclude_end?()
click to toggle source
# File lib/redparse/node.rb, line 1712 def exclude_end?; @exclude_end end
left()
click to toggle source
# File lib/redparse/node.rb, line 1710 def left; first end
parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 1724 def parsetree(o) first=first().parsetree(o) last=last().parsetree(o) if @as_flow_control if :lit==first.first and Integer===first.last first=[:call, [:lit, first.last], :==, [:array, [:gvar, :$.]]] elsif :lit==first.first && Regexp===first.last or :dregx==first.first || :dregx_once==first.first first=[:match, first] end if :lit==last.first and Integer===last.last last=[:call, [:lit, last.last], :==, [:array, [:gvar, :$.]]] elsif :lit==last.first && Regexp===last.last or :dregx==last.first || :dregx_once==last.first last=[:match, last] end tag="flip" else if :lit==first.first and :lit==last.first and Fixnum===first.last and Fixnum===last.last and LiteralNode===first() and LiteralNode===last() return [:lit, Range.new(first.last,last.last,@exclude_end)] end tag="dot" end count= @exclude_end ? ?3 : ?2 tag << count [tag.to_sym, first, last] end
right()
click to toggle source
# File lib/redparse/node.rb, line 1711 def right; last end
special_conditions!()
click to toggle source
# File lib/redparse/node.rb, line 1756 def special_conditions! @as_flow_control=true end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 1760 def unparse(o=default_unparse_options) result=left.unparse(o)+'..' result+='.' if exclude_end? result << right.unparse(o) return result end