Skip to content

Commit

Permalink
Merge commit 'a13f2d1ee9609cc5c4c8ffce9640c353b77a24d8'
Browse files Browse the repository at this point in the history
# Conflicts:
#	vendored_parsers/tree-sitter-scala/queries/scala/highlights.scm
  • Loading branch information
hugo-vrijswijk committed Jul 23, 2024
2 parents 78650c3 + a13f2d1 commit 20db428
Show file tree
Hide file tree
Showing 49 changed files with 516,828 additions and 490,637 deletions.
39 changes: 39 additions & 0 deletions vendored_parsers/tree-sitter-scala/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,toml,yml,gyp}]
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.rs]
indent_style = space
indent_size = 4

[*.{c,cc,h}]
indent_style = space
indent_size = 4

[*.{py,pyi}]
indent_style = space
indent_size = 4

[*.swift]
indent_style = space
indent_size = 4

[*.go]
indent_style = tab
indent_size = 8

[Makefile]
indent_style = tab
indent_size = 8
40 changes: 23 additions & 17 deletions vendored_parsers/tree-sitter-scala/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
- master
jobs:
changedfiles:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
all: ${{ steps.changes.outputs.all}}
c: ${{ steps.changes.outputs.c }}
gen: ${{ steps.changes.outputs.gen }}
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10

Expand All @@ -30,42 +30,47 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04, macos-latest, windows-2019]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10

- name: checkout scala/scala
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: scala/scala
ref: v2.13.10
ref: v2.13.14
path: scala_scala

- name: checkout lampepfl/dotty
- name: checkout scala/scala3
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: lampepfl/dotty
ref: 3.3.0
repository: scala/scala3
ref: 3.5.0-RC2
path: dotty

- name: checkout lichess-org/lila
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v4
with:
repository: lichess-org/lila
ref: 83e61b9ef617164fe1d3a5112fcc611d0e5a7ea9
path: lila

- name: checkout nvim-treesitter/nvim-treesitter
if: ${{ runner.os == 'Linux' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: nvim-treesitter/nvim-treesitter
path: nvim_treesitter

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18

- name: Test C stack code
run: gcc test/test-stack.c -o a.out && ./a.out
node-version: 20

- name: Generate parser from scratch and test it
if: ${{ runner.os == 'Linux' || needs.changedfiles.outputs.c }}
Expand Down Expand Up @@ -93,6 +98,7 @@ jobs:
env:
SCALA_SCALA_DIR: scala_scala
DOTTY_DIR: dotty
LILA_DIR: lila
run: script/smoke_test.sh

- name: copy nvim-treesitter queries
Expand All @@ -102,7 +108,7 @@ jobs:

- name: Check if queries are out of sync with nvim-treesitter
if: ${{ runner.os == 'Linux' }}
uses: tj-actions/verify-changed-files@v13
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Parser fuzzing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: vigoux/tree-sitter-fuzz-action@v1
with:
language: scala
Expand Down
10 changes: 7 additions & 3 deletions vendored_parsers/tree-sitter-scala/.github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:

jobs:
check-and-sync:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
all: ${{ steps.changes.outputs.all}}
c: ${{ steps.changes.outputs.c }}
steps:
- name: checkout tree-sitter-scala
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10

Expand All @@ -27,14 +27,18 @@ jobs:
npm run format
- name: Check for changes
uses: tj-actions/verify-changed-files@v13
uses: tj-actions/verify-changed-files@v19
id: verify-changed-files
with:
files: |
bindings/c/tree-sitter-scala.h
bindings/c/tree-sitter-scala.pc.in
grammar.js
src/grammar.json
src/node-types.json
src/parser.c
src/tree_sitter/alloc.h
src/tree_sitter/array.h
src/tree_sitter/parser.h
- name: Commit changes if necessary
Expand Down
6 changes: 3 additions & 3 deletions vendored_parsers/tree-sitter-scala/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "tree-sitter-scala"
description = "scala grammar for the tree-sitter parsing library"
version = "0.20.0"
version = "0.22.0"
keywords = ["incremental", "parsing", "scala"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-scala"
edition = "2018"
edition = "2021"
license = "MIT"

build = "bindings/rust/build.rs"
Expand All @@ -20,7 +20,7 @@ include = [
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = "0.20.7"
tree-sitter = "0.22.6"

[build-dependencies]
cc = "1.0"
112 changes: 112 additions & 0 deletions vendored_parsers/tree-sitter-scala/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
VERSION := 0.0.1

LANGUAGE_NAME := tree-sitter-scala

# repository
SRC_DIR := src

PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin 2>/dev/null)

ifeq ($(PARSER_URL),)
PARSER_URL := $(subst .git,,$(PARSER_REPO_URL))
ifeq ($(shell echo $(PARSER_URL) | grep '^[a-z][-+.0-9a-z]*://'),)
PARSER_URL := $(subst :,/,$(PARSER_URL))
PARSER_URL := $(subst git@,https://,$(PARSER_URL))
endif
endif

TS ?= tree-sitter

# ABI versioning
SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION)))
SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION)))

# install directory layout
PREFIX ?= /usr/local
INCLUDEDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
PCLIBDIR ?= $(LIBDIR)/pkgconfig

# 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
override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC

# OS-specific bits
ifeq ($(OS),Windows_NT)
$(error "Windows is not supported")
else ifeq ($(shell uname),Darwin)
SOEXT = dylib
SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib
SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib
LINKSHARED := $(LINKSHARED)-dynamiclib -Wl,
ifneq ($(ADDITIONAL_LIBS),)
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS),
endif
LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_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 ($(ADDITIONAL_LIBS),)
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS)
endif
LINKSHARED := $(LINKSHARED)-soname,lib$(LANGUAGE_NAME).so.$(SONAME_MAJOR)
endif
ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),)
PCLIBDIR := $(PREFIX)/libdata/pkgconfig
endif

all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc

lib$(LANGUAGE_NAME).a: $(OBJS)
$(AR) $(ARFLAGS) $@ $^

lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS)
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
ifneq ($(STRIP),)
$(STRIP) $@
endif

$(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in
sed -e 's|@URL@|$(PARSER_URL)|' \
-e 's|@VERSION@|$(VERSION)|' \
-e 's|@LIBDIR@|$(LIBDIR)|' \
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
-e 's|@REQUIRES@|$(REQUIRES)|' \
-e 's|@ADDITIONAL_LIBS@|$(ADDITIONAL_LIBS)|' \
-e 's|=$(PREFIX)|=$${prefix}|' \
-e 's|@PREFIX@|$(PREFIX)|' $< > $@

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

install: all
install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)'
install -m644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER)
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT)

uninstall:
$(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \
'$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc

clean:
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT)

test:
$(TS) test

.PHONY: all install uninstall clean test
13 changes: 12 additions & 1 deletion vendored_parsers/tree-sitter-scala/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# tree-sitter-scala

[![Test the grammar](https://github.com/tree-sitter/tree-sitter-scala/actions/workflows/ci.yml/badge.svg)](https://github.com/tree-sitter/tree-sitter-scala/actions/workflows/ci.yml)
[![CI][ci]](https://github.com/tree-sitter/tree-sitter-scala/actions/workflows/ci.yml)
[![discord][discord]](https://discord.gg/w7nTvsVJhm)
[![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org)
[![crates][crates]](https://crates.io/crates/tree-sitter-scala)
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-scala)

Scala grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter)
covering both Scala 2 and 3.

## References

_Scala 2_

- [The Scala 2 Language Specification](https://www.scala-lang.org/files/archive/spec/2.13/)
- [Scala 2 Syntax Summary](https://www.scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html)

Expand All @@ -19,3 +24,9 @@ _Scala 3_

Please refer to the [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on
getting set up.

[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-scala/ci.yml?logo=github&label=CI
[discord]: https://img.shields.io/discord/1063097320771698699?logo=discord&label=discord
[matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix
[npm]: https://img.shields.io/npm/v/tree-sitter-scala?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-scala?logo=rust
14 changes: 8 additions & 6 deletions vendored_parsers/tree-sitter-scala/binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"targets": [
{
"target_name": "tree_sitter_scala_binding",
"dependencies": [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
"include_dirs": [
"<!(node -e \"require('nan')\")",
"src"
"src",
],
"sources": [
"src/parser.c",
"bindings/node/binding.cc",
"src/scanner.c"
"src/parser.c",
"src/scanner.c",
],
"cflags_c": [
"-std=c99",
]
"-std=c11",
],
}
]
}
16 changes: 16 additions & 0 deletions vendored_parsers/tree-sitter-scala/bindings/c/tree-sitter-scala.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef TREE_SITTER_SCALA_H_
#define TREE_SITTER_SCALA_H_

typedef struct TSLanguage TSLanguage;

#ifdef __cplusplus
extern "C" {
#endif

const TSLanguage *tree_sitter_scala(void);

#ifdef __cplusplus
}
#endif

#endif // TREE_SITTER_SCALA_H_
Loading

0 comments on commit 20db428

Please sign in to comment.