Class: Loxxy::Ast::LoxWhileStmt

Inherits:
LoxCompoundExpr show all
Defined in:
lib/loxxy/ast/lox_while_stmt.rb

Instance Attribute Summary collapse

Attributes inherited from LoxCompoundExpr

#subnodes

Attributes inherited from LoxNode

#position

Instance Method Summary collapse

Methods inherited from LoxNode

#done!

Constructor Details

#initialize(aPosition, condExpr, theBody) ⇒ LoxWhileStmt

Returns a new instance of LoxWhileStmt.

Parameters:



14
15
16
17
# File 'lib/loxxy/ast/lox_while_stmt.rb', line 14

def initialize(aPosition, condExpr, theBody)
  super(aPosition, [condExpr])
  @body = theBody
end

Instance Attribute Details

#bodyLoxNode (readonly)

Returns body of the while loop (as a statement).

Returns:

  • (LoxNode)

    body of the while loop (as a statement)



9
10
11
# File 'lib/loxxy/ast/lox_while_stmt.rb', line 9

def body
  @body
end

Instance Method Details

#accept(visitor) ⇒ Object

Part of the 'visitee' role in Visitor design pattern.

Parameters:



21
22
23
# File 'lib/loxxy/ast/lox_while_stmt.rb', line 21

def accept(visitor)
  visitor.visit_while_stmt(self)
end

#conditionLoxNode

Accessor to the condition expression

Returns:



27
28
29
# File 'lib/loxxy/ast/lox_while_stmt.rb', line 27

def condition
  subnodes[0]
end