class Yadriggy::Loop

while, until, and modifier while/until.

Attributes

body[R]

@return [ASTnode] the loop body.

cond[R]

@return [ASTnode] the condition expression.

op[R]

@return [Symbol] `:while`, `:until`, `:while_mod`, or `:until_mod`.

Public Class Methods

new(sexp) click to toggle source
# File lib/yadriggy/ast.rb, line 1136
def initialize(sexp)
  @op = sexp[0]
  @cond = to_node(sexp[1])
  case @op
  when :while_mod, :until_mod
    @body = to_node(sexp[2])
  else
    @body = Exprs.make(sexp[2])
  end
  add_child(@cond)
  add_child(@body)
end
tags() click to toggle source
# File lib/yadriggy/ast.rb, line 1134
def self.tags() [:while, :until, :while_mod, :until_mod] end

Public Instance Methods

accept(evaluator) click to toggle source

A method for Visitor pattern. @param [Eval] evaluator the visitor of Visitor pattern. @return [void]

# File lib/yadriggy/ast.rb, line 1152
def accept(evaluator)
  evaluator.loop(self)
end
real_operator() click to toggle source

Returns the real operator name. @return [Symbol] the real operator name, `while` or `until`.

# File lib/yadriggy/ast.rb, line 1158
def real_operator
  case @op
  when :while_mod
    :while
  when :until_mod
    :until
  else
    @op
  end
end