I've been playing around with syntax highlighting in VS Code and have so far been able to get a pretty good result using a custom JSON TextMate grammar. Although an extension already existed for GCC ARM Assembly, I thought it sucked, so I used the source code as a starting point to make my own.
However, there is a scenario I can't seem to figure out how to handle. In GCC ARM you can use the .macro
directive to create macros like this:
.macro print format, storage
.data
string\@: .asciz "\format"
.align 2
.text
.ifnb \storage
mov r1, \storage
.endif
ldr r0, =string\@
bl printf
.endm
If you've never looked at GCC ARM, all you need to know is that the first line starts the macro, where print
is the name of the macro and format
and storage
are its arguments. Then inside the macro you can use values of the arguments with \format
and \storage
anywhere you want. There is also \@
, which is a special "variable" which only has meaning inside macros. All it is is a number that increments every time the macro is called.
What I'd like to do is somehow write syntax highlighting that will dynamically recognize the argument names in the macro declaration and then color their corresponding usages (starting with forward slashes) wherever they appear inside the macro. The problem with this seems to be that I will need to somehow dynamically create a list of new "keywords" (or whatever you would like to call the strings of text) that I can refer back to from rules inside the macro context.
Is this possible in VS Code with TextMate grammars? Is it possible in VS Code at all? If not, is it possible in ANY editor? If not possible with TextMate grammars, what would I have to do to achieve this?
Feel free to ask for more details if there is anything I explained poorly and I will edit the question.