Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenization for match-case #235

Open
alexr00 opened this issue Apr 12, 2021 · 3 comments
Open

Tokenization for match-case #235

alexr00 opened this issue Apr 12, 2021 · 3 comments

Comments

@alexr00
Copy link

alexr00 commented Apr 12, 2021

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
image

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.

@cdce8p
Copy link

cdce8p commented May 1, 2021

I opened #237 to address this one

@hawkinsw
Copy link

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?

@contang0
Copy link

This seems to be addressed by 7d0f2b2. Is there going to be new release? Last one was in 2018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants