Sha256: b851879e3ddab68154e4df2a6aa0601aae1c2b95f50cb544929e45f0706c96a1

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require_relative 'lox_node'

module Loxxy
  module Ast
    # A parse tree node that represents a Lox class declaration.
    class LoxClassStmt < LoxNode
      # @return [String] the class name
      attr_reader :name

      # @return [Ast::LoxVariableExpr] variable referencing the superclass (if any)
      attr_reader :superclass

      # @return [Array<Ast::LoxFunStmt>] the methods
      attr_reader :body

      # Constructor for a parse node that represents a Lox function declaration
      # @param aPosition [Rley::Lexical::Position] Position of the entry in the input stream.
      # @param aName [String] the class name
      # @param aSuperclassName [String] the super class name
      # @param theMethods [Array<Loxxy::Ast::LoxFunStmt>] the methods
      def initialize(aPosition, aName, aSuperclassName, theMethods)
        super(aPosition)
        @name = aName.dup
        @superclass = aSuperclassName
        @body = theMethods
      end

      define_accept # Add `accept` method as found in Visitor design pattern
    end # class
  end # module
end # module

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
loxxy-0.4.08 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.07 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.06 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.05 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.04 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.03 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.02 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.01 lib/loxxy/ast/lox_class_stmt.rb
loxxy-0.4.00 lib/loxxy/ast/lox_class_stmt.rb