Class: AbstractSyntaxTree
- Inherits:
-
Object
- Object
- AbstractSyntaxTree
- Defined in:
- lib/AbstractSyntaxTree.rb
Instance Method Summary collapse
- #[](i) ⇒ Object
- #[]=(i, v) ⇒ Object
- #data ⇒ Object
- #each_production {|_self| ... } ⇒ Object
- #first ⇒ Object
-
#initialize(ast, interpretation_context) ⇒ AbstractSyntaxTree
constructor
A new instance of AbstractSyntaxTree.
- #last ⇒ Object
- #length ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(ast, interpretation_context) ⇒ AbstractSyntaxTree
Returns a new instance of AbstractSyntaxTree.
2 |
# File 'lib/AbstractSyntaxTree.rb', line 2 def initialize(ast,interpretation_context) rebind(ImmutableQueue.empty.push(ast), interpretation_context) end |
Instance Method Details
#[](i) ⇒ Object
27 |
# File 'lib/AbstractSyntaxTree.rb', line 27 def [](i) @production[i] end |
#[]=(i, v) ⇒ Object
28 |
# File 'lib/AbstractSyntaxTree.rb', line 28 def []=(i,v) @production[i] = v end |
#data ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/AbstractSyntaxTree.rb', line 32 def data() return @data if @data @data = case when self_production_is_call? then @production[2] else @production end end |
#each_production {|_self| ... } ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/AbstractSyntaxTree.rb', line 40 def each_production() 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
31 |
# File 'lib/AbstractSyntaxTree.rb', line 31 def first() @production.first end |
#last ⇒ Object
30 |
# File 'lib/AbstractSyntaxTree.rb', line 30 def last() @production.last end |
#length ⇒ Object
29 |
# File 'lib/AbstractSyntaxTree.rb', line 29 def length() @production.length end |
#type ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/AbstractSyntaxTree.rb', line 3 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_const? then Tokens.const when self_production_is_initializer? then Tokens.initializer when self_production_is_call? then Tokens.call else Tokens.other end end |