emacs-devel
[Top][All Lists]
Advanced

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

Re: Call for volunteers: add tree-sitter support to major modes


From: Jostein Kjønigsen
Subject: Re: Call for volunteers: add tree-sitter support to major modes
Date: Wed, 19 Oct 2022 10:03:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2



Could someone please tell me how well tree-sitter supports pre-standard
C with liberal (and sometimes non-standard) use of the C language?  I'm
talking about code that looks like this:

MACRO_USED_TO_DEFINE_SPECIAL_FUNCTIONS (function_name, cells, transform)
      some_kind_of_ptr cells;
      another_kind_of_ptr *transform;
{
   extern maybe_tls (int) errno;
   extern caddr_t bar (_P (another_kind_of_ptr, ...));
   int rc;

   BEGIN_A_KIND_OF_SECTION ({
       ENTRY (dx, dy, shx, shy)
        float dx, dy, shx, shy;

       if (!bar (other_function (dx, dy, shx, shy),
                etc, etc, etc))
        die ("bar", sys_errlist[errno]);
     }, register float, section_name);

   rc = more_code_here (&section_name_desc, etc);
   return rc;
}

I don't doubt that tree-sitter is good at parsing newer languages like
Typescript, but does it support C all that well?

If you want to get an idea of the syntaxes which are supported by tree-sitter, all language grammar-specifications have test-cases associated with them.

Some of the test-cases for "vanilla" C can be found here:

https://github.com/tree-sitter/tree-sitter-c/tree/master/test/corpus

You may find the amibiguities file in particular interesting: https://github.com/tree-sitter/tree-sitter-c/blob/master/test/corpus/ambiguities.txt

For C++ there is a separate grammar all together:

https://github.com/tree-sitter/tree-sitter-cpp/tree/master/test/corpus

It similarly has defined test-cases for how ambiguous statements should be parsed:

https://github.com/tree-sitter/tree-sitter-cpp/blob/master/test/corpus/ambiguities.txt

--

Jostein




reply via email to

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