@@ -0,0 +1,2563 @@
+#!/usr/bin/env python%0A# -*- encoding: utf-8 -*-%0A#%0A# Copyright (c) 2016 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%0Aimport operator%0Afrom collections import namedtuple%0Aimport tyr_ast as ast%0Afrom tyr_lexer import Lexer, TokenStream%0Afrom tyr_parser import Parser%0Afrom tyr_error import TyrSyntaxError, report_syntax_error%0Afrom tyr_utils import print_ast, print_tokens, print_env%0A%0ABuiltinFunction = namedtuple('BuiltinFunction', %5B'params', 'body'%5D)%0A%0Aclass Break(Exception):%0A    pass%0A%0Aclass Continue(Exception):%0A    pass%0A%0Aclass Return(Exception):%0A    def __init__(self, value):%0A        self.value = value%0A%0Aclass Environment(object):%0A    def __init__(self, parent=None, args=None):%0A        self.parent = parent%0A        self.values = %7B%7D%0A        if args:%0A            self.init_from_dict(args)%0A%0A    def init_from_dict(self, args):%0A        for key, value in args.items():%0A            self.set(key, value)%0A%0A    def set(self, key, value):%0A        self.values%5Bkey%5D = value%0A%0A%0A    def get(self, key):%0A        value = self.values.get(key, None)%0A        if value is None and self.parent:%0A            return self.parent.get(key)%0A        else:%0A            return value%0A%0A    def as_dict(self):%0A        return self.values%0A%0A    def __repr__(self):%0A        return 'Environment(%7B%7D)'.format(str(self.values))%0A

add environment object