GNU bug report logs - #49946
[PATCH 00/31] Tree-sitter, node-gyp addon support and emacs-tree-sitter

Previous Next

Package: guix-patches;

Reported by: Pierre Langlois <pierre.langlois <at> gmx.com>

Date: Sun, 8 Aug 2021 23:27:01 UTC

Severity: normal

Tags: patch

Full log


Message #881 received at 49946 <at> debbugs.gnu.org (full text, mbox):

From: Pierre Langlois <pierre.langlois <at> gmx.com>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: Pierre Langlois <pierre.langlois <at> gmx.com>, 49946 <at> debbugs.gnu.org
Subject: Re: bug#49946: [PATCH 00/31] Tree-sitter, node-gyp addon support
 and emacs-tree-sitter
Date: Fri, 10 Feb 2023 16:14:38 +0000
[Message part 1 (text/plain, inline)]
Hi!

zimoun <zimon.toutoune <at> gmail.com> writes:

> Hi,
>
> Sorry, I have totally overlooked this tree-sitter story. :-) And I have
> not read all the patch versions and thread yet.
>
>
> On Fri, 25 Nov 2022 at 01:57, Pierre Langlois <pierre.langlois <at> gmx.com> wrote:
>
>> +(define* (install #:key target grammar-directories outputs #:allow-other-keys)
>> +  (let ((lib (string-append (assoc-ref outputs "out")
>> +                            "/lib/tree-sitter")))
>> +    (mkdir-p lib)
>> +    (define (compile-language dir)
>> +      (with-directory-excursion dir
>> +        (let ((lang (assoc-ref (call-with-input-file "src/grammar.json"
>> +                                 read-json)
>> +                               "name"))
>> +              (source-file (lambda (path)
>> +                             (if (file-exists? path)
>> +                                 path
>> +                                 #f))))
>> +          (apply invoke
>> +                 `(,(if target
>> +                        (string-append target "-g++")
>> +                        "g++")
>
> Why is g++ required?  Is gcc not enough?  I thought from Tree-sitter
> documentation that it was only using C files and not C++; but…
>
>> +                   "-shared"
>> +                   "-fPIC"
>> +                   "-fno-exceptions"
>> +                   "-O2"
>> +                   "-g"
>> +                   "-o" ,(string-append lib "/" lang ".so")
>> +                   ;; An additional `scanner.{c,cc}' file is sometimes
>> +                   ;; provided.
>> +                   ,@(cond
>> +                      ((source-file "src/scanner.c")
>> +                       => (lambda (file) (list "-xc" "-std=c99" file)))
>> +                      ((source-file "src/scanner.cc")
>
> …apparently not.

Yeah this is a little strange. IIUC, the final code generated from the
grammar.js->grammar.json->grammar.c process is plain C, but grammar
 packages may also provide some custom hand-written code in terms of a
scanner.{c,cc} file.

Thanks,
Pierre
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 2 years and 120 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.