[HN Gopher] Emacs Tree-sitter custom highlighting
       ___________________________________________________________________
        
       Emacs Tree-sitter custom highlighting
        
       Author : ibobev
       Score  : 40 points
       Date   : 2025-03-01 08:17 UTC (14 hours ago)
        
 (HTM) web link (amitp.blogspot.com)
 (TXT) w3m dump (amitp.blogspot.com)
        
       | kleiba wrote:
       | Classic Emacs syntax highlighting is based on regular expressions
       | ("font-lock-mode"). Of course, the grammars of programming
       | languages are usually not regular languages but higher up in the
       | language class hierarchy (hi, C++!). But you can get a surprising
       | amount of things right just through the context in which a token
       | appears.
       | 
       | For instance, the example of this article (`type` as a keyword
       | vs. `type` as a function) would probably have worked with font-
       | lock-mode as well because you could distinguish the two cases
       | from whether or not a left parenthesis follows the token. But, of
       | course, without proper parsing, there's always the possibility of
       | edge cases that you cannot resolve correctly.
       | 
       | The interesting cases arise anyway when whatever you have in your
       | buffer does _not_ adhere to the grammar, i.e. you have a syntax
       | error: how does then your syntax highlighter cope with that?
        
       ___________________________________________________________________
       (page generated 2025-03-01 23:01 UTC)