-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 18158c0
Showing
29 changed files
with
5,737 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/src/** linguist-vendored | ||
/examples/* linguist-vendored | ||
|
||
src/grammar.json linguist-generated | ||
src/node-types.json linguist-generated | ||
src/parser.c linguist-generated | ||
|
||
src/grammar.json -diff | ||
src/node-types.json -diff | ||
src/parser.c -diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [macos-latest, ubuntu-latest, windows-2019] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Fuzz Parser | ||
|
||
on: | ||
push: | ||
paths: | ||
- src/scanner.c | ||
pull_request: | ||
paths: | ||
- src/scanner.c | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: Parser fuzzing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: vigoux/tree-sitter-fuzz-action@v1 | ||
with: | ||
language: doxygen | ||
external-scanner: src/scanner.c | ||
time: 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install modules | ||
run: npm install | ||
- name: Run ESLint | ||
run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/master' }} | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: tree-sitter-doxygen | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update Rust version | ||
run: | | ||
git fetch origin release-please--branches--master--components--tree-sitter-doxygen | ||
git checkout release-please--branches--master--components--tree-sitter-doxygen | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
repo_name="${{ github.repository }}" | ||
repo_name="${repo_name##*/}" | ||
version=$(grep -o '"version": *"[^"]*"' package.json | sed 's/"version": "\(.*\)"/\1/') | ||
sed -i "s/version = \"[^\"]*\"/version = \"$version\"/g" Cargo.toml | ||
sed -i "s/$repo_name = \"[^\"]*\"/$repo_name = \"$version\"/g" bindings/rust/README.md | ||
git add Cargo.toml bindings/rust/README.md | ||
git commit --amend --no-edit | ||
git push -f | ||
- name: Setup Node | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Publish to NPM | ||
if: ${{ steps.release.outputs.release_created }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
run: npm publish | ||
|
||
- name: Setup Rust | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
- name: Publish to Crates.io | ||
if: ${{ steps.release.outputs.release_created }} | ||
uses: katyo/publish-crates@v2 | ||
with: | ||
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
|
||
- name: Tag stable versions | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
git checkout master | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" | ||
git tag -d stable || true | ||
git push origin :stable || true | ||
git tag -a stable -m "Last Stable Release" | ||
git push origin stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Cargo.lock | ||
node_modules | ||
build | ||
package-lock.json | ||
/target/ | ||
.build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/test | ||
/examples | ||
/build | ||
/script | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "tree-sitter-doxygen" | ||
description = "Doxygen grammar for tree-sitter" | ||
version = "1.0.0" | ||
authors = ["Amaan Qureshi <amaanq12@gmail.com>"] | ||
license = "MIT" | ||
keywords = ["incremental", "parsing", "doxygen"] | ||
categories = ["parsing", "text-editors"] | ||
repository = "https://github.com/amaanq/tree-sitter-doxygen" | ||
edition = "2021" | ||
autoexamples = false | ||
|
||
build = "bindings/rust/build.rs" | ||
include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"] | ||
|
||
[lib] | ||
path = "bindings/rust/lib.rs" | ||
|
||
[dependencies] | ||
tree-sitter = "~0.20.10" | ||
|
||
[build-dependencies] | ||
cc = "~1.0.83" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Amaan Qureshi <amaanq12@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// swift-tools-version:5.3 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "TreeSitterObjc", | ||
platforms: [.macOS(.v10_13), .iOS(.v11)], | ||
products: [ | ||
.library(name: "TreeSitterObjc", targets: ["TreeSitterObjc"]), | ||
], | ||
dependencies: [], | ||
targets: [ | ||
.target(name: "TreeSitterObjc", | ||
path: ".", | ||
exclude: [ | ||
"binding.gyp", | ||
"bindings", | ||
"Cargo.toml", | ||
"test", | ||
"examples", | ||
"grammar.js", | ||
"LICENSE", | ||
"package.json", | ||
"README.md", | ||
"script", | ||
"src/grammar.json", | ||
"src/node-types.json", | ||
], | ||
sources: [ | ||
"src/parser.c", | ||
"src/scanner.c", | ||
], | ||
resources: [ | ||
.copy("queries") | ||
], | ||
publicHeadersPath: "bindings/swift", | ||
cSettings: [.headerSearchPath("src")]) | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# tree-sitter-doxygen | ||
|
||
[![Build Status](https://github.com/amaanq/tree-sitter-doxygen/actions/workflows/ci.yml/badge.svg)](https://github.com/amaanq/tree-sitter-doxygen/actions/workflows/ci.yml) | ||
[![Discord](https://img.shields.io/discord/1063097320771698699?logo=discord)](https://discord.gg/w7nTvsVJhm) | ||
|
||
[Doxygen](https://www.doxygen.nl/manual/commands.html) grammar for [tree-sitter](https://tree-sitter.github.io) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"targets": [ | ||
{ | ||
"target_name": "tree_sitter_doxygen_binding", | ||
"include_dirs": [ | ||
"<!(node -e \"require('nan')\")", | ||
"src" | ||
], | ||
"sources": [ | ||
"bindings/node/binding.cc", | ||
"src/parser.c", | ||
"src/scanner.c", | ||
], | ||
"cflags_c": [ | ||
"-std=c99", | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "nan.h" | ||
#include "tree_sitter/parser.h" | ||
#include <node.h> | ||
|
||
using namespace v8; | ||
|
||
extern "C" TSLanguage *tree_sitter_doxygen(); | ||
|
||
namespace { | ||
|
||
NAN_METHOD(New) {} | ||
|
||
void Init(Local<Object> exports, Local<Object> module) { | ||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); | ||
tpl->SetClassName(Nan::New("Language").ToLocalChecked()); | ||
tpl->InstanceTemplate()->SetInternalFieldCount(1); | ||
|
||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked(); | ||
Local<Object> instance = | ||
constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); | ||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_doxygen()); | ||
|
||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), | ||
Nan::New("doxygen").ToLocalChecked()); | ||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); | ||
} | ||
|
||
NODE_MODULE(tree_sitter_doxygen_binding, Init) | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
try { | ||
module.exports = require('../../build/Release/tree_sitter_doxygen_binding'); | ||
} catch (error1) { | ||
if (error1.code !== 'MODULE_NOT_FOUND') { | ||
throw error1; | ||
} | ||
try { | ||
module.exports = require('../../build/Debug/tree_sitter_doxygen_binding'); | ||
} catch (error2) { | ||
if (error2.code !== 'MODULE_NOT_FOUND') { | ||
throw error2; | ||
} | ||
throw error1; | ||
} | ||
} | ||
|
||
try { | ||
module.exports.nodeTypeInfo = require('../../src/node-types.json'); | ||
} catch (_) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# tree-sitter-doxygen | ||
|
||
This crate provides a Doxygen grammar for the [tree-sitter][] parsing library. | ||
To use this crate, add it to the `[dependencies]` section of your `Cargo.toml` | ||
file. (Note that you will probably also need to depend on the | ||
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful | ||
way.) | ||
|
||
```toml | ||
[dependencies] | ||
tree-sitter = "0.20.10" | ||
tree-sitter-doxygen = "1.0.0" | ||
``` | ||
|
||
Typically, you will use the [language][language func] function to add this | ||
grammar to a tree-sitter [Parser][], and then use the parser to parse some code: | ||
|
||
```rust | ||
let code = r#" | ||
/** | ||
* \brief This is a brief description. | ||
* | ||
* \param[in] param1 This is the first parameter. | ||
*/ | ||
"#; | ||
let mut parser = Parser::new(); | ||
parser.set_language(tree_sitter_doxygen::language()).expect("Error loading Doxygen grammar"); | ||
let parsed = parser.parse(code, None); | ||
``` | ||
|
||
If you have any questions, please reach out to us in the [tree-sitter | ||
discussions] page. | ||
|
||
[language func]: https://docs.rs/tree-sitter-doxygen/*/tree_sitter_doxygen/fn.language.html | ||
[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html | ||
[tree-sitter]: https://tree-sitter.github.io/ | ||
[tree-sitter crate]: https://crates.io/crates/tree-sitter | ||
[tree-sitter discussions]: https://github.com/tree-sitter/tree-sitter/discussions |
Oops, something went wrong.