1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
# -*- coding: utf-8 -*-
require_relative 'atom'
module MIKU
class Macro
include Atom
def initialize(args, list)
@args = args
@list = list
end
def macro_expand(*args)
if not(args.is_a? StaticCode) and args.car.is_a?(StaticCode)
args.extend(StaticCode).staticcode_copy_info(args.car.staticcode_dump) end
scope = MIKU::SymbolTable.new.miracle_binding(@args, args)
# @args.zip(args){ |k, v|
# scope[k] = [v] }
@list.inject(nil){ |last, operator|
scope[:last] = last
miku(operator, scope) } end
def inspect
"<macro #{@args.inspect} #{@list.inspect}>"
end
end
end
|