emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree sitter support for C-like languages


From: Eli Zaretskii
Subject: Re: Tree sitter support for C-like languages
Date: Sat, 12 Nov 2022 14:21:11 +0200

> Cc: emacs-devel@gnu.org
> Date: Fri, 11 Nov 2022 07:01:02 +0100
> From:  Theodor Thornhill via "Emacs development discussions." 
> <emacs-devel@gnu.org>
> 
> See below patch.  The struct issue was an ordering problem when I
> extracted the styles.  Should be good now

Thanks, a few minor comments below.

> diff --git a/etc/NEWS b/etc/NEWS
> index 9ed78bc6b3..3ce9810ece 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -2786,8 +2786,32 @@ when visiting JSON files.
>  ** New mode ts-mode'.
>  Support is added for TypeScript, based on the new integration with
>  Tree-Sitter. There's support for font-locking, indentation and
> -navigation.  Tree-Sitter is required for this mode to function, but if
> -it is not available, we will default to use 'js-mode'.
> +navigation.  Tree-Sitter is required for this mode to function.
> +
> +** New mode c-ts-mode'.
> +Support is added for C, based on the new integration with
> +Tree-Sitter. There's support for font-locking, indentation and
> +navigation.  Tree-Sitter is required for this mode to function.

First, please use 2 spaces between sentences.

Next, I suggest a slightly different boilerplate for these items:

  ** New mode FOO-ts-mode.
  A major mode based on the Tree-sitter library for editing programs
  in the FOO language.  It includes support for font-locking,
  indentation, and navigation.

> +(defvar c++-ts-mode--preproc-keywords
> +  '("#define" "#if" "#ifdef" "#ifndef" "#else" "#elif" "#endif" "#include")
> +  "C++ keywords for tree-sitter font-locking.")

This list seems to be incomplete: what about the following?

  #error
  #warning
  #include_next
  #line
  #pragma

Doesn't Tree-sitter's C++ grammar support those?

> +(defvar c-ts-mode--keywords
> +  '("const" "default" "enum" "extern" "inline" "static"
> +    "struct" "typedef" "union" "volatile" "goto" "register"
> +    "sizeof" "return"
> +    "while" "for" "do" "continue" "break"
> +    "if" "else" "case" "switch")
> +  "C keywords for tree-sitter font-locking.")

Are these all the keywords in C?  Or is it just what Tree-sitter's C
parser support for now?

> +(defvar c-ts-mode--preproc-keywords
> +  '("#define" "#if" "#ifdef" "#ifndef" "#else" "#elif" "#endif"
> +    "#include")
> +  "C keywords for tree-sitter font-locking.")

Same comment here about additional preprocessor directives.



reply via email to

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