unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Paulo Labegalini de Carvalho" <jaopaulolc@gmail.com>
To: Yuan Fu <casouri@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Call for volunteers: add tree-sitter support to major modes
Date: Mon, 24 Oct 2022 09:46:41 -0600	[thread overview]
Message-ID: <CAGjvy28do3yD1zpes+qWVh5gCsuZ+wWnAdKZ52FaJHRwEJTdYA@mail.gmail.com> (raw)
In-Reply-To: <CAGjvy29XYTtRbZx+X+O3B---gTdiVDFtwGno7DX2tUY0oG0Z7g@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4575 bytes --]

This is a better link to show all Bash's reserved words/keywords:
 https://www.gnu.org/software/bash/manual/bash.html#Reserved-Words
<https://www.gnu.org/software/bash/manual/bash.html#Reserved-Words>

I will reach out to tree-sitter-bash folks to add the missing things to the
grammar.

On Mon, Oct 24, 2022 at 9:41 AM João Paulo Labegalini de Carvalho <
jaopaulolc@gmail.com> wrote:

> Thanks for pointing that out. I am still getting familiar with tree-sitter
> thus the message sounded very generic.
>
> According to the GNU Bash Reference Manual, "time" is a reserved
> <https://www.gnu.org/software/bash/manual/bash.html#Major-Differences-From-The-Bourne-Shell>
> word. But tree-sitter does not include it in the grammar.
>
> Should I submit a PR for tree-sitter-bash to add "time", and possibly
> other missing reserved word/keywords, or should I just fontify those
> recognized by tree-sitter-bash in shell-script-mode?
>
> I believe the best course of action is to make tree-sitter-bash as
> complete as possible. That way the regex and tree-sitter fontification will
> fontify exactly the same things.
>
> What do you guys think?
>
> On Sun, Oct 23, 2022 at 10:20 PM Yuan Fu <casouri@gmail.com> wrote:
>
>>
>>
>> > On Oct 22, 2022, at 8:51 AM, João Paulo Labegalini de Carvalho <
>> jaopaulolc@gmail.com> wrote:
>> >
>> > I am getting a query error but I don't understand why.
>> >
>> > The following query is fine:
>> >
>> > (defvar sh-script--treesit-bash-keywords
>> >   '("case" "do" "done" "elif" "else" "esac" "export" "fi" "for"
>> >     "function" "if" "in" "unset" "while" "then"))
>> >
>> > (treesit-validate-query 'bash `([ ,@sh-script--treesit-bash-keywords ]
>> @font-lock-keyword-face))
>> >
>> > However the following query is said INVALID by `treesit-validate-query':
>> > (treesit-validate-query 'bash `([ ,@(sh-feature sh-leading-keywords) ]
>> @font-lock-keyword-face))
>> > Node type error at: 3
>> > ["time" "!" "do" "done" ...] @font-lock-keyword-face
>> >
>> > time" is highlighted in the *tree-sitter check query* buffer.
>> >
>> > Even though the forms below evaluate to equivalent forms:
>> > `([ ,@sh-script--treesit-bash-keywords] @font-lock-keyword-face)
>> > evaluates to:
>> > ([ "case" "do" "done" "elif" ... ] @font-lock-keyword-face)
>> >
>> > `([ ,@(sh-feature sh-leading-keywords) ] @font-lock-keyword-face)
>> > evaluates to:
>> > (["time" "!" "do" "done" ...] @font-lock-keyword-face)
>> >
>> >
>> > Any clues to what I am doing wrong?
>>
>> It is saying that there is no “time” node in bash grammar. You probably
>> need to consult the grammar file of tree-sitter-bash to see what are the
>> keywords it recognizes.
>>
>> For example, running the following snippet
>>
>> (let (collection)
>>   (goto-char (point-min))
>>   (while (re-search-forward "'[^ ][^ ]+?'" nil t)
>>     (push (match-string 0) collection))
>>   (pop-to-buffer "*result*")
>>   (dolist (keyword (cl-remove-duplicates collection :test #'equal))
>>     (insert keyword "\n")))
>>
>> in the grammar.js gives me
>>
>> '\\\\'
>> '>('
>> '<('
>> '$('
>> ':-'
>> ':?'
>> '${'
>> ')*'
>> '([^'
>> '[^'
>> '--'
>> '++'
>> 'alternative'
>> 'consequence'
>> 'right'
>> '>='
>> '<='
>> '-='
>> '!='
>> 'operator'
>> 'left'
>> '<<<'
>> 'destination'
>> '>|'
>> '>&'
>> '<&'
>> '&>>'
>> '&>'
>> '>>'
>> 'descriptor'
>> 'index'
>> '=='
>> '=~'
>> 'argument'
>> 'unsetenv'
>> 'unset'
>> 'local'
>> 'readonly'
>> 'export'
>> 'typeset'
>> 'declare'
>> ']]'
>> '[['
>> '||'
>> '&&'
>> '|&'
>> 'name'
>> 'function'
>> ';;&'
>> ';&'
>> 'fallthrough'
>> ';;'
>> 'termination'
>> 'esac'
>> 'case'
>> 'else'
>> 'elif'
>> 'fi'
>> 'then'
>> 'if'
>> 'done'
>> 'do'
>> 'until'
>> 'while'
>> '))'
>> 'update'
>> 'condition'
>> 'initializer'
>> '(('
>> 'value'
>> 'in'
>> 'variable'
>> 'select'
>> 'for'
>> 'redirect'
>> 'body'
>> '\n'
>> '<<-'
>> '<<'
>> '+='
>> 'bash'
>> '\\s'
>> '\\'
>> '\\]'
>> '\\['
>>
>>
>> Yuan
>
>
>
> --
> João Paulo L. de Carvalho
> Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
> Postdoctoral Research Fellow | University of Alberta | Edmonton, AB -
> Canada
> joao.carvalho@ic.unicamp.br
> joao.carvalho@ualberta.ca
>


-- 
João Paulo L. de Carvalho
Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada
joao.carvalho@ic.unicamp.br
joao.carvalho@ualberta.ca

[-- Attachment #2: Type: text/html, Size: 7191 bytes --]

  reply	other threads:[~2022-10-24 15:46 UTC|newest]

Thread overview: 175+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 23:14 Call for volunteers: add tree-sitter support to major modes João Paulo Labegalini de Carvalho
2022-10-12  5:43 ` Eli Zaretskii
2022-10-12 15:09   ` João Paulo Labegalini de Carvalho
2022-10-12 15:36     ` Eli Zaretskii
2022-10-21 16:47       ` João Paulo Labegalini de Carvalho
2022-10-21 23:45         ` João Paulo Labegalini de Carvalho
2022-10-22  1:52           ` Yuan Fu
2022-10-22  3:42             ` Yuan Fu
2022-10-22  6:42           ` Eli Zaretskii
2022-10-22 15:51             ` João Paulo Labegalini de Carvalho
2022-10-24  4:20               ` Yuan Fu
2022-10-24 15:41                 ` João Paulo Labegalini de Carvalho
2022-10-24 15:46                   ` João Paulo Labegalini de Carvalho [this message]
2022-10-24  6:23               ` Theodor Thornhill
2022-10-24 15:44                 ` João Paulo Labegalini de Carvalho
2022-10-24 16:00                   ` Theodor Thornhill
  -- strict thread matches above, loose matches on Subject: below --
2022-10-12  7:18 Payas Relekar
2022-10-09  9:03 Eli Zaretskii
2022-10-09  9:47 ` Theodor Thornhill
2022-10-09 12:21   ` Eli Zaretskii
2022-10-09 12:41     ` Theodor Thornhill
2022-10-09 14:04       ` Eli Zaretskii
2022-10-09 15:18         ` Theodor Thornhill
2022-10-09 15:36           ` Eli Zaretskii
2022-10-09 19:25             ` Theodor Thornhill
2022-10-09 21:21               ` Theodor Thornhill
2022-10-09 22:03                 ` Emanuel Berg
2022-10-10  6:35                   ` Theodor Thornhill
2022-10-09 22:39                 ` Yuan Fu
2022-10-10  4:05                   ` Yuan Fu
2022-10-10  6:28                     ` Eli Zaretskii
2022-10-10  6:35                       ` Theodor Thornhill
2022-10-10  8:11                         ` Eli Zaretskii
2022-10-10  6:46                       ` Yuan Fu
2022-10-10  8:16                         ` Eli Zaretskii
2022-10-10  7:08                   ` Theodor Thornhill
2022-10-10 15:48                     ` Yuan Fu
2022-10-10 16:29                       ` Theodor Thornhill
2022-10-10 17:16                         ` Yuan Fu
2022-10-10 17:53                           ` Yuan Fu
2022-10-10 18:04                             ` Theodor Thornhill
2022-10-11  6:53                     ` Jostein Kjønigsen
2022-10-11  7:16                       ` Theodor Thornhill
2022-10-09 14:08       ` Dmitry Gutov
2022-10-09 12:26 ` Philip Kaludercic
2022-10-09 12:27   ` Po Lu
2022-10-09 13:27     ` Eli Zaretskii
2022-10-09 14:01       ` Po Lu
2022-10-09 14:07         ` Eli Zaretskii
2022-10-09 13:25   ` Eli Zaretskii
2022-10-09 14:36 ` Brian
2022-10-09 14:53   ` Eli Zaretskii
2022-10-09 15:20     ` Brian
2022-10-09 15:39       ` Eli Zaretskii
2022-10-09 16:03         ` Brian
2022-10-09 17:23           ` Eli Zaretskii
2022-10-09 23:45           ` Yuan Fu
2022-10-10  9:34             ` Brian
2022-10-10 10:10               ` Po Lu
2022-10-10 10:27                 ` Brian
2022-10-10 15:53               ` Yuan Fu
2022-10-10  3:04       ` Stefan Monnier
2022-10-10  6:25         ` Eli Zaretskii
2022-10-10  9:23           ` Brian
2022-10-09 20:01 ` Theodor Thornhill
2022-10-09 20:54   ` Stefan Kangas
2022-10-09 21:12     ` Theodor Thornhill
2022-10-10  0:01   ` Yuan Fu
2022-10-10 19:44     ` Alan Mackenzie
2022-10-10 20:54       ` Yuan Fu
2022-10-17 17:59       ` Eli Zaretskii
2022-10-17 18:47         ` Alan Mackenzie
2022-10-17 22:04           ` Stefan Monnier
2022-10-18 13:47             ` Ketevan Lomidze
2022-10-18  3:24           ` Po Lu
2022-10-18  4:42             ` Yuan Fu
2022-10-18  6:35               ` Po Lu
2022-10-18  9:45                 ` Eli Zaretskii
2022-10-18 10:36                   ` Po Lu
2022-10-18 14:52                     ` Eli Zaretskii
2022-10-20  0:19                       ` Po Lu
2022-10-20  1:15                         ` Stefan Monnier
2022-10-20  6:16                           ` Eli Zaretskii
2022-10-21 19:19                           ` Jostein Kjønigsen
2022-10-20  6:12                         ` Eli Zaretskii
2022-10-18 13:53             ` Stefan Monnier
2022-10-19  8:03             ` Jostein Kjønigsen
2022-10-10  5:55   ` Eli Zaretskii
2022-10-10  6:44     ` Theodor Thornhill
2022-10-10  8:15       ` Eli Zaretskii
2022-10-10  9:04         ` Theodor Thornhill
2022-10-10  9:10           ` Eli Zaretskii
2022-10-10  9:20             ` Theodor Thornhill
2022-10-10  9:39               ` Eli Zaretskii
2022-10-10  9:44                 ` Theodor Thornhill
2022-10-11 21:38           ` Stefan Monnier
2022-10-11 21:45             ` Theodor Thornhill
2022-10-11  0:34         ` Lars Ingebrigtsen
2022-10-11  6:30           ` Eli Zaretskii
2022-10-11  6:41             ` Theodor Thornhill
2022-10-11  6:51               ` Eli Zaretskii
2022-10-11  7:23                 ` Theodor Thornhill
2022-10-11  7:36                   ` Eli Zaretskii
2022-10-11  7:41                     ` Theodor Thornhill
2022-10-11  8:15                     ` Jostein Kjønigsen
2022-10-11  9:54                       ` Stefan Kangas
2022-10-11  9:58                         ` Theodor Thornhill
2022-10-11  6:58               ` Jostein Kjønigsen
2022-10-11  7:13                 ` Theodor Thornhill
2022-10-11 18:31                   ` Lars Ingebrigtsen
2022-10-11 18:43                     ` Theodor Thornhill
2022-10-11 18:54                       ` Lars Ingebrigtsen
2022-10-11 18:57                         ` Theodor Thornhill
2022-10-11 19:01                         ` Theodor Thornhill
2022-10-11 19:30                           ` Lars Ingebrigtsen
2022-10-11 20:36                             ` Theodor Thornhill
2022-10-11 20:49                               ` Lars Ingebrigtsen
2022-10-11 21:01                                 ` Theodor Thornhill
2022-10-11 21:44                             ` Stefan Monnier
2022-10-12 10:58                               ` Lars Ingebrigtsen
2022-10-11 19:20                     ` Philip Kaludercic
2022-10-11 19:28                       ` Theodor Thornhill
2022-10-11  4:43       ` Po Lu
2022-10-11  5:14         ` Yuan Fu
2022-10-11  5:33           ` Theodor Thornhill
2022-10-11  6:45             ` Eli Zaretskii
2022-10-11  6:50               ` Theodor Thornhill
2022-10-11  5:47           ` Po Lu
2022-10-11  7:18             ` Eli Zaretskii
2022-10-11  7:50               ` Po Lu
2022-10-11  8:06                 ` Eli Zaretskii
2022-10-11  8:23                   ` Po Lu
2022-10-11  8:40                     ` Eli Zaretskii
2022-10-11  8:51                       ` Po Lu
2022-10-11 10:09                     ` Stefan Kangas
2022-10-11 12:49                   ` Visuwesh
2022-10-11 16:56                     ` Daniel Martín
2022-10-11 18:18                       ` Yuan Fu
2022-10-11  7:13           ` Eli Zaretskii
2022-10-11  7:35             ` Po Lu
2022-10-11  7:47               ` Theodor Thornhill
2022-10-11  8:17                 ` Po Lu
2022-10-11  8:40                   ` Theodor Thornhill
2022-10-11 10:46                     ` Po Lu
2022-10-11  8:51             ` Yuan Fu
2022-10-11  7:10         ` Eli Zaretskii
2022-10-11  7:31           ` Po Lu
2022-10-11  7:56             ` Eli Zaretskii
2022-10-11  8:15               ` Po Lu
2022-10-11  8:34                 ` Eli Zaretskii
2022-10-11  8:47                   ` Po Lu
2022-10-11 10:17                     ` Daniel Martín
2022-10-11  8:43             ` Jostein Kjønigsen
2022-10-11 16:01             ` Dmitry Gutov
2022-10-11 21:14         ` Stefan Monnier
2022-10-11 21:49           ` Lars Ingebrigtsen
2022-10-11 22:00             ` Stefan Monnier
2022-10-11 22:49               ` Lars Ingebrigtsen
2022-10-12  0:41                 ` Po Lu
2022-10-12  9:51                   ` Stefan Kangas
2022-10-12 10:47                     ` Po Lu
2022-10-12  5:30               ` Eli Zaretskii
2022-10-12  0:26           ` Po Lu
2022-10-12  3:31             ` João Paulo Labegalini de Carvalho
2022-10-12  4:27               ` Po Lu
2022-10-12  9:51                 ` Stefan Kangas
2022-10-12 10:48                   ` Po Lu
2022-10-11 21:29       ` Stefan Monnier
2022-10-10  7:34   ` Roman Rudakov
2022-10-10  7:48     ` Theodor Thornhill
2022-10-10  7:53       ` Roman Rudakov
2022-10-10  9:04         ` Theodor Thornhill
2022-10-11 20:44       ` Roman Rudakov
2022-10-11 21:00         ` Theodor Thornhill
2022-10-11 21:52         ` Stefan Monnier

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=CAGjvy28do3yD1zpes+qWVh5gCsuZ+wWnAdKZ52FaJHRwEJTdYA@mail.gmail.com \
    --to=jaopaulolc@gmail.com \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.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).