@@ -0,0 +1,3288 @@
+#!/usr/bin/env python%0A# -*- encoding: utf-8 -*-%0A#%0A# Copyright (c) 2015 ASMlover. All rights reserved.%0A#%0A# Redistribution and use in source and binary forms, with or without%0A# modification, are permitted provided that the following conditions%0A# are met:%0A#%0A#  * Redistributions of source code must retain the above copyright%0A#    notice, this list ofconditions and the following disclaimer.%0A#%0A#  * Redistributions in binary form must reproduce the above copyright%0A#    notice, this list of conditions and the following disclaimer in%0A#    the documentation and/or other materialsprovided with the%0A#    distribution.%0A#%0A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A# %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS%0A# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE%0A# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,%0A# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,%0A# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;%0A# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER%0A# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT%0A# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN%0A# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE%0A# POSSIBILITY OF SUCH DAMAGE.%0A%0Afrom atom import FALSE%0Afrom interface import Eval%0A%0Aclass Function(Eval):%0A    def __init__(self, fun):%0A        self.fun = fun%0A        self.hint = 'fun'%0A%0A    def __repr__(self):%0A        return '%3Cbuilt-in function %25s%3E' %25 id(self.fun)%0A%0A    def eval(self, env, args):%0A        %22%22%22%0A        Evaluation just delegates out to the builtin.%0A        %22%22%22%0A        return self.fun(env, args)%0A%0Aclass Lambda(Eval):%0A    def __init__(self, names, body):%0A        self.names = names%0A        self.body = body%0A    %0A    def __repr__(self):%0A        return '%3Clambda %25s%3E' %25 id(self)%0A%0A    def set_bindings(self, containing_env, values):%0A        %22%22%22%0A        The bindings are set one by one corresponding to %0A        the input values.%0A        %22%22%22%0A        for i in range(len(values)):%0A            containing_env.environment.binds%5Bself.names%5Bi%5D.data%5D = %0A                values%5Bi%5D.eval(containing_env.env)%0A%0A    def push_bindings(self, containing_env, values):%0A        containing_env.push()%0A        self.set_bindings(containing_env, values)%0A%0A    def eval(self, env, args):%0A        values = %5Ba for a in args%5D%0A        %0A        if len(values) != len(self.names):%0A            raise ValueError(%0A                'Wrong number of arguments, expect %7B0%7D, got %7B1%7D'.format(%0A                    len(self.names), len(args)))%0A        %0A        ELISP = env.get('__elisp__')%0A        self.push_bindings(ELISP, values)%0A        %0A        result = FALSE%0A        for form in self.body:%0A            result = form.eval(ELISP.environment)%0A        %0A        ELISP.pop()%0A        return result%0A%0Aclass Closure(Lambda):%0A    def __init__(self, env, names, body):%0A        super(Closure, self).__init__(names, body)%0A        self.env = env%0A%0A    def __repr__(self):%0A        return '%3Clexical closure %25s%3E' %25 int(self)%0A%0A    def push_bindings(self, containing_env, values):%0A        containing_env.push(self.env.binds)%0A        self.set_bindings(containing_env, values)%0A

add function module for eLisp