unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 60484@debbugs.gnu.org, Mohammed Sadiq <sadiq@sadiqpk.org>
Subject: bug#60484: 29.0.60; c-ts-mode: short tokens are not identified  as type_identifier
Date: Mon, 2 Jan 2023 14:41:12 -0800	[thread overview]
Message-ID: <D7E5E5C9-F777-43B8-A0B3-5C4A2BC8DBD3@gmail.com> (raw)
In-Reply-To: <677a429cb107ff200396e0c59eefecda@sadiqpk.org>


Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Mon, 02 Jan 2023 18:13:34 +0530
>> From: Mohammed Sadiq <sadiq@sadiqpk.org>
>> Cc: 60484@debbugs.gnu.org
>> 
>> On 2023-01-02 17:45, Eli Zaretskii wrote:
>> >> Date: Mon, 02 Jan 2023 10:22:09 +0530
>> >> From: Mohammed Sadiq <sadiq@sadiqpk.org>
>> >> 
>> >> Short tokens are not identified as type_identifier in GNU Emacs
>> >> c-ts-mode, but does work fine with tree-sitter playground[0].
>> >> 
>> >> Say for example, 'a_type' in an empty buffer is identified as a
>> >> type_identifier in tree-sitter playground, but not in c-ts-mode,
>> >> while say, some longer tokens like 'window_type' is identified as
>> >> type_identifier.
>> > 
>> > Where is it written that FOO_type is a type identifier?  is this
>> > something new in some recent C Standard?  Or is it just a popular
>> > convention?
>> 
>> 'a_type' was just a made up example, it can be any valid token, say
>> 'g_file', or whatever.  I was pointing out a disparity in handling of
>> some token in c-ts-mode and tree-sitter: tree-sitter identifiers a 6
>> byte length token as an identifier, but c-ts-mode requires it to be
>> at least 11 byte sized for custom types.
>
> I'm not sure I see a problem here.  It sounds like different
> heuristics to me.  Nothing says that g_file is a type, only its
> parsing can tell.

The parse tree of a buffer with only a_type in it is this:

(translation_unit (ERROR (identifier)))

So tree-sitter-c parses it as a parse error instead of a type. I suppose
the difference is due to different version of tree-sitter-c used by
Emacs (the latest) and the tree-sitter playground website? Maybe the
playground is using an older version. The "cutoff" point for the
playground version seems to be 5 bytes: a_typ is considered an error but
a_type a type.

Yuan





  parent reply	other threads:[~2023-01-02 22:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02  4:52 bug#60484: 29.0.60; c-ts-mode: short tokens are not identified as type_identifier Mohammed Sadiq
2023-01-02 12:15 ` Eli Zaretskii
2023-01-02 12:43   ` Mohammed Sadiq
2023-01-02 12:45     ` Eli Zaretskii
2023-01-02 13:20       ` Mohammed Sadiq
2023-01-02 22:41 ` Yuan Fu [this message]
2023-01-08  0:57 ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D7E5E5C9-F777-43B8-A0B3-5C4A2BC8DBD3@gmail.com \
    --to=casouri@gmail.com \
    --cc=60484@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=sadiq@sadiqpk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).