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

Python: Add match and case (soft) keywords #3142

Merged
merged 2 commits into from Oct 7, 2021

Conversation

hoonweiting
Copy link
Contributor

Python 3.10 (just released on Monday!) introduces structural pattern matching, aka switch-case statements, except that in Python it's match-case. It's currently a soft keyword, together with _ which kinda acts like default in JavaScript. This PR adds match, case, and _ (if : comes right after it) as keywords.

* can be used as a wildcard, and _ can also be used within lists and dictionaries to represent the idea of default. But I'm not sure if I should try to match _ when it is used in such situations? I feel that there'll be quite a few cases to consider (even if we only consider code that follows the style guide), and I don't know how Prism normally deals with this.

@github-actions
Copy link

github-actions bot commented Oct 7, 2021

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of +12 B (+1.1%).

file master pull size diff % diff
components/prism-python.min.js 1.06 KB 1.08 KB +12 B +1.1%

Generated by 🚫 dangerJS against b7f03b3

Copy link
Member

@RunDevelopment RunDevelopment left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR @hoonweiting!

One minor nit, otherwise gtg.

components/prism-python.js Outdated Show resolved Hide resolved
@RunDevelopment
Copy link
Member

RunDevelopment commented Oct 7, 2021

Please rebuild. My bad. All is good.

@RunDevelopment RunDevelopment merged commit 3f24dc7 into PrismJS:master Oct 7, 2021
@RunDevelopment
Copy link
Member

Thank you for contributing @hoonweiting!

@hoonweiting hoonweiting deleted the python-match-case branch October 7, 2021 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants