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:



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

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:



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

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)


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

def origin()
  return range.low
end