Sha256: 3187e7cc782ce0ef86a5e681bc6c73dad8b9c3132a1f39eb5fbab11195c8899a

Contents?: true

Size: 957 Bytes

Versions: 6

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

require_relative 'lox_compound_expr'

module Loxxy
  module Ast
    class LoxIfStmt < LoxCompoundExpr
      # @return [LoxNode] code of then branch
      attr_reader :then_stmt

      # @return [LoxNode, NilClass] code of else branch
      attr_reader :else_stmt

      # @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
      # @param subExpr [Loxxy::Ast::LoxNode]
      def initialize(aPosition, condExpr, thenStmt, elseStmt)
        super(aPosition, [condExpr])
        @then_stmt = thenStmt
        @else_stmt = elseStmt
      end

      # Part of the 'visitee' role in Visitor design pattern.
      # @param visitor [Ast::ASTVisitor] the visitor
      def accept(visitor)
        visitor.visit_if_stmt(self)
      end

      # Accessor to the condition expression
      # @return [LoxNode]
      def condition
        subnodes[0]
      end
    end # class
  end # module
end # module

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
loxxy-0.0.28 lib/loxxy/ast/lox_if_stmt.rb
loxxy-0.0.27 lib/loxxy/ast/lox_if_stmt.rb
loxxy-0.0.26 lib/loxxy/ast/lox_if_stmt.rb
loxxy-0.0.25 lib/loxxy/ast/lox_if_stmt.rb
loxxy-0.0.24 lib/loxxy/ast/lox_if_stmt.rb
loxxy-0.0.23 lib/loxxy/ast/lox_if_stmt.rb