def root(cls): yield words(HTML_VOID_ELEMENTS, prefix=r'(<\s*?/)\s*((?:\w+:)?', suffix=r')\s*(>)'), \ bygroup(Delimiter, Name.Tag, Delimiter) # don't leave no-closing tags yield words(HTML_VOID_ELEMENTS, prefix=r'(<)\s*(', suffix=r')(?:\s*((?:/\s*)?>))?'), \ bygroup(Delimiter, Name.Tag, Delimiter), dselect(MATCH[3], { None: cls.attrs("noclose"), # no ">" or "/>": go to attrs/noclose }) # by default ("/>"): stay in context yield from super().root
def n99(cls): """Numerical value below 100.""" yield _SKIP TENS = cls._TENS + ('dreissig',) yield words(cls._TO19[10:]), Number, -1 yield r'({})(?:\s*und\s*({}))?'.format( words(cls._TO19[1:10]), words(TENS)), bygroup(Number, Number), -1 yield words(TENS + cls._TO19[:1] + ('eins',)), Number, -1 yield default_target, -1
def n99(cls): """Numerical value below 100.""" yield _SKIP yield words(cls._TO19[10:]), Number, -1 yield r'({})(?:\s*[eë]n\s*({}))?'.format( words(cls._TO19[1:10]), words(cls._TENS)), bygroup(Number, Number), -1 yield words(cls._TENS), Number, -1 yield cls._TO19[0], Number, -1 yield default_target, -1
def common(cls): yield r'#', Comment, cls.comment yield fr'({_N_})(\s*)', bygroup(Escape, Whitespace) yield r'\[', Delimiter, cls.list yield r'\(', Delimiter, cls.tuple yield r'\{', Delimiter, cls.dict ## string literals yield from cls.find_string_literals() yield from cls.find_bytes_literals() ## numerical values yield '0[oO](?:_?[0-7])+', Number.Octal yield '0[bB](?:_?[01])+', Number.Binary yield '0[xX](?:_?[0-9a-fA-F])+', Number.Hexadecimal yield r'(?:\.\d(?:_?\d)*|\d(?:_?\d)*(?:\.(?:\d(?:_?\d)*)?)?)(?:[eE][-+]\d(?:_?\d)*)?[jJ]?', Number ## keywords, variables, functions yield words(python_words.keywords, prefix=r'\b', suffix=r'\b'), Keyword yield words(python_words.constants, prefix=r'\b', suffix=r'\b'), Name.Constant yield fr'\b(self|cls)\b(?:{_SN_}*([\[\(]))?', Name.Variable.Special, \ dselect(MATCH[2], {'(': cls.call, '[': cls.item}) # method, class or attribute (keywords after a . are also caught) yield fr'(\.){_SN_}*\b({_I_})\b(?:{_SN_}*([\[\(]))?', \ bygroup( Delimiter, ifmember(MATCH[2], python_words.keywords, Keyword, dselect(MATCH[3], {'(': select(call(isclassname, TEXT), Name.Method, Name.Class)}, select(call(str.isupper, TEXT), select(call(isclassname, TEXT), Name.Attribute, Name.Class), Name.Constant))), Delimiter), \ dselect(MATCH[3], {'(': cls.call, '[': cls.item}) # function, class or variable yield fr'\b({_I_})\b(?:{_SN_}*([\[\(]))?', \ bygroup( findmember(MATCH[1], ((python_words.builtins, Name.Builtin), (python_words.exceptions, Name.Exception)), select(call(str.isupper, TEXT), select(call(isclassname, TEXT), dselect(MATCH[2], {'(': Name.Function}, Name.Variable), Name.Class), Name.Constant)), Delimiter), \ dselect(MATCH[2], {'(': cls.call, '[': cls.item}) ## delimiters, operators yield r'\.\.\.', Delimiter.Special.Ellipsis yield r'(?:\*\*|//|<<|>>|[-+*/%@&|^:])?=', Operator.Assignment yield r'\*\*|//|<<|>>|[<>=!]=|[-+*/%@&|^~<>]', Operator yield r'[.;,:]', Delimiter
def attlist(cls): yield words(("#REQUIRED", "#IMPLIED", "#FIXED"), suffix=r'\b'), Name.Builtin yield words(('CDATA', 'ID', 'IDREF', 'IDREFS', 'ENTITY', 'ENTITIES', 'NMTOKEN', 'NMTOKENS'), prefix=r'\b', suffix=r'\b'), Name.Type yield r'\b(NOTATION)\b(?:\s+(\())', bygroup(Name.Type, Bracket), \ ifgroup(2, cls.attlist_notation) yield _N_, Name.Attribute.Definition yield r'\(', Bracket, cls.attlist_enumeration yield from cls.common_defs() yield r'>', Delimiter, -1
def repeat(cls): """\\repeat mode n.""" yield SKIP_WHITESPACE yield words(("volta", "unfold", "percent", "tremolo"), suffix=r'\b'), Name.Type yield from cls.find_string() yield from cls.find_comment() yield r'\d+', Number, -1 yield default_target, -1
def root(cls): yield r"'", String.Start, cls.string("'") yield r'"', String.Start, cls.string('"') yield r'`', String.Start, cls.template_literal yield '//', Comment, cls.singleline_comment yield r'/\*', Comment.Start, cls.multiline_comment yield fr'(const|let|var)\s+({_I_})\b', bygroup(Keyword, Name.Variable.Definition) yield fr'(function)\s+({_I_})\b', bygroup(Keyword, Name.Function.Definition) yield fr'(new)\s+({_I_})\b', bygroup(Keyword, Name.Class.Definition) yield words(js.JAVASCRIPT_KEYWORDS, prefix=r'\b', suffix=r'\b'), Keyword yield words(js.JAVASCRIPT_DECLARATORS, prefix=r'\b', suffix=r'\b'), Keyword yield words(js.JAVASCRIPT_RESERVED_KEYWORDS, prefix=r'\b', suffix=r'\b'), Keyword.Reserved yield words(js.JAVASCRIPT_CONSTANTS, prefix=r'\b', suffix=r'\b'), Name.Constant yield words(js.JAVASCRIPT_BUILTINS, prefix=r'\b', suffix=r'\b'), Name.Builtin yield words(js.JAVASCRIPT_PROTOTYPES, prefix=r'\b', suffix=r'\b'), Name.Builtin yield fr'(\.)\s*({_I_})\b(?:\s*([\(\[]))?', bygroup(Delimiter, dselect(MATCH[3], {'(': Name.Method}, Name.Attribute), Delimiter), \ dselect(MATCH[3], {'(': cls.call, '[': cls.index}) yield fr'({_I_})(?:\s*([\(\[]))?', bygroup( dselect(MATCH[2], {'(': Name.Function}, Name.Variable), Delimiter), \ dselect(MATCH[2], {'(': cls.call, '[': cls.index}) yield fr'{_I_}\b', select(call(str.isupper, TEXT), Name.Variable, Name.Class) ## numerical values (recently, underscore support inside numbers was added) yield '0[oO](?:_?[0-7])+n?', Number yield '0[bB](?:_?[01])+n?', Number yield '0[xX](?:_?[0-9a-fA-F])+n?', Number yield RE_JS_DECIMAL_NUMBER, Number yield r'\{', Bracket.Start, cls.scope yield r'\[', Bracket.Start, cls.array yield r'\(', Delimiter, cls.paren yield RE_JS_REGEXP, Literal.Regexp yield r'(?:<<|>>>?|[&|^*/%+-])=', Operator.Assignment yield r'&&?|\|\|?|<<|>>>?|[!=]==?|<=?|>=?|\*\*|[-+~!/*%^?:,]', Operator yield r'=', Operator.Assignment yield r';', Delimiter
def n99(cls): """Numerical value below 100.""" yield _SKIP tens = (cls._TENS[4], cls._TENS[6]) # soixante, quatre-vingt + 10-19 yield r'({})[\s-]*({})'.format( words(tens), words(cls._TO19[1:10])), bygroup(Number, Number), -1 # vingt, treize, quatorze, cinquante, soixante, quatre-vingt (+ 0-9) tens = cls._TENS[:5] + cls._TENS[6:7] yield r'({})(?:[\s-]*(?:et)?[\s-]*({}))?'.format( words(tens), words(cls._TO19[1:10])), bygroup(Number, Number), -1 yield words(cls._TO19), Number, -1 yield words(('quatre-vingts', 'zero')), Number, -1 yield default_target, -1
RE_FRACTION = r"\d+/\d+" RE_LILYPOND_ID_RIGHT_BOUND = r"(?![_-]?[^\W\d_])" RE_LILYPOND_ID = r"[^\W\d_]+(?:[_-][^\W\d_]+)*" RE_LILYPOND_SYMBOL = RE_LILYPOND_ID + RE_LILYPOND_ID_RIGHT_BOUND RE_LILYPOND_COMMAND = r"\\(" + RE_LILYPOND_ID + ")" + RE_LILYPOND_ID_RIGHT_BOUND RE_LILYPOND_MARKUP_TEXT = r'[^%{}"\\\s$#][^{}"\\\s$#]*' RE_LILYPOND_LYRIC_TEXT = r'[^%={}"\\\s$#\d][^{}"\\\s$#\d]*' # a string that could be a valid pitch name (or drum name) RE_LILYPOND_PITCHWORD = r"(?<![^\W\d])[a-zé]+(?:[_-][a-zé]+)*(?![^\W\d_])" # all durations RE_LILYPOND_DURATION = ( words(set(filter(lambda w: w.startswith('\\'), lilypond_words.durations)), suffix=RE_LILYPOND_ID_RIGHT_BOUND) + "|" + words(set( filter(lambda w: not w.startswith('\\'), lilypond_words.durations)), suffix=r'(?!\d)')) # Standard actions defined/used here: Rest = Text.Music.Rest Pitch = Text.Music.Pitch Octave = Pitch.Octave OctaveCheck = Pitch.Octave.OctaveCheck Accidental = Pitch.Accidental Articulation = Name.Script.Articulation Context = Name.Constant.Context Grob = Name.Object.Grob Duration = Number.Duration Duration.Dot
def p1(cls): """Numerical value after a tenfold (e.g. 'three' after 'eighty').""" yield _SKIP yield words(cls._TO19[1:10]), Number, -1 yield default_target, -1
def n99(cls): """Numerical value below 100.""" yield _SKIP yield words(cls._TENS), Number, -1, cls.p1 yield words(cls._TO19), Number, -1 yield default_target, -1
def notation(cls): yield words(("SYSTEM", "PUBLIC")), Keyword yield from cls.common_defs() yield r'>', Delimiter, -1
def element(cls): yield r'\(', Bracket, cls.element_contents yield words(("ANY", "EMPTY")), Name.Keyword yield r'[,|?+*]', Operator yield from cls.common_defs() yield r'>', Delimiter, -1
def entity(cls): yield words(("SYSTEM", "PUBLIC", "NDATA")), Keyword yield _N_, Name.Entity yield from cls.common_defs() yield r'>', Delimiter, -1
def doctype(cls): yield words(("SYSTEM", "PUBLIC", "NDATA")), Keyword yield _N_, Name yield from cls.common_defs() yield r'\[', Bracket, cls.internal_dtd yield r'>', Delimiter, -1
def values(cls): yield r"\{", Delimiter, cls.object yield r"\[", Delimiter, cls.array yield '"', String.Start, cls.string yield r"-?\d+(?:\.\d+)?(?:[Ee][+-]?\d+)?", Number yield words(JSON_CONSTANTS, r'\b', r'\b'), Name.Constant