Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #3277

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/generate/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ impl Generator {

add_line!(
self,
"TS_PUBLIC const TSLanguage *{language_function_name}() {{",
"TS_PUBLIC const TSLanguage *{language_function_name}(void) {{",
);
indent!(self);
add_line!(self, "static const TSLanguage language = {{");
Expand Down
12 changes: 7 additions & 5 deletions cli/src/generate/templates/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ INCLUDEDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
PCLIBDIR ?= $(LIBDIR)/pkgconfig

# object files
OBJS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c))
# source/object files
PARSER := $(SRC_DIR)/parser.c
EXTRAS := $(filter-out $(PARSER),$(wildcard $(SRC_DIR)/*.c))
OBJS := $(patsubst %.c,%.o,$(PARSER) $(EXTRAS))

# flags
ARFLAGS := rcs
ARFLAGS ?= rcs
override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC

# OS-specific bits
Expand Down Expand Up @@ -81,8 +83,8 @@ $(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in
-e 's|=$(PREFIX)|=$${prefix}|' \
-e 's|@PREFIX@|$(PREFIX)|' $< > $@

$(SRC_DIR)/parser.c: grammar.js
$(TS) generate --no-bindings
$(PARSER): $(SRC_DIR)/grammar.json
$(TS) generate --no-bindings $^

install: all
install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)'
Expand Down
6 changes: 3 additions & 3 deletions docs/section-3-creating-parsers.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ Finally, you must define five functions with specific names, based on your langu
#### Create

```c
void * tree_sitter_my_language_external_scanner_create() {
void *tree_sitter_my_language_external_scanner_create(void) {
// ...
}
```
Expand Down Expand Up @@ -891,7 +891,7 @@ For example, assuming you wanted to allocate 100 bytes for your scanner, you'd d

// ...

void* tree_sitter_my_language_external_scanner_create() {
void *tree_sitter_my_language_external_scanner_create(void) {
return ts_calloc(100, 1); // or ts_malloc(100)
}

Expand Down Expand Up @@ -921,7 +921,7 @@ enum TokenType {

// Create the array in your create function

void* tree_sitter_my_language_external_scanner_create() {
void *tree_sitter_my_language_external_scanner_create(void) {
return ts_calloc(1, sizeof(Array(int)));

// or if you want to zero out the memory yourself
Expand Down