Ejemplo n.º 1
0
def make_replacements(match, alternatives):
    env = (
        match.env
        if 'OLD' in match.env
        else updated(match.env, [('OLD', match.matched_items)])
    )
    return ChunkResult(
        alternatives.make_substitutions(env),
        match.xtail,
        match.env
    )
Ejemplo n.º 2
0
 def match(self, x, env):
     if len(x) >= 1 and self.condition(x[0]):
         return [x[0]], x[1:], updated(env, ((self.name, [x[0]]),))
     else:
         return None, None, None
Ejemplo n.º 3
0
 def match(self, x, env):
     matched, xtail, new_env = self.target.match(x, env)
     if matched is not None:
         new_env = updated(new_env, [(self.name, matched)])
     return matched, xtail, new_env