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

Methods inherited from Edge

#inspect

Constructor Details

#initialize(thePredecessor, theSuccessor) ⇒ ShortcutEdge

Returns a new instance of ShortcutEdge.



14
15
16
17
18
# File 'lib/rley/gfg/shortcut_edge.rb', line 14

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

Instance Attribute Details

#nonterminalObject (readonly)

The terminal symbol expected from the input stream



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

def nonterminal
  @nonterminal
end

Instance Method Details

#to_sObject



20
21
22
# File 'lib/rley/gfg/shortcut_edge.rb', line 20

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