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


Python State.d方法代码示例

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


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

示例1: closure_0

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import d [as 别名]
 def closure_0(self, state_set):
     result = set()
     # 1) Add state_set to it's own closure
     for element in state_set.elements:
         result.add(element)
     # 2) If there exists an LR-element with a Nonterminal as its next symbol
     #    add all production with this symbol on the left side to the closure
     temp = result
     while 1:
         newelements = set()
         # closure of temp
         for state in temp:
             symbol = state.next_symbol()
             if isinstance(symbol, Nonterminal):
                 alternatives = self.grammar[symbol].alternatives
                 for a in alternatives:
                     # create epsilon symbol if alternative is empty
                     if a == []:
                         a = [epsilon]
                     p = Production(symbol, a)
                     s = State(p, 0)
                     if a == [epsilon]:
                         s.d = 1
                     newelements.add(s)
         # add new elements to result
         temp = newelements.difference(result) # remove elements already in result
         result.update(temp)
         if len(temp) == 0: # no new elements were added
             break
     return StateSet(result)
开发者ID:Britefury,项目名称:eco,代码行数:32,代码来源:helpers.py


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