Class: Sequitur::Digram
- Inherits:
-
Object
- Object
- Sequitur::Digram
- Defined in:
- lib/sequitur/digram.rb
Overview
A digram is a sequence of two grammar symbols (terminal or not).
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
An unique Hash key of the digram.
-
#production_id ⇒ Object
readonly
The object id of the production that contains this digram in its rhs.
-
#symbols ⇒ Object
readonly
The sequence of two consecutive grammar symbols.
Instance Method Summary collapse
-
#initialize(symbol1, symbol2, aProduction) ⇒ Digram
constructor
Constructor.
-
#production ⇒ Object
Return the production object of this digram.
Constructor Details
#initialize(symbol1, symbol2, aProduction) ⇒ Digram
Constructor.
15 16 17 18 19 |
# File 'lib/sequitur/digram.rb', line 15 def initialize(symbol1, symbol2, aProduction) @symbols = [symbol1, symbol2] @key = "#{symbol1.hash.to_s(16)}:#{symbol2.hash.to_s(16)}" @production_id = aProduction.object_id end |
Instance Attribute Details
#key ⇒ Object (readonly)
An unique Hash key of the digram
12 13 14 |
# File 'lib/sequitur/digram.rb', line 12 def key @key end |
#production_id ⇒ Object (readonly)
The object id of the production that contains this digram in its rhs.
9 10 11 |
# File 'lib/sequitur/digram.rb', line 9 def production_id @production_id end |
#symbols ⇒ Object (readonly)
The sequence of two consecutive grammar symbols.
6 7 8 |
# File 'lib/sequitur/digram.rb', line 6 def symbols @symbols end |
Instance Method Details
#production ⇒ Object
Return the production object of this digram
22 23 24 |
# File 'lib/sequitur/digram.rb', line 22 def production() ObjectSpace._id2ref(production_id) end |