Class: Synthra::Parser::AST::Node Abstract

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

Overview

This class is abstract.

Subclass and implement specific node behavior

Base class for all AST nodes

All AST nodes inherit from Node and share the line attribute for error reporting and debugging.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line: nil) ⇒ Node

Create a new AST node

Parameters:

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

    source line number (1-based)



73
74
75
# File 'lib/synthra/parser/ast.rb', line 73

def initialize(line: nil)
  @line = line
end

Instance Attribute Details

#lineInteger? (readonly)

Source line number where this node was defined

Returns:

  • (Integer, nil)

    the line number (1-based) or nil



65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/synthra/parser/ast.rb', line 65

class Node
  attr_reader :line

  # Create a new AST node
  #
  # @param line [Integer, nil] source line number (1-based)
  #

  def initialize(line: nil)
    @line = line
  end
end