Skip to content
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
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,19 @@ jobs:
run: ./scripts/rust_playground_crate.sh publish
env:
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}

crates_routine:
name: Publish Rust routine package
runs-on: ubuntu-latest
environment:
name: crates
url: https://crates.io/crates/tree-sitter-objectscript-routine
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Publish to crates.io
run: ./scripts/rust_routine_crate.sh publish
env:
CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
2 changes: 1 addition & 1 deletion CMakeLists.txt

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

3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ make query

Run from repository root.

- Rust (UDL + routine crate):
- Rust (UDL crate + staged routine/playground crates):

```bash
cargo test --lib --package tree-sitter-objectscript
./scripts/rust_routine_crate.sh package --allow-dirty --no-verify
./scripts/rust_playground_crate.sh package --allow-dirty --no-verify
```

Expand Down
9 changes: 1 addition & 8 deletions Cargo.toml

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

7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![CI][ci]](https://github.com/intersystems/tree-sitter-objectscript/actions/workflows/ci.yml)
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-objectscript)
[![crates-udl][crates-udl]](https://crates.io/crates/tree-sitter-objectscript)
[![crates-routine][crates-routine]](https://crates.io/crates/tree-sitter-objectscript-routine)
[![crates-playground][crates-playground]](https://crates.io/crates/tree-sitter-objectscript-playground)
[![pypi][pypi]](https://pypi.org/project/tree-sitter-objectscript/)

Expand All @@ -27,7 +28,8 @@ Grammar extension graph:
- npm: `tree-sitter-objectscript`
- PyPI: `tree-sitter-objectscript` (ships `tree_sitter_objectscript`, `tree_sitter_objectscript_udl`, and `tree_sitter_objectscript_routine`)
- Rust crates:
- `tree-sitter-objectscript` (UDL + routine grammars)
- `tree-sitter-objectscript` (UDL grammar)
- `tree-sitter-objectscript-routine` (routine grammar)
- `tree-sitter-objectscript-playground` (playground grammar)

## Bindings
Expand All @@ -38,7 +40,7 @@ Language bindings are available under `bindings/`:
- Go: `bindings/go`
- Node.js: `bindings/node`
- Python: `bindings/python`
- Rust: `bindings/rust` and `bindings/rust-playground`
- Rust: `bindings/rust`, `bindings/rust-routine`, and `bindings/rust-playground`
- Swift: `bindings/swift`

Quick binding checks from repo root:
Expand Down Expand Up @@ -127,5 +129,6 @@ MIT. See [LICENSE](LICENSE).
[ci]: https://img.shields.io/github/actions/workflow/status/intersystems/tree-sitter-objectscript/ci.yml?logo=github&label=CI
[npm]: https://img.shields.io/npm/v/tree-sitter-objectscript?logo=npm
[crates-udl]: https://img.shields.io/crates/v/tree-sitter-objectscript?logo=rust
[crates-routine]: https://img.shields.io/crates/v/tree-sitter-objectscript-routine?logo=rust
[crates-playground]: https://img.shields.io/crates/v/tree-sitter-objectscript-playground?logo=rust
[pypi]: https://img.shields.io/pypi/v/tree-sitter-objectscript?logo=pypi&logoColor=ffd242
2 changes: 1 addition & 1 deletion bindings/rust-playground/Cargo.toml

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

39 changes: 39 additions & 0 deletions bindings/rust-routine/Cargo.toml

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

30 changes: 30 additions & 0 deletions bindings/rust-routine/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use std::path::Path;

fn main() {
let root_dir = Path::new(".");
let routine_dir = root_dir.join("objectscript_routine").join("src");
let common_dir = root_dir.join("common");
let mut config = cc::Build::new();

config.include(&routine_dir);

for path in &[
routine_dir.join("parser.c"),
routine_dir.join("scanner.c"),
] {
config.file(path);
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
}

println!(
"cargo:rerun-if-changed={}",
common_dir.join("scanner.h").to_str().unwrap()
);

// MSVC quirk
if cfg!(target_env = "msvc") {
config.define("TREE_SITTER_DISABLE_ATOMIC", None);
}

config.compile("tree-sitter-objectscript-routine");
}
54 changes: 54 additions & 0 deletions bindings/rust-routine/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//! This crate provides ObjectScript routine language support for the [tree-sitter][] parsing library.
//!
//! [tree-sitter]: https://tree-sitter.github.io/

use tree_sitter_language::LanguageFn;

extern "C" {
fn tree_sitter_objectscript_routine() -> *const ();
}

/// The tree-sitter [`LanguageFn`] for ObjectScript routine grammar.
///
/// [LanguageFn]: https://docs.rs/tree-sitter-language/*/tree_sitter_language/struct.LanguageFn.html
pub const LANGUAGE_OBJECTSCRIPT_ROUTINE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_objectscript_routine) };

/// The content of the [`node-types.json`][] file for ObjectScript routine grammar.
///
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
pub const NODE_TYPES: &str = include_str!("objectscript_routine/src/node-types.json");

/// The syntax highlighting query for ObjectScript routine grammar.
pub const HIGHLIGHTS_QUERY: &str = include_str!("objectscript_routine/queries/highlights.scm");

/// The injections query for ObjectScript routine grammar.
pub const INJECTIONS_QUERY: &str = include_str!("objectscript_routine/queries/injections.scm");

/// The indents query for ObjectScript routine grammar.
pub const INDENTS_QUERY: &str = include_str!("objectscript_routine/queries/indents.scm");

#[cfg(test)]
mod tests {
#[test]
fn test_can_load_objectscript_routine_grammar() {
let mut parser = tree_sitter::Parser::new();
parser
.set_language(&super::LANGUAGE_OBJECTSCRIPT_ROUTINE.into())
.expect("Error loading ObjectScript routine parser");
}

#[test]
fn test_indents_query_is_loaded() {
assert!(super::INDENTS_QUERY.contains("indent"));
}

#[test]
fn test_injections_query_is_loaded() {
assert!(super::INJECTIONS_QUERY.contains("injection"));
}

#[test]
fn test_highlights_query_is_loaded() {
assert!(super::HIGHLIGHTS_QUERY.contains("@keyword"));
}
}
7 changes: 3 additions & 4 deletions bindings/rust/build.rs

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

63 changes: 9 additions & 54 deletions bindings/rust/lib.rs

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

16 changes: 7 additions & 9 deletions cargo_readme.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# tree-sitter-objectscript

ObjectScript UDL + routine grammars for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
ObjectScript UDL grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).

This crate publishes:
This crate publishes the UDL (`objectscript_udl`) grammar intended for `.cls`
files.

It includes:

For UDL (`objectscript_udl`, intended for `.cls`):
- `LANGUAGE_OBJECTSCRIPT_UDL`
- `UDL_NODE_TYPES`
- `UDL_HIGHLIGHTS_QUERY`
- `UDL_INJECTIONS_QUERY`
- `UDL_INDENTS_QUERY`

For routine headers/files (`objectscript_routine`, for `.mac`, `.inc`, `.int`, `.rtn`):
- `LANGUAGE_OBJECTSCRIPT_ROUTINE`
- `ROUTINE_NODE_TYPES`
- `ROUTINE_HIGHLIGHTS_QUERY`
- `ROUTINE_INJECTIONS_QUERY`
- `ROUTINE_INDENTS_QUERY`
If you want the routine grammar (`objectscript_routine`), use
`tree-sitter-objectscript-routine`.

If you want the playground/snippet grammar (`objectscript`), use
`tree-sitter-objectscript-playground`.
Expand Down
4 changes: 2 additions & 2 deletions cargo_readme_playground.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ It includes:
For full class-file parsing (`objectscript_udl`), use the
`tree-sitter-objectscript` crate.

For full routine parsing (with routine header or compiled version) (`objectscript_routine`), also use the
`tree-sitter-objectscript` crate.
For full routine parsing (`objectscript_routine`), use the
`tree-sitter-objectscript-routine` crate.
Loading
Loading