def __call__(self, processer, params): e = processer.cenv syntax_object = params[0] syntax_object = processer.process([syntax_object], e) syntax_list = syntax_object.toObject(e) while isinstance(syntax_list, SyntaxSymbol): syntax_list = syntax_list.toObject(e) literals = params[1] patterns = params[2:] for pattern in patterns: if len(pattern) == 2: template = pattern[1:] pattern = pattern[0] guard = True else: template = pattern[2:] guard = pattern[1] pattern = pattern[0] bindings = PatternMatcher(pattern, literals).match(syntax_list) if bindings is None: continue processer.pushStack([guard]) icd = processer.callDepth r = processer.process([guard], processer.cenv) while processer.callDepth > icd: processer.popStackN() processer.popStack(r) if not r: continue env = Environment(processer.cenv) transformedCode = transformCode(template, bindings, env, bindings) return transformedCode[0] raise SyntaxError("syntax-case no case matching %r" % (syntax_list))
def __call__(self, processer, params): params=params[0].toObject(processer.cenv) for pattern in self.patterns: template = pattern[1:] pattern = pattern[0] bindings = PatternMatcher(pattern, self.literals).match(params) if bindings is None: continue env = Environment(self.env) l = {} l.update(globals()) l.update(locals()) #import code #code.InteractiveConsole(locals=l).interact() transformedCode = transformCode(template, bindings, env, self) #osp = processer.stackPointer #processer.popStack(transformedCode) ##processer.ast = transformedCode #processer.stackPointer = osp if scheme.debug.getDebug('syntax'): print 56, transformedCode if len(transformedCode)==1: return transformedCode[0] return transformedCode raise SyntaxError("syntax-rules no case matching %r for %s" % (params, self.name))