本文整理匯總了Python中quex.engine.state_machine.core.StateMachine.from_IncidenceIdMap方法的典型用法代碼示例。如果您正苦於以下問題:Python StateMachine.from_IncidenceIdMap方法的具體用法?Python StateMachine.from_IncidenceIdMap怎麽用?Python StateMachine.from_IncidenceIdMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quex.engine.state_machine.core.StateMachine
的用法示例。
在下文中一共展示了StateMachine.from_IncidenceIdMap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _get_loop_analyzer
# 需要導入模塊: from quex.engine.state_machine.core import StateMachine [as 別名]
# 或者: from quex.engine.state_machine.core.StateMachine import from_IncidenceIdMap [as 別名]
def _get_loop_analyzer(LoopMap, EventHandler):
"""Construct a state machine that triggers only on one character. Actions
according the the triggered character are implemented using terminals which
are entered upon acceptance.
.------.
---->| Loop |
| |----> accept A (normal loop terminals)
| |----> accept B
| |----> accept C
: : :
| |----> accept CoupleIncidenceA (couple terminals towards
| |----> accept CoupleIncidenceB appendix state machines)
| |----> accept CoupleIncidenceC
:______: :
| else |----> accept iid_loop_exit
'------'
RETURNS: [0] Loop analyzer (prepared state machine)
[1] DoorID of loop entry
"""
# Loop StateMachine
sm = StateMachine.from_IncidenceIdMap(
(lei.character_set, lei.incidence_id) for lei in LoopMap
)
# Code Transformation
verdict_f, sm = Setup.buffer_codec.do_state_machine(sm, beautifier)
# Loop Analyzer
analyzer = analyzer_generator.do(sm,
EventHandler.engine_type,
EventHandler.reload_state_extern,
OnBeforeReload = EventHandler.on_before_reload,
OnAfterReload = EventHandler.on_after_reload,
OnBeforeEntry = EventHandler.on_loop_entry)
# If reload state is generated
# => All other analyzers MUST use the same generated reload state.
if EventHandler.reload_state_extern is None:
EventHandler.reload_state_extern = analyzer.reload_state
# Set the 'Re-Entry' Operations.
entry = analyzer.init_state().entry
tid_reentry = entry.enter_OpList(analyzer.init_state_index, index.get(),
EventHandler.on_loop_reentry)
entry.categorize(analyzer.init_state_index)
return analyzer, entry.get(tid_reentry).door_id
示例2: get_transition_function
# 需要導入模塊: from quex.engine.state_machine.core import StateMachine [as 別名]
# 或者: from quex.engine.state_machine.core.StateMachine import from_IncidenceIdMap [as 別名]
def get_transition_function(iid_map, Codec):
if Codec == "UTF8": Setup.buffer_codec_set(bc_factory.do("utf8"), 1)
else: Setup.buffer_codec_set(bc_factory.do("unicode"), -1)
sm = StateMachine.from_IncidenceIdMap(iid_map)
dummy, sm = Setup.buffer_codec.do_state_machine(sm, beautifier)
analyzer = analyzer_generator.do(sm, engine.CHARACTER_COUNTER)
tm_txt = do_analyzer(analyzer)
tm_txt = Lng.GET_PLAIN_STRINGS(tm_txt)
tm_txt.append("\n")
#label = dial_db.get_label_by_door_id(DoorID.incidence(E_IncidenceIDs.MATCH_FAILURE))
for character_set, iid in iid_map:
tm_txt.append("%s return (int)%s;\n" % (Lng.LABEL(DoorID.incidence(iid)), iid))
tm_txt.append("%s return (int)-1;\n" % Lng.LABEL(DoorID.drop_out(-1)))
return "".join(tm_txt)
示例3: get_sm
# 需要導入模塊: from quex.engine.state_machine.core import StateMachine [as 別名]
# 或者: from quex.engine.state_machine.core.StateMachine import from_IncidenceIdMap [as 別名]
def get_sm(SmId, Trigger):
sm = StateMachine.from_IncidenceIdMap([
(NumberSet.from_range(Trigger, Trigger + 1), SmId)
])
sm.set_id(SmId)
return sm