Exemplo n.º 1
0
Arquivo: symbol.py Projeto: 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)
Exemplo n.º 2
0
Arquivo: symbol.py Projeto: 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)
Exemplo n.º 3
0
Arquivo: symbol.py Projeto: 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
Exemplo n.º 4
0
Arquivo: symbol.py Projeto: 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
Exemplo n.º 5
0
Arquivo: symbol.py Projeto: nrc/N
 def subst(self, new, old, env, symbols):
     if self == old:
         #check bindings
         if old in env.boundVars(self):
             return self
         else:
             return new
     else:
         return self
Exemplo n.º 6
0
Arquivo: symbol.py Projeto: nrc/N
 def subst(self, new, old, env, symbols):
   if self == old:
     #check bindings
     if old in env.boundVars(self):
       return self
     else:
       return new
   else:
     return self