def create_ALL_BUT_NEWLINE_state_machine(stream): global Setup result = StateMachine() # NOTE: Buffer control characters are supposed to be filtered out by the code # generator. trigger_set = NumberSet(Interval(ord("\n"))).get_complement(Setup.buffer_codec.source_set) if trigger_set.is_empty(): error_msg("The set of admissible characters contains only newline.\n" "The '.' for 'all but newline' is an empty set.", SourceRef.from_FileHandle(stream)) result.add_transition(result.init_state_index, trigger_set, AcceptanceF=True) return result
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.count_command_map.find_occupier(cs0, set()): result.unite_with(cs0) if not self.count_command_map.find_occupier(cs1, set()): result.unite_with(cs1) if result.is_empty(): error_msg("Trying to implement default whitespace ' ' or '\\t' failed.\n" "Characters are occupied by other elements.", self.sr) return result