[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23501: Non-regex-based syntax highlighting
From: |
Nir Friedman |
Subject: |
bug#23501: Non-regex-based syntax highlighting |
Date: |
Tue, 10 May 2016 14:55:41 -0400 |
For instance, suppose I write some C++ that looks like this:
using MyType = Something::OtherType;
There's no way to determine locally whether Something is a namespace or itself a type, so a regex based syntax highlighter cannot consistently color namespaces and classes differently. To take one example, Eclipse will perform this determination and will consistently color namespaces and classes any color you like. It can do this because it parses the code and uses the AST. It makes many more useful distinctions which cannot be made locally; for example when calling a function foo from a member function bar of an object, there is no way to easily tell whether foo is also a member of the same object as bar, or whether foo is just a free function in the same namespace. One has privileged access and the other probably doesn't, so it's a genuinely useful distinction.
I guess I'm a bit less clear on the solution, because I don't have a good sense of who the owner of the C++ major mode is, and how the code is structured. My thinking was that perhaps hooks could be added to make it easier for plugin writers to modify the syntax coloring of the major mode. As opposed to plugin writers needing to rewrite the C++ major mode from scratch just to change the syntax coloring.