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

Rewrite the grammar once again #120

Merged
merged 1 commit into from
May 4, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions .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
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/src/** linguist-vendored
/examples/* linguist-vendored
/test/libs/* linguist-vendored
/src/parser.c -diff
/src/grammar.json -diff
/src/node-types.json -diff
33 changes: 33 additions & 0 deletions .github/workflows/assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish assets

on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- run: nix -L build .#parser-src
- name: Upload parser sources
uses: actions/upload-artifact@v4
with:
name: tree-sitter-haskell-src
path: result/src

- run: nix -L build .#parser-wasm
- name: Upload wasm binary
uses: actions/upload-artifact@v4
with:
name: tree-sitter-haskell-wasm
path: result/tree-sitter-haskell.wasm
50 changes: 34 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ name: CI

on:
push:
branches:
- "**"
branches: [main]
tags: ['**']
pull_request:
types:
- opened
- synchronize
types: [opened, synchronize]

jobs:
test:
name: test / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: test / ${{matrix.os}}
runs-on: ${{matrix.os}}
if: github.event.pull_request.merged == true || github.event.action != 'closed'
strategy:
fail-fast: false
matrix:
Expand All @@ -27,20 +26,39 @@ jobs:
with:
node-version: '18'

# - name: Install emscripten
# uses: mymindstorm/setup-emsdk@v10
# with:
# version: '2.0.24'
- name: Install emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: '3.1.47'

- name: Build tree-sitter-haskell
- name: Build dependencies
run: npm install

- name: Run tests
run: npm test

- name: Parse examples
run: npm run examples
- name: Parse libraries
run: npm run libs

- name: Parse libraries with wasm
run: npm run libs-wasm

- name: Run fuzzer
if: ${{matrix.os == 'ubuntu-latest'}}
uses: tree-sitter/fuzz-action@v4

# - name: Parse examples with web binding
# run: npm run examples-wasm
legacy:
permissions:
contents: write
id-token: write
needs: test
if: github.ref_type == 'tag'
uses: ./.github/workflows/legacy.yml

release:
permissions:
contents: read
id-token: write
needs: test
if: github.ref_type == 'tag'
uses: ./.github/workflows/release.yml
36 changes: 36 additions & 0 deletions .github/workflows/legacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update legacy branch

on:
workflow_call:

jobs:
commit:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{github.ref}}
- uses: actions/checkout@v4
with:
ref: master

- name: Reset worktree to ${{github.ref_name}}
run: |
git restore --source=${{github.ref}} .
git restore .gitignore

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Generate parser
run: nix -L run .#gen-parser

- name: Commit and push to legacy branch
uses: actions-js/push@v1.4
with:
github_token: ${{secrets.GITHUB_TOKEN}}
message: "Legacy release ${{github.ref_name}}"
branch: master
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Publish package

on:
push:
tags: ["*"]
workflow_call:

concurrency:
group: ${{github.workflow}}-${{github.ref}}
Expand All @@ -17,3 +16,7 @@ jobs:
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
secrets:
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_TOKEN}}
pypi:
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
secrets:
PYPI_API_TOKEN: ${{secrets.PYPI_TOKEN}}
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
node_modules
build
/src/parser.c
/dist-newstyle
/result
/test/libs/*
!/test/libs/.gitkeep
/build/
/target/
/.lib/
/node_modules/
*.log
package-lock.json
repos
examples/*
!examples/.gitkeep
.gdb_history
*.o
*.so
/.build/
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

38 changes: 13 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[package]
name = "tree-sitter-haskell"
description = "haskell grammar for the tree-sitter parsing library"
version = "0.15.0"
version = "1.0.0"
keywords = ["incremental", "parsing", "haskell"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-haskell"
edition = "2018"
license = "MIT"
edition = "2021"

build = "bindings/rust/build.rs"
include = [
Expand All @@ -19,6 +18,24 @@ include = [
[lib]
path = "bindings/rust/lib.rs"

[[test]]
name = "parse-test"
path = "test/rust/parse-test.rs"

[[bin]]
name = "parse"
path = "test/rust/parse.rs"
test = false
bench = false
doc = false

[[bin]]
name = "show"
path = "test/rust/show.rs"
test = false
bench = false
doc = false

[dependencies]
tree-sitter = "0.20"

Expand Down