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

Uploaded CPython 3.8+Windows ARM64

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

Uploaded CPython 3.8+Windows x86-64

tree_sitter_objectscript-1.7.8-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.8-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.8-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.8-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.8-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.8-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.8.tar.gz.

File metadata

  • Download URL: tree_sitter_objectscript-1.7.8.tar.gz
  • Upload date:
  • Size: 15.4 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.8.tar.gz
Algorithm Hash digest
SHA256 0078f9ebf06dfdb4b5c70edc097273a2c6ddb5ca59208a41227f678928b55c45
MD5 50e4f91439321b0423065467e4b813b2
BLAKE2b-256 45601ff24a85bdd2d8ca3cfdec148d3b4cbc430ce07850513600656ddb5eca13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 2d10aec48a253f39ee1c586ab67e1405473d1a4b26ebe53633f1778ff1813876
MD5 43c8de45360bf75be1a4cfde8df30c9b
BLAKE2b-256 89251adc56818ac939defe87f9c69b99a7220817aa7ec3ca4396c52787573c98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c132e5487d4e256961e0866e6ebeaae0e301a35491a0b6829750bae2d46405ec
MD5 e1b3b7fd6b299b6520133273fd82e36e
BLAKE2b-256 f0b5ad06b7525b065d05c08c5e2c8ff8011a0d3edab366381b022909185add43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ef68642e0af56bb1d424c86fb7f1d7d1338cefc87690f3bf5ddf021f0e8305fb
MD5 181a31cef9e94d2085e7c0a3cec4099b
BLAKE2b-256 b9890bd738896998271d1e6b8402ce64f34433abaa9ffdf0b9c0ebedbdab486a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 742f6f70a10ab49cd6042221c4c225343f1c592cc1a09be09c56546343212f87
MD5 496be6160e2e5370b3917df2486a33bb
BLAKE2b-256 5c081d5fb44de3e6b88ae88f225201772d3686364938b5fd5bccffbd092e0d18

See more details on using hashes here.

File details

Details for the file tree_sitter_objectscript-1.7.8-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.8-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 21c27728b24fe7205e616349b78bede9c4fbbb0ea764b281ca562c7462287a4c
MD5 6008f2391918f4360d4b3a1f531c4a74
BLAKE2b-256 695cc6161c3e8b25111eba05075cbdf6c26be230e5bf362900d46c14a8fa545c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 352f4faf9455cd5f999ff97e24414e0bb72d597025d183162f1fbafbfc856441
MD5 b12e436de1c6681f795bbd277409336b
BLAKE2b-256 0b8e127f49b58914d65a49bace765fa1f9d4cfd46d417bf470a5d2bd337cc0d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03d9d02925b6591b8ca0140e0ed587fa865353e6ae0e226b4253123151615bca
MD5 afcdbd3a5e7ba668ad1f7f31387822fe
BLAKE2b-256 e763c87e367c976aaaa795fc9bc4d22218d082443abf2ccf349300431abc3a81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tree_sitter_objectscript-1.7.8-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 500d1ebd7e2c2c032b7d25678b5bcfeae8d4aeb36b279a86d43a8662745b28a1
MD5 343435f9a859356cb3473518d7ba357c
BLAKE2b-256 7f7fb8fb4c7bf4473065d1c26d4acc776653844edffcb38208e47872173c02b9

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