emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add pseudo vector types


From: Yuan Fu
Subject: Re: How to add pseudo vector types
Date: Sat, 24 Jul 2021 13:32:18 -0400


> On Jul 24, 2021, at 12:14 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Sat, 24 Jul 2021 11:04:35 -0400
>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>> Clément Pit-Claudel <cpitclaudel@gmail.com>,
>> emacs-devel@gnu.org
>> 
>> +(define-derived-mode ts-c-mode prog-mode "TS C"
>> +  "C mode with tree-sitter support."
>> +  (setq-local font-lock-fontify-region-function
>> +              #'tree-sitter-fontify-region-function)
>> +  (setq-local tree-sitter-font-lock-settings
>> +              `(("font-lock-c"
>> +                 ,(tree-sitter-c)
>> +                 "(null) @font-lock-constant-face
>> +(true) @font-lock-constant-face
>> +(false) @font-lock-constant-face
>> +
>> +(comment) @font-lock-comment-face
>> +
>> +(system_lib_string) @ts-c-fontify-system-lib
>> +
>> +(unary_expression
>> +  operator: _ @font-lock-negation-char-face)
>> +
>> +(string_literal) @font-lock-string-face
>> +(char_literal) @font-lock-string-face
> 
> Where does this repertoire of possible syntax categories come from?
> Is this from some list that TS exposes or documents?  If so, what
> happens when the repertoire is modified?

These “syntax categories” are defined by individual language grammar definition 
for tree-sitter, so it could change from language to language. And tree-sitter 
does not document them. If these “syntax categories” change, then we need to 
change our code with them. But I doubt that it will happen often. They are hard 
to document, because a non-trivial grammar definition often defines hundreds of 
them; the grammar definition for C has 1000 LOC.

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]