lib/rley/gfg/item_vertex.rb in rley-0.3.04 vs lib/rley/gfg/item_vertex.rb in rley-0.3.05

- old
+ new

@@ -8,65 +8,64 @@ # 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 class ItemVertex < Vertex - # Link to the dotted item object - attr_reader :dotted_item + # Link to the dotted item object + attr_reader :dotted_item - # Optional link to a "shortcut" edge. - # Applicable only if the dotted expects a non-terminal symbol. - attr_reader :shortcut + # Optional link to a "shortcut" edge. + # Applicable only if the dotted expects a non-terminal symbol. + attr_reader :shortcut def initialize(aDottedItem) super() @dotted_item = aDottedItem end - + # Set the "shortcut" edge. def shortcut=(aShortcut) unless aShortcut.kind_of?(ShortcutEdge) - fail StandardError, 'Invalid shortcut argument' + raise StandardError, 'Invalid shortcut argument' end =begin unless next_symbol && next_symbol.kind_of?(Syntax::NonTerminal) - fail StandardError, 'Invalid shortcut usage' + raise StandardError, 'Invalid shortcut usage' end - + shortcut_d_item = aShortcut.successor.dotted_item unless (dotted_item.production == shortcut_d_item.production) && (dotted_item.position == shortcut_d_item.prev_position) - fail StandardError, 'Shortcut refers to wrong vertex' + raise StandardError, 'Shortcut refers to wrong vertex' end -=end +=end @shortcut = aShortcut end def label() - return "#{dotted_item}" + return dotted_item.to_s end # Returns true if the dotted item has a dot at the end of the production. def complete?() return dotted_item.reduce_item? end # Return the symbol before the dot else nil. def prev_symbol() return dotted_item.prev_symbol - end - + end + # Return the symbol after the dot else nil. def next_symbol() return dotted_item.next_symbol end - + # Return the non-terminal symbol at the left-hand side of the production def lhs() return dotted_item.lhs end - end # class end # module end # module -# End of file \ No newline at end of file +# End of file