Class: Rley::GFG::ShortcutEdge

Inherits:
Edge
  • Object
show all
Defined in:
lib/rley/gfg/shortcut_edge.rb

Overview

Abstract class. Represents an edge in a grammar flow graph Responsibilities:

  • To know the successor vertex

Instance Attribute Summary collapse

Attributes inherited from Edge

#successor

Instance Method Summary collapse

Constructor Details

#initialize(thePredecessor, theSuccessor) ⇒ ShortcutEdge

Returns a new instance of ShortcutEdge.



12
13
14
15
16
# File 'lib/rley/gfg/shortcut_edge.rb', line 12

def initialize(thePredecessor, theSuccessor)
  @successor = theSuccessor
  @nonterminal = thePredecessor.next_symbol
  thePredecessor.shortcut = self
end

Instance Attribute Details

#nonterminalObject (readonly)

The terminal symbol expected from the input stream



10
11
12
# File 'lib/rley/gfg/shortcut_edge.rb', line 10

def nonterminal
  @nonterminal
end

Instance Method Details

#to_sObject



18
19
20
# File 'lib/rley/gfg/shortcut_edge.rb', line 18

def to_s()
  " -#{nonterminal}-> #{successor.label}"
end