Skip to content

Commit

Permalink
style: apply automated linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
megalinter-bot committed Oct 20, 2023
1 parent d089706 commit 2f4cc48
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions docs/lexer/safe_ds_lexer/_safe_ds_lexer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from pygments.lexer import RegexLexer, words
from pygments.token import Comment, Keyword, Name, Number, Operator, String, Whitespace

keywords_annotation = (
"annotation",
)
keywords_annotation = ("annotation",)

keywords_class = (
"class",
Expand Down Expand Up @@ -63,14 +61,13 @@
"Number",
"Int",
"Float",
"List"
"Map",
"ListMap",
"String",
)

identifier_fragment = r"[_a-zA-Z][_a-zA-Z0-9]*"
identifier_regex = fr"{identifier_fragment}|`{identifier_fragment}`"
qualified_name_regex = fr"({identifier_regex})(\.({identifier_regex}))*"
identifier_regex = rf"{identifier_fragment}|`{identifier_fragment}`"
qualified_name_regex = rf"({identifier_regex})(\.({identifier_regex}))*"


class SafeDsLexer(RegexLexer):
Expand All @@ -90,30 +87,36 @@ class SafeDsLexer(RegexLexer):
# Literals
(r"\b([0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?)\b", Number),
(r'"|}}', String, "string"),

# Keywords
(words(keywords_annotation, prefix=r"\b", suffix=r"\b"), Keyword, "annotation"),
(
words(keywords_annotation, prefix=r"\b", suffix=r"\b"),
Keyword,
"annotation",
),
(words(keywords_class, prefix=r"\b", suffix=r"\b"), Keyword, "class"),
(words(keywords_constant, prefix=r"\b", suffix=r"\b"), Keyword.Declaration, "placeholder"),
(
words(keywords_constant, prefix=r"\b", suffix=r"\b"),
Keyword.Declaration,
"placeholder",
),
(words(keywords_function, prefix=r"\b", suffix=r"\b"), Keyword, "function"),
(words(keywords_literal, prefix=r"\b", suffix=r"\b"), Keyword.Constant),
(words(keywords_namespace, prefix=r"\b", suffix=r"\b"), Keyword.Namespace, "namespace"),
(
words(keywords_namespace, prefix=r"\b", suffix=r"\b"),
Keyword.Namespace,
"namespace",
),
(words(keywords_generic, prefix=r"\b", suffix=r"\b"), Keyword),

# Operators
(words(operators, prefix=r"\b", suffix=r"\b"), Operator.Word),

# Builtins
(words(builtins, prefix=r"\b", suffix=r"\b"), Name.Builtin),

# Identifiers
(fr"@{identifier_regex}", Name.Decorator),
(rf"@{identifier_regex}", Name.Decorator),
(identifier_regex, Name),

# Comments
(r"//.+?$", Comment.Single),
(r"/\*[\s\S]*?\*/", Comment.Multiline),

# Whitespace
(r"\s+", Whitespace),
],
Expand Down

0 comments on commit 2f4cc48

Please sign in to comment.