Class: Production
- Inherits:
-
Object
- Object
- Production
- Defined in:
- lib/Production.rb
Instance Method Summary collapse
- #[](i) ⇒ Object
- #[]=(i, v) ⇒ Object
- #data ⇒ Object
- #each {|_self| ... } ⇒ Object
- #first ⇒ Object
-
#initialize(ast, interpretation_context) ⇒ Production
constructor
A new instance of Production.
- #last ⇒ Object
- #length ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(ast, interpretation_context) ⇒ Production
Returns a new instance of Production.
2 3 4 |
# File 'lib/Production.rb', line 2 def initialize(ast, interpretation_context) rebind(ImmutableQueue.empty.push(ast), interpretation_context) end |
Instance Method Details
#[](i) ⇒ Object
29 30 31 |
# File 'lib/Production.rb', line 29 def [](i) @production[i] end |
#[]=(i, v) ⇒ Object
33 34 35 |
# File 'lib/Production.rb', line 33 def []=(i, v) @production[i] = v end |
#data ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/Production.rb', line 49 def data() return @data if @data @data = case when self_production_is_call? then @production[2] else @production end end |
#each {|_self| ... } ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/Production.rb', line 59 def each() yield(self) if production.instance_of?((Sexp or production.instance_of?(Array))) then @queue = @queue.push_array(production) end while @queue.!=(ImmutableQueue.empty) do rebind(@queue, @interpretation_context) yield(self) if production.instance_of?((Sexp or production.instance_of?(Array))) then @queue = @queue.push_array(production) end end end |
#first ⇒ Object
45 46 47 |
# File 'lib/Production.rb', line 45 def first() @production.first end |
#last ⇒ Object
41 42 43 |
# File 'lib/Production.rb', line 41 def last() @production.last end |
#length ⇒ Object
37 38 39 |
# File 'lib/Production.rb', line 37 def length() @production.length end |
#type ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/Production.rb', line 6 def type() case when (nil == production) then nil when self_production_is_block_with_bind? then Tokens.block_with_bind when self_production_is_block? then Tokens.block when (production.instance_of?(Fixnum) or production.instance_of?(Symbol)) then Tokens.terminal when self_production_is_rolemethod_call? then Tokens.rolemethod_call when self_production_is_role? then Tokens.role when self_production_is_indexer? then Tokens.indexer when self_production_is_call? then Tokens.call else Tokens.other end end |