Feature Request: Add `illegal` and `deprecated` Syntax Elements
Ciao André,
I suggest adding two new native elements to langDefs: illegal
and deprecated
. Addition of these elements won't break backward compatibility, but all exisiting syntaxes could eventually be tweaked to include them (if required).
Many editors support these, in one form or another, and they're usually employed to show erroneous tokens with a red background and white foreground (for illegal
) and orange BG black FG (for deprecated
).
Sublime Text defines these scopes as follows:
INVALID.
Elements that are illegal in a specific context should use the following scope. Overuse of this will likely lead to unpleasant highlighting for users as they edit code.
invalid.illegal
Deprecated elements should be scoped using the following scope. This should be very rarely used, as users may be working with older versions of a language.
invalid.deprecated
The illegal
element could be used, for example, to capture invalid escape sequences, malformed numeric constants, and a wide range of malformed elements. Probably invalide escape sequences is a good example case, as most editors and native IDEs catch these and mark them with a strong visual indicator of error.
The deprecated
element would be usable at the discretion of a language maintainer — depending on whether one wishes the langDef to support highlighting source code for older and newer version of a syntax alike. But definitely it would be most useful when one wishes to create ad hoc syntaxes (or mod existing ones) targetting specific language versions, so it would be a useful feature in many contexts.
Of course, these could be handled with keywords groups, but I think that they deserve to be first-class citizens in Highlight, so that every langDef and themes can target them in a straight forward manner (especially since these two element require shouting styling, and usually red color). Relying on keywords groups would dilute the purpose of this.