Class: Foxtail::Syntax::Parser::AST::SyntaxNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/foxtail/syntax/parser/ast/syntax_node.rb

Overview

Base class for AST nodes that can have span information Extends BaseNode with source position tracking capabilities

Instance Attribute Summary collapse

Attributes inherited from BaseNode

#type

Instance Method Summary collapse

Methods inherited from BaseNode

#==, #accept, #children, #initialize, #to_h

Constructor Details

This class inherits a constructor from Foxtail::Syntax::Parser::AST::BaseNode

Instance Attribute Details

#spanObject

Returns the value of attribute span.



10
11
12
# File 'lib/foxtail/syntax/parser/ast/syntax_node.rb', line 10

def span
  @span
end

Instance Method Details

#add_span(start_pos, end_pos) ⇒ Object

Add span information to this syntax node

Parameters:

  • start_pos (Integer)

    Starting position in the source

  • end_pos (Integer)

    Ending position in the source



15
16
17
# File 'lib/foxtail/syntax/parser/ast/syntax_node.rb', line 15

def add_span(start_pos, end_pos)
  @span = Span.new(start_pos, end_pos)
end