def test(sm, pre_sm): print "EXPRESSION = ", sm print "PRE-CONDITION = ", pre_sm inverse_pre_context_sm = setup_pre_context.do(sm, pre_sm, False) # print "with pre-context = ", sm print "inverse pre-context = ", inverse_pre_context_sm
def mount_pre_context_sm(self): if self.__pre_context_sm_to_be_inverted is None \ and self.__pre_context_begin_of_line_f == False: return self.__pre_context_sm = setup_pre_context.do( self.__sm, self.__pre_context_sm_to_be_inverted, self.__pre_context_begin_of_line_f)
def mount_pre_context_sm(self): if self.__pre_context_sm_to_be_inverted is None \ and self.__pre_context_begin_of_line_f == False: return self.__pre_context_sm = setup_pre_context.do(self.__sm, self.__pre_context_sm_to_be_inverted, self.__pre_context_begin_of_line_f)
def test(sm, pre_sm): print "EXPRESSION = ", sm print "PRE-CONDITION = ", pre_sm pre_context_sm = setup_pre_context.do(sm, pre_sm, False, False) inverse_pre_context_sm = reverse.do(pre_context_sm) inverse_pre_context_sm.set_id(pre_context_sm.get_id()) # print "with pre-context = ", sm print "inverse pre-context = ", inverse_pre_context_sm
def finalize(self, CaMap): """Prepares for further processing: * Determines line column counting information (lcci) * Mounts pre and post context state machines RETURNS: 'Pattern' object. NOTE: After the call to this function 'self' is dysfunctional (empty). """ assert not self.__finalized_f assert self.__sm is not None self.__finalized_f = True # Count information must be determined BEFORE transformation! if CaMap is not None: lcci = SmLineColumnCountInfo.from_DFA(CaMap, self.__sm, self.pre_context_trivial_begin_of_line_f, Setup.buffer_encoding) else: lcci = None original_incidence_id = self.__sm.get_id() # (*) Pre-contexts and BIPD can only be mounted, after the transformation. sm_main, \ sm_bipd_to_be_reversed = _finalize_mount_post_context_sm(self.__sm, self.__post_context_sm, self.__post_context_end_of_line_f, self.__post_context_end_of_stream_f, self.__sr) sm_pre_context_to_be_reversed = setup_pre_context.do(sm_main, self.__pre_context_sm_to_be_reversed, self.__pre_context_begin_of_line_f, self.__pre_context_begin_of_stream_f) sm_main = sm_main.clone() sm_main.set_id(original_incidence_id) self.__mark_dysfunctional() return Pattern(sm_main, sm_pre_context_to_be_reversed, sm_bipd_to_be_reversed, lcci, PatternString = self.__pattern_string, Sr = self.__sr)
def test(Idx, sm_pre, sm, sm_post, BOL_F, EOL_F): ## if Idx != 5: return result = sm.clone() print "##-- %i -----------------------------------------------------------------------" % Idx if sm_pre is not None: print " -- pre-condition = True" else: print " -- pre-condition = False" if sm_post is not None: print " -- post-condition = True" else: print " -- post-condition = False" print " -- begin of line = ", BOL_F print " -- end of line = ", EOL_F ipsb_sm = setup_post_context.do(result, sm_post, EOL_F, False, SourceRef_VOID) pre_context_sm = setup_pre_context.do(result, sm_pre, BOL_F, False) if pre_context_sm is None: inverse_pre_context_sm = None else: inverse_pre_context_sm = reverse.do(pre_context_sm) inverse_pre_context_sm.set_id(pre_context_sm.get_id()) # # print "EXPRESSION = ", result # print "POST CONDITION = ", post_sm # print "APPENDED = ", result result = beautifier.do(result) # # print print "result sm.id = ", result.get_id() if inverse_pre_context_sm is not None: print "result pre sm.id = ", inverse_pre_context_sm.get_id() begin_of_line_f = None for state in result.get_acceptance_state_list(): BOF = state.single_entry.has_pre_context_begin_of_line() if begin_of_line_f is None: begin_of_line_f = BOF else: assert begin_of_line_f == BOF print "result = ", result if inverse_pre_context_sm is not None: print "inverse_pre_context_sm = ", inverse_pre_context_sm print "trivially pre-conditioned = ", begin_of_line_f
def test(Idx, sm_pre, sm, sm_post, BOF_F, EOF_F): result = sm.clone() print "##-- %i -----------------------------------------------------------------------" % Idx if sm_pre is not None: print " -- pre-condition = True" else: print " -- pre-condition = False" if sm_post is not None: print " -- post-condition = True" else: print " -- post-condition = False" print " -- begin of line = ", BOF_F print " -- end of line = ", EOF_F ipsb_sm = setup_post_context.do(result, sm_post, EOF_F, SourceRef_VOID) inverse_pre_context_sm = setup_pre_context.do(result, sm_pre, BOF_F) # # print "EXPRESSION = ", result # print "POST CONDITION = ", post_sm # print "APPENDED = ", result result = beautifier.do(result) # # print print "result sm.id = ", result.get_id() if inverse_pre_context_sm is not None: print "result pre sm.id = ", inverse_pre_context_sm.get_id() begin_of_line_f = None for state in result.get_acceptance_state_list(): BOF = state.single_entry.has_begin_of_line_pre_context() if begin_of_line_f is None: begin_of_line_f = BOF else: assert begin_of_line_f == BOF print "result = ", result if inverse_pre_context_sm is not None: print "inverse_pre_context_sm = ", inverse_pre_context_sm print "trivially pre-conditioned = ", begin_of_line_f