EvgeniyPeshkov / syntax-highlighter

Syntax Highlighter extension for Visual Studio Code (VSCode). Based on Tree-sitter.
https://marketplace.visualstudio.com/items?itemName=evgeniypeshkov.syntax-highlighter
MIT License
210 stars 43 forks source link

[C++] "this" is a keyword #14

Closed alekseyt closed 5 years ago

alekseyt commented 5 years ago

this as in

this->f();

Currently it's not highlighted. I tried to add it to the end of the list of control keywords in grammar/cpp.json:

         "\"catch\"": "control",
+        "\"this\"": "control",

         "\"sizeof\"": "operator",

but it's still not highlighted. What am i missing?

EvgeniyPeshkov commented 5 years ago

Unfortunately, tree-sitter parses such expressions like varibale->function(). Without expansion of syntax nodes and looking at what text is actually inside, it's impossible to distinguish keywords in such cases. At the moment i do not plan to implement parsing of node's text because of performance impact. This will imply considerable performance drop, because every term will have to be checked against a list of special words or regexps. Please, look at this answer for details. Edit: Also, in some sense, this is indeed variable, the one, that we are inside at the moment.

alekseyt commented 5 years ago

If it's on tree-siiter then i'm closing this issue then.