Beispiel #1
0
def on_gps_started():
    register_highlighter(
        language="asm",
        spec=(
            # Match comments lines
            region(r"#", "\n", tag=tag_comment,
                   highlighter=(hl_comment_notes,)),

            # Match function names
            simple(r"^[-\w\d+_:]+\:$", tag=tag_block),

            # Match instructions
            simple(r"^\s*\w+", tag=tag_keyword),

            # Match section names
            simple(r"[^\w]\.\w+", tag=tag_type),

            # Match number literals
            simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number),

            # Match strings
            region(
                r'"', r'"|[^\\]$',  tag=tag_string,
                highlighter=(hl_inside_strings,)
            )
        )
    )
Beispiel #2
0
  <Context>
    <Can_Indent>True</Can_Indent>
    <Syntax_Highlighting>False</Syntax_Highlighting>
    <Case_Sensitive>True</Case_Sensitive>
  </Context>
</Language>
"""
GPS.parse_xml(XML)

register_highlighter(
    language="matlab",
    spec=(
        # Match keywords
        words([
            "break", "case", "catch", "continue", "else", "elseif", "end",
            "for", "function", "global", "if", "otherwise", "persistent",
            "return", "switch", "try", "while", "classdef", "methods"
        ],
              tag=tag_keyword),

        # Match comments lines
        region(r"%", "\n", tag=tag_comment, highlighter=(hl_comment_notes, )),

        # Match strings
        region(r"'", r"'|$", tag=tag_string,
               highlighter=(hl_inside_strings, )),

        # Match number literals
        simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number),
    ))
from highlighter.common import words, simple, tag_number, tag_keyword, region,\
    tag_comment, register_highlighter, tag_string, tag_type

number_literal = simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number)

keywords = "|".join(["theory", "type", "constant", "function", "predicate",
                     "inductive", "axiom", "lemma", "goal", "use", "clone",
                     "prop", "meta", "scope", "import", "export", "end",
                     "forall", "exists", "not", "true", "false", "if", "then",
                     "else", "let", "in", "match", "with", "as", "epsilon"])

comment_region = region(r"\(\*", "\*\)", tag=tag_comment)

ada_keywords = "|".join(["True", "False"])

task_specific = "|".join(["Local Context", "Goal"])

register_highlighter(
    language="why",
    spec=(
        number_literal,
        # Match comments lines
        comment_region,

        # Match keywords
        words(keywords, tag=tag_keyword),
        words(ada_keywords, tag=tag_string),
        words(task_specific, tag=tag_type)
    )
)
Beispiel #4
0
from highlighter.common import register_highlighter, region, existing_style, \
    tag_keyword, simple

file_tag = existing_style("Diff-Patch-File-Header-Variant", "file-diff")
code_tag = existing_style("Diff-Patch-Code-Header-Variant", "code-diff")
added_tag = existing_style("Diff-Patch-Append-Variant", "added-diff")
removed_tag = existing_style("Diff-Patch-Remove-Variant", "removed-diff")

register_highlighter(
    language="diff",
    spec=(
        # Match file section
        region(r"^diff", "\n", tag=file_tag),
        # Match code section
        region(r"^\@\@", "\n", tag=code_tag),
        # Match added line
        region(r"^\+", "\n", tag=added_tag),
        # Match removed line
        region(r"^\-", "\n", tag=removed_tag),
        # Match header keyword
        simple(r"^[\w|-]+:", tag=tag_keyword)))
Beispiel #5
0
from keyword import kwlist

from highlighter.common import region, words, simple, \
    tag_number, tag_block, tag_comment_notes, tag_comment, tag_keyword, \
    hl_inside_strings, tag_type, region_template, tag_string_escapes, \
    tag_string, register_highlighter, hl_comment_notes

hl_format_escapes = simple(r"\{\d+?\}", tag=tag_string_escapes)
string_hl = region_template(tag=tag_string,
                            highlighter=(hl_inside_strings, hl_format_escapes))

register_highlighter(
    language="python",
    spec=(
        # Match multiline strings
        string_hl(r'"""', r'"""', name="multiline_string_sq"),
        string_hl(r"'''", r"'''", name="multiline_string_dq"),

        # Match string literals
        string_hl(r"'", r"'|$"),
        string_hl(r'"', r'"|$'),

        # Match comments lines
        region(r"#", "\n", tag=tag_comment, highlighter=(hl_comment_notes, )),

        # Match number literals
        simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number),

        # Match keywords
        words(kwlist, tag=tag_keyword),
Beispiel #6
0
from keyword import kwlist

from highlighter.common import region, words, simple, \
    tag_number, tag_block, tag_comment, tag_keyword, \
    hl_inside_strings, tag_type, region_template, tag_string_escapes, \
    tag_string, register_highlighter, hl_comment_notes

hl_format_escapes = simple(r"\{\d+?\}", tag=tag_string_escapes)
string_hl = region_template(tag=tag_string,
                            highlighter=(hl_inside_strings, hl_format_escapes))

register_highlighter(
    language="python",
    spec=(
        # Match multiline strings
        string_hl(r'"""', r'"""', name="multiline_string_sq"),
        string_hl(r"'''", r"'''", name="multiline_string_dq"),

        # Match string literals
        string_hl(r"'", r"'|$"),
        string_hl(r'"', r'"|$'),

        # Match comments lines
        region(r"#", "\n", tag=tag_comment, highlighter=(hl_comment_notes, )),

        # Match number literals
        simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number),

        # Match keywords
        words(kwlist, tag=tag_keyword),
Beispiel #7
0
    "package",
    "range",
    "then",
    "type",
    "use",
    "with",
]

recordflux_literals = [
    "False",
    "True",
]

tag_aspect = hl.existing_style("Src-Editor-Aspects-Variant", "aspects")

hl_type = hl.simple(r"\b[^;\s]+", tag=hl.tag_type)
type_region = hl.region(r":",
                        r"\b",
                        highlighter=(hl_type, ),
                        tag=hl.tag_default)
string_literal = hl.region(r'"', r'"', matchall=False, tag=hl.tag_string)

hl.register_highlighter(
    language="recordflux",
    spec=(
        hl.simple(r"--[^\n]*", tag=hl.tag_comment),
        type_region,
        hl.simple(r"\b'First", tag=tag_aspect),
        hl.simple(r"\b'Last", tag=tag_aspect),
        hl.simple(r"\b'Length", tag=tag_aspect),
        hl.simple(r"\b'Size", tag=tag_aspect),
Beispiel #8
0
string_template = region_template(tag=tag_string,
                                  highlighter=(hl_inside_strings, ))

simple_quoted_strings = string_template(r"'",
                                        r"'",
                                        name="simple_quoted_strings")
double_quoted_strings = string_template(r'"',
                                        r'"',
                                        name="double_quoted_strings")

comments = region(r"/\*",
                  r"\*/",
                  tag=tag_comment,
                  highlighter=(hl_comment_notes, ))

number_literals = simple(r"\b[0-9]*\.?[0-9]+\b", tag=tag_number)

colors = simple(r"#[0-9-a-f-A-F]{3}(?:[0-9-a-f-A-F]{3})?\b", tag=tag_number)

length_units = simple(r"{0}".format(length_units_list), tag=tag_keyword)

length_values = region(r"\b[0-9]",
                       r"\b",
                       tag=tag_number,
                       highlighter=(length_units, ))

properties = words(properties_list, tag=tag_type)

html_elements = words(html_elements_list, tag=tag_keyword)

color_names = words(color_names_list, tag=tag_string)