def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_char_class"]: msg = "b_Sym_char_class: Symbol class specification char '" + b_symbol.io_mapper[ "b_Sym_char_class"] + "' expected but '" + text_repr[ 0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid hex_repr = text_repr[1:] self.charClass = set() self._text = "[" for i in range(0, len(hex_repr) / 2): chex_repr = hex_repr[i * 2] + hex_repr[i * 2 + 1] self.charClass.add(chr(int(chex_repr, 16))) self._text += chr(int(chex_repr, 16)) self._text += "]"
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_class_string"]: msg = "b_Sym_class_string: Symbol class specification char '" + b_symbol.io_mapper["b_Sym_class_string"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid hex_repr = text_repr[2:] splited_hex_repr = hex_repr.split("|") self.string = list() self._text = "" for i in range(1, len(splited_hex_repr)): self._text += "[" charClass = set() for j in range(0, len(splited_hex_repr[i]) / 2): chex_repr = splited_hex_repr[i][j * 2] + splited_hex_repr[i][j * 2 + 1] charClass.add(chr(int(chex_repr, 16))) self._text += chr(int(chex_repr, 16)) self._text += "]" self.string.append(charClass) self._text += ""
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_string"]: msg = "b_Sym_string: Symbol class specification char '" + b_symbol.io_mapper["b_Sym_string"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid hex_repr = text_repr[1:] self.string = "" self._text = "" for i in range(0, len(hex_repr) / 2): chex_repr = hex_repr[i * 2] + hex_repr[i * 2 + 1] self.string += chr(int(chex_repr, 16)) self._text += chr(int(chex_repr, 16)) self._text += ""
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != io_mapper["DEF_SYMBOLS"]: msg = "DEF_SYMBOLS: Symbol class specification char '" + io_mapper["DEF_SYMBOLS"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid self._text = "default"
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_kchar"]: msg = "b_Sym_kchar: Symbol class specification char '" + b_symbol.io_mapper["b_Sym_kchar"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid self.last = int(text_repr[1] + text_repr[2], 16) eof = text_repr[3] + text_repr[4] if eof == "00": self.eof = False else: self.eof = True hex_repr = text_repr[5:] splited_hex_repr = hex_repr.split("|") self._text = "{" kchar = list() for i in range(1, len(splited_hex_repr)): if len(splited_hex_repr[i]) > 2: charClass = set() self._text += "[" for j in range(0, len(splited_hex_repr[i]) / 2): chex_repr = splited_hex_repr[i][j * 2] + splited_hex_repr[i][j * 2 + 1] charClass.add(chr(int(chex_repr, 16))) self._text += chr(int(chex_repr, 16)) self._text += "]" kchar.append(charClass) else: kchar.append(chr(int(splited_hex_repr[i], 16))) self._text += chr(int(splited_hex_repr[i], 16)) self._text += "}" self.kchar = tuple(kchar)
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != io_mapper["DEF_SYMBOLS"]: msg = "DEF_SYMBOLS: Symbol class specification char '" + io_mapper[ "DEF_SYMBOLS"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid self._text = "default"
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_cnt_constr"]: msg = "b_Sym_cnt_constr: Symbol class specification char '" + b_symbol.io_mapper[ "b_Sym_cnt_constr"] + "' expected but '" + text_repr[ 0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid splited = text_repr.split("|") self.m = int(splited[1]) if splited[2] == "inf": self.n = float(splited[2]) else: self.n = int(splited[2]) hex_repr = splited[3] if len(hex_repr) == 2: self.symbol = chr(int(hex_repr, 16)) self._text = chr(int(hex_repr, 16)) else: self.symbol = set() self._text = "[" for i in range(0, len(hex_repr) / 2): chex_repr = hex_repr[i * 2] + hex_repr[i * 2 + 1] self.charClass.add(chr(int(chex_repr, 16))) self._text += chr(int(chex_repr, 16)) self._text += "]" self._text += "{" + str(self.m) + "," + str(self.n) + "}"
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_cnt_constr"]: msg = "b_Sym_cnt_constr: Symbol class specification char '" + b_symbol.io_mapper["b_Sym_cnt_constr"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid splited = text_repr.split("|") self.m = int(splited[1]) if splited[2] == "inf": self.n = float(splited[2]) else: self.n = int(splited[2]) hex_repr = splited[3] if len(hex_repr) == 2: self.symbol = chr(int(hex_repr, 16)) self._text = chr(int(hex_repr, 16)) else: self.symbol = set() self._text = "[" for i in range(0, len(hex_repr) / 2): chex_repr = hex_repr[i * 2] + hex_repr[i * 2 + 1] self.charClass.add(chr(int(chex_repr, 16))) self._text += chr(int(chex_repr, 16)) self._text += "]" self._text += "{" + str(self.m) + "," + str(self.n) + "}"
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_kstring"]: msg = "b_Sym_kstring: Symbol class specification char '" + b_symbol.io_mapper[ "b_Sym_kstring"] + "' expected but '" + text_repr[ 0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid hex_repr = text_repr[2:] splited_hex_repr = hex_repr.split("|") self.string = list() self._text = "" self.stride = int(splited_hex_repr[0]) for i in range(1, len(splited_hex_repr)): self._text += "{" kchar = list() for j in xrange(0, self.stride): self._text += "[" charClass = set() for j in range(0, len(splited_hex_repr[i]) / 2): chex_repr = splited_hex_repr[i][ j * 2] + splited_hex_repr[i][j * 2 + 1] charClass.add(chr(int(chex_repr, 16))) self._text += chr(int(chex_repr, 16)) self._text += "]" kchar.append(frozenset(charClass)) self._text += "}" self.string.append(tuple(kchar)) self.string = tuple(self.string)
def import_symbol(self, text_repr, tid): """ Creates symbol from its string representation compatible with FSM tools. See export method for more datails. :param text_repr: String representation. :type text_repr: string :param tid: Symbol identification number, must be unique. :type tid: int """ if text_repr[0] != b_symbol.io_mapper["b_Sym_char"]: msg = "b_Sym_char: Symbol class specification char '" + b_symbol.io_mapper[ "b_Sym_char"] + "' expected but '" + text_repr[0] + "' found!" raise pattern_exceptions.symbol_import_exception(msg) self._id = tid hex_repr = text_repr[1:] if len(hex_repr) > 0: self.char = chr(int(hex_repr, 16)) self._text = chr(int(hex_repr, 16)) else: self.char = "" self._text = "eps"