class Rley::GFG::ItemVertex
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
Attributes
Link to the dotted item object @return [DottedItem] The corresponding dotted item
Optional link to a “shortcut” edge. Applicable only if the dotted expects a non-terminal symbol. @return [ShortcutEdge] Optional “shortcut” edge
Public Class Methods
Source
# File lib/rley/gfg/item_vertex.rb, line 25 def initialize(aDottedItem) super() @dotted_item = aDottedItem end
Constructor. @param aDottedItem [DottedItem] the corresponding dotted item.
Public Instance Methods
Source
# File lib/rley/gfg/item_vertex.rb, line 49 def complete? dotted_item.reduce_item? end
Returns true if the dotted item has a dot at the end of the production. @return [Boolean]
Source
# File lib/rley/gfg/item_vertex.rb, line 43 def label dotted_item.to_s end
The label of this vertex. It is the same as the label of the corresponding dotted item. @return [String] Label for this vertex
Source
# File lib/rley/gfg/item_vertex.rb, line 68 def lhs dotted_item.lhs end
Return the non-terminal symbol at the left-hand side of the production @return [Syntax::GrmSymbol]
The non-terminal symbol at left side of production.
Source
# File lib/rley/gfg/item_vertex.rb, line 61 def next_symbol @next_symbol ||= dotted_item.next_symbol end
Return the symbol after the dot. @return [Syntax::GrmSymbol, NilClass] Next grammar symbol otherwise nil.
Source
# File lib/rley/gfg/item_vertex.rb, line 55 def prev_symbol dotted_item.prev_symbol end
Return the symbol before the dot. @return [Syntax::GrmSymbol, NilClass] Previous symbol otherwise nil.
Source
# File lib/rley/gfg/item_vertex.rb, line 32 def shortcut=(aShortcut) unless aShortcut.is_a?(ShortcutEdge) raise StandardError, 'Invalid shortcut argument' end @shortcut = aShortcut end
Set the “shortcut” edge. @param aShortcut [ShortcutEdge] the “shortcut” edge.