sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 586 forks source link

[RFC] Add new scopes to "jumping" flow control keywords/statements. #1228

Open FHTheron opened 6 years ago

FHTheron commented 6 years ago

Intro

First let me define what I mean with "jump" keywords. Things like if and else are of course also flow control keywords and they do result in the CPU executing branches, but I'm more specifically considering the jump in terms of visual code flow. For example, a subtle goto that radically changes the execution flow isn't always as visible as the effect it has.

Current scopes

In C these currently get the scope keyword.control.c, but this scope is also used (correctly) for if, while, and other actual flow control keywords.

In Python the scope is keyword.control.flow.python and includes loop keywords as well as return and raise.

New scopes

I suggest that some of these flow control keywords get scoped as two new flow control types - one type jumps within the current frame/call stack the other jumps out of the current call stack.

C

C++

Python

And many more languages with similar keywords/statements.

Alternative

The same colouring can be achieved if all languages define unique scopes for all flow control keywords. This will avoid having to define what each keyword's jump type is. Python has this for 2 keywords, Shell-Unix-Generic seems to have keyword.control.*.shell for all keywords. A colour scheme can then add each of these to colour them as desired. It does mean that the colour scheme now defines what jump type a jump keyword is, which may or may not matter.

Example screenshots

Current: current

Proposed, using new scopes with illustrative colours: proposed