Class: Synthra::Parser::AST::ArrayTypeNode

Inherits:
TypeNode show all
Defined in:
lib/synthra/parser/ast.rb

Overview

Array type node

Represents an array type with element type and size specification. Extends TypeNode with array-specific attributes.

Examples:

DSL

tags: array(text, 1..5)
items: array(Item, 3)

AST

ArrayTypeNode.new(
  element_type: TypeNode.new(name: "text"),
  size_range: 1..5
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element_type:, size_range:, nullable: false, line: nil) ⇒ ArrayTypeNode

Create a new ArrayTypeNode

Parameters:

  • element_type (TypeNode)

    element type

  • size_range (Range, Integer, Hash)

    size specification

  • nullable (Boolean) (defaults to: false)

    whether the array can be null

  • line (Integer, nil) (defaults to: nil)

    source line number



648
649
650
651
652
653
654
655
656
657
# File 'lib/synthra/parser/ast.rb', line 648

def initialize(element_type:, size_range:, nullable: false, line: nil)
  super(
    name: "array",
    arguments: { element: element_type, size: size_range },
    nullable: nullable,
    line: line
  )
  @element_type = element_type
  @size_range = size_range
end

Instance Attribute Details

#element_typeObject (readonly)

Returns the value of attribute element_type.



632
633
634
# File 'lib/synthra/parser/ast.rb', line 632

def element_type
  @element_type
end

#size_rangeObject (readonly)

Returns the value of attribute size_range.



638
639
640
# File 'lib/synthra/parser/ast.rb', line 638

def size_range
  @size_range
end