emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter introduction documentation


From: Eli Zaretskii
Subject: Re: Tree-sitter introduction documentation
Date: Tue, 27 Dec 2022 20:06:23 +0200

> From: Philip Kaludercic <philipk@posteo.net>
> Cc: monnier@iro.umontreal.ca,  dgutov@yandex.ru,  theophilusx@gmail.com,
>   emacs-devel@gnu.org
> Date: Tue, 27 Dec 2022 17:20:29 +0000
> 
> > It _is_ as simple as above (modulo the need to detect C++ sources and
> > use g++ in that case).  And I already said that such a command will
> > have its place in Emacs (and Stefan agrees, AFAIU).  So there should
> > be no argument anymore about the possibility; it's just a matter of
> > Someone sitting down and coding the darn thing.  Like everything else
> > in Emacs.
> 
> I'd be glad to help, if I knew what the interface/input/output should
> be.  But I'm guessing that is half the work.

I already did that half ;-)  Here's a simple Makefile I use to build
(almost) all the grammar libraries:

  PARSER_NAME = $(notdir $(abspath $(CURDIR)/..))
  DLL = $(addsuffix .dll,$(addprefix lib,$(PARSER_NAME)))

  CPPSRC := $(filter-out schema.generated.cc,$(filter-out binding.cc,$(wildcard 
*.cc)))
  SRC := $(wildcard *.c)
  SRC += $(CPPSRC)
  OBJ := $(addsuffix .o,$(basename $(SRC)))

  CC = gcc
  ifeq (, $(CPPSRC))
          CCLD = gcc
  else
          CCLD = g++
  endif
  CFLAGS = -O2 -I.
  CXXFLAGS = -O2 -I.

  all: $(DLL)

  $(DLL): $(OBJ)
          $(CCLD) $(LDFLAGS) -shared $^ $(LDLIBS) -ltree-sitter -o $@

This is for Windows, thus "DLL" and stuff, not .so.  Also, Posix
platforms need -fPIC compiler switch.

There are a couple of grammars that need a slightly more complex
approach, because their repositories produce more than one shared
library.  One notable example is tree-sitter-typescript (which Emacs
uses).

HTH



reply via email to

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