Tokenization for match-case
alexr00 opened this issue · 3 comments
Originally from @SNvMK in microsoft/vscode#120734
So, in python 3.10, there is match/case syntax. Currently, it is just white words(for monokai). I'd like if you add highlight for this. Thanks

a = 'world'
match a:
case 'world':
print('Hello!')
case _:
print('I dont know you!')Currently the match and case are only tokenized as source.python.
Though @cdce8p closed his PR, I think that this would still be beneficial. The VS Code markdown "previewer" use this grammar when rendering Python-labeled triple backtick blocks. I am happy to pick up on where @cdce8p left his great work.
I am trying to figure out if there is a reference for the yaml format that drives the production of the other files. In particular, I am wondering if there is documentation that explains whether there is a way to determine (using regular expression as much as possible) if the tokenizer is in a particular section. In other words, does the yaml file support defining a region (or something like that) according to two sets of regular expressions that could be used to label a section of code as belonging to the body of a lambda or with. We could write such a group detector for match statements which would make it easier to label case and _ as keywords when they are more likely to be keywords.
Obviously regular expressions are not enough to capture the full context sensitivity required to definitively mark match, case and _, but perhaps it could be a good start?