[Mlir-commits] [mlir] [mlir] add a simple pygments lexer (PR #120942)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Dec 23 00:47:04 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r bda7aadfcd0596675c8b4b381f178f3d8f854f20...7d9e824a3736f939cb889fbd6b142b5900bafbc5 mlir/utils/pygments/mlir_lexer.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- mlir_lexer.py	2024-12-23 08:41:51.000000 +0000
+++ mlir_lexer.py	2024-12-23 08:46:37.909718 +0000
@@ -3,35 +3,36 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 from pygments.lexer import RegexLexer
 from pygments.token import *
 
+
 class MlirLexer(RegexLexer):
-    name = 'MLIR'
-    aliases = ['mlir']
-    filenames = ['*.mlir']
+    name = "MLIR"
+    aliases = ["mlir"]
+    filenames = ["*.mlir"]
 
     tokens = {
-        'root': [
-            (r'%[a-zA-Z0-9_]+', Name.Variable),
-            (r'@[a-zA-Z_][a-zA-Z0-9_]+', Name.Function),
-            (r'\^[a-zA-Z0-9_]+', Name.Label),
-            (r'#[a-zA-Z0-9_]+', Name.Constant),
-            (r'![a-zA-Z0-9_]+', Keyword.Type),
-            (r'[a-zA-Z_][a-zA-Z0-9_]*\.', Name.Entity),
-            (r'memref[^.]', Keyword.Type),
-            (r'index', Keyword.Type),
-            (r'i[0-9]+', Keyword.Type),
-            (r'f[0-9]+', Keyword.Type),
-            (r'[0-9]+', Number.Integer),
-            (r'[0-9]*\.[0-9]*', Number.Float),
+        "root": [
+            (r"%[a-zA-Z0-9_]+", Name.Variable),
+            (r"@[a-zA-Z_][a-zA-Z0-9_]+", Name.Function),
+            (r"\^[a-zA-Z0-9_]+", Name.Label),
+            (r"#[a-zA-Z0-9_]+", Name.Constant),
+            (r"![a-zA-Z0-9_]+", Keyword.Type),
+            (r"[a-zA-Z_][a-zA-Z0-9_]*\.", Name.Entity),
+            (r"memref[^.]", Keyword.Type),
+            (r"index", Keyword.Type),
+            (r"i[0-9]+", Keyword.Type),
+            (r"f[0-9]+", Keyword.Type),
+            (r"[0-9]+", Number.Integer),
+            (r"[0-9]*\.[0-9]*", Number.Float),
             (r'"[^"]*"', String.Double),
-            (r'affine_map', Keyword.Reserved),
+            (r"affine_map", Keyword.Reserved),
             # TODO: this should be within affine maps only
-            (r'\+-\*\/', Operator),
-            (r'floordiv', Operator.Word),
-            (r'ceildiv', Operator.Word),
-            (r'mod', Operator.Word),
-            (r'()\[\]<>,{}', Punctuation),
-            (r'\/\/.*\n', Comment.Single),
+            (r"\+-\*\/", Operator),
+            (r"floordiv", Operator.Word),
+            (r"ceildiv", Operator.Word),
+            (r"mod", Operator.Word),
+            (r"()\[\]<>,{}", Punctuation),
+            (r"\/\/.*\n", Comment.Single),
         ]
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/120942


More information about the Mlir-commits mailing list