Skip to content

Commit

Permalink
Merge commit 'b5dbafd164af7113e208de9b36068046f5ce8678' into f_sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed May 14, 2024
2 parents d92b65c + b5dbafd commit ac5af62
Show file tree
Hide file tree
Showing 61 changed files with 361,227 additions and 602,324 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn main() {
TreeSitterParser {
name: "tree-sitter-f-sharp",
src_dir: "vendored_parsers/tree-sitter-f-sharp-src",
extra_files: vec!["scanner.cc"],
extra_files: vec!["scanner.c"],
},
TreeSitterParser {
name: "tree-sitter-gleam",
Expand Down
43 changes: 43 additions & 0 deletions vendored_parsers/tree-sitter-f-sharp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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

[*.fs]
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 = 2

[*.{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
20 changes: 20 additions & 0 deletions vendored_parsers/tree-sitter-f-sharp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
'env': {
'commonjs': true,
'es2021': true,
},
'extends': 'google',
'overrides': [
],
'parserOptions': {
'ecmaVersion': 'latest',
'sourceType': 'module',
},
'rules': {
'indent': ['error', 2, {'SwitchCase': 1}],
'max-len': [
'error',
{'code': 120, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true},
],
},
};
11 changes: 11 additions & 0 deletions vendored_parsers/tree-sitter-f-sharp/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* text eol=lf

src/*.json linguist-generated
src/parser.c linguist-generated
src/tree_sitter/* linguist-generated

bindings/** linguist-vendored
binding.gyp linguist-vendored
setup.py linguist-vendored
Makefile linguist-vendored
Package.swift linguist-vendored
55 changes: 42 additions & 13 deletions vendored_parsers/tree-sitter-f-sharp/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
name: Build/test
name: CI

on:
pull_request:
push:
branches:
- "develop"
- "main"
branches: ["main"]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.os }}
name: Test parser
runs-on: ${{matrix.os}}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- uses: actions/checkout@v4
- uses: tree-sitter/setup-action/cli@v1
- uses: tree-sitter/parser-test-action@v2
with:
generate: ${{runner.os == 'Linux'}}
fuzz:
name: Fuzz parser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Checkout repository
uses: actions/checkout@v4
with:
node-version: 16
- run: npm install
- run: npm test
fetch-depth: 2
- name: Check for scanner changes
id: scanner-changes
run: |-
if git diff --quiet HEAD^ -- src/scanner.c; then
printf 'changed=false\n' >> "$GITHUB_OUTPUT"
else
printf 'changed=true\n' >> "$GITHUB_OUTPUT"
fi
- name: Fuzz parser
uses: tree-sitter/fuzz-action@v4
if: steps.scanner-changes.outputs.changed == 'true'
42 changes: 35 additions & 7 deletions vendored_parsers/tree-sitter-f-sharp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
Cargo.lock
package-lock.json
node_modules
build
*.log
examples/*
*.o
# Rust artifacts
/Cargo.lock
/target/

# Node artifacts
/build/
/node_modules/

# Swift artifacts
/.build/

# Python artifacts
/dist/
*.egg-info
*.whl

# Zig artifacts
/zig-cache/
/zig-out/

# C artifacts
*.a
*.so
*.so.*
*.dylib
*.dll
*.pc

# Example dirs
/examples/*/

# Grammar volatiles
dsl.d.ts
*.wasm
*.obj
*.o
17 changes: 17 additions & 0 deletions vendored_parsers/tree-sitter-f-sharp/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bindings/c
bindings/go
bindings/python
bindings/rust
bindings/swift
Cargo.toml
Makefile
examples
pyproject.toml
setup.py
test
.editorconfig
.github
.gitignore
.gitattributes
.gitmodules
.npmignore
6 changes: 3 additions & 3 deletions vendored_parsers/tree-sitter-f-sharp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.0.1"
keywords = ["incremental", "parsing", "fsharp"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/nsidorenco/tree-sitter-fsharp"
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"
tree-sitter = ">=0.21.0"

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

LANGUAGE_NAME := tree-sitter-fsharp

# 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

# object files
OBJS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c))

# 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)|' $< > $@

$(SRC_DIR)/parser.c: grammar.js
$(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
48 changes: 48 additions & 0 deletions vendored_parsers/tree-sitter-f-sharp/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// swift-tools-version:5.3
import PackageDescription

let package = Package(
name: "TreeSitterFsharp",
platforms: [.macOS(.v10_13), .iOS(.v11)],
products: [
.library(name: "TreeSitterFsharp", targets: ["TreeSitterFsharp"]),
],
dependencies: [],
targets: [
.target(name: "TreeSitterFsharp",
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",
// NOTE: if your language has an external scanner, add it here.
],
resources: [
.copy("queries")
],
publicHeadersPath: "bindings/swift",
cSettings: [.headerSearchPath("src")])
],
cLanguageStandard: .c11
)
Loading

0 comments on commit ac5af62

Please sign in to comment.