Sha256: 9b62a9ff0621c98f9f634bffac89116720419a5fd139dce750f652969b3b3e89

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative 'lox_node'

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

      # @return [Array<String>] the parameter names
      attr_reader :params

      # @return [Ast::LoxBlockStmt] the parse tree representing the function's body
      attr_reader :body

      # @return [Boolean] true if the function is a method
      attr_accessor :is_method

      # 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 function name
      # @param paramList [Array<String>] the parameter names
      # @param aBody [Ast::LoxBlockStmt] the parse tree representing the function's body
      def initialize(aPosition, aName, paramList, aBody)
        super(aPosition)
        @name = aName.dup
        @params = paramList
        @body = aBody
        @is_method = false
      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_fun_stmt.rb
loxxy-0.4.07 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.06 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.05 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.04 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.03 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.02 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.01 lib/loxxy/ast/lox_fun_stmt.rb
loxxy-0.4.00 lib/loxxy/ast/lox_fun_stmt.rb