Class: Loxxy::Ast::LoxIfStmt

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

Instance Attribute Summary collapse

Attributes inherited from LoxCompoundExpr

#subnodes

Attributes inherited from LoxNode

#position

Instance Method Summary collapse

Methods inherited from LoxCompoundExpr

#accept

Methods inherited from LoxNode

#accept, #done!

Methods included from ASTVisitee

#define_accept, #snake_case

Constructor Details

#initialize(aPosition, condExpr, thenStmt, elseStmt) ⇒ LoxIfStmt

Returns a new instance of LoxIfStmt.

Parameters:



18
19
20
21
22
# File 'lib/loxxy/ast/lox_if_stmt.rb', line 18

def initialize(aPosition, condExpr, thenStmt, elseStmt)
  super(aPosition, [condExpr])
  @then_stmt = thenStmt
  @else_stmt = elseStmt
end

Instance Attribute Details

#else_stmtLoxNode, NilClass (readonly)

Returns code of else branch.

Returns:

  • (LoxNode, NilClass)

    code of else branch



12
13
14
# File 'lib/loxxy/ast/lox_if_stmt.rb', line 12

def else_stmt
  @else_stmt
end

#then_stmtLoxNode (readonly)

Returns code of then branch.

Returns:

  • (LoxNode)

    code of then branch



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

def then_stmt
  @then_stmt
end

Instance Method Details

#conditionLoxNode

Accessor to the condition expression

Returns:



26
27
28
# File 'lib/loxxy/ast/lox_if_stmt.rb', line 26

def condition
  subnodes[0]
end