def eval(self, token): if is_list(token): if not len(token): return token fn = self.eval(token[0]) if not hasattr(fn, '__call__'): raise Exception("Uncallable expression: %s" % fn) args = token[1:] if is_procedure(fn): return fn([self.eval(arg) for arg in args]) # special form return fn(self, *args) if is_symbol(token): if token.name in fexpr: return fexpr[token.name] return self.deref(token) return token
def completer(self, input, state): tokens = lexer.tokenize(input) symbol = tokens[-1] if not lexer.is_symbol(symbol): return None options = self.get_options(self.scope, symbol.name) if state >= len(options): return None tokens[-1] = options[state] return "".join(tokens)
def fexpr_lambda(scope, args, *body): for arg in args: if not is_symbol(arg): raise Exception("Syntax error: '%s' is not a valid arg name" % arg) return Lambda(body, scope, args)