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: Eli Zaretskii
Subject: Re: How to add pseudo vector types
Date: Sat, 24 Jul 2021 20:42:57 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Sat, 24 Jul 2021 13:32:18 -0400
> Cc: monnier@iro.umontreal.ca,
>  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.

Isn't there a better way of updating those than manually take them out
of the TS grammar?  Maybe write a short program linked against TS that
would spill them in some format that's convenient to use?  Manual
updates are a serious maintenance burden.



reply via email to

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