Skip to content

Commit eb7c965

Browse files
authored
Merge pull request #4 from merico-dev/automatically-sync-from-upstream-repo
Automatically sync from upstream repo
2 parents 8be7ee7 + 4efa8fc commit eb7c965

File tree

11 files changed

+528217
-630141
lines changed

11 files changed

+528217
-630141
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: build
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- "**" # Don't trust forks because miners
8+
9+
jobs:
10+
build:
11+
name: build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Setup Node
18+
uses: actions/setup-node@v2-beta
19+
with:
20+
node-version: '12'
21+
22+
- name: Display Node versions
23+
run: |
24+
node --version
25+
npm --version
26+
27+
- name: Install dependencies
28+
run: npm install
29+
30+
- name: Test corpus
31+
run: npm test
32+
33+
- name: Parse examples
34+
run: |
35+
PATH=$(npm bin):$PATH
36+
script/fetch-examples
37+
script/parse-examples
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish on crates.io
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
CARGO_INCREMENTAL: 0
11+
12+
jobs:
13+
publish:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Install rust
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: stable
25+
profile: minimal
26+
override: true
27+
28+
- name: Verify publish crate
29+
uses: katyo/publish-crates@v1
30+
with:
31+
dry-run: true
32+
33+
- name: Publish crate
34+
uses: katyo/publish-crates@v1
35+
with:
36+
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

Package.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// swift-tools-version:5.3
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "TreeSitterCSharp",
6+
products: [
7+
.library(name: "TreeSitterCSharp", targets: ["TreeSitterCSharp"]),
8+
],
9+
dependencies: [],
10+
targets: [
11+
.target(name: "TreeSitterCSharp",
12+
path: ".",
13+
exclude: [
14+
"binding.gyp",
15+
"bindings",
16+
"Cargo.toml",
17+
"corpus",
18+
"grammar.js",
19+
"index.js",
20+
"LICENSE",
21+
"Makefile",
22+
"package.json",
23+
"README.md",
24+
"script",
25+
"src/grammar.json",
26+
"src/node-types.json",
27+
],
28+
sources: [
29+
"src/parser.c",
30+
"src/scanner.c",
31+
],
32+
resources: [
33+
.copy("queries")
34+
],
35+
publicHeadersPath: "bindings/swift",
36+
cSettings: [.headerSearchPath("src")])
37+
]
38+
)

bindings/rust/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# tree-sitter-c-sharp
2+
3+
This crate provides a C# grammar for the [tree-sitter][] parsing library. To
4+
use this crate, add it to the `[dependencies]` section of your `Cargo.toml`
5+
file. (Note that you will probably also need to depend on the
6+
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful
7+
way.)
8+
9+
``` toml
10+
[dependencies]
11+
tree-sitter = "0.17"
12+
tree-sitter-c-sharp = "0.16"
13+
```
14+
15+
Typically, you will use the [language][language func] function to add this
16+
grammar to a tree-sitter [Parser][], and then use the parser to parse some code:
17+
18+
``` rust
19+
let code = r#"
20+
class Test {
21+
int double(int x) => x * 2;
22+
}
23+
"#;
24+
let mut parser = Parser::new();
25+
parser.set_language(tree_sitter_c_sharp::language()).expect("Error loading C# grammar");
26+
let parsed = parser.parse(code, None);
27+
```
28+
29+
If you have any questions, please reach out to us in the [tree-sitter
30+
discussions] page.
31+
32+
[Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
33+
[language func]: https://docs.rs/tree-sitter-c-sharp/*/tree_sitter_c_sharp/fn.language.html
34+
[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
35+
[tree-sitter]: https://tree-sitter.github.io/
36+
[tree-sitter crate]: https://crates.io/crates/tree-sitter
37+
[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef TREE_SITTER_CSHARP_H_
2+
#define TREE_SITTER_CSHARP_H_
3+
4+
typedef struct TSLanguage TSLanguage;
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
extern TSLanguage *tree_sitter_c_sharp();
11+
12+
#ifdef __cplusplus
13+
}
14+
#endif
15+
16+
#endif // TREE_SITTER_CSHARP_H_

0 commit comments

Comments
 (0)