def short_string_raw_common(cls): yield arg(), String.End, -1 yield r'\\\\', String yield pattern( ifeq(ARG, "'", fr"([^\\']*?|\\'{_S_}*)$", fr'([^\\"]*?|\\"{_S_}*)$')), String.Invalid, -1 yield arg(prefix=r'\\'), String # escape quote, but the \ remains yield default_action, String
def string(cls): yield arg(), String.End, -1 yield (r'''\\(?:[0"'\\nrvtbf]''' r'|x[a-fA-F0-9]{2}' r'|u[a-fA-F0-9]{4}' r'|u\{[a-fA-F0-9]{1,6}\})'), String.Escape yield default_action, String
def short_bytes_raw_common(cls): yield r'\\\\', Bytes yield pattern( ifeq(ARG, "'", fr"([^\\']*?|\\'{_S_}*)$", fr'([^\\"]*?|\\"{_S_}*)$')), Bytes.Invalid, -1 yield arg(prefix=r'\\'), Bytes # escape quote, but the \ remains yield from cls.long_bytes_common()
def musiclist(cls): """A ``{`` ... ``}`` or ``<<`` ... ``>>`` musical construct. Derive with the end arg (``}`` or ``>>``). """ yield arg(), Bracket.End, -1 yield from cls.music() yield from cls.common() yield from cls.commands()
def math(cls): yield arg(default=r'\}'), Delimiter, -1 yield from cls.math_common()
def here(cls): yield arg(prefix=r"\b", suffix=r"\b"), Name, -1 yield r"\w+", Text
def inputmode_list(cls, lexicon): """Yield boilerplate rules for the contents of an input mode.""" yield arg(), Bracket.End, -1 yield r"<<", Bracket.Start, lexicon('>>') yield r"\{", Bracket.Start, lexicon('}')
def long_bytes_common(cls): yield arg(), Bytes.End, -1 yield default_action, Bytes
def short_bytes_common(cls): yield arg(), Bytes.End, -1 yield pattern(ifeq(ARG, "'", r"[^']*?$", r'[^"]*?$')), Bytes.Invalid, -1 yield default_action, Bytes
def long_string_common(cls): yield arg(), String.End, -1 yield default_action, String
def long_string_raw_format(cls): yield arg(prefix=r'\\'), String # escape quote, but the \ remains yield from cls.string_formatstring() yield from cls.long_string_common()
def short_string_common(cls): yield arg(), String.End, -1 yield pattern(ifeq(ARG, "'", r"[^']*?$", r'[^"]*?$')), String.Invalid, -1 yield default_action, String