[PATCH] D125427: [TableGen] Add a new json textmate description for syntax highlighting

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 13 04:42:45 PDT 2022


sebastian-ne added a comment.

The highlighting looks nice with this.
I didn’t see anything blatantly wrong or missing, so thumbs up from me.

FWIW, there’s a tree-sitter grammar here: https://github.com/Flakebi/tree-sitter-tablegen
which also lists some interesting edge cases like nested comments or identifiers that start with digits: https://github.com/Flakebi/tree-sitter-tablegen/blob/master/test/corpus/regressions.td

For fun facts, `2var` is a valid identifier in tablegen, but in LLVM IR `%2var` is actually a variable and a keyword (yes, `%2 = load i8, i8* %1store i8 %2, i8* %1` is valid IR).



================
Comment at: llvm/utils/textmate/tablegen.json:43-50
+          "begin": "/\\*",
+          "end": "\\*/",
+          "captures": {
+            "0": {
+              "name": "comment.block.tablegen"
+            }
+          },
----------------
I’m not familiar with textmate parsers, so not sure if this is handled here (or can be handled), but tablegen supports nested block comments. I.e.
```
/* nested /*
comment */
still a comment
*/
```

(and for the record, only tablegen supports nested comments, LLVM IR or MIR doesn’t)


================
Comment at: llvm/utils/textmate/tablegen.json:217
+        {
+          "match": "\\b(assert|else|foreach|defset|defvar|if|in|let|then)\\b",
+          "name": "keyword.other.tablegen"
----------------
`field` is also a keyword (although deprecated)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125427/new/

https://reviews.llvm.org/D125427



More information about the llvm-commits mailing list