Class: Rley::GFG::ItemVertex

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

Overview

Specialization of Vertex class. Represents a vertex in a grammar flow graph 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, #inspect, #selfie

Constructor Details

#initialize(aDottedItem) ⇒ ItemVertex

Constructor.

Parameters:

  • aDottedItem (DottedItem)

    the corresponding dotted item.



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

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

Instance Attribute Details

#dotted_itemDottedItem (readonly)

Link to the dotted item object

Returns:

  • (DottedItem)

    The corresponding dotted item



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

def dotted_item
  @dotted_item
end

#shortcutShortcutEdge

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

Returns:



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

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

#labelString

The label of this vertex. It is the same as the label of the corresponding dotted item.

Returns:

  • (String)

    Label for this vertex



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

def label()
  return dotted_item.to_s
end

#lhsSyntax::GrmSymbol

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

Returns:



68
69
70
# File 'lib/rley/gfg/item_vertex.rb', line 68

def lhs()
  return dotted_item.lhs
end

#next_symbolSyntax::GrmSymbol, NilClass

Return the symbol after the dot.

Returns:



61
62
63
# File 'lib/rley/gfg/item_vertex.rb', line 61

def next_symbol()
  return dotted_item.next_symbol
end

#prev_symbolSyntax::GrmSymbol, NilClass

Return the symbol before the dot.

Returns:



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

def prev_symbol()
  return dotted_item.prev_symbol
end