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


Python NumberSet.from_union_of_iterable方法代码示例

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


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

示例1: _get_loop_map

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_union_of_iterable [as 别名]
def _get_loop_map(TheCountMap, SmList, IidLoopExit):
    """A loop map tells about the behavior of the core loop. It tells what
    needs to happen as a consequence to an incoming character. Two options:

        -- Return to loop (normal case)
        -- Enter the tail (appendix) of a parallel state machine.

    RETURNS: List of LoopMapEntry-s. 

    A LoopMapEntry consists of:

       .character_set: Character set that triggers.
       .count_action:  Count action related to the character set.
                       == None, if the character set causes 'loop exit'.
       .incidence_id:  Incidence Id of terminal that is triggered by character set.
                       -- incidence id of count action terminal, or
                       -- incidence id of couple terminal.
       .appendix_sm:   Appendix state machine
                       -- combined appendix state machines, or
                       -- None, indicating that there is none.
    """
    L = TheCountMap.loop_character_set()

    # 'couple_list': Transitions to 'couple terminals' 
    #                => connect to appendix state machines
    couple_list,     \
    appendix_sm_list = _get_LoopMapEntry_list_parallel_state_machines(TheCountMap, 
                                                                      SmList)

    L_couple = NumberSet.from_union_of_iterable(
        lei.character_set for lei in couple_list
    )

    # 'plain_list': Transitions to 'normal terminals' 
    #               => perform count action and loop.
    L_plain    = L.difference(L_couple)
    plain_list = _get_LoopMapEntry_list_plain(TheCountMap, L_plain)

    # 'L_exit': Transition to exit
    #           => remaining characters cause exit.
    L_loop = NumberSet.from_union_of_iterable(
        x.character_set for x in chain(couple_list, plain_list)
    )
    universal_set = Setup.buffer_codec.source_set
    L_exit        = L_loop.get_complement(universal_set)
    exit_list     = [ LoopMapEntry(L_exit, None, IidLoopExit, None) ]

    result = couple_list + plain_list + exit_list

    assert not any(lei is None for lei in result)
    assert not any(lei.character_set is None for lei in result)
    assert not any(lei.incidence_id is None for lei in result)
    return result, appendix_sm_list
开发者ID:xxyzzzq,项目名称:quex,代码行数:55,代码来源:loop.py

示例2: get_incidence_id_map

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_union_of_iterable [as 别名]
    def get_incidence_id_map(self, BeyondIncidenceId=None):
        """RETURNS: A list of pairs: (character_set, incidence_id) 
             
           All same counting actions are referred to by the same incidence id.

           If BeyondIncidenceId is given, then the remaining set of characters
           is associated with 'BeyondIncidenceId'.
        """
        result = [ (x.character_set, x.incidence_id) for x in self.__map ]

        if BeyondIncidenceId is None:
            return result

        all_set    = NumberSet.from_union_of_iterable(x.character_set for x in self.__map)
        beyond_set = all_set.get_complement(Setup.buffer_codec.source_set)
        if not beyond_set.is_empty(): 
            result.append((beyond_set, BeyondIncidenceId))
        return result
开发者ID:mplucinski,项目名称:quex,代码行数:20,代码来源:counter.py

示例3: loop_character_set

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_union_of_iterable [as 别名]
 def loop_character_set(self):
     return NumberSet.from_union_of_iterable(x.character_set for x in self.__map)
开发者ID:xxyzzzq,项目名称:quex,代码行数:4,代码来源:loop_counter.py


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