class RedParse::ListInNode::LogicalNode
Constants
- OP_EQUIV
- OP_EXPAND
Attributes
opmap[R]
Public Class Methods
[](*list)
click to toggle source
# File lib/redparse/node.rb, line 2818 def self.[](*list) options=list.pop if Hash===list.last result=allocate.replace list opmap=options[:@opmap] if options and options[:@opmap] opmap||=result.op[0,1]*(list.size-1) result.instance_variable_set(:@opmap, opmap) return result end
new(left,op,right)
click to toggle source
# File lib/redparse/node.rb, line 2827 def initialize(left,op,right) op=op.ident if op.respond_to? :ident @opmap=op[0,1] case op when "&&"; op="and" when "||"; op="or" end #@reverse= op=="or" #@op=op replace [left,right] (size-1).downto(0){|i| expr=self[i] if self.class==expr.class self[i,1]=Array.new expr opmap[i,0]=expr.opmap end } end
Public Instance Methods
left()
click to toggle source
# File lib/redparse/node.rb, line 2862 def left self[0] end
left=(val)
click to toggle source
# File lib/redparse/node.rb, line 2865 def left= val self[0]=val end
parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 2875 def parsetree(o) result=[].replace(self).reverse last=result.shift.begin_parsetree(o) first=result.pop result=result.inject(last){|sum,x| [op.to_sym, x.begin_parsetree(o), sum] } [op.to_sym, first.rescue_parsetree(o), result] end
right()
click to toggle source
# File lib/redparse/node.rb, line 2868 def right self[1] end
right=(val)
click to toggle source
# File lib/redparse/node.rb, line 2871 def right= val self[1]=val end
special_conditions!()
click to toggle source
# File lib/redparse/node.rb, line 2885 def special_conditions! each{|x| if x.respond_to? :special_conditions! and !(ParenedNode===x) x.special_conditions! end } end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 2850 def unparse o=default_unparse_options result='' each_with_index{|expr,i| result.concat expr.unparse(o) result.concat ?\s result.concat OP_EXPAND[@opmap[i]] result.concat ?\s } return result end