'match the string `nugget` to a format specifier.'

def _match_spec(self, nugget):

    all_spec = self._all_spec
    original_nugget = nugget
    length_str = []
    length_spec = None
    for (j, c) in enumerate(nugget):
        if (c in string.digits):
            length_str.append(c)
        else:
            nugget = nugget[j:]
            length_spec = (None if (len(length_str) == 0) else int(''.join(length_str)))
            break
    length_spec_str_len = (0 if (length_spec is None) else len(length_str))
    for spec in all_spec:
        if nugget.startswith(spec):
            nugget = nugget[:len(spec)]
            original_nugget = original_nugget[:(length_spec_str_len + len(spec))]
            nugtype = all_spec[nugget]
            try:
                typeobj = sim_type.parse_type(nugtype).with_arch(self.state.arch)
            except:
                raise SimProcedureError(("format    specifier    uses    unknown    type    '%s'" % repr(nugtype)))
            return FormatSpecifier(original_nugget, length_spec, (typeobj.size / 8), typeobj.signed)
    return None
