mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 02:46:05 +00:00
[mlir] Significantly overhaul the textmate grammar
The current grammar is really crusty, only supports a handful of cases, and is also out-of-date after various refactorings. This commit refactors the textmate grammar to handle significantly more cases, and now provides proper coloring for a majority of cases (including dialect attributes, operations, types, etc.) Differential Revision: https://reviews.llvm.org/D125458
This commit is contained in:
parent
e82e4fa7ef
commit
86f5caeee9
@ -1,40 +1,49 @@
|
||||
{
|
||||
"name": "MLIR",
|
||||
"fileTypes": [
|
||||
"mlir"
|
||||
],
|
||||
"patterns": [
|
||||
{
|
||||
"include": "#comment"
|
||||
},
|
||||
{
|
||||
"include": "#string"
|
||||
},
|
||||
{
|
||||
"include": "#top_level_entity"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"attribute": {
|
||||
"match": "\\W[\\w_][\\w\\d_.$]*\\s*=",
|
||||
"name": "meta.attribute.mlir"
|
||||
},
|
||||
"branch_target": {
|
||||
"match": "\\^bb[\\w\\d_$\\.-]+",
|
||||
"name": "entity.name.label.mlir"
|
||||
},
|
||||
"comment": {
|
||||
"match": "\/\/.*$",
|
||||
"name": "comment.line.double-slash.mlir"
|
||||
},
|
||||
"identifier": {
|
||||
"match": "[\\%#@][\\w_][\\w\\d_.$]*",
|
||||
"captures": {
|
||||
"0": {
|
||||
"name": "variable.mlir"
|
||||
}
|
||||
},
|
||||
"name": "meta.identifier.mlir"
|
||||
},
|
||||
"integer": {
|
||||
"match": "[\\Wx]([0-9]+)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "meta.identifier.mlir"
|
||||
]
|
||||
},
|
||||
"string": {
|
||||
"end": "\"",
|
||||
"begin": "\"",
|
||||
"beginCaptures": {
|
||||
"0": {
|
||||
@ -45,12 +54,9 @@
|
||||
{
|
||||
"match": "\\\\[nt\"]",
|
||||
"name": "constant.character.escape.mlir"
|
||||
},
|
||||
{
|
||||
"match": "\\\\.",
|
||||
"name": "invalid.illegal.mlir"
|
||||
}
|
||||
],
|
||||
"end": "\"",
|
||||
"endCaptures": {
|
||||
"0": {
|
||||
"name": "punctuation.definition.string.end.mlir"
|
||||
@ -58,58 +64,335 @@
|
||||
},
|
||||
"name": "string.quoted.double.mlir"
|
||||
},
|
||||
"types": {
|
||||
"match": "[\\Wx](index|i[1-9][0-9]*|f16|bf16|f32|f64|memref|tensor|vector)\\b",
|
||||
"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": "storage.type.mlir"
|
||||
"name": "constant.language.mlir"
|
||||
}
|
||||
},
|
||||
"name": "meta.types.simple.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": "\\}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"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": "\\>"
|
||||
}
|
||||
]
|
||||
},
|
||||
"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*(|private|public)\\s*(@[\\w_][\\w\\d_.$]*)",
|
||||
"captures": {
|
||||
"1": {
|
||||
"name": "keyword.function.mlir"
|
||||
},
|
||||
"2": {
|
||||
"name": "keyword.function.mlir"
|
||||
},
|
||||
"3": {
|
||||
"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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user