Esempio n. 1
0
 def __call__(self, *args, **kwargs):
     ret = self.func(*args, **kwargs)
     if hasattr(ret, "cotf"):
         return ret
     elif type(ret) is str:
         return string(ret)
     elif type(ret) in (int, float, long):
         return number(ret)
     return null
Esempio n. 2
0
 def __call__(self, *args, **kwargs):
     ret = self.func(*args, **kwargs)
     if hasattr(ret, "cotf"):
         return ret
     elif type(ret) is str:
         return string(ret)
     elif type(ret) in (int, float, long):
         return number(ret)
     return null
Esempio n. 3
0
    def loads(self, string):
        type = string[0]
        string = string[1:]

        # List
        if type == "(":
            return self.handle_list(string)
            #return [self.loads(item) for item in string[:-1].split("\x1b")]
        elif type == "{":
            return self.handle_dict(string)
        elif type == '"':
            return interpreter.string( string )
        elif type == "$":
            try:
                return interpreter.number( string )
            except ValueError:
                return interpreter.number( int(string) )
        return None
Esempio n. 4
0
    def loads(self, string):
        type = string[0]
        string = string[1:]

        # List
        if type == "(":
            return self.handle_list(string)
            #return [self.loads(item) for item in string[:-1].split("\x1b")]
        elif type == "{":
            return self.handle_dict(string)
        elif type == '"':
            return interpreter.string(string)
        elif type == "$":
            try:
                return interpreter.number(string)
            except ValueError:
                return interpreter.number(int(string))
        return None
Esempio n. 5
0
    if x in (undefined, null):
        return getattr(obj, name, undefined)
    return x

@PythonFunction
def set(obj, name, value):
    try:
        obj[name] = value
    except:
        setattr(obj, name, value)

_exit = exit
def exit(code = None):
    _exit(code)

builtins = {"input" : clean(raw_input),
            "exit" : clean(exit),

            "import" : _import,
            "print" : _print,
            "repr" : _repr,
            "get" : get,
            "set" : set,
            "if" : _if,
            
            "undefined" : undefined,
            "null" : null,

            "true" : number(1),
            "false" : number(0)}