Example #1
0
 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
Example #2
0
    def common(cls, pop=0):
        """Yield common stuff. ``pop`` can be set to -1 for one-arg mode."""
        yield r"['`]|,@?", Delimiter.Scheme.Quote
        yield r"\(", Delimiter.OpenParen, pop, cls.list
        yield r"#\(", Delimiter.OpenVector, pop, cls.vector
        yield r'"', String, pop, cls.string
        yield r';', Comment, pop, cls.singleline_comment
        yield r'#!', Comment, pop, cls.multiline_comment

        yield r"#[tTfF]\b", Number.Boolean, pop
        yield r"#\\([a-z]+|.)", Character, pop
        yield RE_SCHEME_ID, cls.get_word_action(), pop

        _g = lambda action: bygroup(Number.Prefix, action, skip, Number.Prefix)
        yield r'(#[eEiI])?(#([bBoOxXdD]))(#[eEiI])?', findmember(
            MATCH[3],
            (('bB', (_g(Number.Prefix.Binary), pop, cls.number(2))),
             ('oO', (_g(Number.Prefix.Octal), pop, cls.number(8))),
             ('xX', (_g(Number.Prefix.Hexadecimal), pop, cls.number(16)))),
            (_g(Number.Prefix.Decimal), pop, cls.number))
        yield r'#[eEiI]', Number.Prefix, pop, cls.number
        yield r'[-+]inf.0', Number.Infinity, pop, cls.number
        yield r'[-+]nan.0', Number.NaN, pop, cls.number
        yield r'[-+]', Operator.Sign, pop, cls.number
        yield r'(\.?)(\d+)', bygroup(Number.Dot,
                                     Number.Decimal), pop, cls.number

        if pop == 0:
            yield r"\.(?!\S)", Delimiter.Dot
Example #3
0
 def music(cls):
     """Musical items."""
     yield from cls.find_string(cls.list)
     yield from cls.find_scheme(cls.list)
     yield r"\{", Bracket.Start, cls.musiclist('}')
     yield r"<<", Bracket.Start, cls.musiclist('>>')
     yield r"<", Delimiter.Chord.Start, cls.chord
     yield r"\\\\", Separator.VoiceSeparator
     yield r"\|", Separator.PipeSymbol
     yield r"\\[\[\]]", Spanner.Ligature
     yield r"[\[\]]", Spanner.Beam
     yield r"\\[()]", Spanner.Slur.Phrasing
     yield r"[()]", Spanner.Slur
     yield r"~", Spanner.Tie
     yield r"\\~", Spanner.PesOrFlexa
     yield r"\\[<>!]", Dynamic
     yield r"[-_^]", Direction, cls.script
     yield r"(\\=)\s*(?:(\d+)|({}))?".format(RE_LILYPOND_SYMBOL), \
         bygroup(Spanner.Id, Number, cls.ifpitch(Name.Symbol.Invalid, Name.Symbol))
     yield RE_LILYPOND_SYMBOL, findmember(TEXT, (
         ('q', Pitch),
         (lilypond_words.rests, Rest),
         (lilypond_words.all_pitch_names, (Pitch, cls.pitch)),
         (lilypond_words.contexts, (Context, cls.list)),
         (lilypond_words.grobs, (Grob, cls.list)),
     ), (Name.Symbol, cls.list))
     yield r'[.,]', Delimiter
     yield r'(:)\s*(8|16|32|64|128|256|512|1024|2048)?(?!\d)', bygroup(
         Delimiter.Tremolo, Duration.Tremolo)
     yield RE_FRACTION, Number.Fraction
     yield r'\d+\.\d+', Number.Float
     yield r'(\d+)(?=\s*,)', Number, cls.list
     yield RE_LILYPOND_DURATION, Duration, cls.duration
     yield r"\d+", Number, cls.list
Example #4
0
File: html.py Project: wbsoft/parce
 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
Example #5
0
 def request(cls):
     yield from cls.escapes()
     yield r'\n', skip, -1
     yield r' (")', bygroup(String), cls.string
     yield r'([-+]?(?:\d+(?:\.\d*)?)|\.\d+)([ciPpmMnuvsf])?', bygroup(
         Number, Name.Unit)
     yield r'[-+*/%=<>&:!()]|[=<>]=', Operator
     yield r'[<>]\?|;', Operator  # GNU extension
     yield default_action, Text
Example #6
0
 def root(cls):
     yield from cls.find_comments()
     yield fr'(<!)(ENTITY)\b(?:\s*(%))?(?:\s*({_N_}))?', \
         bygroup(Delimiter, Keyword, Keyword, Name.Entity.Definition), cls.entity
     yield fr'(<!)(ELEMENT|ATTLIST|NOTATION)\b(?:\s*({_N_}))?', \
         bygroup(Delimiter, Keyword, Name.Element.Definition), \
         dselect(MATCH[2], {"ELEMENT": cls.element, "ATTLIST": cls.attlist}, cls.notation)
     yield fr'%{_N_};', Name.Entity.Escape
     yield default_action, select(call(str.isspace, TEXT), Text, skip)
Example #7
0
 def root(cls):
     tag = ifmember(MATCH[2], DOCBOOK_ELEMENTS, Keyword, Name.Tag)
     # copied and modified from Xml to use Keyword for known DB tags
     yield fr'(<\s*?/)\s*({RE_XML_NAME})\s*(>)', bygroup(Delimiter, tag, Delimiter), -1
     yield fr'(<)\s*({RE_XML_NAME})(?:\s*((?:/\s*)?>))?', \
         bygroup(Delimiter, tag, Delimiter), dselect(MATCH[3], {
             None: cls.attrs,        # no ">" or "/>": go to attrs
             ">": cls.tag,           # a ">": go to tag
         })                          # by default ("/>"): stay in context
     yield from super().root
Example #8
0
 def root(cls):
     yield '#', Comment, cls.comment
     yield r'(\[\[)(?:[ \t]*(\.))?', bygroup(Bracket.Start,
                                             Invalid), cls.array_table
     yield r'(\[)(?:[ \t]*(\.))?', bygroup(Bracket.Start,
                                           Invalid), cls.table
     yield r'=[^\n#]*', Invalid
     yield r'\.[^\n#]*', Invalid
     yield r'\s+', skip
     yield default_target, cls.key
Example #9
0
    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
Example #10
0
 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
Example #11
0
File: tcl.py Project: wbsoft/parce
 def values(cls):
     yield r'\[', Delimiter, cls.command
     yield r'"', String, cls.quoted
     yield r'\{', Delimiter.Bracket, cls.braced
     yield r'(\$(?:[0-9a-zA-Z_]|::+)+)(\()?', \
         bygroup(Name.Variable, Delimiter), ifgroup(2, cls.index)
     yield r'\${.*?\}', Name.Variable
     yield r'\\(?:[0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|\n|.)', Escape
     yield r'^\s*(#)', bygroup(Comment), cls.comment
     yield RE_TCL_NUMBER, gselect(Number.Octal, Number.Binary,
                                  Number.Hexadecimal, Number.Decimal)
     yield r'(;)(?:[ \t]*(#))?', bygroup(Delimiter.Separator, Comment), \
         ifgroup(2, cls.comment)
Example #12
0
    def find_string_literals(cls, target=None, allow_newlines=None):
        """Find string literals."""
        # short strings not closed on the same line are invalid
        yield r'''[rRuUfF]{,2}["']$''', String.Invalid

        if target is None:
            target = cls.string(allow_newlines)

        # long strings
        yield r'(\b[rR])("""|'r"''')", \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.long_string_raw, MATCH[2])
        yield r'(\b(?:[fF][rR])|(?:[rR][fF]))("""|'r"''')", \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.long_string_raw_format, MATCH[2])
        yield r'(\b[uU])?("""|'r"''')", \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.long_string, MATCH[2])
        yield r'(\b[fF])("""|'r"''')", \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.long_string_format, MATCH[2])

        # short strings
        yield r'''(\b[rR])(['"])''', \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.short_string_raw, MATCH[2])
        yield r'''(\b(?:[fF][rR])|(?:[rR][fF]))(['"])''', \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.short_string_raw_format, MATCH[2])
        yield r'''(\b[uU])?(['"])''', \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.short_string, MATCH[2])
        yield r'''(\b[fF])(['"])''', \
            bygroup(String.Prefix, String.Start), \
            target, derive(cls.short_string_format, MATCH[2])
Example #13
0
File: csv.py Project: wbsoft/parce
 def record(cls):
     """Split a record in escaped (string) and non-escaped fields."""
     yield r'$\n?', skip, -1
     yield r'[^,"\n]+(?=$|,|\n)', a.Name
     yield r'[ \t]*((?:[^,"\s]+[ \t]*)+)?(")', bygroup(
         a.Invalid, a.String.Start), cls.string
     yield ',', a.Separator
Example #14
0
 def lilypond(cls):
     """Stuff between .lilypond start and .lilypond end."""
     from .lilypond import LilyPond
     yield r"^(['.])[ \t]*(lilypond) +(end)\b", \
         bygroup(Delimiter.Request, Name.Identifier.Preprocessed, Name.Command), \
         -1
     yield from LilyPond.root
Example #15
0
 def root(cls):
     yield r'@[@{}. ]', Escape
     yield r'''@['",=^`~](\{[a-zA-Z]\}|[a-zA-Z]\b)''', Escape
     yield r'@c(?:omment)?\b', Comment, cls.singleline_comment
     yield r'@ignore\b', Comment, cls.multiline_comment
     yield r'@verbatim\b', Keyword.Verbatim, cls.verbatim
     yield r'@html', Keyword, cls.html
     yield r'(@lilypond)\b(?:(\[)([^\n\]]*)(\]))?(\{)?', bygroup(
         Name.Function, Bracket, Name.Property, Bracket, Bracket.Start), \
         ifgroup(5, cls.lilypond_brace, cls.lilypond_block)
     yield r'(@[a-zA-Z]+)(?:(\{)(\})?)?', bygroup(
             ifgroup(2, ifgroup(3, Name.Symbol, Name.Function), Name.Command),
             Bracket.Start,
             Bracket.End), \
         ifgroup(2, ifgroup(3, (), cls.brace))
     yield default_action, Text
Example #16
0
 def processing_instruction(cls):
     yield fr'({_N_})\s*?(=)(?=\s*?["\'])', bygroup(Name.Attribute,
                                                    Operator)
     yield from cls.find_strings()
     yield r'&\S*?;', Escape
     yield r'\?>', Bracket.Preprocessed.End, -1
     yield default_action, Text.Preprocessed
Example #17
0
File: tex.py Project: wbsoft/parce
 def common(cls):
     yield r'(\\begin)(?:\s*(?:(\{)(.*?)(\})|(\[))|(?=[\W\d]))', \
         bygroup(Name.Builtin, Delimiter, Name.Tag, Delimiter, Delimiter.Bracket), \
         ifgroup(5, cls.environment_option, cls.get_environment_target(MATCH[3]))
     yield r'(\\[^\W\d]+)(?:\s*(\[))?', bygroup(Name.Command, Delimiter.Bracket), \
         ifgroup(2, cls.option)
     yield r'\{\\(oe|OE|ae|AE|aa|AA|o|O|l|L|ss|SS)\}', Escape
     yield r"[!?]'", Escape
     yield r"""\\[`'^"~=.]([a-zA-Z]{1,2}|\\[ij])(?=[\W\d])""", Escape
     yield r"""\\[`'^"~=.uvHtcdbr]\{([a-zA-Z]{1,2}|\\[ij])\}""", Escape
     yield r'\{', Delimiter.Brace, cls.brace
     yield r'\\\[', Delimiter, cls.math(r'\]')
     yield r'\$\$', Delimiter, cls.math(r'$$')
     yield r'\\\(', Delimiter, cls.math(r'\)')
     yield r'\$', Delimiter, cls.math(r'$')
     yield from cls.base()
Example #18
0
File: html.py Project: wbsoft/parce
 def root(cls):
     yield r'(<)(style|script)\b(>|/\s*>)?', bygroup(Delimiter, Name.Tag, Delimiter), \
         dselect(MATCH[2], {
             "style": dselect(MATCH[3], {'>': cls.css_style_tag, None: cls.attrs("css")}),
             "script": dselect(MATCH[3], {'>': cls.script_tag, None: cls.attrs("js")}),
         })  # by default a close tag, stay in the context.
     yield from super().root
Example #19
0
 def root(cls):
     yield from cls.find_comments()
     yield r'(<!\[)(CDATA)(\[)', bygroup(Delimiter, Data.Definition,
                                         Delimiter), cls.cdata
     yield fr'(<!)(DOCTYPE)\b(?:\s*({_N_}))?', \
         bygroup(Delimiter, Keyword, Name.Tag.Definition), cls.doctype
     yield fr'(<\?)({_N_})?', bygroup(Bracket.Preprocessed.Start, Name.Tag.Preprocessed), \
         cls.processing_instruction
     yield fr'(<\s*?/)\s*({_N_})\s*(>)', bygroup(Delimiter, Name.Tag,
                                                 Delimiter), -1
     yield fr'(<)\s*({_N_})(?:\s*((?:/\s*)?>))?', \
         bygroup(Delimiter, Name.Tag, Delimiter), dselect(MATCH[3], {
             None: cls.attrs,        # no ">" or "/>": go to attrs
             ">": cls.tag,           # a ">": go to tag
         })                          # by default ("/>"): stay in context
     yield r'&\S*?;', Escape
     yield default_action, select(call(str.isspace, TEXT), Text, Whitespace)
Example #20
0
 def chord_modifier(cls):
     """Stuff in chord mode after a `:`"""
     yield SKIP_WHITESPACE
     yield r"((?<![a-z])|^)(?:aug|dim|sus|min|maj|m)(?![a-z])", Name.Symbol
     yield r"(\d+)([-+])?", bygroup(Number, Operator.Alteration)
     yield r"\.", Separator.Dot
     yield from cls.find_comment()
     yield default_target, -1
Example #21
0
 def root(cls):
     yield fr'^{_S_}+($|(?=#))?', ifgroup(1, Whitespace, Whitespace.Indent)
     yield r'@', Name.Decorator, cls.decorator
     yield fr'(class\b){_S_}*({_I_})', bygroup(
         Keyword,
         ifmember(MATCH[2], python_words.keywords, Invalid,
                  Name.Class.Definition)), cls.classdef
     yield fr'(def\b){_S_}*({_I_})', bygroup(
         Keyword,
         ifmember(MATCH[2], python_words.keywords, Invalid,
                  Name.Function.Definition)), cls.funcdef
     yield fr':(?={_S_}*(?:$|#))', Delimiter.Indent
     yield fr'({_I_})\s*(=)', bygroup(
         select(call(str.isupper, TEXT),
                select(call(isclassname, TEXT), Name.Variable, Name.Class),
                Name.Constant), Operator.Assignment)
     yield from cls.common()
Example #22
0
 def layout(cls):
     """A layout block."""
     yield r'\}', Bracket.End, -1
     yield RE_LILYPOND_SYMBOL, Name.Attribute, cls.list
     yield r"(\\context)\s*(\{)", bygroup(Keyword,
                                          Bracket.Start), cls.layout_context
     yield from cls.music()
     yield from cls.common()
     yield from cls.commands(list_target=cls.start_list)
Example #23
0
 def chordlist(cls):
     """Chordmode music between ``{`` ... ``}`` or ``<<`` ... ``>>``."""
     yield from cls.inputmode_list(cls.chordlist)
     yield r"[:^]", Separator.Chord, cls.chord_modifier
     yield r"(/\+?)\s*(" + RE_LILYPOND_PITCHWORD + ")?", bygroup(
         Separator.Chord, cls.ifpitch())
     yield from cls.music()
     yield from cls.common()
     yield from cls.commands()
Example #24
0
File: tcl.py Project: wbsoft/parce
 def root(cls):
     yield r'\A#!.*?$', Comment.Special
     yield from cls.values()
     yield r"([^\s\\{}[\]$'();]+)(\()?", bygroup(
         findmember(MATCH[1],
                    ((operators, Operator), (tcl_commands, Keyword),
                     (tk_commands, Name.Command)), Text.Word),
         Delimiter), ifgroup(2, cls.index)
     yield r'\(\)', Delimiter
Example #25
0
 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
Example #26
0
 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
Example #27
0
File: html.py Project: wbsoft/parce
 def attrs(cls):
     """Reimplemented to recognize style attributes and switch to style tag."""
     yield r'(style)\s*(=)\s*(")', bygroup(Name.Attribute, Operator, String), \
         cls.css_style_attribute
     yield r'>', Delimiter, -1, dselect(ARG, {
         "js": cls.script_tag,
         "css": cls.css_style_tag,
         None: cls.tag
     })
     yield from super().attrs
Example #28
0
File: css.py Project: wbsoft/parce
 def common(cls):
     """Find stuff that can be everywhere, string, comment, color, identifier"""
     yield r'"', String, cls.dqstring
     yield r"'", String, cls.sqstring
     yield r"/\*", Comment, cls.comment
     yield r"\{", Bracket, cls.rule
     yield RE_CSS_NUMBER, Number, cls.unit
     yield RE_HEX_COLOR, Literal.Color
     yield r"(url)(\()", bygroup(Name, Delimiter), cls.url_function
     yield from anyof(cls.identifier)
     yield r"[:,;@%!]", Delimiter
Example #29
0
    def list(cls):
        r"""A list of numbers, symbols, strings or scheme expressions.

        Consumes both . and , as separators.

        Jump here:

        * plainly: start_list
        * when a ", # or $ is ahead: start_list
        * from a number followed by , (but don't consume the ,)
        * from a symbol

        """
        yield SKIP_WHITESPACE
        yield r'([.,])\s*(\d+)(?!(?:/|\.\d+))' + RE_LILYPOND_ID_RIGHT_BOUND, bygroup(
            Separator, Number)
        yield r'([.,])\s*(' + RE_LILYPOND_ID + r')' + RE_LILYPOND_ID_RIGHT_BOUND, \
            bygroup(Separator, cls.get_symbol_action(MATCH[2], Name.Variable))
        yield r'([.,])\s*(?=[#$"])', bygroup(Separator), cls._continue_list
        yield from cls.find_comment()
        yield default_target, -1
Example #30
0
 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