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