Class: Rley::SPPF::SPPFNode

Inherits:
Object
  • Object
show all
Defined in:
lib/rley/sppf/sppf_node.rb

Overview

Abstract class. The generalization for all kinds of nodes occurring in a shared packed parse forest (SPPF).

Direct Known Subclasses

CompositeNode, LeafNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aRange) ⇒ SPPFNode

Constructor

Parameters:



16
17
18
# File 'lib/rley/sppf/sppf_node.rb', line 16

def initialize(aRange)
  @range = Lexical::TokenRange.new(aRange)
end

Instance Attribute Details

#rangeLexical::TokenRange (readonly)

A range of token indices corresponding to this node.

Returns:



12
13
14
# File 'lib/rley/sppf/sppf_node.rb', line 12

def range
  @range
end

Instance Method Details

#originInteger

Return the origin, that is, the index of the first token matched by this node.

Returns:

  • (Integer)


23
24
25
# File 'lib/rley/sppf/sppf_node.rb', line 23

def origin
  range.low
end