@classmethod<EOL><INDENT>def fromstring(cls, s, *args, **kwargs):<DEDENT>
s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>p = []<EOL>i = <NUM_LIT:0><EOL>for m in re.finditer(r"<STR_LIT>", s):<EOL><INDENT>p.append(s[i:m.start()])<EOL>p.append(s[m.start():m.end()].replace("<STR_LIT:U+0020>", "<STR_LIT>")); i=m.end()<EOL><DEDENT>p.append(s[i:])<EOL>s = "<STR_LIT>".join(p) <EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s = re.sub(r"<STR_LIT>", "<STR_LIT:|>", s)  <EOL>s = re.sub(r"<STR_LIT>", "<STR_LIT:U+0020>", s)<EOL>s = re.sub(r"<STR_LIT>", "<STR_LIT:{>", s)<EOL>s = re.sub(r"<STR_LIT>", "<STR_LIT:}>", s)<EOL>s = s.split("<STR_LIT:U+0020>")<EOL>s = [v.replace("<STR_LIT>","<STR_LIT:U+0020>") for v in s]<EOL>P = cls([], *args, **kwargs)<EOL>G, O, i = [], [], <NUM_LIT:0><EOL>for s in s:<EOL><INDENT>constraint = Constraint.fromstring(s.strip("<STR_LIT:{}>"), taxonomy=kwargs.get("<STR_LIT>", TAXONOMY))<EOL>constraint.index = len(P.sequence)<EOL>P.sequence.append(constraint)<EOL>while s.startswith("<STR_LIT:{>"):<EOL><INDENT>s = s[<NUM_LIT:1>:]<EOL>G.append((i, [])); i+=<NUM_LIT:1><EOL>O.append([])<EOL><DEDENT>for g in G:<EOL><INDENT>g[<NUM_LIT:1>].append(constraint)<EOL><DEDENT>while s.endswith("<STR_LIT:}>"):<EOL><INDENT>s = s[:-<NUM_LIT:1>]<EOL>if G: O[G[-<NUM_LIT:1>][<NUM_LIT:0>]] = G[-<NUM_LIT:1>][<NUM_LIT:1>]; G.pop()<EOL><DEDENT><DEDENT>P.groups = [g for g in O if g]<EOL>return P<EOL>
Returns a new Pattern from the given string.
            Constraints are separated by a space.
            If a constraint contains a space, it must be wrapped in [].