Class: Rley::GFG::ItemVertex
- 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
-
#dotted_item ⇒ DottedItem
readonly
Link to the dotted item object.
-
#shortcut ⇒ ShortcutEdge
Optional link to a "shortcut" edge.
Attributes inherited from Vertex
Instance Method Summary collapse
-
#complete? ⇒ Boolean
Returns true if the dotted item has a dot at the end of the production.
-
#initialize(aDottedItem) ⇒ ItemVertex
constructor
Constructor.
-
#label ⇒ String
The label of this vertex.
-
#lhs ⇒ Syntax::GrmSymbol
Return the non-terminal symbol at the left-hand side of the production.
-
#next_symbol ⇒ Syntax::GrmSymbol, NilClass
Return the symbol after the dot.
-
#prev_symbol ⇒ Syntax::GrmSymbol, NilClass
Return the symbol before the dot.
Methods inherited from Vertex
Constructor Details
#initialize(aDottedItem) ⇒ ItemVertex
Constructor.
23 24 25 26 |
# File 'lib/rley/gfg/item_vertex.rb', line 23 def initialize(aDottedItem) super() @dotted_item = aDottedItem end |
Instance Attribute Details
#dotted_item ⇒ DottedItem (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 |
#shortcut ⇒ ShortcutEdge
Optional link to a "shortcut" edge. Applicable only if the dotted expects a non-terminal symbol.
19 20 21 |
# File 'lib/rley/gfg/item_vertex.rb', line 19 def shortcut @shortcut end |
Instance Method Details
#complete? ⇒ Boolean
Returns true if the dotted item has a dot at the end of the production.
57 58 59 |
# File 'lib/rley/gfg/item_vertex.rb', line 57 def complete?() return dotted_item.reduce_item? end |
#label ⇒ String
The label of this vertex. It is the same as the label of the corresponding dotted item.
51 52 53 |
# File 'lib/rley/gfg/item_vertex.rb', line 51 def label() return dotted_item.to_s end |
#lhs ⇒ Syntax::GrmSymbol
Return the non-terminal symbol at the left-hand side of the production
75 76 77 |
# File 'lib/rley/gfg/item_vertex.rb', line 75 def lhs() return dotted_item.lhs end |
#next_symbol ⇒ Syntax::GrmSymbol, NilClass
Return the symbol after the dot.
69 70 71 |
# File 'lib/rley/gfg/item_vertex.rb', line 69 def next_symbol() return dotted_item.next_symbol end |
#prev_symbol ⇒ Syntax::GrmSymbol, NilClass
Return the symbol before the dot.
63 64 65 |
# File 'lib/rley/gfg/item_vertex.rb', line 63 def prev_symbol() return dotted_item.prev_symbol end |