def parallelAtSeller1_events(): events = [] events.append(TransitionFactory.create(LocalType.RESV, 'Order', 'Buyer')) events.append( TransitionFactory.create(LocalType.SEND, 'Confirmation', 'Buyer')) events.append(TransitionFactory.create(LocalType.SEND, 'OK', 'Buyer')) return events
def main_auction_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Seller')) events.append(TransitionFactory.create(LocalType.RESV, 'Invoice', 'Seller')) events.append(TransitionFactory.create(LocalType.SEND, 'OK', 'Buyer')) return events
def DataAcquisition_at_U_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Push', 'A')) events.append(TransitionFactory.create(LocalType.RESV, 'Formatted', 'A')) events.append(TransitionFactory.create(LocalType.RESV, 'Formatted', 'A')) events.append(TransitionFactory.create(LocalType.SEND, 'Stop', 'A')) return events
def UnorderedAtBuyer_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append(TransitionFactory.create(LocalType.RESV, 'Order', 'Seller1')) events.append(TransitionFactory.create(LocalType.SEND, 'OK', 'Seller')) return events
def DataAcquisition_at_I_events(): events = [] events.append(TransitionFactory.create(LocalType.RESV, 'StreamMode', 'A')) events.append(TransitionFactory.create(LocalType.SEND, 'Supported', 'A')) events.append(TransitionFactory.create(LocalType.RESV, 'ConfigStream', 'A')) events.append(TransitionFactory.create(LocalType.SEND, 'Raw', 'A')) events.append(TransitionFactory.create(LocalType.RESV, 'Stop', 'A')) return events
def logic_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) return events
def _check(self, invocation, op_type, self_principal, target_principal): operation = invocation.get_header_value("op", "") cid = invocation.get_header_value("conv-id", 0) conv_seq = invocation.get_header_value("conv-seq", 0) conversation_key = self._get_conversation_context_key(self_principal, invocation) # INITIALIZE FSM if (conv_seq == 1 and self._should_be_monitored(invocation, self_principal, operation)) and not ( (conversation_key in self.conversation_context) ): role_spec = self._get_protocol_spec(self_principal, operation) if not role_spec: self._report_error( invocation, GovernanceDispatcher.STATUS_SKIPPED, "The message cannot be monitored since the protocol specification was not found: %s", ) else: conversation_context = self._initialize_conversation_context( cid, role_spec, self_principal, target_principal, operation ) if conversation_context: self.conversation_context[conversation_key] = conversation_context # CHECK if conversation_key in self.conversation_context: conversation_context = self.conversation_context[conversation_key] # target_role = conversation_context.get_role_by_principal(target_principal) target_role = target_principal # if target_principal_queue and target_role: # conversation_context.set_role_mapping(target_role, target_principal_queue) fsm = conversation_context.get_fsm() control_conv_msg_type = self._get_control_conv_msg(invocation) if control_conv_msg_type == MSG_TYPE.ACCEPT: transition = TransitionFactory.create(op_type, "accept", target_role) (msg_correct, error, should_pop) = self._is_msg_correct(invocation, fsm, transition) if not msg_correct: self._report_error(invocation, GovernanceDispatcher.STATUS_REJECT, error) return transition = TransitionFactory.create(op_type, operation, target_role) # Check the message by running the fsm. (msg_correct, error, should_pop) = self._is_msg_correct(invocation, fsm, transition) if not msg_correct: self._report_error(invocation, GovernanceDispatcher.STATUS_REJECT, error) # Stop monitoring if msg is wrong or this is the response of the request that had started the conversation if (should_pop) and (conversation_context.get_conversation_id() == cid): self.conversation_context.pop(conversation_key)
def DataAcquisition_at_A_events_push_supported(): events = [] events.append(TransitionFactory.create(LocalType.RESV, 'Push', 'U')) events.append(TransitionFactory.create(LocalType.SEND, 'StreamMode', 'I')) events.append(TransitionFactory.create(LocalType.RESV, 'Supported', 'I')) events.append(TransitionFactory.create(LocalType.SEND, 'ConfigStream', 'I')) events.append(TransitionFactory.create(LocalType.RESV, 'Raw', 'I')) events.append(TransitionFactory.create(LocalType.SEND, 'Formatted', 'U')) events.append(TransitionFactory.create(LocalType.RESV, 'Raw', 'I')) events.append(TransitionFactory.create(LocalType.SEND, 'Formatted', 'U')) events.append(TransitionFactory.create(LocalType.RESV, 'Stop', 'U')) events.append(TransitionFactory.create(LocalType.SEND, 'Stop', 'I')) return events
def DataAcquisition_at_A_events_poll_not_supported(): events = [] events.append(TransitionFactory.create(LocalType.RESV, 'Poll', 'U')) events.append(TransitionFactory.create(LocalType.SEND, 'SampleMode', 'I')) events.append(TransitionFactory.create(LocalType.RESV, 'NotSupported', 'I')) events.append(TransitionFactory.create(LocalType.SEND, 'ConfigPush', 'I')) events.append(TransitionFactory.create(LocalType.RESV, 'Raw', 'I')) events.append(TransitionFactory.create(LocalType.RESV, 'Raw', 'I')) events.append(TransitionFactory.create(LocalType.SEND, 'Formatted', 'U')) events.append(TransitionFactory.create(LocalType.RESV, 'Stop', 'U')) events.append(TransitionFactory.create(LocalType.SEND, 'Stop', 'I')) return events
def ECOOPLogic_Server_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Balance', 'Client')) events.append(TransitionFactory.create(LocalType.SEND, 'OverdraftLimit', 'Client')) events.append(TransitionFactory.create(LocalType.RESV, 'MakePayment', 'Client')) events.append(TransitionFactory.create(LocalType.SEND, 'Balance', 'Client')) events.append(TransitionFactory.create(LocalType.SEND, 'OverdraftLimit', 'Client')) events.append(TransitionFactory.create(LocalType.RESV, 'CloseAccount', 'Client')) return events
def Interrupt_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append(TransitionFactory.create(LocalType.RESV, 'Help', 'Seller')) events.append( TransitionFactory.create(LocalType.SEND, 'MoreHelp', 'Seller')) return events
def purchasingAtBuyer_events(): events = [] events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Broker')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append(TransitionFactory.create(LocalType.SEND, 'Order', 'Broker')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) return events
def locateChoiceAtBuyer_events(): events = [] events.append( TransitionFactory.create(LocalType.RESV, 'Confirmation', 'Seller')) events.append(TransitionFactory.create(LocalType.SEND, 'OK', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'OutOfStock', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'OutOfStock', 'Seller')) events.append( TransitionFactory.create(LocalType.RESV, 'OutOfStock', 'Seller')) events.append(TransitionFactory.create(LocalType.SEND, 'Finish', 'Seller')) return events
def _check(self, invocation, op_type, self_principal, target_principal): operation = invocation.get_header_value('op', '') cid = invocation.get_header_value('conv-id', 0) conv_seq = invocation.get_header_value('conv-seq', 0) conversation_key = self._get_conversation_context_key( self_principal, invocation) # INITIALIZE FSM if ((conv_seq == 1 and self._should_be_monitored( invocation, self_principal, operation)) and not ((conversation_key in self.conversation_context))): role_spec = self._get_protocol_spec(self_principal, operation) if not role_spec: self._report_error( invocation, GovernanceDispatcher.STATUS_SKIPPED, 'The message cannot be monitored since the protocol specification was not found: %s' ) else: conversation_context = self._initialize_conversation_context( cid, role_spec, self_principal, target_principal, operation) if conversation_context: self.conversation_context[ conversation_key] = conversation_context # CHECK if (conversation_key in self.conversation_context): conversation_context = self.conversation_context[conversation_key] #target_role = conversation_context.get_role_by_principal(target_principal) target_role = target_principal #if target_principal_queue and target_role: #conversation_context.set_role_mapping(target_role, target_principal_queue) fsm = conversation_context.get_fsm() control_conv_msg_type = self._get_control_conv_msg(invocation) if (control_conv_msg_type == MSG_TYPE.ACCEPT): transition = TransitionFactory.create(op_type, 'accept', target_role) (msg_correct, error, should_pop) = self._is_msg_correct(invocation, fsm, transition) if not msg_correct: self._report_error(invocation, GovernanceDispatcher.STATUS_REJECT, error) return transition = TransitionFactory.create(op_type, operation, target_role) #Check the message by running the fsm. (msg_correct, error, should_pop) = self._is_msg_correct(invocation, fsm, transition) if not msg_correct: self._report_error(invocation, GovernanceDispatcher.STATUS_REJECT, error) # Stop monitoring if msg is wrong or this is the response of the request that had started the conversation if (should_pop) and (conversation_context.get_conversation_id() == cid): self.conversation_context.pop(conversation_key)
def activityDef(self, ): val = None type = None rlabel = None rtype = None role = None assertion = None slabel = None stype = None label = None labelID = None try: try: # BuildFSM.g:69:12: ( ^( RESV ^( VALUE (val= ID type= ID )* ) rlabel= ID (rtype= ID )* role= ID ^( ASSERT (assertion= ASSERTION )? ) ) | ^( SEND ^( VALUE (val= ID type= ID )* ) slabel= ID (stype= ID )* role= ID ^( ASSERT (assertion= ASSERTION )? ) ) | ^( 'choice' ( ^( BRANCH ( activityDef )+ ) )+ ) | ^( PARALLEL ( ^( BRANCH ( activityDef )+ ) )+ ) | ^( 'repeat' ( ^( BRANCH ( activityDef )+ ) ) ) | ^( 'rec' label= ID ( ^( BRANCH ( activityDef )+ ) ) ) | ^( 'RECLABEL' labelID= ID ) ) alt14 = 7 LA14 = self.input.LA(1) if LA14 == RESV: alt14 = 1 elif LA14 == SEND: alt14 = 2 elif LA14 == 39: alt14 = 3 elif LA14 == PARALLEL: alt14 = 4 elif LA14 == 42: alt14 = 5 elif LA14 == 43: alt14 = 6 elif LA14 == RECLABEL: alt14 = 7 else: nvae = NoViableAltException("", 14, 0, self.input) raise nvae if alt14 == 1: # BuildFSM.g:70:4: ^( RESV ^( VALUE (val= ID type= ID )* ) rlabel= ID (rtype= ID )* role= ID ^( ASSERT (assertion= ASSERTION )? ) ) pass self.match(self.input, RESV, self.FOLLOW_RESV_in_activityDef68) self.match(self.input, DOWN, None) self.match(self.input, VALUE, self.FOLLOW_VALUE_in_activityDef75) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # BuildFSM.g:71:12: (val= ID type= ID )* while True: #loop2 alt2 = 2 LA2_0 = self.input.LA(1) if (LA2_0 == ID) : alt2 = 1 if alt2 == 1: # BuildFSM.g:71:13: val= ID type= ID pass val=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef80) type=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef85) else: break #loop2 self.match(self.input, UP, None) #action start self.memory.append('In RESV value') #action end rlabel=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef99) #action start #INFO: This is the way to write comments in actions self.memory.append('resv' + rlabel.text) #action end # BuildFSM.g:74:4: (rtype= ID )* while True: #loop3 alt3 = 2 LA3_0 = self.input.LA(1) if (LA3_0 == ID) : LA3_1 = self.input.LA(2) if (LA3_1 == ID) : alt3 = 1 if alt3 == 1: # BuildFSM.g:74:6: rtype= ID pass rtype=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef117) #action start self.memory.append(rtype.text) #action end else: break #loop3 role=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef127) #action start self.current_fsm.add_transition(TransitionFactory.create(LocalType.RESV,rlabel, role)) #action end self.match(self.input, ASSERT, self.FOLLOW_ASSERT_in_activityDef138) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # BuildFSM.g:76:13: (assertion= ASSERTION )? alt4 = 2 LA4_0 = self.input.LA(1) if (LA4_0 == ASSERTION) : alt4 = 1 if alt4 == 1: # BuildFSM.g:76:14: assertion= ASSERTION pass assertion=self.match(self.input, ASSERTION, self.FOLLOW_ASSERTION_in_activityDef143) self.match(self.input, UP, None) #action start self.memory.append('In RESV assertion') #action end self.match(self.input, UP, None) elif alt14 == 2: # BuildFSM.g:78:4: ^( SEND ^( VALUE (val= ID type= ID )* ) slabel= ID (stype= ID )* role= ID ^( ASSERT (assertion= ASSERTION )? ) ) pass self.match(self.input, SEND, self.FOLLOW_SEND_in_activityDef159) self.match(self.input, DOWN, None) self.match(self.input, VALUE, self.FOLLOW_VALUE_in_activityDef164) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # BuildFSM.g:79:10: (val= ID type= ID )* while True: #loop5 alt5 = 2 LA5_0 = self.input.LA(1) if (LA5_0 == ID) : alt5 = 1 if alt5 == 1: # BuildFSM.g:79:11: val= ID type= ID pass val=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef169) type=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef174) else: break #loop5 self.match(self.input, UP, None) #action start self.memory.append('In SEND value') #action end slabel=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef187) #action start self.memory.append('send' + slabel.text) #action end # BuildFSM.g:80:58: (stype= ID )* while True: #loop6 alt6 = 2 LA6_0 = self.input.LA(1) if (LA6_0 == ID) : LA6_1 = self.input.LA(2) if (LA6_1 == ID) : alt6 = 1 if alt6 == 1: # BuildFSM.g:80:60: stype= ID pass stype=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef197) #action start self.memory.append(stype.text) #action end else: break #loop6 role=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef207) #action start self.current_fsm.add_transition(TransitionFactory.create(LocalType.SEND,slabel, role)) #action end self.match(self.input, ASSERT, self.FOLLOW_ASSERT_in_activityDef215) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # BuildFSM.g:82:11: (assertion= ASSERTION )? alt7 = 2 LA7_0 = self.input.LA(1) if (LA7_0 == ASSERTION) : alt7 = 1 if alt7 == 1: # BuildFSM.g:82:12: assertion= ASSERTION pass assertion=self.match(self.input, ASSERTION, self.FOLLOW_ASSERTION_in_activityDef220) self.match(self.input, UP, None) #action start self.memory.append('In SEND assertion') #action end self.match(self.input, UP, None) elif alt14 == 3: # BuildFSM.g:84:3: ^( 'choice' ( ^( BRANCH ( activityDef )+ ) )+ ) pass self.match(self.input, 39, self.FOLLOW_39_in_activityDef234) #action start self.memory.append('enter choice state') self.current_fsm.choice_start_stat. = self.current_fsm.get_current_state() self.current_fsm.choice_end_state = self.current_fsm.state_gen.next() #action end self.match(self.input, DOWN, None) # BuildFSM.g:89:2: ( ^( BRANCH ( activityDef )+ ) )+ cnt9 = 0 while True: #loop9 alt9 = 2 LA9_0 = self.input.LA(1) if (LA9_0 == BRANCH) : alt9 = 1 if alt9 == 1: # BuildFSM.g:89:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef244) #action start self.memory.append('enter choice branch and save the current state') self.current_fsm.move_current_state(self.current_fsm.choice_start_state) #action end self.match(self.input, DOWN, None) # BuildFSM.g:93:4: ( activityDef )+ cnt8 = 0 while True: #loop8 alt8 = 2 LA8_0 = self.input.LA(1) if ((RESV <= LA8_0 <= SEND) or (RECLABEL <= LA8_0 <= PARALLEL) or LA8_0 == 39 or (42 <= LA8_0 <= 43)) : alt8 = 1 if alt8 == 1: # BuildFSM.g:93:4: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef250) self.activityDef() self._state.following.pop() else: if cnt8 >= 1: break #loop8 eee = EarlyExitException(8, self.input) raise eee cnt8 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit choice branch and set the current state to the end state for the choice') self.current_fsm.add_transition(self.fsm.EMPTY_TRANSITION, self.current_fsm.get_current_state(), nothing, self.current_fsm.choice_end_state) #action end else: if cnt9 >= 1: break #loop9 eee = EarlyExitException(9, self.input) raise eee cnt9 += 1 self.match(self.input, UP, None) #action start self.memory.append('set the current state to be equal to the end state for the choice') self.current_fsm.move_current_state(self.choice_end_state) #action end elif alt14 == 4: # BuildFSM.g:103:4: ^( PARALLEL ( ^( BRANCH ( activityDef )+ ) )+ ) pass self.match(self.input, PARALLEL, self.FOLLOW_PARALLEL_in_activityDef269) #action start self.memory.append('enter parallel state') self.current_fsm.processing_par_state = True #action end self.match(self.input, DOWN, None) # BuildFSM.g:108:2: ( ^( BRANCH ( activityDef )+ ) )+ cnt11 = 0 while True: #loop11 alt11 = 2 LA11_0 = self.input.LA(1) if (LA11_0 == BRANCH) : alt11 = 1 if alt11 == 1: # BuildFSM.g:108:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef286) #action start self.memory.append('enter parallel branch') self.current_fsm.start_new_par_branch = True nested_fsm = FSMBuilderState(self.fsm) self.current_fsm.add_fsm_to_memory(self.current_fsm.get_current_state(), nested_fsm) self.current_fsm = nested_fsm #action end self.match(self.input, DOWN, None) # BuildFSM.g:117:2: ( activityDef )+ cnt10 = 0 while True: #loop10 alt10 = 2 LA10_0 = self.input.LA(1) if ((RESV <= LA10_0 <= SEND) or (RECLABEL <= LA10_0 <= PARALLEL) or LA10_0 == 39 or (42 <= LA10_0 <= 43)) : alt10 = 1 if alt10 == 1: # BuildFSM.g:117:3: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef295) self.activityDef() self._state.following.pop() #action start self.start_new_branch = False #action end else: if cnt10 >= 1: break #loop10 eee = EarlyExitException(10, self.input) raise eee cnt10 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit parallel branch') self.current_fsm.start_new_par_branch = True #action end else: if cnt11 >= 1: break #loop11 eee = EarlyExitException(11, self.input) raise eee cnt11 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit parallel state') self.current_fsm.processing_par_state = False self.current_fsm = self.current_fsm.parent self.current_fsm.add_transition(self.fsm.EMPTY_TRANSITION, self.current_fsm.get_current_state(), nothing, self.current_fsm.move_current_state()) #action end elif alt14 == 5: # BuildFSM.g:127:3: ^( 'repeat' ( ^( BRANCH ( activityDef )+ ) ) ) pass self.match(self.input, 42, self.FOLLOW_42_in_activityDef318) #action start self.memory.append('enter repeat state') #action end self.match(self.input, DOWN, None) # BuildFSM.g:129:2: ( ^( BRANCH ( activityDef )+ ) ) # BuildFSM.g:129:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef327) self.match(self.input, DOWN, None) # BuildFSM.g:129:12: ( activityDef )+ cnt12 = 0 while True: #loop12 alt12 = 2 LA12_0 = self.input.LA(1) if ((RESV <= LA12_0 <= SEND) or (RECLABEL <= LA12_0 <= PARALLEL) or LA12_0 == 39 or (42 <= LA12_0 <= 43)) : alt12 = 1 if alt12 == 1: # BuildFSM.g:129:13: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef330) self.activityDef() self._state.following.pop() #action start self.memory.append('repeat statement') #action end else: if cnt12 >= 1: break #loop12 eee = EarlyExitException(12, self.input) raise eee cnt12 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.memory.append('exit repeat state') #action end elif alt14 == 6: # BuildFSM.g:132:10: ^( 'rec' label= ID ( ^( BRANCH ( activityDef )+ ) ) ) pass self.match(self.input, 43, self.FOLLOW_43_in_activityDef354) self.match(self.input, DOWN, None) label=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef360) #action start self.memory.append('enter rec state ' + label.text) self.current_fsm.recursions_states.setdefault(label.text, self.current_fsm.get_current_state()) #action end # BuildFSM.g:136:2: ( ^( BRANCH ( activityDef )+ ) ) # BuildFSM.g:136:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef376) self.match(self.input, DOWN, None) # BuildFSM.g:136:12: ( activityDef )+ cnt13 = 0 while True: #loop13 alt13 = 2 LA13_0 = self.input.LA(1) if ((RESV <= LA13_0 <= SEND) or (RECLABEL <= LA13_0 <= PARALLEL) or LA13_0 == 39 or (42 <= LA13_0 <= 43)) : alt13 = 1 if alt13 == 1: # BuildFSM.g:136:13: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef379) self.activityDef() self._state.following.pop() #action start self.memory.append('rec statement') #action end else: if cnt13 >= 1: break #loop13 eee = EarlyExitException(13, self.input) raise eee cnt13 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.memory.append('exit rec state ' + label.text) #action end elif alt14 == 7: # BuildFSM.g:139:3: ^( 'RECLABEL' labelID= ID ) pass self.match(self.input, RECLABEL, self.FOLLOW_RECLABEL_in_activityDef397) self.match(self.input, DOWN, None) labelID=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef404) #action start self.memory.append('repeat rec again ' + labelID.text) self.current_fsm.copy_transitions(self.current_fsm.recursions_states[labelID.text], self.current_fsm.get_current_state()) #action end self.match(self.input, UP, None) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) finally: pass return
def activityDef(self, ): val = None vtype = None rlabel = None rtype = None role = None assertion = None slabel = None stype = None label = None labelID = None try: try: # src\\SavedFSM\\BuildFSM.g:108:12: ( ^( RESV ( ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) ) rlabel= ID (rtype= ID )* role= ID ( ^( ASSERT (assertion= ASSERTION )? ) ) ) | ^( SEND ( ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) ) slabel= ID (stype= ID )* role= ID ( ^( ASSERT (assertion= ASSERTION )? ) ) ) | ^( 'choice' ( ^( BRANCH ( activityDef )+ ) )+ ) | ^( PARALLEL ( ^( BRANCH ( activityDef )+ ) )+ ) | ^( 'repeat' ( ^( BRANCH ( activityDef )+ ) ) ) | ^( 'rec' label= ID ( ^( BRANCH ( activityDef )+ ) ) ) | ^( 'RECLABEL' labelID= ID ) | ^( GLOBAL_ESCAPE ( ^( 'do' ( ( activityDef )+ ) ) ) ( ^( 'interrupt' roleName ( ( activityDef )+ ) ) ) ) ) alt16 = 8 LA16 = self.input.LA(1) if LA16 == RESV: alt16 = 1 elif LA16 == SEND: alt16 = 2 elif LA16 == 47: alt16 = 3 elif LA16 == PARALLEL: alt16 = 4 elif LA16 == 49: alt16 = 5 elif LA16 == 50: alt16 = 6 elif LA16 == RECLABEL: alt16 = 7 elif LA16 == GLOBAL_ESCAPE: alt16 = 8 else: nvae = NoViableAltException("", 16, 0, self.input) raise nvae if alt16 == 1: # src\\SavedFSM\\BuildFSM.g:109:2: ^( RESV ( ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) ) rlabel= ID (rtype= ID )* role= ID ( ^( ASSERT (assertion= ASSERTION )? ) ) ) pass self.match(self.input, RESV, self.FOLLOW_RESV_in_activityDef66) #action start local_context = [] #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:110:5: ( ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) ) # src\\SavedFSM\\BuildFSM.g:110:6: ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) pass self.match(self.input, VALUE, self.FOLLOW_VALUE_in_activityDef76) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:110:14: ( (val= ID vtype= ( INT | STRING ) ) )* while True: #loop2 alt2 = 2 LA2_0 = self.input.LA(1) if (LA2_0 == ID) : alt2 = 1 if alt2 == 1: # src\\SavedFSM\\BuildFSM.g:110:15: (val= ID vtype= ( INT | STRING ) ) pass # src\\SavedFSM\\BuildFSM.g:110:15: (val= ID vtype= ( INT | STRING ) ) # src\\SavedFSM\\BuildFSM.g:110:16: val= ID vtype= ( INT | STRING ) pass val=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef82) vtype = self.input.LT(1) if (INT <= self.input.LA(1) <= STRING): self.input.consume() self._state.errorRecovery = False else: mse = MismatchedSetException(None, self.input) raise mse #action start if ((val is not None) and (vtype is not None)): local_context.append((val.text, vtype.text)) #action end else: break #loop2 self.match(self.input, UP, None) rlabel=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef107) #action start #INFO: This is the way to write comments in actions self.memory.append('resv' + rlabel.text) #action end # src\\SavedFSM\\BuildFSM.g:112:5: (rtype= ID )* while True: #loop3 alt3 = 2 LA3_0 = self.input.LA(1) if (LA3_0 == ID) : LA3_1 = self.input.LA(2) if (LA3_1 == ID) : alt3 = 1 if alt3 == 1: # src\\SavedFSM\\BuildFSM.g:112:6: rtype= ID pass rtype=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef121) #action start self.memory.append(rtype.text) #action end else: break #loop3 role=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef131) # src\\SavedFSM\\BuildFSM.g:113:5: ( ^( ASSERT (assertion= ASSERTION )? ) ) # src\\SavedFSM\\BuildFSM.g:113:6: ^( ASSERT (assertion= ASSERTION )? ) pass self.match(self.input, ASSERT, self.FOLLOW_ASSERT_in_activityDef139) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:113:15: (assertion= ASSERTION )? alt4 = 2 LA4_0 = self.input.LA(1) if (LA4_0 == ASSERTION) : alt4 = 1 if alt4 == 1: # src\\SavedFSM\\BuildFSM.g:113:16: assertion= ASSERTION pass assertion=self.match(self.input, ASSERTION, self.FOLLOW_ASSERTION_in_activityDef144) self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.current_fsm.add_transition(TransitionFactory.create(LocalType.RESV,rlabel, role), assertion, local_context) #action end elif alt16 == 2: # src\\SavedFSM\\BuildFSM.g:119:3: ^( SEND ( ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) ) slabel= ID (stype= ID )* role= ID ( ^( ASSERT (assertion= ASSERTION )? ) ) ) pass self.match(self.input, SEND, self.FOLLOW_SEND_in_activityDef163) #action start local_context = [] #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:120:12: ( ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) ) # src\\SavedFSM\\BuildFSM.g:120:13: ^( VALUE ( (val= ID vtype= ( INT | STRING ) ) )* ) pass self.match(self.input, VALUE, self.FOLLOW_VALUE_in_activityDef180) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:120:21: ( (val= ID vtype= ( INT | STRING ) ) )* while True: #loop5 alt5 = 2 LA5_0 = self.input.LA(1) if (LA5_0 == ID) : alt5 = 1 if alt5 == 1: # src\\SavedFSM\\BuildFSM.g:120:22: (val= ID vtype= ( INT | STRING ) ) pass # src\\SavedFSM\\BuildFSM.g:120:22: (val= ID vtype= ( INT | STRING ) ) # src\\SavedFSM\\BuildFSM.g:120:23: val= ID vtype= ( INT | STRING ) pass val=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef186) vtype = self.input.LT(1) if (INT <= self.input.LA(1) <= STRING): self.input.consume() self._state.errorRecovery = False else: mse = MismatchedSetException(None, self.input) raise mse #action start if ((val is not None) and (vtype is not None)): local_context.append((val.text, vtype.text)) #action end else: break #loop5 self.match(self.input, UP, None) slabel=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef212) #action start self.memory.append('send' + slabel.text) #action end # src\\SavedFSM\\BuildFSM.g:121:61: (stype= ID )* while True: #loop6 alt6 = 2 LA6_0 = self.input.LA(1) if (LA6_0 == ID) : LA6_1 = self.input.LA(2) if (LA6_1 == ID) : alt6 = 1 if alt6 == 1: # src\\SavedFSM\\BuildFSM.g:121:63: stype= ID pass stype=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef222) #action start self.memory.append(stype.text) #action end else: break #loop6 role=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef232) # src\\SavedFSM\\BuildFSM.g:122:5: ( ^( ASSERT (assertion= ASSERTION )? ) ) # src\\SavedFSM\\BuildFSM.g:122:6: ^( ASSERT (assertion= ASSERTION )? ) pass self.match(self.input, ASSERT, self.FOLLOW_ASSERT_in_activityDef240) if self.input.LA(1) == DOWN: self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:122:15: (assertion= ASSERTION )? alt7 = 2 LA7_0 = self.input.LA(1) if (LA7_0 == ASSERTION) : alt7 = 1 if alt7 == 1: # src\\SavedFSM\\BuildFSM.g:122:16: assertion= ASSERTION pass assertion=self.match(self.input, ASSERTION, self.FOLLOW_ASSERTION_in_activityDef245) self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.memory.append('In SEND assertion') #action end #action start self.current_fsm.add_transition(TransitionFactory.create(LocalType.SEND,slabel, role), assertion, local_context) #action end elif alt16 == 3: # src\\SavedFSM\\BuildFSM.g:127:3: ^( 'choice' ( ^( BRANCH ( activityDef )+ ) )+ ) pass self.match(self.input, 47, self.FOLLOW_47_in_activityDef264) #action start self.memory.append('enter choice state') self.current_fsm.choice_start_state.append(self.current_fsm.get_current_state()) self.current_fsm.choice_end_state.append(self.current_fsm.state_gen.next()) #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:132:2: ( ^( BRANCH ( activityDef )+ ) )+ cnt9 = 0 while True: #loop9 alt9 = 2 LA9_0 = self.input.LA(1) if (LA9_0 == BRANCH) : alt9 = 1 if alt9 == 1: # src\\SavedFSM\\BuildFSM.g:132:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef274) #action start self.memory.append('enter choice branch and save the current state') self.current_fsm.move_current_state(self.current_fsm.choice_start_state[-1]) #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:137:4: ( activityDef )+ cnt8 = 0 while True: #loop8 alt8 = 2 LA8_0 = self.input.LA(1) if ((RESV <= LA8_0 <= SEND) or (RECLABEL <= LA8_0 <= PARALLEL) or LA8_0 == GLOBAL_ESCAPE or LA8_0 == 47 or (49 <= LA8_0 <= 50)) : alt8 = 1 if alt8 == 1: # src\\SavedFSM\\BuildFSM.g:137:4: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef280) self.activityDef() self._state.following.pop() else: if cnt8 >= 1: break #loop8 eee = EarlyExitException(8, self.input) raise eee cnt8 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit choice branch and set the current state to the end state for the choice') self.current_fsm.fsm.add_transition(self.current_fsm.fsm.EMPTY_TRANSITION, self.current_fsm.get_current_state(), self.current_fsm.choice_end_state[-1]) #action end else: if cnt9 >= 1: break #loop9 eee = EarlyExitException(9, self.input) raise eee cnt9 += 1 self.match(self.input, UP, None) #action start self.memory.append('set the current state to be equal to the end state for the choice') self.current_fsm.move_current_state(self.current_fsm.choice_end_state[-1]) self.current_fsm.choice_end_state.pop() self.current_fsm.choice_start_state.pop() #action end elif alt16 == 4: # src\\SavedFSM\\BuildFSM.g:149:4: ^( PARALLEL ( ^( BRANCH ( activityDef )+ ) )+ ) pass self.match(self.input, PARALLEL, self.FOLLOW_PARALLEL_in_activityDef299) #action start self.memory.append('enter parallel state') self.parallel_root = self.current_fsm #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:154:2: ( ^( BRANCH ( activityDef )+ ) )+ cnt11 = 0 while True: #loop11 alt11 = 2 LA11_0 = self.input.LA(1) if (LA11_0 == BRANCH) : alt11 = 1 if alt11 == 1: # src\\SavedFSM\\BuildFSM.g:154:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef316) #action start self.memory.append('enter parallel branch') nested_fsm = FSMBuilderState(self.parallel_root) self.parallel_root.fsm.add_fsm_to_memory(self.parallel_root.get_current_state(), nested_fsm.fsm) self.current_fsm = nested_fsm #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:161:2: ( activityDef )+ cnt10 = 0 while True: #loop10 alt10 = 2 LA10_0 = self.input.LA(1) if ((RESV <= LA10_0 <= SEND) or (RECLABEL <= LA10_0 <= PARALLEL) or LA10_0 == GLOBAL_ESCAPE or LA10_0 == 47 or (49 <= LA10_0 <= 50)) : alt10 = 1 if alt10 == 1: # src\\SavedFSM\\BuildFSM.g:161:3: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef325) self.activityDef() self._state.following.pop() else: if cnt10 >= 1: break #loop10 eee = EarlyExitException(10, self.input) raise eee cnt10 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit parallel branch') self.current_fsm.add_transition(self.current_fsm.fsm.END_PAR_TRANSITION) #action end else: if cnt11 >= 1: break #loop11 eee = EarlyExitException(11, self.input) raise eee cnt11 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit parallel state') self.current_fsm = self.current_fsm.parent self.current_fsm.fsm.add_transition(self.current_fsm.fsm.EMPTY_TRANSITION, self.current_fsm.get_current_state(), self.current_fsm.move_current_state()) #action end elif alt16 == 5: # src\\SavedFSM\\BuildFSM.g:171:3: ^( 'repeat' ( ^( BRANCH ( activityDef )+ ) ) ) pass self.match(self.input, 49, self.FOLLOW_49_in_activityDef346) #action start self.memory.append('enter repeat state') #action end self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:173:2: ( ^( BRANCH ( activityDef )+ ) ) # src\\SavedFSM\\BuildFSM.g:173:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef355) self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:173:12: ( activityDef )+ cnt12 = 0 while True: #loop12 alt12 = 2 LA12_0 = self.input.LA(1) if ((RESV <= LA12_0 <= SEND) or (RECLABEL <= LA12_0 <= PARALLEL) or LA12_0 == GLOBAL_ESCAPE or LA12_0 == 47 or (49 <= LA12_0 <= 50)) : alt12 = 1 if alt12 == 1: # src\\SavedFSM\\BuildFSM.g:173:13: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef358) self.activityDef() self._state.following.pop() #action start self.memory.append('repeat statement') #action end else: if cnt12 >= 1: break #loop12 eee = EarlyExitException(12, self.input) raise eee cnt12 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.memory.append('exit repeat state') #action end elif alt16 == 6: # src\\SavedFSM\\BuildFSM.g:176:10: ^( 'rec' label= ID ( ^( BRANCH ( activityDef )+ ) ) ) pass self.match(self.input, 50, self.FOLLOW_50_in_activityDef382) self.match(self.input, DOWN, None) label=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef388) #action start self.memory.append('enter rec state ' + label.text + str(self.current_fsm.get_current_state())) self.current_fsm.recursions_states.setdefault(label.text, (self.current_fsm.format_state_name(self.current_fsm.get_current_state()), True)) #action end # src\\SavedFSM\\BuildFSM.g:180:2: ( ^( BRANCH ( activityDef )+ ) ) # src\\SavedFSM\\BuildFSM.g:180:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef404) self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:180:12: ( activityDef )+ cnt13 = 0 while True: #loop13 alt13 = 2 LA13_0 = self.input.LA(1) if ((RESV <= LA13_0 <= SEND) or (RECLABEL <= LA13_0 <= PARALLEL) or LA13_0 == GLOBAL_ESCAPE or LA13_0 == 47 or (49 <= LA13_0 <= 50)) : alt13 = 1 if alt13 == 1: # src\\SavedFSM\\BuildFSM.g:180:13: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef407) self.activityDef() self._state.following.pop() #action start self.memory.append('rec statement') #action end else: if cnt13 >= 1: break #loop13 eee = EarlyExitException(13, self.input) raise eee cnt13 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) #action start (start_state, isActive) = self.current_fsm.recursions_states.get(label.text) self.memory.append('exit rec state ' + label.text + 'start_state' + str(start_state)) self.current_fsm.recursions_states[label.text] = (start_state, False) #action end elif alt16 == 7: # src\\SavedFSM\\BuildFSM.g:187:3: ^( 'RECLABEL' labelID= ID ) pass self.match(self.input, RECLABEL, self.FOLLOW_RECLABEL_in_activityDef425) self.match(self.input, DOWN, None) labelID=self.match(self.input, ID, self.FOLLOW_ID_in_activityDef432) #action start (start_rec_state, isActive) = self.current_fsm.recursions_states.get(labelID.text) self.memory.append('rec label:' + labelID.text + 'starts from state:' + str(start_rec_state)) if isActive: self.current_fsm.fsm.add_transition(self.current_fsm.fsm.EMPTY_TRANSITION, self.current_fsm.format_state_name(self.current_fsm.get_current_state()), start_rec_state) # Generate unreachable state for the choice construct self.current_fsm.move_current_state() else: raise ExceptionFSM('Calling a recusrion label from a recursion that is not valid') #action end self.match(self.input, UP, None) #action start # Do not need it for no #self.current_fsm.fsm.copy_transitions(self.current_fsm.recursions_states[labelID.text], self.current_fsm.get_current_state()) #action end elif alt16 == 8: # src\\SavedFSM\\BuildFSM.g:204:3: ^( GLOBAL_ESCAPE ( ^( 'do' ( ( activityDef )+ ) ) ) ( ^( 'interrupt' roleName ( ( activityDef )+ ) ) ) ) pass self.match(self.input, GLOBAL_ESCAPE, self.FOLLOW_GLOBAL_ESCAPE_in_activityDef446) self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:205:5: ( ^( 'do' ( ( activityDef )+ ) ) ) # src\\SavedFSM\\BuildFSM.g:205:6: ^( 'do' ( ( activityDef )+ ) ) pass self.match(self.input, 56, self.FOLLOW_56_in_activityDef455) self.match(self.input, DOWN, None) # src\\SavedFSM\\BuildFSM.g:205:13: ( ( activityDef )+ ) # src\\SavedFSM\\BuildFSM.g:205:14: ( activityDef )+ pass # src\\SavedFSM\\BuildFSM.g:205:14: ( activityDef )+ cnt14 = 0 while True: #loop14 alt14 = 2 LA14_0 = self.input.LA(1) if ((RESV <= LA14_0 <= SEND) or (RECLABEL <= LA14_0 <= PARALLEL) or LA14_0 == GLOBAL_ESCAPE or LA14_0 == 47 or (49 <= LA14_0 <= 50)) : alt14 = 1 if alt14 == 1: # src\\SavedFSM\\BuildFSM.g:205:14: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef458) self.activityDef() self._state.following.pop() else: if cnt14 >= 1: break #loop14 eee = EarlyExitException(14, self.input) raise eee cnt14 += 1 #action start self.current_fsm.fsm.final_state = self.current_fsm.get_current_state() #action end self.match(self.input, UP, None) # src\\SavedFSM\\BuildFSM.g:206:5: ( ^( 'interrupt' roleName ( ( activityDef )+ ) ) ) # src\\SavedFSM\\BuildFSM.g:206:6: ^( 'interrupt' roleName ( ( activityDef )+ ) ) pass self.match(self.input, 57, self.FOLLOW_57_in_activityDef471) self.match(self.input, DOWN, None) self._state.following.append(self.FOLLOW_roleName_in_activityDef473) self.roleName() self._state.following.pop() #action start self.memory.append('before setting interrupt_transition to True') self.current_fsm.interrupt_start_state = self.current_fsm.move_current_state() self.current_fsm.set_interrupt_transition = True #action end # src\\SavedFSM\\BuildFSM.g:209:56: ( ( activityDef )+ ) # src\\SavedFSM\\BuildFSM.g:209:57: ( activityDef )+ pass # src\\SavedFSM\\BuildFSM.g:209:57: ( activityDef )+ cnt15 = 0 while True: #loop15 alt15 = 2 LA15_0 = self.input.LA(1) if ((RESV <= LA15_0 <= SEND) or (RECLABEL <= LA15_0 <= PARALLEL) or LA15_0 == GLOBAL_ESCAPE or LA15_0 == 47 or (49 <= LA15_0 <= 50)) : alt15 = 1 if alt15 == 1: # src\\SavedFSM\\BuildFSM.g:209:57: activityDef pass self._state.following.append(self.FOLLOW_activityDef_in_activityDef482) self.activityDef() self._state.following.pop() else: if cnt15 >= 1: break #loop15 eee = EarlyExitException(15, self.input) raise eee cnt15 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) finally: pass return
def events(self): events = [ TransitionFactory.create(node[0], node[1], node[2]) for node in self.interactions ] return events
def activityDef(self, ): rlabel = None rtype = None role = None slabel = None stype = None label = None labelID = None try: try: # src/BuildFSM.g:63:12: ( ^( RESV rlabel= ID (rtype= ID )* role= ID ) | ^( SEND slabel= ID (stype= ID )* role= ID ) | ^( 'choice' ( ^( BRANCH ( activityDef )+ ) )+ ) | ^( PARALLEL ( ^( BRANCH ( activityDef )+ ) )+ ) | ^( 'repeat' ( ^( BRANCH ( activityDef )+ ) ) ) | ^( 'rec' label= ID ( ^( BRANCH ( activityDef )+ ) ) ) | ^( 'RECLABEL' labelID= ID ) ) alt10 = 7 LA10 = self.input.LA(1) if LA10 == RESV: alt10 = 1 elif LA10 == SEND: alt10 = 2 elif LA10 == 39: alt10 = 3 elif LA10 == PARALLEL: alt10 = 4 elif LA10 == 42: alt10 = 5 elif LA10 == 43: alt10 = 6 elif LA10 == RECLABEL: alt10 = 7 else: nvae = NoViableAltException("", 10, 0, self.input) raise nvae if alt10 == 1: # src/BuildFSM.g:64:4: ^( RESV rlabel= ID (rtype= ID )* role= ID ) pass self.match(self.input, RESV, self.FOLLOW_RESV_in_activityDef73) self.match(self.input, DOWN, None) rlabel = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef79) #action start #check this comments self.memory.append('resv' + rlabel.text) #action end # src/BuildFSM.g:66:48: (rtype= ID )* while True: #loop2 alt2 = 2 LA2_0 = self.input.LA(1) if (LA2_0 == ID): LA2_1 = self.input.LA(2) if (LA2_1 == ID): alt2 = 1 if alt2 == 1: # src/BuildFSM.g:66:50: rtype= ID pass rtype = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef93) #action start self.memory.append(rtype.text) #action end else: break #loop2 role = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef103) self.match(self.input, UP, None) #action start self.add_transition( TransitionFactory.create(LocalType.RESV, rlabel, role)) #action end elif alt10 == 2: # src/BuildFSM.g:69:4: ^( SEND slabel= ID (stype= ID )* role= ID ) pass self.match(self.input, SEND, self.FOLLOW_SEND_in_activityDef117) self.match(self.input, DOWN, None) slabel = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef123) #action start self.memory.append('send' + slabel.text) #action end # src/BuildFSM.g:69:67: (stype= ID )* while True: #loop3 alt3 = 2 LA3_0 = self.input.LA(1) if (LA3_0 == ID): LA3_1 = self.input.LA(2) if (LA3_1 == ID): alt3 = 1 if alt3 == 1: # src/BuildFSM.g:69:69: stype= ID pass stype = self.match( self.input, ID, self.FOLLOW_ID_in_activityDef133) #action start self.memory.append(stype.text) #action end else: break #loop3 role = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef143) self.match(self.input, UP, None) #action start self.add_transition( TransitionFactory.create(LocalType.SEND, slabel, role)) #action end elif alt10 == 3: # src/BuildFSM.g:72:3: ^( 'choice' ( ^( BRANCH ( activityDef )+ ) )+ ) pass self.match(self.input, 39, self.FOLLOW_39_in_activityDef158) #action start self.memory.append('enter choice state') self.choice_start_state = self.get_current_state() self.choice_end_state = self.state_gen.next() #action end self.match(self.input, DOWN, None) # src/BuildFSM.g:77:2: ( ^( BRANCH ( activityDef )+ ) )+ cnt5 = 0 while True: #loop5 alt5 = 2 LA5_0 = self.input.LA(1) if (LA5_0 == BRANCH): alt5 = 1 if alt5 == 1: # src/BuildFSM.g:77:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef168) #action start self.memory.append( 'enter choice branch and save the current state' ) self.move_current_state(self.choice_start_state) #action end self.match(self.input, DOWN, None) # src/BuildFSM.g:81:4: ( activityDef )+ cnt4 = 0 while True: #loop4 alt4 = 2 LA4_0 = self.input.LA(1) if ((RESV <= LA4_0 <= SEND) or (RECLABEL <= LA4_0 <= PARALLEL) or LA4_0 == 39 or (42 <= LA4_0 <= 43)): alt4 = 1 if alt4 == 1: # src/BuildFSM.g:81:4: activityDef pass self._state.following.append( self. FOLLOW_activityDef_in_activityDef174) self.activityDef() self._state.following.pop() else: if cnt4 >= 1: break #loop4 eee = EarlyExitException(4, self.input) raise eee cnt4 += 1 self.match(self.input, UP, None) #action start self.memory.append( 'exit choice branch and set the current state to the end state for the choice' ) self.fsm.add_transition(self.fsm.EMPTY_TRANSITION, self.get_current_state(), nothing, self.choice_end_state) #action end else: if cnt5 >= 1: break #loop5 eee = EarlyExitException(5, self.input) raise eee cnt5 += 1 self.match(self.input, UP, None) #action start self.memory.append( 'set the current state to be equal to the end state for the choice' ) self.move_current_state(self.choice_end_state) #action end elif alt10 == 4: # src/BuildFSM.g:91:4: ^( PARALLEL ( ^( BRANCH ( activityDef )+ ) )+ ) pass self.match(self.input, PARALLEL, self.FOLLOW_PARALLEL_in_activityDef193) #action start self.memory.append('enter parallel state') self.processing_par_state = True #action end self.match(self.input, DOWN, None) # src/BuildFSM.g:96:2: ( ^( BRANCH ( activityDef )+ ) )+ cnt7 = 0 while True: #loop7 alt7 = 2 LA7_0 = self.input.LA(1) if (LA7_0 == BRANCH): alt7 = 1 if alt7 == 1: # src/BuildFSM.g:96:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef210) #action start self.memory.append('enter parallel branch') self.start_new_par_branch = True #action end self.match(self.input, DOWN, None) # src/BuildFSM.g:101:2: ( activityDef )+ cnt6 = 0 while True: #loop6 alt6 = 2 LA6_0 = self.input.LA(1) if ((RESV <= LA6_0 <= SEND) or (RECLABEL <= LA6_0 <= PARALLEL) or LA6_0 == 39 or (42 <= LA6_0 <= 43)): alt6 = 1 if alt6 == 1: # src/BuildFSM.g:101:3: activityDef pass self._state.following.append( self. FOLLOW_activityDef_in_activityDef219) self.activityDef() self._state.following.pop() #action start self.start_new_branch = False #action end else: if cnt6 >= 1: break #loop6 eee = EarlyExitException(6, self.input) raise eee cnt6 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit parallel branch') self.start_new_par_branch = True #action end else: if cnt7 >= 1: break #loop7 eee = EarlyExitException(7, self.input) raise eee cnt7 += 1 self.match(self.input, UP, None) #action start self.memory.append('exit parallel state') self.processing_par_state = False self.fsm.add_transition(self.fsm.EMPTY_TRANSITION, self.get_current_state(), nothing, self.move_current_state()) #action end elif alt10 == 5: # src/BuildFSM.g:110:3: ^( 'repeat' ( ^( BRANCH ( activityDef )+ ) ) ) pass self.match(self.input, 42, self.FOLLOW_42_in_activityDef242) #action start self.memory.append('enter repeat state') #action end self.match(self.input, DOWN, None) # src/BuildFSM.g:112:2: ( ^( BRANCH ( activityDef )+ ) ) # src/BuildFSM.g:112:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef251) self.match(self.input, DOWN, None) # src/BuildFSM.g:112:12: ( activityDef )+ cnt8 = 0 while True: #loop8 alt8 = 2 LA8_0 = self.input.LA(1) if ((RESV <= LA8_0 <= SEND) or (RECLABEL <= LA8_0 <= PARALLEL) or LA8_0 == 39 or (42 <= LA8_0 <= 43)): alt8 = 1 if alt8 == 1: # src/BuildFSM.g:112:13: activityDef pass self._state.following.append( self.FOLLOW_activityDef_in_activityDef254) self.activityDef() self._state.following.pop() #action start self.memory.append('repeat statement') #action end else: if cnt8 >= 1: break #loop8 eee = EarlyExitException(8, self.input) raise eee cnt8 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.memory.append('exit repeat state') #action end elif alt10 == 6: # src/BuildFSM.g:115:10: ^( 'rec' label= ID ( ^( BRANCH ( activityDef )+ ) ) ) pass self.match(self.input, 43, self.FOLLOW_43_in_activityDef278) self.match(self.input, DOWN, None) label = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef284) #action start self.memory.append('enter rec state ' + label.text) self.recursions_states.setdefault(label.text, self.get_current_state()) #action end # src/BuildFSM.g:119:2: ( ^( BRANCH ( activityDef )+ ) ) # src/BuildFSM.g:119:3: ^( BRANCH ( activityDef )+ ) pass self.match(self.input, BRANCH, self.FOLLOW_BRANCH_in_activityDef300) self.match(self.input, DOWN, None) # src/BuildFSM.g:119:12: ( activityDef )+ cnt9 = 0 while True: #loop9 alt9 = 2 LA9_0 = self.input.LA(1) if ((RESV <= LA9_0 <= SEND) or (RECLABEL <= LA9_0 <= PARALLEL) or LA9_0 == 39 or (42 <= LA9_0 <= 43)): alt9 = 1 if alt9 == 1: # src/BuildFSM.g:119:13: activityDef pass self._state.following.append( self.FOLLOW_activityDef_in_activityDef303) self.activityDef() self._state.following.pop() #action start self.memory.append('rec statement') #action end else: if cnt9 >= 1: break #loop9 eee = EarlyExitException(9, self.input) raise eee cnt9 += 1 self.match(self.input, UP, None) self.match(self.input, UP, None) #action start self.memory.append('exit rec state ' + label.text) #action end elif alt10 == 7: # src/BuildFSM.g:122:3: ^( 'RECLABEL' labelID= ID ) pass self.match(self.input, RECLABEL, self.FOLLOW_RECLABEL_in_activityDef321) self.match(self.input, DOWN, None) labelID = self.match(self.input, ID, self.FOLLOW_ID_in_activityDef328) #action start self.memory.append('repeat rec again ' + labelID.text) self.fsm.copy_transitions( self.recursions_states[labelID.text], self.get_current_state()) #action end self.match(self.input, UP, None) except RecognitionException, re: self.reportError(re) self.recover(self.input, re) finally: pass return