class RedParse::ListInNode::SequenceNode
Constants
- LITCAT
LITCAT=proc{|item| item.grep(~LITSTR).empty?} class<<LITCAT; alias === call; end
- LITFIX
- LITNODE
- LITRANGE
- LITSTR
- LITUPLUS
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
RedParse::ListInNode::ListOpNode::new
# File lib/redparse/node.rb, line 1542 def initialize(*args) return if args.empty? super @offset=self.first.offset end
Public Instance Methods
+(other)
click to toggle source
# File lib/redparse/node.rb, line 1547 def +(other) if SequenceNode===other dup.push( *other ) else dup.push other end end
[]=(*args)
click to toggle source
Calls superclass method
RedParse::ListInNode::Node#[]=
# File lib/redparse/node.rb, line 1555 def []=(*args) val=args.pop if SequenceNode===val val=Array.new(val) #munge args too if args.size==1 and Integer===args.first args<<1 end end super( *args<<val ) end
image()
click to toggle source
# File lib/redparse/node.rb, line 1567 def image; '(;)' end
parsetree(o)
click to toggle source
VarNode| why not this too?
# File lib/redparse/node.rb, line 1591 def parsetree(o) data=compact data.empty? and return items=Array.new(data[0...-1]) if o[:quirks] items.shift while LITNODE===items.first else items.reject!{|expr| LITNODE===expr } end items.map!{|expr| expr.rescue_parsetree(o)}.push last.parsetree(o) # items=map{|expr| expr.parsetree(o)} items.reject!{|expr| []==expr } if o[:quirks] unless BeginNode===data[0] header=items.first (items[0,1] = *header[1..-1]) if header and header.first==:block end else (items.size-1).downto(0){|i| header=items[i] (items[i,1] = *header[1..-1]) if header and header.first==:block } end result= if items.size>1 items.unshift :block elsif items.size==1 items.first else items end limit=o[:quirks] ? 1 : result.size-1 (0..limit).each{|i| result[i,1]=result[i][1..-1] if Array===result[i] and result[i][0]==:block } return result end
to_lisp()
click to toggle source
# File lib/redparse/node.rb, line 1568 def to_lisp "#{map{|x| x.to_lisp}.join("\n")}" end
to_lisp_with_parens()
click to toggle source
# File lib/redparse/node.rb, line 1572 def to_lisp_with_parens "(#{to_lisp})" end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 1631 def unparse o=default_unparse_options return "" if empty? unparse_nl(first,o,'')+first.unparse(o)+ self[1..-1].map{|expr| unparse_nl(expr,o)+expr.unparse(o) }.join end