diff mlir/utils/textmate/mlir.json @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children
line wrap: on
line diff
--- a/mlir/utils/textmate/mlir.json	Wed Jul 21 10:27:27 2021 +0900
+++ b/mlir/utils/textmate/mlir.json	Wed Nov 09 17:45:10 2022 +0900
@@ -1,113 +1,398 @@
 {
-  "fileTypes":[
+  "name": "MLIR",
+  "fileTypes": [
     "mlir"
   ],
-  "repository":{
-    "attribute":{
-      "match":"\\W[\\w_][\\w\\d_.$]*\\s*=",
-      "name":"meta.attribute.mlir"
+  "patterns": [
+    {
+      "include": "#comment"
+    },
+    {
+      "include": "#string"
     },
-    "branch_target":{
-      "match":"\\^bb[\\w\\d_$\\.-]+",
-      "name":"entity.name.label.mlir"
+    {
+      "include": "#top_level_entity"
+    }
+  ],
+  "repository": {
+    "comment": {
+      "match": "\/\/.*$",
+      "name": "comment.line.double-slash.mlir"
     },
-    "comment":{
-      "match":"\/\/.*$",
-      "name":"comment.line.double-slash.mlir"
+    "number": {
+      "patterns": [
+        {
+          "match": "(\\W)?([0-9]+\\.[0-9]*)([eE][+-]?[0-9]+)?",
+          "name": "constant.numeric.mlir"
+        },
+        {
+          "match": "([\\W])?(0x[0-9a-zA-Z]+)",
+          "captures": {
+            "2": {
+              "name": "constant.numeric.mlir"
+            }
+          }
+        },
+        {
+          "match": "([\\Wx])?([0-9]+)",
+          "captures": {
+            "2": {
+              "name": "constant.numeric.mlir"
+            }
+          }
+        }
+      ]
     },
-    "identifier":{
-      "match":"[\\%#@][\\w_][\\w\\d_.$]*",
-      "captures":{
-        "0":{
-          "name":"variable.mlir"
+    "string": {
+      "begin": "\"",
+      "beginCaptures": {
+        "0": {
+          "name": "punctuation.definition.string.begin.mlir"
         }
       },
-      "name":"meta.identifier.mlir"
-    },
-    "integer":{
-      "match":"[\\Wx]([0-9]+)",
-      "captures":{
-        "1":{
-          "name":"constant.numeric.mlir"
-        }
-      },
-      "name":"meta.identifier.mlir"
-    },
-    "string":{
-      "end":"\"",
-      "begin":"\"",
-      "beginCaptures":{
-        "0":{
-          "name":"punctuation.definition.string.begin.mlir"
-        }
-      },
-      "patterns":[
+      "patterns": [
         {
-          "match":"\\\\[nt\"]",
-          "name":"constant.character.escape.mlir"
-        },
-        {
-          "match":"\\\\.",
-          "name":"invalid.illegal.mlir"
+          "match": "\\\\[nt\"]",
+          "name": "constant.character.escape.mlir"
         }
       ],
-      "endCaptures":{
-        "0":{
-          "name":"punctuation.definition.string.end.mlir"
+      "end": "\"",
+      "endCaptures": {
+        "0": {
+          "name": "punctuation.definition.string.end.mlir"
         }
       },
-      "name":"string.quoted.double.mlir"
+      "name": "string.quoted.double.mlir"
+    },
+    "top_level_entity": {
+      "patterns": [
+        {
+          "include": "#attribute_alias_def"
+        },
+        {
+          "include": "#type_alias_def"
+        },
+        {
+          "include": "#operation_body"
+        }
+      ]
+    },
+    "attribute_alias_def": {
+      "match": "^\\s*(\\#\\w+)\\b\\s+\\=",
+      "captures": {
+        "1": {
+          "name": "constant.language.mlir"
+        }
+      }
+    },
+    "type_alias_def": {
+      "match": "^\\s*(\\!\\w+)\\b\\s+\\=",
+      "captures": {
+        "1": {
+          "name": "entity.name.type.mlir"
+        }
+      }
+    },
+    "operation": {
+      "patterns": [
+        {
+          "match": "^\\s*(\\%[\\%\\w\\:\\,\\s]+)\\s+\\=\\s+([\\w\\.\\$\\-]+)\\b",
+          "captures": {
+            "1": {
+              "patterns": [
+                {
+                  "include": "#ssa_value"
+                }
+              ]
+            },
+            "2": {
+              "name": "variable.other.enummember.mlir"
+            }
+          }
+        },
+        {
+          "match": "^\\s*([\\w\\.\\$\\-]+)\\b(?=[^\\<\\:])",
+          "name": "variable.other.enummember.mlir"
+        }
+      ]
+    },
+    "operation_body": {
+      "patterns": [
+        {
+          "include": "#operation"
+        },
+        {
+          "include": "#region_body_or_attr_dict"
+        },
+        {
+          "include": "#comment"
+        },
+        {
+          "include": "#ssa_value"
+        },
+        {
+          "include": "#block"
+        },
+        {
+          "include": "#attribute_value"
+        },
+        {
+          "include": "#bare_identifier"
+        }
+      ]
+    },
+    "region_body_or_attr_dict": {
+      "patterns": [
+        {
+          "begin": "\\{\\s*(?=\\%|\\/|\\^)",
+          "patterns": [
+            {
+              "include": "#operation_body"
+            }
+          ],
+          "end": "\\}"
+        },
+        {
+          "begin": "\\{\\s*(?=[^\\}]*$)",
+          "patterns": [
+            {
+              "include": "#operation_body"
+            }
+          ],
+          "end": "\\}"
+        },
+        {
+          "begin": "\\{\\s*(?=\\%)",
+          "patterns": [
+            {
+              "include": "#operation_body"
+            }
+          ],
+          "end": "\\}"
+        },
+        {
+          "begin": "\\{\\s*(?=.*$)",
+          "patterns": [
+            {
+              "include": "#attribute_dictionary_body"
+            }
+          ],
+          "end": "\\}"
+        }
+      ]
     },
-    "types":{
-      "match":"[\\Wx](index|i[1-9][0-9]*|f16|bf16|f32|f64|memref|tensor|vector)\\b",
-      "captures":{
-        "1":{
-          "name":"storage.type.mlir"
+    "attribute_value": {
+      "patterns": [
+        {
+          "include": "#string"
+        },
+        {
+          "include": "#comment"
+        },
+        {
+          "include": "#number"
+        },
+        {
+          "match": "\\b(false|true|unit)\\b",
+          "name": "constant.language.mlir"
+        },
+        {
+          "begin": "\\b(affine_map|affine_set)\\s*\\<",
+          "beginCaptures": {
+            "1": {
+              "name": "constant.language.mlir"
+            }
+          },
+          "patterns": [
+            {
+              "match": "\\b(ceildiv|floordiv|mod|symbol)\\b",
+              "name": "entity.name.function.mlir"
+            },
+            {
+              "match": "\\b([\\w\\.\\$\\-]+)\\b",
+              "name": "variable.mlir"
+            },
+            {
+              "include": "#number"
+            }
+          ],
+          "end": "\\)\\>"
+        },
+        {
+          "begin": "\\b(dense|opaque|sparse)\\s*\\<",
+          "beginCaptures": {
+            "1": {
+              "name": "constant.language.mlir"
+            }
+          },
+          "patterns": [
+            {
+              "include": "#attribute_value"
+            }
+          ],
+          "end": "\\>"
+        },
+        {
+          "begin": "\\[",
+          "patterns": [
+            {
+              "include": "#attribute_value"
+            },
+            {
+              "include": "#operation_body"
+            }
+          ],
+          "end": "\\]"
+        },
+        {
+          "begin": "\\{",
+          "patterns": [
+            {
+              "include": "#attribute_dictionary_body"
+            }
+          ],
+          "end": "\\}"
+        },
+        {
+          "match": "(\\@[\\w+\\$\\-\\.]*)",
+          "name": "entity.name.function.mlir"
+        },
+        {
+          "begin": "(\\#[\\w\\$\\-\\.]+)\\<",
+          "beginCaptures": {
+            "1": {
+              "name": "constant.language.mlir"
+            }
+          },
+          "patterns": [
+            {
+              "include": "#attribute_value"
+            },
+            {
+              "match": "\\-\\>|\\>\\="
+            },
+            {
+              "include": "#bare_identifier"
+            }
+          ],
+          "end": "\\>"
+        },
+        {
+          "match": "\\#[\\w\\$\\-\\.]+\\b",
+          "name": "constant.language.mlir"
+        },
+        {
+          "include": "#type_value"
+        },
+        {
+          "begin": "\\<",
+          "patterns": [
+            {
+              "include": "#attribute_value"
+            },
+            {
+              "include": "#bare_identifier"
+            }
+          ],
+          "end": "\\>"
         }
-      },
-      "name":"meta.types.simple.mlir"
+      ]
+    },
+    "attribute_dictionary_body": {
+      "patterns": [
+        {
+          "include": "#comment"
+        },
+        {
+          "include": "#string"
+        },
+        {
+          "include": "#attribute_value"
+        },
+        {
+          "match": "(\\%)?\\b([\\w\\.\\-\\$\\:0-9]+)\\b\\s*(?=\\=|\\,|\\})",
+          "name": "variable.other.mlir"
+        }
+      ]
+    },
+    "type_value": {
+      "patterns": [
+        {
+          "begin": "(\\![\\w\\$\\-\\.]+)\\<",
+          "beginCaptures": {
+            "1": {
+              "name": "entity.name.type.mlir"
+            }
+          },
+          "patterns": [
+            {
+              "include": "#attribute_value"
+            },
+            {
+              "match": "\\-\\>|\\>\\=",
+              "name": "punctuation.other.mlir"
+            },
+            {
+              "include": "#bare_identifier"
+            }
+          ],
+          "end": "\\>"
+        },
+        {
+          "match": "\\![\\w\\$\\-\\.]+\\b",
+          "name": "entity.name.type.mlir"
+        },
+        {
+          "begin": "(complex|memref|tensor|tuple|vector)\\<",
+          "beginCaptures": {
+            "1": {
+              "name": "entity.name.type.mlir"
+            }
+          },
+          "patterns": [
+            {
+              "match": "[\\?x0-9\\[\\]]+",
+              "captures": {
+                "0": {
+                  "patterns": [
+                    {
+                      "include": "#number"
+                    }
+                  ]
+                }
+              }
+            },
+            {
+              "include": "#attribute_value"
+            },
+            {
+              "match": "\\-\\>|\\>\\=",
+              "name": "punctuation.other.mlir"
+            },
+            {
+              "include": "#bare_identifier"
+            }
+          ],
+          "end": "\\>"
+        },
+        {
+          "match": "bf16|f16|f32|f64|f80|f128|index|none|(u|s)?i[0-9]+",
+          "name": "entity.name.type.mlir"
+        }
+      ]
+    },
+    "bare_identifier": {
+      "match": "\\b([\\w\\.\\$\\-]+)\\b",
+      "name": "keyword.other.mlir"
+    },
+    "ssa_value": {
+      "match": "\\%[\\w\\.\\$\\:\\#]+",
+      "name": "variable.other.mlir"
+    },
+    "block": {
+      "match": "\\^[\\w\\d_$\\.-]+",
+      "name": "keyword.control.mlir"
     }
   },
-  "patterns":[
-    {
-      "include":"#comment"
-    },
-    {
-      "include":"#string"
-    },
-    {
-      "match":"\\b(func)\\b\\s*(@[\\w_][\\w\\d_.$]*)",
-      "captures":{
-        "1":{
-          "name":"keyword.function.mlir"
-        },
-        "2":{
-          "name":"entity.name.function.mlir"
-        }
-      },
-      "name":"support.function.mlir"
-    },
-    {
-      "match":"\\b(attributes|br|call|constant|loc|return)\\b",
-      "name":"keyword.module.mlir"
-    },
-    {
-      "include":"#identifier"
-    },
-    {
-      "include":"#branch_target"
-    },
-    {
-      "include":"#attribute"
-    },
-    {
-      "include":"#types"
-    },
-    {
-      "include":"#integer"
-    }
-  ],
-  "name":"MLIR",
-  "scopeName":"source.mlir"
-}
-
+  "scopeName": "source.mlir"
+}
\ No newline at end of file