class RedParse::ListInNode::LoopNode
Public Class Methods
new(loopword,condition,thenword,body,endtok)
click to toggle source
Calls superclass method
RedParse::ListInNode::Node::new
# File lib/redparse/node.rb, line 4434 def initialize(loopword,condition,thenword,body,endtok) @offset=loopword.offset condition.special_conditions! if condition.respond_to? :special_conditions! super(condition,body) @reverse= loopword.ident=="until" @loopword_offset=loopword.offset end
Public Instance Methods
image()
click to toggle source
# File lib/redparse/node.rb, line 4444 def image; "(#{loopword})" end
parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 4475 def parsetree(o) cond=condition.rescue_parsetree(o) if cond.first==:not reverse=!@reverse cond=cond.last else reverse=@reverse end [reverse ? :until : :while, cond, body&&body.parsetree(o), true] end
reversed()
click to toggle source
# File lib/redparse/node.rb, line 4462 def reversed @reverse end
test_first()
click to toggle source
# File lib/redparse/node.rb, line 4466 def test_first false end
to_lisp()
click to toggle source
# File lib/redparse/node.rb, line 4470 def to_lisp body=body() "(#{@reverse ? :until : :while} #{condition.to_lisp}\n#{body.to_lisp})" end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 4446 def unparse o=default_unparse_options [@reverse? "until " : "while ", condition.unparse(o), unparse_nl(body||self,o), body&&body.unparse(o), ";end" ].join end
until()
click to toggle source
# File lib/redparse/node.rb, line 4458 def until @reverse ? condition : negate(condition, @loopword_offset) end
while()
click to toggle source
# File lib/redparse/node.rb, line 4454 def while @reverse ? negate(condition, @loopword_offset) : condition end