当前位置: 首页>>代码示例>>Python>>正文


Python Env.freshOld方法代码示例

本文整理汇总了Python中env.Env.freshOld方法的典型用法代码示例。如果您正苦于以下问题:Python Env.freshOld方法的具体用法?Python Env.freshOld怎么用?Python Env.freshOld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在env.Env的用法示例。


在下文中一共展示了Env.freshOld方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checkJudge

# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import freshOld [as 别名]
  def checkJudge(self, name):
    pTree = self.world.judgeTrees[name][0]
    judge = JudgeDef(pTree)
    judge.name = pTree.val
    judge.envs = map(lambda x: self.strToSym(x, pTree.syntax), pTree.syntax.envs)
    judge.args = map(lambda x: self.strToSym(x, pTree.syntax), pTree.syntax.children)
    freshGen = Env()
    judge.envLabels = map(lambda x: freshGen.freshOld(x), judge.envs)
    judge.argLabels = map(lambda x: freshGen.freshOld(x), judge.args)
    
    
    self.world.judges[pTree.val] = judge
    
    for i in range(len(pTree.children)):
      self.checkJCase(pTree.children[i], judge, i)
      
    curIndex = len(pTree.children)
    
    #add any other asts which hold parts of the judgement
    for oTree in self.world.judgeTrees[name][1:]:
      #check the shapes match (ignore any latex or label)
      envs = map(lambda x: self.strToSym(x, oTree.syntax), oTree.syntax.envs)
      args = map(lambda x: self.strToSym(x, oTree.syntax), oTree.syntax.children)
      check = reduce(lambda x,y: x and y, map(lambda (x,y): x == y, zip(args, judge.args)), True)
      check = check and reduce(lambda x,y: x and y, map(lambda (x,y): x == y, zip(envs, judge.envs)), True)
      if not check:
        expectStr = "; ".join(map(lambda x: x.name, judge.envs)) + " |- " + "; ".join(map(lambda x: x.name, judge.args))
        foundStr = "; ".join(map(lambda x: x.name, envs)) + " |- " + "; ".join(map(lambda x: x.name, args))
        self.addErr("Shape of repeated judgment does not match original judgement: found: " + foundStr + ", expected: " + expectStr, oTree)

      #add any cases
      for i in range(len(oTree.children)):
        self.checkJCase(oTree.children[i], judge, curIndex + i)
      curIndex += len(oTree.children)
开发者ID:nrc,项目名称:N,代码行数:36,代码来源:nchecker.py


注:本文中的env.Env.freshOld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。