Class: RedParse::RangeNode
- Defined in:
- lib/redparse/node.rb,
lib/redparse/node.rb
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from Stackable::Meta
#boolean_identity_params, #identity_params
Class Method Summary collapse
-
.[](*list) ⇒ Object
def self.[] *list result=RawOpNode result.extend RangeNode return result end.
Instance Method Summary collapse
- #begin ⇒ Object
- #end ⇒ Object
- #exclude_end? ⇒ Boolean
-
#initialize(left, op, right = nil) ⇒ RangeNode
constructor
A new instance of RangeNode.
- #left ⇒ Object
- #parsetree(o) ⇒ Object
- #right ⇒ Object
- #special_conditions! ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from RawOpNode
Methods inherited from ValueNode
Methods inherited from Node
#+, #+@, #==, #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #image, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvalue, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #to_parsetree, #to_parsetree_and_warnings, #unary, #walk, #xform_tree!
Methods included from Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(left, op, right = nil) ⇒ RangeNode
Returns a new instance of RangeNode.
1585 1586 1587 1588 1589 1590 1591 |
# File 'lib/redparse/node.rb', line 1585 def initialize(left,op,right=nil) op,right="..",op unless right op=op.ident if op.respond_to? :ident @exclude_end=!!op[2] @as_flow_control=false super(left,op,right) end |
Class Method Details
.[](*list) ⇒ Object
def self.[] *list
result=RawOpNode[*list]
result.extend RangeNode
return result
end
1604 1605 1606 |
# File 'lib/redparse/node.rb', line 1604 def self.[] *list new(*list) end |
Instance Method Details
#begin ⇒ Object
1592 |
# File 'lib/redparse/node.rb', line 1592 def begin; first end |
#end ⇒ Object
1593 |
# File 'lib/redparse/node.rb', line 1593 def end; last end |
#exclude_end? ⇒ Boolean
1596 |
# File 'lib/redparse/node.rb', line 1596 def exclude_end?; @exclude_end end |
#left ⇒ Object
1594 |
# File 'lib/redparse/node.rb', line 1594 def left; first end |
#parsetree(o) ⇒ Object
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 |
# File 'lib/redparse/node.rb', line 1608 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 ⇒ Object
1595 |
# File 'lib/redparse/node.rb', line 1595 def right; last end |
#special_conditions! ⇒ Object
1640 1641 1642 |
# File 'lib/redparse/node.rb', line 1640 def special_conditions! @as_flow_control=true end |
#unparse(o = default_unparse_options) ⇒ Object
1644 1645 1646 1647 1648 1649 |
# File 'lib/redparse/node.rb', line 1644 def unparse(o=) result=left.unparse(o)+'..' result+='.' if exclude_end? result << right.unparse(o) return result end |