本文整理匯總了Python中quex.engine.misc.interval_handling.NumberSet.from_range方法的典型用法代碼示例。如果您正苦於以下問題:Python NumberSet.from_range方法的具體用法?Python NumberSet.from_range怎麽用?Python NumberSet.from_range使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quex.engine.misc.interval_handling.NumberSet
的用法示例。
在下文中一共展示了NumberSet.from_range方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: buffer_codec_prepare
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def buffer_codec_prepare(self, BufferCodecName, BufferCodecFileName=None, Module=None):
"""Determines: Setup.buffer_codec_name
Setup.buffer_codec
"""
assert BufferCodecName == "unit-test" \
or self.__buffer_element_specification_done_f == True
if BufferCodecName in ("utf8", "utf16"):
assert Module is not None
result = codec_db.CodecDynamicInfo(BufferCodecName, Module)
elif BufferCodecFileName:
os.path.splitext(os.path.basename(BufferCodecFileName))
try:
os.path.splitext(os.path.basename(BufferCodecFileName))
except:
error.log("cannot interpret string following '--codec-file'")
result = codec_db.CodecTransformationInfo(FileName=BufferCodecFileName)
elif BufferCodecName == "unicode":
# (Still, 'icu' or 'iconv' may provide converted content, but ...)
# If the internal buffer is 'unicode', then the pattern's state
# machines are not converted. The requirement for the pattern's
# range is the same as for the 'buffer element chunks'.
result = codec_db.CodecInfo("unicode",
NumberSet.from_range(0, self.get_character_value_limit()),
NumberSet.from_range(0, self.get_character_value_limit()))
elif BufferCodecName == "unit-test":
result = codec_db.CodecInfo("unicode",
NumberSet.from_range(-sys.maxint, sys.maxint),
NumberSet.from_range(-sys.maxint, sys.maxint))
else:
result = codec_db.CodecTransformationInfo(BufferCodecName)
self.buffer_codec = result
示例2: get_setup
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def get_setup(L0, L1, FSM0, FSM1, FSM2):
# SPECIALITIES: -- sm0 and sm1 have an intersection between their second
# transition.
# -- sm1 transits further upon acceptance.
# -- sm2 has only one transition.
ci_list = [
CountInfo(dial_db.new_incidence_id(), NumberSet.from_range(L0, L1),
CountAction(E_CharacterCountType.COLUMN, 0)),
]
# Generate State Machine that does not have any intersection with
# the loop transitions.
sm0 = StateMachine()
si = sm0.add_transition(sm0.init_state_index, FSM0)
si = sm0.add_transition(si, NS_A, AcceptanceF=True)
sm0.states[si].mark_acceptance_id(dial_db.new_incidence_id())
sm1 = StateMachine()
si0 = sm1.add_transition(sm1.init_state_index, FSM1)
si = sm1.add_transition(si0, NS_A, AcceptanceF=True)
iid1 = dial_db.new_incidence_id()
sm1.states[si].mark_acceptance_id(iid1)
si = sm1.add_transition(si, NS_B, si0)
sm1.states[si].mark_acceptance_id(iid1)
sm2 = StateMachine()
si = sm2.add_transition(sm2.init_state_index, FSM2, AcceptanceF=True)
sm2.states[si].mark_acceptance_id(dial_db.new_incidence_id())
return ci_list, [sm0, sm1, sm2]
示例3: __init__
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def __init__(self):
EncodingTrafoBySplit.__init__(self, "utf16",
CodeUnitRange=NumberSet.from_range(0, 0x10000))
self.error_range_code_unit0 = NumberSet([
Interval(0x0000, 0xDC00), Interval(0xE000, 0x10000)
]).get_complement(NumberSet_All())
self.error_range_code_unit1 = NumberSet([
Interval(0xDC00, 0xE000)
]).get_complement(NumberSet_All())
示例4: test
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def test(ci_list, SM_list=[]):
Setup.buffer_codec.source_set = NumberSet_All()
ci_map = CountInfoMap(ci_list, NumberSet.from_range(0, 100))
iid_loop_exit = dial_db.new_incidence_id()
loop_map, appendix_sm_list = loop._get_loop_map(ci_map, SM_list, iid_loop_exit)
print
print
print
general_checks(loop_map, appendix_sm_list)
print_this(loop_map, appendix_sm_list)
示例5: __init__
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def __init__(self):
drain_set = NumberSet.from_range(0, 0x100)
EncodingTrafoBySplit.__init__(self, "utf8", CodeUnitRange=drain_set)
self.UnchangedRange = 0x7F
self.error_range_byte0 = NumberSet([
Interval(0b00000000, 0b01111111+1), Interval(0b11000000, 0b11011111+1),
Interval(0b11100000, 0b11101111+1), Interval(0b11110000, 0b11110111+1),
Interval(0b11111000, 0b11111011+1), Interval(0b11111100, 0b11111101+1),
]).get_complement(NumberSet_All())
self.error_range_byteN = NumberSet(
Interval(0b10000000, 0b10111111+1)
).get_complement(NumberSet_All())
示例6: __init__
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def __init__(self, Name, CodeUnitRange):
base.EncodingTrafo.__init__(self, Name, NumberSet.from_range(0, 0x110000),
CodeUnitRange)
示例7: get_codec_element_range
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def get_codec_element_range():
"""Codec element's size is 1 byte."""
return NumberSet.from_range(0, 0x100)
示例8: get_unicode_range
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def get_unicode_range():
return NumberSet.from_range(0, 0x110000)
示例9: NumberSetGenerator
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
if k == 0:
self.__cursor[k] += 2
if self.__cursor[k] < 8:
break
else:
self.__cursor[k] += 1
if self.__cursor[k] < 3:
break
self.__cursor[k] = 1
k += 1
return result
generator = NumberSetGenerator()
all = NumberSet.from_range(-sys.maxint, sys.maxint)
# Generate 100 NumberSets
number_set_list = []
for i in range(100):
result = generator.get()
number_set_list.append(generator.get())
def test(N1, Op1, N2, Op2):
global number_set_list
the_tester = Tester(N1, Op1, N2, Op2)
# Permutate all existing intervals against each other
count_n = 0
for i, x in enumerate(number_set_list):
for y in number_set_list[i + 1:]:
示例10: set_all_character_set_UNIT_TEST
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def set_all_character_set_UNIT_TEST(self, Begin, End):
self.buffer_codec.source_set = NumberSet.from_range(Begin, End)
示例11: ord
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
import sys
import os
sys.path.insert(0, os.environ["QUEX_PATH"])
from quex.engine.counter import LineColumnCount, \
CountAction
from quex.engine.state_machine.core import StateMachine
from quex.engine.misc.interval_handling import NumberSet, \
NumberSet_All
from quex.engine.analyzer.door_id_address_label import dial_db
from quex.engine.loop_counter import CountInfoMap, \
CountInfo
import quex.output.core.loop as loop
from quex.blackboard import E_CharacterCountType, \
setup as Setup
NS_A = NumberSet.from_range(ord('A'), ord('A') + 1)
NS_B = NumberSet.from_range(ord('B'), ord('B') + 1)
NS_C = NumberSet.from_range(ord('C'), ord('C') + 1)
NS_D = NumberSet.from_range(ord('D'), ord('D') + 1)
if "--hwut-info" in sys.argv:
print "Loop: Get Loop Map."
print "CHOICES: Plain, AppendixNoI, AppendixI, Split;"
def test(ci_list, SM_list=[]):
Setup.buffer_codec.source_set = NumberSet_All()
ci_map = CountInfoMap(ci_list, NumberSet.from_range(0, 100))
iid_loop_exit = dial_db.new_incidence_id()
loop_map, appendix_sm_list = loop._get_loop_map(ci_map, SM_list, iid_loop_exit)
print
示例12: get_sm
# 需要導入模塊: from quex.engine.misc.interval_handling import NumberSet [as 別名]
# 或者: from quex.engine.misc.interval_handling.NumberSet import from_range [as 別名]
def get_sm(SmId, Trigger):
sm = StateMachine.from_IncidenceIdMap([
(NumberSet.from_range(Trigger, Trigger + 1), SmId)
])
sm.set_id(SmId)
return sm