Sha256: 61bf154f8745f57fe0774d25c3721fd00d2b051bd1e78b57fac6bd7a49fb0e17

Contents?: true

Size: 651 Bytes

Versions: 4

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

require_relative 'composite_node'

module Rley
  module RGN
    # A syntax node for a sequence of AST nodes
    class SequenceNode < CompositeNode
      def name
        result = +''
        subnodes.each do |sn|
          result << "_#{sn.name}"
        end

        "seq#{result}"
      end

      def to_text
        arr = subnodes.map(&:to_text)
        arr.join(' ')
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rley-0.8.11 lib/rley/rgn/sequence_node.rb
rley-0.8.10 lib/rley/rgn/sequence_node.rb
rley-0.8.09 lib/rley/rgn/sequence_node.rb
rley-0.8.08 lib/rley/rgn/sequence_node.rb