Class: Loxxy::Ast::LoxUnaryExpr

Inherits:
LoxCompoundExpr show all
Defined in:
lib/loxxy/ast/lox_unary_expr.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, anOperator, operand) ⇒ LoxUnaryExpr

Returns a new instance of LoxUnaryExpr.

Parameters:

  • aPosition (Rley::Lexical::Position)

    Position of the entry in the input stream.

  • operand (Loxxy::Ast::LoxNode)


13
14
15
16
# File 'lib/loxxy/ast/lox_unary_expr.rb', line 13

def initialize(aPosition, anOperator, operand)
  super(aPosition, [operand])
  @operator = anOperator
end

Instance Attribute Details

#operatorSymbol (readonly)

Returns message name to be sent to receiver.

Returns:

  • (Symbol)

    message name to be sent to receiver



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

def operator
  @operator
end

Instance Method Details

#accept(visitor) ⇒ Object

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

Parameters:



20
21
22
# File 'lib/loxxy/ast/lox_unary_expr.rb', line 20

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