Class: Rley::GFG::Vertex

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

Overview

Abstract class. Represents a vertex in a grammar flow graph Responsibilities:

  • To know its outgoing edges
  • To know its label

Direct Known Subclasses

ItemVertex, NonTerminalVertex

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVertex

Returns a new instance of Vertex.



11
12
13
# File 'lib/rley/gfg/vertex.rb', line 11

def initialize()
  @edges = []
end

Instance Attribute Details

#edgesObject (readonly)

The edges linking the successor vertices to this one.



9
10
11
# File 'lib/rley/gfg/vertex.rb', line 9

def edges
  @edges
end

Instance Method Details

#add_edge(anEdge) ⇒ Object

Add an graph edge to this vertex



16
17
18
19
# File 'lib/rley/gfg/vertex.rb', line 16

def add_edge(anEdge)
  arrow = check_add_edge(anEdge)
  edges << arrow
end

#complete?Boolean

Returns true iff the vertex corresponds to an dotted item that has its dot at the end of a production (i.e. is a reduced item).

Returns:

  • (Boolean)


23
24
25
# File 'lib/rley/gfg/vertex.rb', line 23

def complete?()
  return false # Default implementation
end

#next_symbolObject

Return the symbol after the dot else nil.



33
34
35
# File 'lib/rley/gfg/vertex.rb', line 33

def next_symbol()
  return nil # Default implementation
end

#prev_symbolObject

Return the symbol before the dot else nil.



28
29
30
# File 'lib/rley/gfg/vertex.rb', line 28

def prev_symbol()
  return nil # Default implementation
end