Add syntax highlighting for SemIR. (#6958)

This applies to files named *.semir, but more interestingly also to
Carbon source lines starting `// CHECK:STDOUT:`.

Assisted-by: Gemini 3.1 Pro via Antigravity
This commit is contained in:
Richard Smith
2026-03-31 18:49:02 +00:00
committed by GitHub
parent 396756c151
commit 2e0d9dc709
3 changed files with 137 additions and 0 deletions
@@ -0,0 +1,21 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"scopeName": "source.carbon-check-test",
"injectionSelector": "L:source.carbon",
"patterns": [
{
"begin": "^(\\s*//\\s*CHECK:STDOUT:)",
"beginCaptures": {
"1": {
"name": "comment.line.carbon"
}
},
"end": "$",
"patterns": [
{
"include": "source.carbon-semir"
}
]
}
]
}
+21
View File
@@ -27,6 +27,15 @@
".carbon"
],
"configuration": "./language-configuration.json"
},
{
"id": "semir",
"aliases": [
"SemIR"
],
"extensions": [
".semir"
]
}
],
"grammars": [
@@ -34,6 +43,18 @@
"language": "carbon",
"scopeName": "source.carbon",
"path": "./carbon.tmLanguage.json"
},
{
"language": "semir",
"scopeName": "source.carbon-semir",
"path": "./semir.tmLanguage.json"
},
{
"scopeName": "source.carbon-check-test",
"path": "./carbon-check-test.tmLanguage.json",
"injectTo": [
"source.carbon"
]
}
],
"configuration": {
+95
View File
@@ -0,0 +1,95 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "semir",
"scopeName": "source.carbon-semir",
"fileTypes": ["semir"],
"patterns": [
{
"include": "#keywords"
},
{
"include": "#identifiers"
},
{
"include": "#strings"
},
{
"include": "#numbers"
},
{
"include": "#labels"
},
{
"include": "#punctuation"
}
],
"repository": {
"keywords": {
"patterns": [
{
"name": "storage.type.semir",
"match": "\\b(var|ref|init|out|type|val)\\b"
},
{
"name": "storage.modifier.semir",
"match": "\\b(concrete)\\b"
},
{
"name": "support.function.semir",
"match": "\\b[a-z_][a-z0-9_]+\\b"
}
]
},
"identifiers": {
"patterns": [
{
"name": "entity.name.variable.semir",
"match": "(?:[a-zA-Z0-9_]+\\.)?%[a-zA-Z0-9_.]+"
},
{
"name": "entity.name.function.semir",
"match": "@[a-zA-Z0-9_.]+"
}
]
},
"labels": {
"patterns": [
{
"name": "entity.name.label.semir",
"match": "![a-zA-Z0-9_]+:"
}
]
},
"strings": {
"patterns": [
{
"name": "string.quoted.double.semir",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.semir",
"match": "\\\\."
}
]
}
]
},
"numbers": {
"patterns": [
{
"name": "constant.numeric.semir",
"match": "\\b\\d+(\\.\\d+)?\\b"
}
]
},
"punctuation": {
"patterns": [
{
"name": "keyword.operator.semir",
"match": "(=>|->|=|:)"
}
]
}
}
}