Skip to main content

Objectscript grammar for tree-sitter

Project description

tree-sitter-objectscript

CI npm crates-udl crates-routine crates-playground pypi

Tree-sitter grammars for InterSystems ObjectScript.

Grammars

This repository publishes five related grammars:

  • objectscript: playground/snippet grammar.
  • objectscript_udl: class-file grammar for .cls.
  • objectscript_core: routine/statement grammar.
  • objectscript_expr: expression grammar.
  • objectscript_routine: routine-file grammar for .mac, .inc, .rtn, and .int.

Grammar extension graph: objectscript_expr -> objectscript_core -> objectscript_udl -> objectscript objectscript_expr -> objectscript_core -> objectscript_routine

Packages

  • 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 grammar)
    • tree-sitter-objectscript-routine (routine grammar)
    • tree-sitter-objectscript-playground (playground grammar)

Bindings

Language bindings are available under bindings/:

  • C: bindings/c
  • Go: bindings/go
  • Node.js: bindings/node
  • Python: bindings/python
  • Rust: bindings/rust, bindings/rust-routine, and bindings/rust-playground
  • Swift: bindings/swift

Quick binding checks from repo root:

nvm use
npm ci
cargo test --lib --package tree-sitter-objectscript
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -U pip setuptools wheel pytest tree-sitter
python3 setup.py build_ext --inplace
PYTHONPATH=$PWD/bindings/python python3 -m pytest -q bindings/python/tests/test_binding.py
npm test
go test ./bindings/go/...
swift test
make test

The routine and playground Rust crates are staged from bindings/rust-routine and bindings/rust-playground via helper scripts. See CONTRIBUTING.md for the current local build workflow and the temporary studio-highlights.scm copy step those staged crates need today.

For Node bindings specifically, .nvmrc pins the expected Node version.

Quick Development

Install the tree-sitter CLI, then run commands from a grammar directory (objectscript, udl, core, expr, or objectscript_routine):

tree-sitter generate
tree-sitter test
tree-sitter build

For playground work:

tree-sitter build --wasm
tree-sitter playground

If you change an upstream grammar (expr or core), regenerate downstream grammars as needed (udl, objectscript, objectscript_routine).

Query Sync

scripts/sync_queries.py manages the canonical query trio for each grammar:

  • highlights.scm
  • indents.scm
  • injections.scm

It composes the layered query trees for core, udl, objectscript, and objectscript_routine, then mirrors those composed files into the Python binding query directories. studio-highlights.scm files are intentionally left out of that sync process and are maintained separately.

Corpus Sync

objectscript/test/corpus is treated as a synced corpus directory. On commit, the repository pre-commit hook:

  • Replaces objectscript/test/corpus contents with files from:
    • core/test/corpus
    • udl/test/corpus
    • objectscript_routine/test/corpus
  • Removes objectscript/test/corpus/invalid.txt
  • Removes objectscript/test/corpus/compiled-header.txt

Contributing

See CONTRIBUTING.md for setup, workflow, query sync, and binding test instructions.

References

Editor Integration

  • Zed On Zed, you can use tree-sitter-objectscript by downloading the InterSystems ObjectScript extension

  • Neovim We currently have a PR open with nvim-treesitter, and if that gets merged in, the setup process will be automated. However, this repo is currently archived, so for now do the following to setup the grammars in neovim:

    Step 1: Create ~/.config/nvim/lua/plugins/objectscript-treesitter.lua

    Add the following content to that file: IMPORTANT: Make sure to replace the revision section with the commit that you want.

    return {
    -- configure nvim-treesitter
    {
      "nvim-treesitter/nvim-treesitter",
      init = function()
        vim.filetype.add({
          extension = {
            cls = "objectscript_udl",
            mac = "objectscript_routine",
            inc = "objectscript_routine",
            int = "objectscript_routine",
            rtn = "objectscript_routine"
          },
        })
    
        vim.api.nvim_create_autocmd("FileType", {
          pattern = { "objectscript_udl", "objectscript_routine" },
          callback = function(args)
            vim.treesitter.start(args.buf)
          end,
        })
    
        vim.api.nvim_create_autocmd('User', { pattern = 'TSUpdate',
        callback = function()
        local parsers = require("nvim-treesitter.parsers")
    
          parsers.objectscript_udl = {
            install_info = {
              url = "https://github.com/intersystems/tree-sitter-objectscript",
              revision = "f1c568c622a0a43191563fd4c5e649a61eef11cc", 
              location = "udl",
              queries = "udl/queries",
            }
          }
    
          parsers.objectscript_routine = {
            install_info = {
              url = "https://github.com/intersystems/tree-sitter-objectscript",
              revision = "f1c568c622a0a43191563fd4c5e649a61eef11cc", 
              location = "objectscript_routine",
              queries = "objectscript_routine/queries",
            }
          }
        end})
      end,
    
        opts = function(_, opts)
          opts.ensure_installed = opts.ensure_installed or {}
          for _, lang in ipairs({ "objectscript_udl", "objectscript_routine" }) do
            if not vim.tbl_contains(opts.ensure_installed, lang) then
              table.insert(opts.ensure_installed, lang)
            end
          end
        end,
      },
    }
    

    Step 2: Remove cached data from nvim if necessary (if previously installed)

    rm -rf ~/.local/share/nvim/site/parser \
      ~/.local/share/nvim/site/parser-info \
      ~/.local/share/nvim/site/queries
    

    Step 3: Open Neovim and Install objectscript_udl and objectscript_routine

    :TSInstall objectscript_udl objectscript_routine
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_objectscript-1.7.13.tar.gz (15.5 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_objectscript-1.7.13-cp38-abi3-win_arm64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows ARM64

tree_sitter_objectscript-1.7.13-cp38-abi3-win_amd64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.13-cp38-abi3-musllinux_1_2_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

tree_sitter_objectscript-1.7.13-cp38-abi3-musllinux_1_2_aarch64.whl (4.4 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

tree_sitter_objectscript-1.7.13-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

tree_sitter_objectscript-1.7.13-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (4.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

tree_sitter_objectscript-1.7.13-cp38-abi3-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

tree_sitter_objectscript-1.7.13-cp38-abi3-macosx_10_9_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

File details

Details for the file tree_sitter_objectscript-1.7.13.tar.gz.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13.tar.gz
Algorithm Hash digest
SHA256 ef2cc60552087f29ed2d361db7ad9716ebdd5d03b467d495627bb34f30dc9a5c
MD5 8779d3e613dd04afe7f74a373af736f4
BLAKE2b-256 ca20c4e3f1ed2046c67be944c17035ea6767c742f22b9a332205e4dbf368f2a0

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 3b7e36993b3f163ab645c6532381907fab3500e8cb9b404baff432cb82f525eb
MD5 5c9e18a18f6cb3414d6433f3696529a2
BLAKE2b-256 36ad52d9223325a4b39fd5f98bf44335621c9e17bc964f7106cee432a9d6927b

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 663d5e681170eb90e0ffd5edc52d8d3164624b879e9497b5bbf073070a5f9427
MD5 e55a91d4b86d6ae5cb2a6d27b7dad952
BLAKE2b-256 a3b4da7a12b0e541b884485c6126b4c1634abcf2fc1561992a9a0726ec5c43d1

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 af478dd63a7d83efd0f7e3cc456bb95d742b6c5f6dd4feaabdbb22b637226241
MD5 f61952dcb9ab9dd3d260d1f01092c205
BLAKE2b-256 d35642b29f011b22b327863fc7c459c0ed3f52cdddd4ebe44e47fb261092dec2

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2e8917e5b495335462643e4780a1b0f49cea0eaa2cf202c564421bc7c6a144d3
MD5 c89908949a7945f88c687dac4541dc18
BLAKE2b-256 94898ae111fd610255952074f8610be5b173a77d09ee38339c53c5877cefe321

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3744fd0609485851a4876085d5ca9c49ae9241d8ba25e31850a9d4c2c06d1781
MD5 fe5e1fcff8eecd8f513f572344ca15f3
BLAKE2b-256 3733d4a12c65aafd91f136baac01e783dc1500d69e6aed3b5463b119b864e58f

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 121cd5502baa59836d785f60262d388a394fe11f09044428b4fb96bf3e81234b
MD5 435d02b3fa0aa20cf9d24fb21bddc107
BLAKE2b-256 ab128c9bbe74bbdb87c19a6c7b45912e8f5e84e90d3dff80da89cc4e892230b9

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b22f0f9479eb81ba87c45e4b82df8dc07eca0ef3f0c98246c42051f993b8f028
MD5 5f99151a9aef0a93cc9e6744c217b760
BLAKE2b-256 410877df6848430f5f5ccb3ff9e2de463e76a800298f6ad99b133d4fdf858080

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.13-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.13-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f6ee34d253194ad2105879eba04eace75a2d844f259f2cca134187370e487cac
MD5 104ac59eca3c00807bf3fc563abcbd89
BLAKE2b-256 6ca0e8878f33c1592624deacc6a7c569c1c0a1073f59af527e783dc269b94269

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page