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


Python NumberSet.unite_with方法代码示例

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


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

示例1: test_on_UCS_sample_sets

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
def test_on_UCS_sample_sets(Trafo, unicode_to_transformed_sequence):
    script_list = [
        "Arabic", "Armenian", "Balinese", "Bengali", "Bopomofo", "Braille", "Buginese", "Buhid",
        "Canadian_Aboriginal", "Cherokee", "Common",  "Cuneiform",  "Cypriot",  "Deseret",
        "Gothic",  "Greek",  
        "Hanunoo", "Hebrew", "Hiragana", "Inherited", "Kannada", "Han",  
        "Katakana", "Kharoshthi", "Khmer", "Lao", "Latin", "Limbu", "Linear_B", "Malayalam",
        "Mongolian", "Myanmar", "New_Tai_Lue", "Nko", "Osmanya", "Ogham", "Old_Italic", "Old_Persian",
        "Phoenician",  "Shavian",  "Syloti_Nagri", 
        "Syriac", "Tagalog", "Tagbanwa", "Tai_Le", "Tamil", "Telugu", "Thaana", "Thai",
        "Tibetan", "Tifinagh", "Ugaritic", "Yi"
    ]
    sets = [ X(name) for name in script_list ]

    orig = get_combined_state_machine(map(lambda x: x.sm, sets))
    state_n_before, result = transform(Trafo, orig)

    # print result.get_graphviz_string(Option="hex")

    for set in sets:
        set.check(result, unicode_to_transformed_sequence)
    print "Translated %i groups without abortion on error (OK)" % len(sets)

    union = NumberSet()
    for nset in map(lambda set: set.charset, sets):
        union.unite_with(nset)

    inverse_union = NumberSet(Interval(0, 0x110000))
    inverse_union.subtract(union)
    # print inverse_union.get_string(Option="hex")
    check_negative(result, inverse_union.get_intervals(PromiseToTreatWellF=True), 
                   unicode_to_transformed_sequence)
开发者ID:xxyzzzq,项目名称:quex,代码行数:34,代码来源:helper.py

示例2: general_checks

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
def general_checks(loop_map, appendix_sm_list):
    print "#_[ Checks ]__________________________________________________"
    print
    print "character sets do not intersect",
    all_set = NumberSet()
    for lei in loop_map:
        assert lei.character_set is not None
        assert not lei.character_set.has_intersection(all_set)
        all_set.unite_with(lei.character_set)
    print "[ok]"

    print "count actions do not appear more than once",
    count_action_couple_set = set()
    count_action_plain_set  = set()
    exit_exists_f           = False
    appendix_sm_id_set      = set()
    for lei in loop_map:
        if lei.count_action is None: 
            assert lei.appendix_sm_id is None
            exit_exists_f = True
        elif lei.appendix_sm_id is None:
            assert lei.incidence_id not in count_action_plain_set
            count_action_plain_set.add(lei.incidence_id)
        else:
            assert lei.incidence_id not in count_action_couple_set
            count_action_couple_set.add(lei.incidence_id)
            appendix_sm_id_set.add(lei.appendix_sm_id)
    print "[ok]"
    list_id_set = set(sm.get_id() for sm in appendix_sm_list)
    assert appendix_sm_id_set == list_id_set
    print "appendix sm-ids are the same in loop map and sm list: [ok]"
    print "exit character set exits: [%s]" % exit_exists_f

    print
开发者ID:xxyzzzq,项目名称:quex,代码行数:36,代码来源:loop-get_loop_map.py

示例3: __get_remaining_set

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
 def __get_remaining_set(self):
     ignored = (E_CharacterCountType.BAD, 
                E_CharacterCountType.BEGIN_NEWLINE_SUPPRESSOR, 
                E_CharacterCountType.BEGIN_NEWLINE, 
                E_CharacterCountType.END_NEWLINE) 
     result  = NumberSet()
     for character_set, info in self.__map:
         if info.cc_type in ignored: continue
         result.unite_with(character_set)
     return result.get_complement(Setup.buffer_codec.source_set)
开发者ID:xxyzzzq,项目名称:quex,代码行数:12,代码来源:counter.py

示例4: get_ending_character_set

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
 def get_ending_character_set(self):
     """Returns the union of all characters that trigger to an acceptance
        state in the given state machine. This is to detect whether the
        newline or suppressor end with an indentation character (grid or space).
     """
     result = NumberSet()
     for end_state_index in self.get_acceptance_state_index_list():
         for state in self.states.itervalues():
             if state.target_map.has_target(end_state_index) == False: continue
             result.unite_with(state.target_map.get_trigger_set_to_target(end_state_index))
     return result
开发者ID:mplucinski,项目名称:quex,代码行数:13,代码来源:core.py

示例5: __wildcard_value_match

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
    def __wildcard_value_match(self, WildCardValue):
        result = NumberSet()

        value_list = self.get_wildcard_value_matches(WildCardValue)
        if len(value_list) == 0: 
            return None

        for value in value_list:
            result.unite_with(NumberSet(self.code_point_db[value]))

        # No decoupling, since result is computed each fresh and new
        return result
开发者ID:mplucinski,项目名称:quex,代码行数:14,代码来源:parser.py

示例6: __whitespace_default

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
    def __whitespace_default(self):
        """Try to define default whitespace ' ' or '\t' if their positions
        are not yet occupied in the count_command_map.
        """
        cs0 = NumberSet(ord(" "))
        cs1 = NumberSet(ord("\t"))
        result = NumberSet()
        if not self.specifier_count_op_map.find_occupier(cs0, set()):
            result.unite_with(cs0)
        if not self.specifier_count_op_map.find_occupier(cs1, set()):
            result.unite_with(cs1)

        if result.is_empty():
            error.log("Trying to implement default whitespace ' ' or '\\t' failed.\n"
                      "Characters are occupied by other elements.", self.sr)
        return result
开发者ID:xxyzzzq,项目名称:quex,代码行数:18,代码来源:counter.py

示例7: is_DFA_compliant

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
    def is_DFA_compliant(self):
        """Checks if the current state transitions are DFA compliant, i.e. it
           investigates if trigger sets pointing to different targets intersect.
           RETURNS:  True  => OK
                    False => Same triggers point to different target. This cannot
                             be part of a deterministic finite automaton (DFA).
        """
        # DFA's do not have epsilon transitions
        if len(self.__epsilon_target_index_list) != 0: return False

        # check whether trigger sets intersect
        all_trigger_sets = NumberSet()
        for trigger_set in self.__db.itervalues():
            if all_trigger_sets.has_intersection(trigger_set): 
                return False
            else:
                all_trigger_sets.unite_with(trigger_set)

        return True
开发者ID:mplucinski,项目名称:quex,代码行数:21,代码来源:target_map.py

示例8: get_character_set

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
    def get_character_set(self, Value=None):
        """Returns the character set that corresponds to 'Property==Value'.
           'Value' can be a property value or a property value alias.
           For binary properties 'Value' must be None.
        """
        assert self.type != "Binary" or Value is None

        def get_value_combination(CmbAlias):
            result = []
            for alias in self.alias_to_alias_combination_db[CmbAlias]:
                name = self.alias_to_name_map.get(alias)
                if name is None:
                    return "Unicode database error: no name related to alias '%s'" % alias
                result.append(name)
            return result

        if self.type != "Binary" and Value is None:
            return "Property '%s' requires a value setting.\n" % self.name + \
                   "Possible Values: " + \
                   self.get_value_list_help()

        if self.code_point_db is None:
            self.init_code_point_db()

        if self.type == "Binary": 
            # Decouple, since we refer to an internal database
            return deepcopy(self.code_point_db)

        adapted_value = Value.replace(" ", "_")

        if   self.code_point_db.has_key(adapted_value): 
            # 'value' is present as name in the code point database
            value = adapted_value

        elif Value in self.alias_to_name_map.keys():
            # 'value' is present as alias in code pointer database
            value = self.alias_to_name_map[adapted_value]

        elif Value in self.alias_to_alias_combination_db.keys():
            # 'value' is present as a combination of aliases
            value = get_value_combination(adapted_value)

        elif self.name_to_alias_map.has_key(adapted_value):
            # The value was a combination of values
            value = get_value_combination(self.name_to_alias_map[adapted_value])

        else:
            # -- WILDCARD MATCH: Results in a list of property values  
            character_set = self.__wildcard_value_match(adapted_value)
            if character_set is None:
                return "Property '%s' cannot have a value or value alias '%s'.\n" % (self.name, Value) + \
                       "Possible Values: " + \
                       self.get_value_list_help()
            # No need to decouple, since character is not a reference to
            # internal database (for safety, do it)
            return deepcopy(character_set)

        if type(value) == list:
            result = NumberSet()
            for element in value:
                if element == "Unassigned": continue
                entry = self.code_point_db.get(element)
                if entry is None:
                    return "%s/%s is not supported by Unicode database." % (self.name, repr(element))
                result.unite_with(entry)
        else:
            result = self.code_point_db.get(value)
            if result is None:
                return "%s/%s is not supported by Unicode database." % (self.name, repr(value))

        # Reference to internal database --> decouple with 'deepcopy'
        return deepcopy(result)
开发者ID:mplucinski,项目名称:quex,代码行数:74,代码来源:parser.py

示例9: covers

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
    def covers(self, Min, Max):
        result = NumberSet()

        for info in self.__map:
            result.unite_with(info.character_set)
        return result.covers_range(Min, Max)
开发者ID:mplucinski,项目名称:quex,代码行数:8,代码来源:counter.py

示例10: _get_all_character_set

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
def _get_all_character_set(*DbList):
    result = NumberSet()
    for db in DbList:
        for character_set in db.itervalues():
            result.unite_with(character_set)
    return result
开发者ID:mplucinski,项目名称:quex,代码行数:8,代码来源:counter.py

示例11: get_trigger_set_union

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
 def get_trigger_set_union(self):
     result = NumberSet()
     for trigger_set in self.__db.itervalues():
         result.unite_with(trigger_set)
     return result
开发者ID:mplucinski,项目名称:quex,代码行数:7,代码来源:target_map.py

示例12: map

# 需要导入模块: from quex.engine.misc.interval_handling import NumberSet [as 别名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import unite_with [as 别名]
            for cmd in result.states[s_idx].single_entry:
                assert not cmd.is_acceptance()

    print " (OK)"

sets = map(lambda name: X(name),
        ["Arabic", "Armenian", "Balinese", "Bengali", "Bopomofo", "Braille",
            "Hanunoo", "Hebrew", "Hiragana", "Inherited", "Kannada",
            "Katakana", "Kharoshthi", "Khmer", "Lao", "Latin", "Limbu", "Linear_B", "Malayalam",
            "Mongolian", "Myanmar", "New_Tai_Lue", "Nko", "Ogham", "Old_Italic", "Old_Persian",
            "Syriac", "Tagalog", "Tagbanwa", "Tai_Le", "Tamil", "Telugu", "Thaana", "Thai",
            "Tibetan", "Tifinagh", "Ugaritic", "Yi"])

orig = get_combined_state_machine(map(lambda x: x.sm, sets))
print "Number of states in state machine:"
print "   Unicode:       %i" % len(orig.states)
result = trafo.do(orig)
print "   UTF8-Splitted: %i" % len(result.states)

for set in sets:
    set.check(result)

union = NumberSet()
for nset in map(lambda set: set.charset, sets):
    union.unite_with(nset)

inverse_union = NumberSet(Interval(0, 0x110000))
inverse_union.subtract(union)
# print inverse_union.get_string(Option="hex")
check_negative(result, inverse_union.get_intervals(PromiseToTreatWellF=True))
开发者ID:mplucinski,项目名称:quex,代码行数:32,代码来源:test-utf8_state_split-do.py


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