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.6.tar.gz (15.6 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.6-cp38-abi3-win_arm64.whl (4.3 MB view details)

Uploaded CPython 3.8+Windows ARM64

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

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.6-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.6-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.6-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.6-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.6-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.6-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.6.tar.gz.

File metadata

  • Download URL: tree_sitter_objectscript-1.7.6.tar.gz
  • Upload date:
  • Size: 15.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tree_sitter_objectscript-1.7.6.tar.gz
Algorithm Hash digest
SHA256 77224350c49880f79cfc990314312d06269b56d59f28766edd90313f10aebfc8
MD5 8086a88eb76a9d6919411a6e9c510eb4
BLAKE2b-256 8ccfa926d66ed748e09d52b64e19fafc5811c104e3e83bb3fbe0c8a6234f5df5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 53f0a4039adba18362398173c2b6521496d785b7cf5009e837d75dde951fc17d
MD5 fbb49598ca4782b2b30fcb772130305d
BLAKE2b-256 9009398a3c3d84a8f1469d71c33c2582867730dc39a8e976be72f7481aa8ceaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c8e0810fedc32fb10ce4471800accf9ad7db3fcb32fcef307a9d4d64ede3afb7
MD5 4f5161279bbc5990ce1b548a5d138b36
BLAKE2b-256 ccce58e6fd8f6497517922a01039888a6312a128b3d5756ad02c3012745e32e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 877b20db20a791c18ba0a01b345e88ee98ab111dac110afabcae5a4b5b335968
MD5 b763f073427d6b2d17a77c284f3b69c8
BLAKE2b-256 889d4b926679e9c986b037a44fb7e1026de0193c6abe522eaf766d669064e45c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 55608dd3137328f2619da43f5142ee53df31b71835bf36dcf7150d538bea96a6
MD5 12aa057408f8a78ac41473d13f66c2ae
BLAKE2b-256 fcc9277a078b74817788431c41bdc4a23d1bd8ad0c5a305fdd0b82a85991ebff

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.6-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.6-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 995f02e43c223dd2e54b4b4bc10526f2a1e8073494ab333da9b3c43eb6013616
MD5 adc99a6f55702a15c03e9af9c7f73af1
BLAKE2b-256 519fd1ab14b6849ee1736492e776dba601765f779f60d843931d99f03f381095

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4d1ca9e61d916d08185ab699005eafb8e4f8ee95e0ffeda7e15f1c69c56e7308
MD5 4a60c5539ec8295509a9ec173db7fedf
BLAKE2b-256 3373c0cd363cff7c72e1bbaeff072eaa7ad5a5f3d7fcdf1dd2b5cab6e30a6ead

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 102ea74e4d8fc019c988e9bac1c80cba8c7c86ad14612da26b07fde5a593a049
MD5 973fca97298a86abc67602ec1ea825fa
BLAKE2b-256 f3f38835ea0838e7dffc22910bb4ec79536c1525edc7fa962194733f087f56af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.6-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2550c2560a54a29a23968c5a362dfd47e83d1143189980ce8a82212f1b1937eb
MD5 2277e1c9020865319f8901170f83c0e2
BLAKE2b-256 c14c3e29ddb532125333ba80383258f11ac1eb02a4baeb7e079361b8aedf9bcc

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