예제 #1
0
def fastInterpret(program):
    a = Stream.Buffer(program)
    b = Tokenizer.tokenize(a)
    c = Parser.parse(b)

    return Interpreter.interpret(c[1], {})
예제 #2
0
                '(eval(hack),GetModule() if "GetModule" in globals() else None)',
                {'hack': hack})[1]

            if not mod or not isinstance(mod, Module):
                raise Exception('Python module "' + source_name +
                                '" does not contain a valid Atto module!')

            toplevel_env[mod.name] = mod
            mc.add(mod)
            _flatten(mod, flatten_modules, toplevel_env)
        elif ext == '.atto':
            f = open(source_name, 'r')
            text = f.read()
            f.close()

            buff = Stream.Buffer(text)
            tokens = Tokenizer.tokenize(buff)
            pos = 0

            while pos < len(tokens):
                (pos, c) = Parser.parse(tokens, pos)
                mod = Interpreter.interpret(c, toplevel_env)

                if not isinstance(mod, Module):
                    raise Exception('Source "' + source_name +
                                    '" does not contain a valid Atto module!')

                toplevel_env[mod.name] = mod
                mc.add(mod)
                _flatten(mod, flatten_modules, toplevel_env)
        else: