Class: Rley::GFG::ItemVertex

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

Overview

TODO: modify definition Represents a specialized vertex in a grammar flow graph that is associated to a given dotted item. Responsibilities (in addition to inherited ones):

  • Know its related non-terminal symbol

Instance Attribute Summary collapse

Attributes inherited from Vertex

#edges

Instance Method Summary collapse

Methods inherited from Vertex

#add_edge

Constructor Details

#initialize(aDottedItem) ⇒ ItemVertex

Returns a new instance of ItemVertex.



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

def initialize(aDottedItem)
  super()
  @dotted_item = aDottedItem
end

Instance Attribute Details

#dotted_itemObject (readonly)

Link to the dotted item object



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

def dotted_item
  @dotted_item
end

#shortcutObject

Optional link to a "shortcut" edge. Applicable only if the dotted expects a non-terminal symbol.



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

def shortcut
  @shortcut
end

Instance Method Details

#complete?Boolean

Returns true if the dotted item has a dot at the end of the production.

Returns:

  • (Boolean)


49
50
51
# File 'lib/rley/gfg/item_vertex.rb', line 49

def complete?()
  return dotted_item.reduce_item?
end

#labelObject



44
45
46
# File 'lib/rley/gfg/item_vertex.rb', line 44

def label()
  return dotted_item.to_s
end

#lhsObject

Return the non-terminal symbol at the left-hand side of the production



64
65
66
# File 'lib/rley/gfg/item_vertex.rb', line 64

def lhs()
  return dotted_item.lhs
end

#next_symbolObject

Return the symbol after the dot else nil.



59
60
61
# File 'lib/rley/gfg/item_vertex.rb', line 59

def next_symbol()
  return dotted_item.next_symbol
end

#prev_symbolObject

Return the symbol before the dot else nil.



54
55
56
# File 'lib/rley/gfg/item_vertex.rb', line 54

def prev_symbol()
  return dotted_item.prev_symbol
end