Пример #1
0
Файл: symbol.py Проект: nrc/N
    def fv(self, kind, env):
        if env.isBoundVar(self):
            return Concat(None)

        def simpleType(x):
            if isinstance(x, Id):
                return x.symbol
            if isinstance(x, List):
                return simpleType(x.arg)
            return None

        if kind in map(lambda x: simpleType(x), env.boundVars(self)):
            result = SetSub(None)
            result.lhs = FV(kind, self, None)
            result.rhs = Concat(None)
            result.rhs.elements = set(env.boundVars(self))
            return result

        if kind not in self.symbol.deepVars():
            return Concat(None)

        if self.symbol == kind:
            return self

        return FV(kind, self, None)
Пример #2
0
Файл: symbol.py Проект: nrc/N
  def fv(self, kind, env):
    if env.isBoundVar(self):
      return Concat(None)
      
    def simpleType(x):
      if isinstance(x, Id):
        return x.symbol
      if isinstance(x, List):
        return simpleType(x.arg)
      return None
      
    if kind in map(lambda x: simpleType(x), env.boundVars(self)):
      result = SetSub(None)
      result.lhs = FV(kind, self, None)
      result.rhs = Concat(None)
      result.rhs.elements = set(env.boundVars(self))
      return result
      
    if kind not in self.symbol.deepVars():
      return Concat(None)

    if self.symbol == kind:
      return self    

    return FV(kind, self, None)
Пример #3
0
Файл: symbol.py Проект: nrc/N
    def subst(self, new, old, env, symbols):
        if env.isBoundVar(self):
            return self

        if env.provesIn(old, env.boundVars(self)):
            return self

        if env.provesEq(self, old):
            return new

        sym = old
        if isinstance(old, Id):
            sym = old.symbol

        if self.symbol == sym and env.provesNE(self, old):
            return self

        if not env.provesIn(sym, self.symbol.deepVars()):
            return self

        result = Subst(None)
        result.body = self
        result.lhs = new
        result.rhs = old
        return result
Пример #4
0
Файл: symbol.py Проект: nrc/N
  def subst(self, new, old, env, symbols):
    if env.isBoundVar(self):
      return self
      
    if env.provesIn(old, env.boundVars(self)):
      return self

    if env.provesEq(self, old):
      return new
      
    sym = old
    if isinstance(old, Id):
      sym = old.symbol

    if self.symbol == sym and env.provesNE(self, old):
      return self
      
    if not env.provesIn(sym, self.symbol.deepVars()):
      return self
      
    result = Subst(None)
    result.body = self
    result.lhs = new
    result.rhs = old
    return result