Class: Rley::GFG::Edge

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

Overview

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

  • To know the successor vertex

Direct Known Subclasses

CallEdge, EpsilonEdge, ReturnEdge, ScanEdge, ShortcutEdge

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thePredecessor, theSuccessor) ⇒ Edge

Construct a directed edge between two given vertices

Parameters:



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

def initialize(thePredecessor, theSuccessor)
  @successor = theSuccessor
  thePredecessor.add_edge(self)
end

Instance Attribute Details

#successorVertex (readonly)

Returns The destination vertex of the edge .

Returns:

  • (Vertex)

    The destination vertex of the edge .



8
9
10
# File 'lib/rley/gfg/edge.rb', line 8

def successor
  @successor
end

Instance Method Details

#inspectString

Returns a string containing a human-readable representation of the production.

Returns:

  • (String)


26
27
28
# File 'lib/rley/gfg/edge.rb', line 26

def inspect()
  to_s
end

#to_sString

Returns:

  • (String)


19
20
21
# File 'lib/rley/gfg/edge.rb', line 19

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