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 #333

Merged
merged 6 commits into from
May 3, 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
15 changes: 11 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
/src/** linguist-vendored
/script/** text eol=lf
/src/parser.c -diff
/src/grammar.json -diff
* text eol=lf

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

bindings/** linguist-generated
binding.gyp linguist-generated
setup.py linguist-generated
Makefile linguist-generated
Package.swift linguist-generated
148 changes: 126 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,139 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- master
branches: [master]
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp
pull_request:
branches:
- "**" # Don't trust forks because miners
paths:
- grammar.js
- src/**
- test/**
- bindings/**
- binding.gyp

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-14, ubuntu-latest]
os: [ubuntu-latest, windows-latest, macos-14]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up tree-sitter
uses: tree-sitter/setup-action/cli@v1
- name: Set up examples
run: |-
git clone https://github.com/JamesNK/Newtonsoft.Json examples/Newtonsoft.Json --single-branch --depth=1 --filter=blob:none
git clone https://github.com/nunit/nunit examples/nunit --single-branch --depth=1 --filter=blob:none
git clone https://github.com/OrchardCMS/orchard examples/orchard --single-branch --depth=1 --filter=blob:none
git clone https://github.com/microsoft/PowerToys examples/PowerToys --single-branch --depth=1 --filter=blob:none
- name: Run tests
uses: tree-sitter/parser-test-action@v2
with:
node-version: 18
- run: npm install
- run: npm test

test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
test-rust: ${{runner.os == 'Linux'}}
- name: Parse examples
uses: tree-sitter/parse-action@v4
id: test
with:
node-version: 18
- run: npm install
- run: npm run-script test-windows
files: |
examples/**/*.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ExceptionHandlingAsyncTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ExceptionHandlingTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/FloatAsyncTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/FloatTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/MiscAsyncTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/MiscTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ParseAsyncTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ParseTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ReadAsyncTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/JsonTextReaderTests/ReadTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Linq/DynamicTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Linq/JTokenTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Linq/JsonPath/JPathExecuteTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Schema/JsonSchemaSpecTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Serialization/ContractResolverTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Serialization/SerializationErrorHandlingTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Serialization/WebApiIntegrationTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/TestFixtureBase.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/TestObjects/DefaultValueAttributeTestClass.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/TestObjects/Organization/Person.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/TestObjects/Pair.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Utilities/DateTimeUtilsTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Utilities/EnumUtilsTests.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Bson/BsonBinaryWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Bson/BsonWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Converters/JavaScriptDateTimeConverter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Converters/UnixDateTimeConverter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonConvert.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonException.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonReader.Async.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonReader.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonReaderException.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonSerializationException.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonTextReader.Async.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonTextReader.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonTextWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonValidatingReader.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonWriter.Async.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/JsonWriterException.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/IJEnumerable.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JContainer.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JObject.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JToken.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JTokenWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JValue.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JsonPath/FieldMultipleFilter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Linq/JsonPath/QueryExpression.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Schema/JsonSchemaException.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Schema/JsonSchemaNode.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/DefaultContractResolver.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/DefaultSerializationBinder.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonDictionaryContract.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonObjectContract.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonPrimitiveContract.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/JsonTypeReflector.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Serialization/TraceJsonWriter.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Utilities/DictionaryWrapper.cs
!examples/Newtonsoft.Json/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs
!examples/PowerToys/src/modules/MouseWithoutBorders/App/Class/InputHook.cs
!examples/PowerToys/src/settings-ui/Settings.UI.Library/Attributes/CmdConfigureIgnoreAttribute.cs
!examples/PowerToys/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs
!examples/nunit/src/NUnitFramework/framework/Attributes/TimeoutAttribute.cs
!examples/nunit/src/NUnitFramework/framework/Compatibility/LongLivedMarshalByRefObject.cs
!examples/nunit/src/NUnitFramework/framework/Constraints/MsgUtils.cs
!examples/nunit/src/NUnitFramework/framework/Internal/DisposeHelper.cs
!examples/nunit/src/NUnitFramework/framework/Internal/OSPlatform.cs
!examples/nunit/src/NUnitFramework/framework/Internal/Reflect.cs
!examples/nunit/src/NUnitFramework/framework/Internal/Results/TestResult.cs
!examples/nunit/src/NUnitFramework/framework/Internal/TestExecutionContext.cs
!examples/nunit/src/NUnitFramework/nunitlite/Options.cs
!examples/nunit/src/NUnitFramework/tests/Assertions/WarningTests.cs
!examples/nunit/src/NUnitFramework/tests/Attributes/ApartmentAttributeTests.cs
!examples/nunit/src/NUnitFramework/tests/Attributes/DerivedPropertyAttributeTests.cs
!examples/nunit/src/NUnitFramework/tests/Attributes/RequiresThreadAttributeTests.cs
!examples/nunit/src/NUnitFramework/tests/Attributes/SingleThreadedFixtureTests.cs
!examples/nunit/src/NUnitFramework/tests/Internal/EventQueueTests.cs
!examples/nunit/src/NUnitFramework/tests/SynchronizationContextTests.cs
!examples/nunit/src/NUnitFramework/tests/Syntax/PathConstraintTests.cs
21 changes: 21 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Fuzz Parser

on:
push:
branches: [master]
paths:
- src/scanner.c
pull_request:
paths:
- src/scanner.c

jobs:
fuzz:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run fuzzer
uses: tree-sitter/fuzz-action@v4
with:
tree-sitter-version: v0.22.5
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
branches: [master]
paths:
- grammar.js
pull_request:
paths:
- grammar.js

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{vars.NODE_VERSION}}
- name: Install modules
run: npm ci --legacy-peer-deps
- name: Run ESLint
run: npm run lint
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish package

on:
push:
tags: ["*"]

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

jobs:
npm:
uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
secrets:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
crates:
uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
secrets:
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
pypi:
uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
secrets:
PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
33 changes: 0 additions & 33 deletions .github/workflows/publish_crate.yml

This file was deleted.

49 changes: 37 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
# Rust artifacts
Cargo.lock
node_modules
build
npm-debug.log
package-lock.json
parser.exp
parser.lib
parser.obj
examples
!examples/.gitkeep
scanner.obj
/target/
.build/
target/

# Node artifacts
build/
prebuilds/
node_modules/
*.tgz

# Swift artifacts
.build/

# Go artifacts
go.sum
_obj/

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

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

# Example dirs
/examples/*/

# Grammar volatiles
*.wasm
*.obj
*.o
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

30 changes: 10 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
[package]
name = "tree-sitter-c-sharp"
description = "C# grammar for the tree-sitter parsing library"
version = "0.20.0"
description = "C# grammar for tree-sitter"
version = "0.21.0"
authors = [
"Damien Guard <[email protected]>",
"Max Brunsfeld <[email protected]>",
"Martin Midtgaard <[email protected]>",
"Sjoerd Langkemper <[email protected]>",
"Patrick Thomson <[email protected]>",
"Noelle Caldwell <[email protected]>",
"Douglas Creager <[email protected]>",
"Max Brunsfeld <[email protected]>",
"Amaan Qureshi <[email protected]>",
]
license = "MIT"
readme = "bindings/rust/README.md"
keywords = ["incremental", "parsing", "c-sharp"]
keywords = ["incremental", "parsing", "tree-sitter", "c-sharp"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-c-sharp"
edition = "2018"
edition = "2021"
autoexamples = false

build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]
include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]

[lib]
path = "bindings/rust/lib.rs"

[dependencies]
tree-sitter = ">= 0.19, < 0.21"
tree-sitter = ">=0.21.0"

[build-dependencies]
cc = "1.0"
cc = "1.0.96"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2023 Max Brunsfeld, Damien Guard, and contributors.
Copyright (c) 2014-2023 Max Brunsfeld, Damien Guard, Amaan Qureshi, and contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading