Class: Dendroid::Parsing::ParseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/dendroid/parsing/parse_node.rb

Overview

An abstract class (i.e. a generalization) for elements forming a parse tree (forest). A parse tree is a graph data structure that represents the parsed input text into a tree-like hierarchy of elements constructed by applying syntax rules of the language at hand. A parse forest is a data structure that merges a number parse trees into one graph. Contrary to parse trees, a parse forests can represent the results of an ambiguous parsing.

Direct Known Subclasses

CompositeParseNode, EmptyRuleNode, TerminalNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lowerBound, upperBound) ⇒ ParseNode

Returns a new instance of ParseNode.

Parameters:

  • lowerBound (Integer)

    Rank of first input token that is matched by this node

  • upperBound (Integer)

    Rank of last input token that is matched by this node



20
21
22
# File 'lib/dendroid/parsing/parse_node.rb', line 20

def initialize(lowerBound, upperBound)
  @range = valid_range(lowerBound, upperBound)
end

Instance Attribute Details

#rangeRange (readonly)

Returns The range of indexes of the input tokens that match this node.

Returns:

  • (Range)

    The range of indexes of the input tokens that match this node.



16
17
18
# File 'lib/dendroid/parsing/parse_node.rb', line 16

def range
  @range
end