lib/Production.rb in maroon-0.7.0 vs lib/Production.rb in maroon-0.7.1
- old
+ new
@@ -75,14 +75,10 @@
@data = nil
@production, @queue = queue.pop
@interpretation_context = ctx
end
- attr_reader :interpretation_context
- attr_reader :queue
- attr_reader :production
-
def self_production_is_role?()
case
when (self_production_is_call? and interpretation_context.roles.has_key?(production[2])) then
@date = [production[2]]
return true
@@ -107,13 +103,27 @@
end
def self_production_is_block_with_bind?()
if self_production_is_block? then
body = @production.last
- if body and exp = body[0] then
+ if body and exp = body[1] then
bind = Production.new(exp, @interpretation_context)
- true if (bind.type == Tokens.call) and (bind.data == :bind)
+ if (bind.type == Tokens.call) and (bind.data == :bind) then
+ aliases = {}
+ list = exp.last[(1..-1)]
+ (list.length / 2).times do |i|
+ local = list[(i * 2)].last
+ role_name = list[((i * 2) + 1)].last
+ raise("Local in bind should be a symbol") unless local.instance_of?(Symbol)
+ unless role_name.instance_of?(Symbol) then
+ raise("Role name in bind should be a symbol")
+ end
+ aliases[local] = role_name
+ end
+ @data = aliases
+ true
+ end
end
end
end
def self_production_is_rolemethod_call?()
@@ -129,7 +139,11 @@
@data = [data, instance_data]
end
end
can_be
end
+
+ attr_reader :interpretation_context
+ attr_reader :queue
+ attr_reader :production
end
\ No newline at end of file