forked from getgrit/gritql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: copy "resources/language-submodules/tree-sitter-kotlin/" -> "res…
…ources/language-metavariables/tree-sitter-kotlin/" fixes getgrit#570
- Loading branch information
1 parent
ba69382
commit 8e6ef11
Showing
53 changed files
with
709,310 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
resources/language-metavariables/tree-sitter-kotlin/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
resources/language-metavariables/tree-sitter-kotlin/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "tree-sitter-kotlin" | ||
description = "Kotlin grammar for the tree-sitter parsing library" | ||
version = "0.3.9" | ||
keywords = ["incremental", "parsing", "kotlin"] | ||
categories = ["parsing", "text-editors"] | ||
repository = "https://github.com/fwcd/tree-sitter-kotlin" | ||
edition = "2018" | ||
license = "MIT" | ||
readme = "bindings/rust/README.md" | ||
|
||
build = "bindings/rust/build.rs" | ||
include = [ | ||
"bindings/rust/*", | ||
"grammar.js", | ||
"queries/*", | ||
"src/*", | ||
] | ||
|
||
[lib] | ||
path = "bindings/rust/lib.rs" | ||
|
||
[dependencies] | ||
tree-sitter = ">= 0.21, < 0.23" | ||
|
||
[build-dependencies] | ||
cc = "1.0" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 fwcd | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
114 changes: 114 additions & 0 deletions
114
resources/language-metavariables/tree-sitter-kotlin/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
VERSION := 0.3.9 | ||
|
||
# Repository | ||
SRC_DIR := src | ||
|
||
PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin ) | ||
|
||
ifeq (, $(PARSER_NAME)) | ||
PARSER_NAME := $(shell basename $(PARSER_REPO_URL)) | ||
PARSER_NAME := $(subst tree-sitter-,,$(PARSER_NAME)) | ||
PARSER_NAME := $(subst .git,,$(PARSER_NAME)) | ||
endif | ||
|
||
ifeq (, $(PARSER_URL)) | ||
PARSER_URL := $(subst :,/,$(PARSER_REPO_URL)) | ||
PARSER_URL := $(subst git@,https://,$(PARSER_URL)) | ||
PARSER_URL := $(subst .git,,$(PARSER_URL)) | ||
endif | ||
|
||
UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z ) | ||
|
||
# install directory layout | ||
PREFIX ?= /usr/local | ||
INCLUDEDIR ?= $(PREFIX)/include | ||
LIBDIR ?= $(PREFIX)/lib | ||
PCLIBDIR ?= $(LIBDIR)/pkgconfig | ||
|
||
# collect C++ sources, and link if necessary | ||
CPPSRC := $(wildcard $(SRC_DIR)/*.cc) | ||
|
||
ifeq (, $(CPPSRC)) | ||
ADDITIONALLIBS := | ||
else | ||
ADDITIONALLIBS := -lc++ | ||
endif | ||
|
||
# collect sources | ||
SRC := $(wildcard $(SRC_DIR)/*.c) | ||
SRC += $(CPPSRC) | ||
OBJ := $(addsuffix .o,$(basename $(SRC))) | ||
|
||
# ABI versioning | ||
SONAME_MAJOR := 0 | ||
SONAME_MINOR := 0 | ||
|
||
CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) | ||
CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR) | ||
override CFLAGS += -std=gnu99 -fPIC | ||
override CXXFLAGS += -fPIC | ||
|
||
# OS-specific bits | ||
ifeq ($(shell uname),Darwin) | ||
SOEXT = dylib | ||
SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib | ||
SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib | ||
LINKSHARED := $(LINKSHARED)-dynamiclib -Wl, | ||
ifneq ($(ADDITIONALLIBS),) | ||
LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), | ||
endif | ||
LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/libtree-sitter-$(PARSER_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks | ||
else | ||
SOEXT = so | ||
SOEXTVER_MAJOR = so.$(SONAME_MAJOR) | ||
SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR) | ||
LINKSHARED := $(LINKSHARED)-shared -Wl, | ||
ifneq ($(ADDITIONALLIBS),) | ||
LINKSHARED := $(LINKSHARED)$(ADDITIONALLIBS), | ||
endif | ||
LINKSHARED := $(LINKSHARED)-soname,libtree-sitter-$(PARSER_NAME).so.$(SONAME_MAJOR) | ||
endif | ||
ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly)) | ||
PCLIBDIR := $(PREFIX)/libdata/pkgconfig | ||
endif | ||
|
||
all: libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXTVER) bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc | ||
|
||
libtree-sitter-$(PARSER_NAME).a: $(OBJ) | ||
$(AR) rcs $@ $^ | ||
|
||
libtree-sitter-$(PARSER_NAME).$(SOEXTVER): $(OBJ) | ||
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@ | ||
ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXT) | ||
ln -sf $@ libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) | ||
|
||
bindings/c/$(PARSER_NAME).h: | ||
sed -e 's|@UPPER_PARSERNAME@|$(UPPER_PARSER_NAME)|' \ | ||
-e 's|@PARSERNAME@|$(PARSER_NAME)|' \ | ||
bindings/c/tree-sitter.h.in > $@ | ||
|
||
bindings/c/tree-sitter-$(PARSER_NAME).pc: | ||
sed -e 's|@LIBDIR@|$(LIBDIR)|;s|@INCLUDEDIR@|$(INCLUDEDIR)|;s|@VERSION@|$(VERSION)|' \ | ||
-e 's|=$(PREFIX)|=$${prefix}|' \ | ||
-e 's|@PREFIX@|$(PREFIX)|' \ | ||
-e 's|@ADDITIONALLIBS@|$(ADDITIONALLIBS)|' \ | ||
-e 's|@PARSERNAME@|$(PARSER_NAME)|' \ | ||
-e 's|@PARSERURL@|$(PARSER_URL)|' \ | ||
bindings/c/tree-sitter.pc.in > $@ | ||
|
||
install: all | ||
install -d '$(DESTDIR)$(LIBDIR)' | ||
install -m755 libtree-sitter-$(PARSER_NAME).a '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).a | ||
install -m755 libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER) | ||
ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) | ||
ln -sf libtree-sitter-$(PARSER_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/libtree-sitter-$(PARSER_NAME).$(SOEXT) | ||
install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter | ||
install -m644 bindings/c/$(PARSER_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/ | ||
install -d '$(DESTDIR)$(PCLIBDIR)' | ||
install -m644 bindings/c/tree-sitter-$(PARSER_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/ | ||
|
||
clean: | ||
rm -f $(OBJ) libtree-sitter-$(PARSER_NAME).a libtree-sitter-$(PARSER_NAME).$(SOEXT) libtree-sitter-$(PARSER_NAME).$(SOEXTVER_MAJOR) libtree-sitter-$(PARSER_NAME).$(SOEXTVER) | ||
rm -f bindings/c/$(PARSER_NAME).h bindings/c/tree-sitter-$(PARSER_NAME).pc | ||
|
||
.PHONY: all install clean |
47 changes: 47 additions & 0 deletions
47
resources/language-metavariables/tree-sitter-kotlin/Package.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// swift-tools-version:5.3 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "TreeSitterKotlin", | ||
products: [ | ||
.library(name: "TreeSitterKotlin", targets: ["TreeSitterKotlin"]), | ||
], | ||
dependencies: [], | ||
targets: [ | ||
.target(name: "TreeSitterKotlin", | ||
path: ".", | ||
exclude: [ | ||
"Cargo.toml", | ||
"Makefile", | ||
"binding.gyp", | ||
"bindings/c", | ||
"bindings/go", | ||
"bindings/node", | ||
"bindings/python", | ||
"bindings/rust", | ||
"prebuilds", | ||
"grammar.js", | ||
"package.json", | ||
"package-lock.json", | ||
"pyproject.toml", | ||
"setup.py", | ||
"test", | ||
"examples", | ||
".editorconfig", | ||
".github", | ||
".gitignore", | ||
".gitattributes", | ||
".gitmodules", | ||
], | ||
sources: [ | ||
"src/parser.c", | ||
"src/scanner.c", | ||
], | ||
resources: [ | ||
.copy("queries") | ||
], | ||
publicHeadersPath: "bindings/swift", | ||
cSettings: [.headerSearchPath("src")]) | ||
], | ||
cLanguageStandard: .c11 | ||
) |
66 changes: 66 additions & 0 deletions
66
resources/language-metavariables/tree-sitter-kotlin/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Kotlin Grammar for Tree-sitter | ||
|
||
[![Build](https://github.com/fwcd/tree-sitter-kotlin/actions/workflows/build.yml/badge.svg)](https://github.com/fwcd/tree-sitter-kotlin/actions/workflows/build.yml) | ||
[![NPM](https://img.shields.io/npm/v/tree-sitter-kotlin)](https://www.npmjs.com/package/tree-sitter-kotlin) | ||
[![crates.io](https://img.shields.io/crates/v/tree-sitter-kotlin)](https://crates.io/crates/tree-sitter-kotlin) | ||
|
||
[Kotlin](https://kotlinlang.org) language grammar for [Tree-sitter](http://tree-sitter.github.io/tree-sitter/). You can try it out directly [on the web](https://fwcd.github.io/tree-sitter-kotlin). | ||
|
||
![Icon](Icon128.png) | ||
|
||
The grammar is based on the [official language grammar](https://kotlinlang.org/docs/reference/grammar.html). | ||
|
||
## Project Structure | ||
|
||
| File | Description | | ||
| ---- | ----------- | | ||
| grammar.js | The Tree-sitter grammar | | ||
| grammar-reference.js | A direct translation of the Kotlin language grammar that is, however, ambiguous to Tree-sitter | | ||
| src | The generated parser | | ||
|
||
## Setup | ||
|
||
>`npm install` | ||
## Development | ||
|
||
### Compilation | ||
|
||
To (re-)compile the grammar, run: | ||
|
||
>`npm run generate` | ||
Note that the grammar is written completely in JavaScript (`grammar.js`), the other source files are generated by `tree-sitter`. | ||
|
||
### Testing | ||
|
||
To run the unit tests, run: | ||
|
||
>`npm run test` | ||
## WebAssembly | ||
|
||
### Compilation | ||
|
||
First make sure to have [Emscripten](https://emscripten.org/) installed. If you use Homebrew, you can `brew install emscripten`. Then run: | ||
|
||
>`npm run build-wasm` | ||
### Playground | ||
|
||
After compiling the grammar to WebAssembly, you can invoke | ||
|
||
>`npm run playground` | ||
to launch an interactive editing environment that displays the parsed syntax tree on-the-fly in the browser. You can also view a deployed version of this playground [on the web](https://fwcd.github.io/tree-sitter-kotlin). | ||
|
||
![Screenshot](playground-screenshot.png) | ||
|
||
## Documentation | ||
|
||
More documentation on how to create Tree-sitter grammars [can be found here](https://tree-sitter.github.io/tree-sitter/creating-parsers). | ||
|
||
## See also | ||
|
||
* [Kotlin Language Server](https://github.com/fwcd/kotlin-language-server) for code completion, diagnostics and more | ||
* [Kotlin Debug Adapter](https://github.com/fwcd/kotlin-debug-adapter) for JVM debugging support |
30 changes: 30 additions & 0 deletions
30
resources/language-metavariables/tree-sitter-kotlin/binding.gyp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"targets": [ | ||
{ | ||
"target_name": "tree_sitter_kotlin_binding", | ||
"dependencies": [ | ||
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except", | ||
], | ||
"include_dirs": [ | ||
"src", | ||
], | ||
"sources": [ | ||
"bindings/node/binding.cc", | ||
"src/parser.c", | ||
"src/scanner.c" | ||
], | ||
"conditions": [ | ||
["OS!='win'", { | ||
"cflags_c": [ | ||
"-std=c11", | ||
], | ||
}, { # OS == "win" | ||
"cflags_c": [ | ||
"/std:c11", | ||
"/utf-8", | ||
], | ||
}], | ||
], | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
resources/language-metavariables/tree-sitter-kotlin/bindings/c/tree-sitter-kotlin.pc.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prefix=@PREFIX@ | ||
libdir=@LIBDIR@ | ||
includedir=@INCLUDEDIR@ | ||
|
||
Name: tree-sitter-kotlin | ||
Description: Kotlin grammar for tree-sitter | ||
URL: @URL@ | ||
Version: @VERSION@ | ||
Requires: @REQUIRES@ | ||
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-kotlin | ||
Cflags: -I${includedir} |
16 changes: 16 additions & 0 deletions
16
resources/language-metavariables/tree-sitter-kotlin/bindings/c/tree-sitter.h.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef TREE_SITTER_@UPPER_PARSERNAME@_H_ | ||
#define TREE_SITTER_@UPPER_PARSERNAME@_H_ | ||
|
||
#include <tree_sitter/parser.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
extern TSLanguage *tree_sitter_@PARSERNAME@(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // TREE_SITTER_@UPPER_PARSERNAME@_H_ |
Oops, something went wrong.